Skip to content

[rewriter | torchlib] respect ops order in torchscript graph #2134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
8 changes: 4 additions & 4 deletions onnxscript/function_libs/torch_lib/ops/nn.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,8 @@
inner = op.Div(self, 1.4142135623730951)
erf = op.Erf(inner)
inner = op.Add(erf, 1)
inner = op.Mul(self, inner)
result = op.Mul(0.5, inner)
inner = op.Mul(0.5, inner)
result = op.Mul(self, inner)

Check warning on line 491 in onnxscript/function_libs/torch_lib/ops/nn.py

View check run for this annotation

Codecov / codecov/patch

onnxscript/function_libs/torch_lib/ops/nn.py#L490-L491

Added lines #L490 - L491 were not covered by tests
return result


Expand All @@ -505,8 +505,8 @@
inner = op.Mul(op.Sqrt(two_over_pi), inner)
inner = op.Tanh(inner)
inner = op.Add(inner, 1)
inner = op.Mul(self, inner)
result = op.Mul(0.5, inner)
inner = op.Mul(0.5, inner)
result = op.Mul(self, inner)

Check warning on line 509 in onnxscript/function_libs/torch_lib/ops/nn.py

View check run for this annotation

Codecov / codecov/patch

onnxscript/function_libs/torch_lib/ops/nn.py#L508-L509

Added lines #L508 - L509 were not covered by tests
return result


Expand Down
4 changes: 2 additions & 2 deletions onnxscript/rewriter/ort_fusions/gelu.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def pattern(self, op, x):
t4 = op.Mul(_sqrt_two_over_pi, t3)
t5 = op.Tanh(t4)
t6 = op.Add(t5, 1)
t7 = op.Mul(x, t6)
result = op.Mul(0.5, t7)
t7 = op.Mul(0.5, t6)
result = op.Mul(x, t7)
return result

def rewrite(self, op, x):
Expand Down
4 changes: 2 additions & 2 deletions onnxscript/rewriter/ort_fusions/gelu_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
t4 = op.Mul(_sqrt_two_over_pi, t3)
t5 = op.Tanh(t4)
t6 = op.Add(t5, 1)
t7 = op.Mul(x, t6)
result = op.Mul(0.5, t7)
t7 = op.Mul(0.5, t6)
result = op.Mul(x, t7)

Check warning on line 32 in onnxscript/rewriter/ort_fusions/gelu_test.py

View check run for this annotation

Codecov / codecov/patch

onnxscript/rewriter/ort_fusions/gelu_test.py#L31-L32

Added lines #L31 - L32 were not covered by tests
return result

model_proto = gelu_model.to_model_proto(
Expand Down
Loading