-
Notifications
You must be signed in to change notification settings - Fork 166
Optimize JoinDims and SplitDims by canonicalizing to simpler operations (Partial fixes #1843) #1847
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
Open
mengxingbw
wants to merge
12
commits into
pymc-devs:main
Choose a base branch
from
mengxingbw:fix/1843-rewrite-optimizations
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+79
−2
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
04e391e
Add canonicalization rewrites for JoinDims/SplitDims
mbaldourw 9a5e536
removed constant; merged func
mbaldourw 273ecc3
removed specify shape
mbaldourw 0037dfa
merged functions; updated test
mbaldourw cacda87
updated tests
mbaldourw 69943d5
fixed splitdims test; updated function def
mbaldourw 1c77c0e
fixed join dims def and test
mbaldourw 104ab1a
removed redundant assertion in test
mbaldourw e26249c
restored changes to reshape and updated test
mbaldourw a268570
cleaned up tests
mbaldourw 436d179
cleaned up redundant asserts
mbaldourw 80b45b9
restored original test
mbaldourw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The in_xs, in_ys is fishy
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.
when i take out the in_xs and in_ys, got this error:
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 don't need to create
FunctionGraph, pass the variable directly torewrite_graph(..., clone=False)(if clone=False is not the default already). That should mean the x before and after are the same variableThere 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.
I'm reading more into the
assert_equal_computationsandequal_computationsto understand what the in_xs and in_ys doThere 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.
xs and ys in are for cases where you have the same graph but the root variables (like x) are different. This can happen in this case if x is cloned by the FunctionGraph. But even in that case you should just say xs_in=[x], ys_in=[fg.inputs[0]]. (basically saying the original x is not the one in the fgraph.
But I don't think you need fgraph, or if you do you can pass
copy_inputs=Falseorclone=Falseso that it uses the original x as wellThere 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.
how do i write the test without fgraph? can i do rewrite_graph without the fgraph? then how does rewrite work?
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.
Yeah you can call rewrite graph on a variable. Internally it creates an fg for you, but I think it doesn't copy x. Give it a try, I could be wrong.
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.
Yeah you can call rewrite graph on a variable. Internally it creates an fg for you, but I think it doesn't copy x. Give it a try, I could be wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
if this is what you mean
I got the following error:
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 need to store the output of rewrite graph, that's the one you want to pass to the comparison function. And you want to pass the output to rewrite_graph not the input.
Something like