Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added input/output node tests #6

Merged
merged 3 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
# stop the build if there are Python syntax errors or undefined names
ruff --format=github --select=E9,F63,F7,F82 --target-version=py37 .
# default set of ruff rules with GitHub Annotations
ruff --format=github --target-version=py37 .
ruff --format=github --target-version=py37 --exclude=docs/ .
- name: Test with pytest
run: |
pytest
13 changes: 13 additions & 0 deletions nir/test/test_ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,16 @@ def test_simple():
assert ir.nodes[0].weights == [1, 2, 3]
assert ir.nodes[0].bias == 4
assert ir.edges == [(0, 0)]

def test_simple_with_input_output():
ir = nir.NIR(
nodes=[
nir.Input(shape=[3,]),
nir.Linear(weights=[1, 2, 3], bias=4),
nir.Output()],
edges=[(0, 1), (1,2)])
assert ir.nodes[0].shape == [3,]
assert ir.nodes[1].weights == [1, 2, 3]
assert ir.nodes[1].bias == 4
assert ir.edges == [(0, 1), (1, 2)]

9 changes: 9 additions & 0 deletions nir/test/test_readwrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,12 @@ def test_leaky_integrator_and_fire():
edges=[(0, 0)],
)
factory_test_graph(ir)

def test_simple_with_read_write():
ir = nir.NIR(
nodes=[nir.Input(shape=[3,]),
nir.Linear(weights=[1, 2, 3], bias=4),
nir.Output()],
edges=[(0, 1), (1,2)]
)
factory_test_graph(ir)