Skip to content

Conversation

@lhutton1
Copy link
Contributor

@lhutton1 lhutton1 commented Mar 8, 2023

In the test test_llvm_div, some cases can lead to a division by 0. Consider the case when start=-12, end=-12, dstart=-2 and dend=0, the range of values input to clipb() will be: [-12, ..., -1, 1] (with 1 being specially selected to prevent division by 0). For the input 1, clipb evaluates to: min(/*dend=*/0, max(/*dstart=*/-12, /*i=*/1)) = 0, thus leading to a division by 0.

LLVM11, which runs in CI, doesn't seem to throw any kind of error, while using LLVM15 leads to a "floating point exception". Regardless, since division by 0 is undefined behaviour and the compiler can do anything, the solution here is to fix the test so division by 0 doesn't occur.

In the test `test_llvm_div`, some cases can lead to a division by 0.
Consider the case when `start=-12, end=-12, dstart=-2 and dend=0`, the
range of values input to clipb() will be: [-12, ..., -1, 1] (with 1
being specially selected to prevent division by 0). For the input 1,
clipb evaluates to: min(/*dend=*/0, max(/*dstart=*/-12, /*i=*/1)) = 0,
thus leading to a division by 0.

LLVM11, which runs in CI, doesn't seem to throw any kind of error, while
using LLVM15 leads to a "floating point exception". Regardless, since
division by 0 is undefined behaviour and the compiler can do anything,
the solution here is to fix the test so division by 0 doesn't occur.

Change-Id: Ib82776e9e0aff443dacc101a579d382059bb9826
@tvm-bot
Copy link
Collaborator

tvm-bot commented Mar 8, 2023

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

  • No users to tag found in teams: test See #10317 for details

Generated by tvm-bot

Copy link
Contributor

@asparkhi asparkhi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @lhutton1 - LGTM!

@junrushao junrushao merged commit 6b4e3d0 into apache:main Mar 9, 2023
@lhutton1 lhutton1 deleted the fix-div-0-test branch March 14, 2023 23:22
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.

4 participants