Are graph.get_nodes() and MatchSolution.get_all() sorted ?
I want to retrieve nodes based on the direction of the graph.
However, I am not sure if the method GraphView.get_nodes()
or the method MatchSolution.get_all()
return a sorted list of nodes.
Is it the case ?
My point is : I have a sequence of Reshape -> Transpose -> Reshape -> Transpose -> Reshape -> Transpose -> Reshape with different sizes of vector for Reshape and Transpose nodes. While Reshape nodes are GenericOperators in my model, I want to replace these nodes with Reshape nodes from aidge.
Here I have two options :
-
Replace the whole sequence of Reshape -> Transpose -> ... with a complete sequence of Reshape nodes from aidge AND Transpose nodes from my original model (while there are only Transpose2D and Transpose3D available, I need n-D Transpose nodes) by using the Regex tool, this is why I need to retrieve my Transpose nodes in a sorted way.
-
Replace each Reshape node by Reshape nodes from aidge by using
node.type()
in a for loop and a counter for targeting the right Reshape nodes with the right size vectors, this is why I need to have a sorted list of Reshape nodes for targeting the right ones while replacing.
Finally, how does replace work ? While we don't have to specify the graph we want to modify as an argument, how can we be sure the replace function aims the right graph ? Replace will always target the main graph we imported ?
Thank you, I will certainly have more questions about other issues in a close future.