Skip to content
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

[Unity][Transform] Handle dynamic shapes in CombineParallelMatmul #16591

Merged

Conversation

Lunderberg
Copy link
Contributor

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.

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.
Copy link
Contributor

@slyubomirsky slyubomirsky left a comment

Choose a reason for hiding this comment

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

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);
Copy link
Contributor

Choose a reason for hiding this comment

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

Very clever to use a comparison between bools.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. I went back and forth on whether this was reasonably clever, or too clever, and I think I like it.

@Lunderberg Lunderberg merged commit 89cc09c into apache:main Feb 23, 2024
20 checks passed
@Lunderberg Lunderberg deleted the relax_dynamic_combine_parallel_matmul branch February 23, 2024 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants