Skip to content

Commit de4e42c

Browse files
committed
Update base for Update on "Implement the experimental evaluator for folding branches and castlikes | feat(torchlib)"
As an effort described in #1095, this PR - Implements the experimental evaluator for folding branches and castlikes so that they are eagerly evaluated when possible. Set `TORCHLIB_EXPERIMENTAL_PREFER_TRACING=1` and tested locally. E.g. clamp_min now becomes ``` < ir_version: 8, opset_import: ["" : 18, "pkg.onnxscript.torch_lib.common" : 1], producer_name: "pytorch", producer_version: "2.2.0" > main_graph (int32[5,10,5] input_0, int32[10,5] input_1) => (int32[5,10,5] _val_9) <int64 _val_2, int64[2] _val_3, int64 _val_4, int64 _val_5, bool _val_6, int64 _val_7, bool _val_8> { _val_2 = Size (input_0) _val_3 = Shape <start: int = 0> (input_1) _val_4 = Size (_val_3) _val_5 = Constant <value: tensor = int64 {0}> () _val_6 = Equal (_val_2, _val_5) _val_7 = Constant <value: tensor = int64 {0}> () _val_8 = Equal (_val_4, _val_7) _val_9 = Max (input_0, input_1) } < domain: "pkg.onnxscript.torch_lib.common", opset_import: ["" : 18] > Rank (input) => (return_val) { tmp = Shape (input) return_val = Size (tmp) } < domain: "pkg.onnxscript.torch_lib.common", opset_import: ["" : 18] > IsScalar (input) => (return_val) { tmp = Shape (input) tmp_0 = Size (tmp) tmp_1 = Constant <value_int: int = 0> () return_val = Equal (tmp_0, tmp_1) } ``` [ghstack-poisoned]
1 parent cea67b4 commit de4e42c

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

.github/workflows/main.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ jobs:
3131
- py310-torch-nightly
3232
- py310-onnx-weekly
3333
- py310-ort-nightly
34+
- py311-ort-nightly
35+
- py310-experimental-torchlib-tracing
3436
include:
3537
- name: py310
3638
python-version: "3.10"
@@ -50,6 +52,12 @@ jobs:
5052
- name: py310-ort-nightly
5153
python-version: "3.10"
5254
nox-tag: test-ort-nightly
55+
- name: py311-ort-nightly
56+
python-version: "3.11"
57+
nox-tag: test-ort-nightly
58+
- name: py310-experimental-torchlib-tracing
59+
python-version: "3.10"
60+
nox-tag: test-experimental-torchlib-tracing
5361
runs-on: ${{ matrix.os }}
5462
steps:
5563
- uses: actions/checkout@v4

noxfile.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,20 @@ def test_ort_nightly(session):
9595
session.install(".", "--no-deps")
9696
session.run("pip", "list")
9797
session.run("pytest", "onnxscript", *session.posargs)
98+
99+
100+
@nox.session(tags=["test-experimental-torchlib-tracing"])
101+
def test_experimental_torchlib_tracing(session):
102+
"""Test TorchLib with the experimental TORCHLIB_EXPERIMENTAL_PREFER_TRACING flag on."""
103+
session.install(
104+
*COMMON_TEST_DEPENDENCIES, PYTORCH, ONNX, *ONNX_RUNTIME_NIGHTLY_DEPENDENCIES
105+
)
106+
session.install("-r", "requirements/ci/requirements-ort-nightly.txt")
107+
session.install(".", "--no-deps")
108+
session.run("pip", "list")
109+
session.run(
110+
"pytest",
111+
"onnxscript/tests/function_libs/torch_lib/ops_test.py",
112+
*session.posargs,
113+
env={"TORCHLIB_EXPERIMENTAL_PREFER_TRACING": "1"},
114+
)

0 commit comments

Comments
 (0)