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

Faster infer_static_shape #521

Merged
merged 1 commit into from
Nov 27, 2023
Merged

Conversation

ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented Nov 24, 2023

This method which is called every time we create an Alloc or RandomVariable Op, can be pretty slow, because it calls canonicalize + constant_folding on the shape graph, which can be pretty large sometimes. This can also be pretty wasteful if the shapes are already constant to begin with!

The utility is now much more targeted, using only rewrites that are directly relevant for static shape propagation. It also avoids doing costly C-compilation

This should result in much snappier creation of RandomVariables and rewrites

@codecov-commenter
Copy link

codecov-commenter commented Nov 24, 2023

Codecov Report

Merging #521 (77e597d) into main (7ecb9f8) will increase coverage by 0.01%.
The diff coverage is 91.78%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #521      +/-   ##
==========================================
+ Coverage   80.82%   80.84%   +0.01%     
==========================================
  Files         162      162              
  Lines       46194    46249      +55     
  Branches    11288    11318      +30     
==========================================
+ Hits        37337    37388      +51     
- Misses       6630     6633       +3     
- Partials     2227     2228       +1     
Files Coverage Δ
pytensor/tensor/rewriting/basic.py 94.09% <100.00%> (+0.08%) ⬆️
pytensor/tensor/rewriting/math.py 86.50% <100.00%> (+<0.01%) ⬆️
pytensor/tensor/rewriting/shape.py 81.43% <100.00%> (+0.41%) ⬆️
pytensor/tensor/rewriting/subtensor.py 88.80% <100.00%> (+0.07%) ⬆️
pytensor/tensor/shape.py 93.09% <86.66%> (+0.01%) ⬆️
pytensor/tensor/basic.py 88.39% <87.50%> (-0.05%) ⬇️

@ricardoV94 ricardoV94 changed the title Faster infer_shape Faster infer_static_shape Nov 27, 2023
@ricardoV94 ricardoV94 marked this pull request as ready for review November 27, 2023 14:29
@ricardoV94 ricardoV94 requested review from twiecki and removed request for ferrine November 27, 2023 15:19
@ricardoV94 ricardoV94 merged commit af7ed24 into pymc-devs:main Nov 27, 2023
53 checks passed
@ricardoV94 ricardoV94 mentioned this pull request Dec 11, 2023
11 tasks
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.

3 participants