for example, for a computation flow:
z = a + b
i want to change it to:
z = torch.sum(torch.abs(a)) + b
for now, i only figure out a way to do it like this:
with gm.graph.inseting_after(node_a):
abs_node = gm.graph.call_function(torch.abs)
abs_node.args = (node_a,)
# without this second with statement, sum_node will be added before abs_node
with gm.graph.inserting_after(abs_node):
sum_node = gm.graph.call_function(torch.sum)
sum_node.args = (abs_node,)
node_a.replace_all_uses_with(sum_node)
the question is, how can i do it faster and more elegant if i have 10 nodes to insert after node_a?