-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add Constant fold helper #6150
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
Add Constant fold helper #6150
Conversation
858f124
to
789e07c
Compare
Codecov Report
Additional details and impacted files@@ 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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice.
if not all(isinstance(folded_x, Constant) for folded_x in folded_xs): | ||
raise NotConstantValueError |
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Oops a test was failing... I thought it was just the pre-commit issue that was fixed in the meantime |
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
constant_fold
helperDocs / Maintenance