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

[shape_poly] Add heuristics for deciding >= 0 #18762

Merged
merged 1 commit into from
Dec 1, 2023

Conversation

gnecula
Copy link
Collaborator

@gnecula gnecula commented Dec 1, 2023

The rules for deciding inequalities of symbolic expressions are incomplete. Here we add two heuristics that help decide the bounds checking of indices computed for indexing with slices:

  1. To decide whether an expression that contains non_negative(e) is >= 0, it is sufficient to show that the expression is >=0 if we replace the non_negative(e) with 0 and with e.

  2. To decide whether floordiv(e, k) is >= 0, when k >= 0, it is sufficient to show that e is >= 0.

These are sufficient for the bounds checking that JAX is doing internally, but may not be for the cases when the user program does index computations using those operators.

This enables us to re-enable the shape_poly indexing tests.

@gnecula gnecula self-assigned this Dec 1, 2023
@gnecula gnecula added the pull ready Ready for copybara import and testing label Dec 1, 2023
The rules for deciding inequalities of symbolic expressions
are incomplete. Here we add two heuristics that help decide
the bounds checking of indices computed for indexing with slices:

To decide whether an expression that contains `non_negative(e)` is
>= 0, it is sufficient to show that the expression is >=0 if we
replace the `non_negative(e)` with `0` and with `e`.

To decide whether `floordiv(e, k)` is >= 0, when `k >= 0`, it
is sufficient to show that `e` is >= 0.

These are sufficient for the bounds checking that JAX is doing
internally, but may not be for the cases when the user program
does index computations using those operators.

This enables us to re-enable the shape_poly indexing tests.
@copybara-service copybara-service bot merged commit b3c579e into jax-ml:main Dec 1, 2023
7 checks passed
@gnecula gnecula deleted the poly_getitem_next branch December 1, 2023 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pull ready Ready for copybara import and testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant