neuromorphs / NIRTorch

PyTorch helper module to translate to and from NIR
https://neuroir.org/docs
BSD 3-Clause "New" or "Revised" License
7 stars 3 forks source link

cannot import and then export #16

Closed stevenabreu7 closed 1 year ago

stevenabreu7 commented 1 year ago

when importing a NIR graph through NIRTorch, and then exporting that back to NIR, it messes up the edges of the NIR graph:

original NIR edges [('input', '0'), ('0', '1'), ('1', 'output')]
converted NIR edges [('input', '0'), ('0', 'output'), ('1', '1')]

in a simple sequential network with two nodes, it never connects them:

Tensor_0(1, 1) (Tensor)
    -> 0 (Linear) [torch.Size([1, 1])]
0 (Linear)
    -> Tensor_1(1, 1) (Tensor) [torch.Size([1, 1])]
Tensor_1(1, 1) (Tensor)
Tensor_2(1, 1) (Tensor)
    -> 1 (Leaky) [torch.Size([1, 1])]
1 (Leaky)
    -> Tensor_3(1, 1) (Tensor) [torch.Size([1, 1])]
Tensor_3(1, 1) (Tensor)

in the new forward pass inside the graphexecutor, we are creating a new input based on the graph executor state (potentially summing together multiple inputs). pytorch then sees this input tensor as a new tensor, and the comparison with the old output tensor (which may be the same) fails.

stevenabreu7 commented 1 year ago

fixed, but not merged yet, in #13, closing this issue