Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[shape_polyO] Performance improvements for symbolic dimension manipul…
…ations (step 2) We make the following improvements: * Cache the state of the decision procedure after we process the explicit constraints, and reuse it for new decisions. * Rationalize the usage of add_implicit_constraints. We used to call it conservatively, too often. Now we call it only once for each explicit constraint, and once for each bounds decision we make. Then, in the add_implicit_constraints we call it recursively when we encounter new sub-expressions. * Eliminate some usage of __str__ for symbolic expressions in combine_and_add_constraints since we should only need it for reporting error messages. This speeds up inequality reasoning: Before: ``` In [1]: from jax.experimental import export ...: from jax import core ...: a, b, c = export.symbolic_shape("a, b, c", constraints=["a >= 3", "a <= 5", "b >= 8"]) In [2]: %timeit a >= b 109 µs ± 637 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each) In [3]: %timeit core.max_dim(a, c) >= a - c 442 µs ± 2.22 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each) ``` After: ``` In [2]: %timeit a >= b 11.7 µs ± 27.2 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each) In [3]: %timeit core.max_dim(a, c) >= a - c 34.8 µs ± 175 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each) ```
- Loading branch information
Showing
3 changed files
with
95 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters