Suppose I have the following graph and example code.
import torch
class Net(torch.nn.Module):
def __init__(self):
super(Net, self).__init__()
def forward(self, x):
z = x.squeeze(0)
z.add_(2)
x.mul_(5)
return x
if __name__ == "__main__":
script = torch.jit.script(Net().eval())
print(str(script))
print("-" * 10)
for node in script.graph.nodes():
print(node)
Is the loop guaranteed to iterate over the nodes in an order that preserves the semantics of the in-place operations in the graph?
In this simple example its just enough that the add is looped over before the mul, but the general case is more important to me.
I do get the correct order when running this script, but Iām interested if this is guaranteed.