Skip to content

Commit

Permalink
Enable optimization via environment variable
Browse files Browse the repository at this point in the history
Signed-off-by: Ganesan Ramalingam <[email protected]>
  • Loading branch information
gramalingam committed Sep 17, 2024
1 parent 82dac0f commit 6b0f78c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions onnxscript/_framework_apis/torch_2_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import onnx

from onnxscript import ir
from onnxscript import ir, optimizer
from onnxscript.function_libs.torch_lib import registration
from onnxscript.ir import _external_data

Expand All @@ -28,6 +28,9 @@
os.getenv("TORCH_ONNX_OFFLOAD_EXTERNAL_DATA_WITH_IR") != "0"
)

# Internal flag. Will go away.
_TORCH_ONNX_ENABLE_OPTIMIZATION = os.getenv("TORCH_ONNX_ENABLE_OPTIMIZATION") == "1'"


@dataclasses.dataclass(frozen=True)
class _OnnxFunctionMeta:
Expand All @@ -50,7 +53,8 @@ class _OnnxFunctionMeta:
def optimize(model: ir.Model) -> ir.Model:
"""Optimize the model."""

# TODO(justinchuby): Use the optimizer
if _TORCH_ONNX_ENABLE_OPTIMIZATION:
optimizer.optimize_ir(model)

Check warning on line 57 in onnxscript/_framework_apis/torch_2_5.py

View check run for this annotation

Codecov / codecov/patch

onnxscript/_framework_apis/torch_2_5.py#L57

Added line #L57 was not covered by tests
return model


Expand Down

0 comments on commit 6b0f78c

Please sign in to comment.