File tree 1 file changed +16
-0
lines changed
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 32
32
from qonnx .transformation .general import SortGraph
33
33
34
34
35
+ class InsertIdentityOnAllTopLevelIO (Transformation ):
36
+ """
37
+ Transformation that inserts an Identity node on all top-level inputs and outputs
38
+ of the ONNX graph. This can be useful before calling transformations that do not
39
+ gracefully handle edge cases where transformed tensors are top-level inputs or outputs.
40
+ """
41
+
42
+ def apply (self , model ):
43
+ graph = model .graph
44
+ for inp in graph .input :
45
+ model = model .transform (InsertIdentity (inp .name , "consumer" ))
46
+ for out in graph .output :
47
+ model = model .transform (InsertIdentity (out .name , "producer" ))
48
+ return model , False
49
+
50
+
35
51
class InsertIdentity (Transformation ):
36
52
"""
37
53
Transformation that inserts an Identity node in the ONNX graph. For edge cases
You can’t perform that action at this time.
0 commit comments