Skip to content

Conversation

@ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented Nov 4, 2024

The existing constant_folding makes use of Op.do_constant_folding to decide whether to apply itself or not, even when all inputs are constant. This is a hackish way of trying to not perform constant_folding in cases where it may lead to a sub-optimal graph (basically requiring extra copies). It is also used for rewrites to have a chance to apply themselves.

This PR adds a constant_folding helper that does not follow this logic. It is not registered in the database. It's meant for advanced users / libraries to force constant_folding whenever it it is actually possible to.


📚 Documentation preview 📚: https://pytensor--1068.org.readthedocs.build/en/1068/

@ricardoV94 ricardoV94 added enhancement New feature or request graph rewriting labels Nov 4, 2024
@ricardoV94 ricardoV94 requested a review from lucianopaz November 4, 2024 12:25
@codecov
Copy link

codecov bot commented Nov 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.95%. Comparing base (e73258b) to head (560f41e).
Report is 97 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@ Coverage Diff @@ ## main #1068 +/- ## ======================================= Coverage 81.95% 81.95% ======================================= Files 182 182 Lines 47866 47870 +4 Branches 8622 8622 ======================================= + Hits 39228 39232 +4  Misses 6472 6472 Partials 2166 2166 
Files with missing lines Coverage Δ
pytensor/tensor/rewriting/basic.py 94.15% <100.00%> (+0.03%) ⬆️
@ricardoV94 ricardoV94 merged commit f2ad711 into pymc-devs:main Nov 11, 2024
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request graph rewriting

2 participants