Skip to content
Closed
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
6 changes: 2 additions & 4 deletions olive/passes/onnx/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,6 @@ def _export_pytorch_model(
# is taken, the old export always writes a model to the disk. When that happens we need to
# load the model back into IR and load all the external tensor to memory
with tempfile.TemporaryDirectory(prefix="olive_tmp") as tmp_dir:
tmp_model_path = resolve_onnx_path(tmp_dir)

if dynamo:
# Take the "release" version so that dev builds like 2.5.0dev1234 are treated as 2.5.0
if _torch_is_older_than("2.7.0") and (
Expand Down Expand Up @@ -239,15 +237,13 @@ def _export_pytorch_model(
onnx_program = torch.onnx.export( # pylint: disable=unexpected-keyword-arg,no-value-for-parameter
pytorch_model,
dummy_inputs,
tmp_model_path, # needed for fallback=True
kwargs=dummy_kwargs,
opset_version=config.target_opset,
input_names=io_config.input_names,
output_names=io_config.output_names,
dynamic_axes=dynamic_axes_for_export,
dynamic_shapes=io_config.dynamic_shapes,
dynamo=True,
fallback=False,
optimize=config.optimize,
report=logger.isEnabledFor(logging.DEBUG),
)
Expand All @@ -264,6 +260,8 @@ def _export_pytorch_model(
# default is True in 2.9.0 and later
dynamo_args["dynamo"] = False

tmp_model_path = resolve_onnx_path(tmp_dir)

torch.onnx.export(
pytorch_model,
dummy_inputs,
Expand Down
Loading