File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -63,9 +63,9 @@ def sanitize(self) -> None:
63
63
self .ensure_graph_name_exists ()
64
64
onnx_utils .name_onnx_nodes (self .model .graph )
65
65
self .replace_custom_domain_nodes ()
66
+ self .sanitize_io_casts ()
66
67
self .cleanup_model ()
67
68
self .set_ir_version (self .max_ir_version )
68
- self .sanitize_io_casts ()
69
69
70
70
def find_custom_nodes (self ) -> None :
71
71
"""Find custom nodes in the model.
@@ -356,6 +356,10 @@ def sanitize_io_casts(self) -> None:
356
356
for node in nodes_to_add :
357
357
self .model .graph .node .append (node )
358
358
359
+ # Make sure the graph is topologically sorted
360
+ gs_graph = gs .import_onnx (self .model ).cleanup ().toposort ()
361
+ self .model = gs .export_onnx (gs_graph )
362
+
359
363
def _create_layernorm_node (self , pattern : dict ) -> onnx .NodeProto :
360
364
"""Create a LayerNormalization node with optional bias."""
361
365
ln_name = f"LayerNorm_{ pattern ['mean_node' ].name } "
You can’t perform that action at this time.
0 commit comments