Skip to content
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

[Bugfix] Fix other div zero errors also in rewrite_simplify #8983

Merged
merged 9 commits into from
Sep 16, 2021

Conversation

syang-ng
Copy link
Contributor

Similar to the bug reported in PR 8961, I find there are other three divisions in src/arith/rewrite_simplify.cc also don't check whether the divisor is 0.

Bug Description

Each line of rewrite_simplify can trigger the segmentation fault error.

import tvm

analyzer = tvm.arith.Analyzer()
# mod
analyzer.rewrite_simplify(tvm.tir.Mod(tvm.tir.Ramp(1,1,2), tvm.tir.Broadcast(0, 2)))
# floordiv
analyzer.rewrite_simplify(tvm.tir.FloorDiv(tvm.tir.Ramp(1,1,2), tvm.tir.Broadcast(0, 2)))
# floormod
analyzer.rewrite_simplify(tvm.tir.FloorMod(tvm.tir.Ramp(1,1,2), tvm.tir.Broadcast(0, 2)))

To fix these errors, I add three zero checks in operator mod, floordiv, floormod. And I hope there will be no division by zero errors elsewhere :-)

@vinx13
Copy link
Member

vinx13 commented Sep 15, 2021

There are some flaky tests on CI, could you push again to retrigger CI?

@jroesch jroesch merged commit 6dc54aa into apache:main Sep 16, 2021
AndrewZhaoLuo added a commit to AndrewZhaoLuo/tvm that referenced this pull request Sep 16, 2021
* main: (102 commits)
  Implementation of relay_to_tir target hook (apache#8423)
  [Onnx] Fix NLL Loss tests (apache#8971)
  [Bugfix] Fix other div zero errors also in rewrite_simplify (apache#8983)
  [ONNX] enable the onnx tests after PR apache#8274 merged (apache#9019)
  [Hexagon] Disable `thread_local` on Hexagon (apache#9025)
  [Hexagon] Allow undefined symbols in libtvm_runtime.so on Hexagon (apache#9024)
  [Onnx] Add momentum (apache#9000)
  fix (apache#9021)
  [Community] @AndrewZhaoLuo -> Reviewer (apache#9020)
  [Hexagon] Implement model launcher (apache#8986)
  [Relay][Pass] Add ExtractOperators pass (apache#8996)
  [BYOC][TensorRT] Add TensorRT own int8 calibration support to TensorRT BYOC integration (apache#8808)
  [ONNX] Add Einsum converter (apache#8985)
  Add standalone_crt/ to be part of the wheel package, when available. (apache#9005)
  [Relay] Remove memory planing from LowerTEPass  (apache#8974)
  [Hexagon] Treat floats as float32 when passing args to offloaded kernels (apache#9010)
  [Runtime] Pipeline Executor Initial patch. (apache#8702)
  [Hexagon] `llvm-options` attribute is an array of strings (apache#9011)
  disable cuda int8 schedule for non-cuda gpu target (apache#9014)
  [Torch] Add an option to make imported models compatible with the Relay text parser (apache#9015)
  ...
ylc pushed a commit to ylc/tvm that referenced this pull request Sep 29, 2021
)

* fix div zero error in rewrite_simplify

* update the style to fix ci error

* remove useless code and comment

* fix div zero error of mod, floordiv, floormod in rewrite_simplify

* rewrite the test case of divison by zero to fix ci error

* remove useless tab

* retrigger ci

* remove useless blank to retrigger ci
@syang-ng syang-ng deleted the fix-division-by-zero branch November 16, 2021 08:30
ylc pushed a commit to ylc/tvm that referenced this pull request Jan 13, 2022
)

* fix div zero error in rewrite_simplify

* update the style to fix ci error

* remove useless code and comment

* fix div zero error of mod, floordiv, floormod in rewrite_simplify

* rewrite the test case of divison by zero to fix ci error

* remove useless tab

* retrigger ci

* remove useless blank to retrigger ci
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants