Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions _doc/cmds/validate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ Let's export with ONNX this time and checks for discrepancies.
python -m onnx_diagnostic validate -m arnir0/Tiny-LLM --run -v 1 --export onnx-dynamo -o dump_models --patch --opt ir

.. runpython::
:process:

from onnx_diagnostic._command_lines_parser import main

Expand All @@ -117,6 +118,7 @@ of function :func:`onnx_diagnostic.torch_models.validate.run_ort_fusion`.
python -m onnx_diagnostic validate -m arnir0/Tiny-LLM --run -v 1 --export onnx-dynamo -o dump_models --patch --opt ir --ortfusiontype ALL

.. runpython::
:process:

from onnx_diagnostic._command_lines_parser import main

Expand Down
3 changes: 2 additions & 1 deletion _doc/examples/plot_dump_intermediate_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@
# results to intermediate results in ONNX.
# Let's create the ONNX model.

epo = torch.onnx.export(model, inputs, dynamic_shapes=ds, dynamo=True)
ep = torch.export.export(model, inputs, dynamic_shapes=ds)
epo = torch.onnx.export(ep, dynamo=True)
epo.optimize()
epo.save("plot_dump_intermediate_results.onnx")

Expand Down
9 changes: 6 additions & 3 deletions _doc/recipes/plot_export_dim1.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ def forward(self, x, y, z):
# Same model, a dynamic dimension = 1 and backed_size_oblivious=True
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

with torch.fx.experimental._config.patch(backed_size_oblivious=True):
ep = torch.export.export(model, (x, y, z), dynamic_shapes=(ds, ds, ds))
print(ep.graph)
try:
with torch.fx.experimental._config.patch(backed_size_oblivious=True):
ep = torch.export.export(model, (x, y, z), dynamic_shapes=(ds, ds, ds))
print(ep.graph)
except RuntimeError as e:
print("ERROR", e)

# %%
# It worked.
Expand Down
5 changes: 4 additions & 1 deletion onnx_diagnostic/helpers/cache_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,16 @@ def flatten_unflatten_for_dynamic_shapes(
return tuple(subtrees)
if spec.type is list:
return list(subtrees)
if spec.type is None and not subtrees:
return None
if spec.context:
# This is a custom class with attributes.
# It is returned as a list.
return list(subtrees)
raise ValueError(
f"Unable to interpret spec type {spec.type} "
f"(type is {type(spec.type)}, context is {spec.context})."
f"(type is {type(spec.type)}, context is {spec.context}), "
f"spec={spec}, subtrees={subtrees}"
)
# This is a list.
return subtrees
Expand Down
Loading