Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@
#
# - How to refactor the model to use :func:`torch.cond` for exporting.
# - How to export a model with control flow logic to ONNX.
# - How to optimize the exported model using the ONNX optimizer.
#
# Prerequisites
# ~~~~~~~~~~~~~
#
# * ``torch >= 2.6``
# * ``torch >= 2.8``


import torch
Expand Down Expand Up @@ -138,13 +137,6 @@ def neg(x):
onnx_program = torch.onnx.export(model, (x,), dynamo=True)
print(onnx_program.model)


###############################################################################
# We can optimize the model and get rid of the model local functions created to capture the control flow branches.

onnx_program.optimize()
print(onnx_program.model)

###############################################################################
# Conclusion
# ----------
Expand Down