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

[Simplifier] Rewrite simplification rule to eliminate unnecessary conditionals. #4076

Merged
merged 1 commit into from
Oct 9, 2019

Conversation

ajtulloch
Copy link
Contributor

@ajtulloch ajtulloch commented Oct 7, 2019

The current bounds checking infrastructure inserts checks like:

for (i, 0, bounds[n]) {
  if (likely(i < bounds[n]) {
     ...
  }
}

into the TVM IR which is currently not removed by simplification infrastructure.

This is a little unclean, as these are trivially true since for a loop var i with a given min and extent, we are guaranteed that i >= min and i < min + extent. Thus, we can insert these checks into the IR and use them to eliminate trivial bounds checks early on.

Unit tests added, and now pass.

Resolves #3770 . cc @tqchen @sgrechanik-h

The current bounds checking infrastructure inserts checks like:

```
for (i, 0, bounds[n]) {
  if (likely(i < bounds[n]) {
     ...
  }
}
```

into the TVM IR which is currently not removed by simplification infrastructure.
This is a little unclean, as these are trivially true since for a loop var `i`
with a given min and extent, we are guaranteed that `i >= min` and `i < min +
extent`. Thus, we can insert these checks into the IR and use them to eliminate
trivial bounds checks early on.
@tqchen tqchen merged commit f2abd9f into apache:master Oct 9, 2019
@tqchen
Copy link
Member

tqchen commented Oct 9, 2019

Thanks @ajtulloch !

anijain2305 pushed a commit to anijain2305/tvm that referenced this pull request Oct 17, 2019
…ls. (apache#4076)

The current bounds checking infrastructure inserts checks like:

```
for (i, 0, bounds[n]) {
  if (likely(i < bounds[n]) {
     ...
  }
}
```

into the TVM IR which is currently not removed by simplification infrastructure.
This is a little unclean, as these are trivially true since for a loop var `i`
with a given min and extent, we are guaranteed that `i >= min` and `i < min +
extent`. Thus, we can insert these checks into the IR and use them to eliminate
trivial bounds checks early on.
wweic pushed a commit to neo-ai/tvm that referenced this pull request Oct 18, 2019
…ls. (apache#4076)

The current bounds checking infrastructure inserts checks like:

```
for (i, 0, bounds[n]) {
  if (likely(i < bounds[n]) {
     ...
  }
}
```

into the TVM IR which is currently not removed by simplification infrastructure.
This is a little unclean, as these are trivially true since for a loop var `i`
with a given min and extent, we are guaranteed that `i >= min` and `i < min +
extent`. Thus, we can insert these checks into the IR and use them to eliminate
trivial bounds checks early on.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Simplifier] [Regression] Bounds checks for variable-extent loops not eliminated by simplifier
2 participants