Skip to content

Commit a4ad5da

Browse files
committed
more stats
1 parent 390e03f commit a4ad5da

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

_scripts/compare_model_execution.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@
6565
print(f"-- creating session 1 from {onnx1!r}")
6666
opts = onnxruntime.SessionOptions()
6767
opts.optimized_model_filepath = "debug1_full.onnx"
68+
opts.log_severity_level = 0
69+
opts.log_verbosity_level = 0
6870
sess1 = onnxruntime.InferenceSession(onnx1, opts, providers=providers)
6971
print(f"-- creating session 2 from {onnx2!r}")
7072
opts.optimized_model_filepath = "debug2_full.onnx"
73+
opts.log_severity_level = 0
74+
opts.log_verbosity_level = 0
7175
sess2 = onnxruntime.InferenceSession(onnx2, opts, providers=providers)
7276

73-
for n in ["debug1_full.onnx", "debug2_full.onnx"]:
74-
x = onnx.load(n, load_external_data=False)
75-
onnx.save(x, n.replace(".onnx", "-ext.onnx"), save_as_external_data=True)
76-
7777
print("-- run session1")
7878
expected1 = sess1.run(None, feeds)
7979
print(f"-- got {string_type(expected1, with_shape=True)}")

onnx_diagnostic/torch_models/validate.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,15 +852,24 @@ def node_iter(proto):
852852
raise NotImplementedError(f"Unexpected type={type(proto)}")
853853

854854
counts: Dict[str, Union[float, int]] = {}
855+
n_nodes = 0
856+
n_nodes_nocst = 0
855857
for proto in node_iter(onx):
856858
if isinstance(proto, onnx.NodeProto):
857859
key = f"n_node_{proto.op_type}"
860+
n_nodes += 1
861+
if proto.op_type != "Constant":
862+
n_nodes_nocst += 1
858863
else:
859864
key = f"n_node_initializer_{proto.data_type}"
860865

861866
if key not in counts:
862867
counts[key] = 0
863868
counts[key] += 1
869+
870+
counts["n_node_nodes"] = n_nodes
871+
counts["n_node_nodes_nocst"] = n_nodes_nocst
872+
counts["n_node_functions"] = len(onx.functions)
864873
return counts
865874

866875

0 commit comments

Comments
 (0)