Skip to content

Conversation

ricardoV94
Copy link
Member

What is this PR about?

This PR refactors repeated constant fold logic into a helper function in aesaraf

Checklist

Major / Breaking Changes

  • ...

Bugfixes / New features

  • Add constant_fold helper

Docs / Maintenance

  • ...

@codecov
Copy link

codecov bot commented Sep 27, 2022

Codecov Report

Merging #6150 (789e07c) into main (1417785) will decrease coverage by 2.64%.
The diff coverage is 70.83%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #6150      +/-   ##
==========================================
- Coverage   91.93%   89.28%   -2.65%     
==========================================
  Files         101       91      -10     
  Lines       20948    20717     -231     
==========================================
- Hits        19258    18497     -761     
- Misses       1690     2220     +530     
Impacted Files Coverage Δ
pymc/distributions/logprob.py 89.33% <33.33%> (-7.99%) ⬇️
pymc/distributions/timeseries.py 30.85% <40.00%> (-53.24%) ⬇️
pymc/aesaraf.py 93.54% <100.00%> (+0.15%) ⬆️
pymc/exceptions.py 100.00% <100.00%> (ø)
pymc/tests/step_methods/hmc/test_quadpotential.py 0.00% <0.00%> (-95.82%) ⬇️
pymc/tests/distributions/test_timeseries.py 0.00% <0.00%> (-95.79%) ⬇️
pymc/model_graph.py 66.66% <0.00%> (-12.29%) ⬇️
pymc/step_methods/hmc/quadpotential.py 73.76% <0.00%> (-6.94%) ⬇️
... and 16 more

Copy link
Member

@junpenglao junpenglao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

Comment on lines +997 to +998
if not all(isinstance(folded_x, Constant) for folded_x in folded_xs):
raise NotConstantValueError
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the implication if we remove this? folded_xs would just be a tensor?
I am thinking that instead of raising error, maybe we can make the function being "best effort constant fold".

Copy link
Member Author

@ricardoV94 ricardoV94 Sep 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be a tensor, but we cloned the graph, so it has nothing to do with the original one (except for shared inputs). If you tried to evaluate with the original inputs you would get unused input and missing input errors

Copy link
Member

@junpenglao junpenglao Sep 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL i was looking at this line and feeling we are being a bit more too aggressive - seems my hunch was justified.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean the follow up PR? If so, yeah I thought I had already pushed it and you were looking at it. My bad :P

@ricardoV94 ricardoV94 merged commit 75e9406 into pymc-devs:main Sep 28, 2022
@ricardoV94
Copy link
Member Author

ricardoV94 commented Sep 28, 2022

Oops a test was failing... I thought it was just the pre-commit issue that was fixed in the meantime

@ricardoV94 ricardoV94 added bug no releasenotes Skipped in automatic release notes generation labels Sep 28, 2022
@ricardoV94 ricardoV94 mentioned this pull request Sep 28, 2022
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug no releasenotes Skipped in automatic release notes generation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants