I just found the issue!!
In my code I additionally do,
x = torch.randn(1, 3, 5, 5)
torch.onnx.export(net, x, ‘ayeonnx.onnx’)
net(x)
to convert the model to onnx (for some use case ) before executing net(x)
and this messes up the whole thing!
if I instead do
torch.onnx.export(copy.deepcopy(net), x, 'ayeonnx.onnx')


I get what you get. Is this not a bug in that I had to deepcopy and for some reason the net object got affected without that or is this expected?