[Unity][Transform] Handle dynamic shapes in CombineParallelMatmul#16591
Merged
Lunderberg merged 2 commits intoapache:mainfrom Feb 23, 2024
Merged
Conversation
Prior to this commit, if the weight of a matmul a dynamic shape, and that matmul is being combined with the `CombineParallelMatmul` pass, it could cause a segfault when `dim.as<IntImmNode>()` returns a null pointer. This commit adds explicit test cases for these dynamic shapes, and updates `CombineParallelMatmul` to handle the dynamic shapes.
slyubomirsky
approved these changes
Feb 23, 2024
Contributor
slyubomirsky
left a comment
There was a problem hiding this comment.
The change seems fairly self-contained and I liked the clever use of a stable sort. The explanations for the test cases are also nice for understanding the intended behavior in these situations.
Random question: I just saw that CombineParallelMatmul is not listed in transform.h. Is that intentional? If not, we should probably make it available on the C++ side 😅
| }; | ||
| std::stable_sort(splits.begin(), splits.end(), | ||
| [&is_dynamic_split](const auto& a, const auto& b) { | ||
| return is_dynamic_split(a) < is_dynamic_split(b); |
Contributor
There was a problem hiding this comment.
Very clever to use a comparison between bools.
Contributor
Author
There was a problem hiding this comment.
Thank you. I went back and forth on whether this was reasonably clever, or too clever, and I think I like it.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Prior to this commit, if the weight of a matmul a dynamic shape, and that matmul is being combined with the
CombineParallelMatmulpass, it could cause a segfault whendim.as<IntImmNode>()returns a null pointer.This commit adds explicit test cases for these dynamic shapes, and updates
CombineParallelMatmulto handle the dynamic shapes.