-
Notifications
You must be signed in to change notification settings - Fork 88
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
Broadcast with dims matcher #2927
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4c2643a
Merge branch 'expand_dyn_op' into broadcast_with_dims_matcher
bpickrel beeed3a
added simplify_dyn_ops matcher to substitute broadcast_with_dims op, …
bpickrel 96950d6
tidy changes
bpickrel f46788b
Merge branch 'expand_dyn_op' into broadcast_with_dims_matcher
bpickrel ad7998d
Comments
bpickrel 165d23e
cosmetic variable name change
bpickrel 39b15ce
comment
bpickrel 371a873
remove duplicated tests
bpickrel 21f42b7
added a negative simplify_dyn_ops test
bpickrel e8ffc81
style; changed vector initialization
bpickrel 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
There are no files selected for viewing
This file contains 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 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,56 @@ void run_pass(migraphx::module& m) | |
migraphx::run_passes(m, {migraphx::simplify_dyn_ops{}, migraphx::dead_code_elimination{}}); | ||
} | ||
|
||
TEST_CASE(broadcast_with_dims) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @CharlieL7 can you think of any other tests needed for this matcher PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good as is |
||
{ | ||
migraphx::module m0; | ||
{ | ||
// the X input | ||
migraphx::shape sx{migraphx::shape::float_type, {3, 1, 1}}; | ||
auto inx = m0.add_parameter("x", sx); | ||
|
||
// the shape input. Broadcast to this | ||
migraphx::shape dims_s{migraphx::shape::int64_type, {4}}; | ||
std::vector<size_t> dims = {2, 3, 4, 5}; | ||
auto out_dims = m0.add_literal(migraphx::literal{dims_s, dims}); | ||
|
||
auto r = m0.add_instruction(migraphx::make_op("broadcast_with_dims"), inx, out_dims); | ||
m0.add_return({r}); | ||
} | ||
run_pass(m0); | ||
|
||
migraphx::module m1; | ||
{ | ||
migraphx::shape sx{migraphx::shape::float_type, {3, 1, 1}}; | ||
auto inx = m1.add_parameter("x", sx); | ||
|
||
auto r = m1.add_instruction( | ||
migraphx::make_op("multibroadcast", {{"out_lens", {2, 3, 4, 5}}}), inx); | ||
m1.add_return({r}); | ||
} | ||
EXPECT(m0 == m1); | ||
} | ||
|
||
TEST_CASE(broadcast_with_dims_invalid) | ||
{ | ||
migraphx::module m0; | ||
{ | ||
// X input shape is not broadcastable to given shape | ||
migraphx::shape sx{migraphx::shape::float_type, {3, 1, 2}}; | ||
auto inx = m0.add_parameter("x", sx); | ||
|
||
// the shape input. Broadcast to this | ||
migraphx::shape dims_s{migraphx::shape::int64_type, {4}}; | ||
std::vector<size_t> dims = {2, 3, 4, 5}; | ||
auto out_dims = m0.add_literal(migraphx::literal{dims_s, dims}); | ||
|
||
auto r = m0.add_instruction(migraphx::make_op("broadcast_with_dims"), inx, out_dims); | ||
m0.add_return({r}); | ||
} | ||
// replacement will be rejected by multibroadcast operation | ||
EXPECT(test::throws([&] { run_pass(m0); })); | ||
} | ||
|
||
TEST_CASE(resize) | ||
{ | ||
migraphx::module m0; | ||
|
Oops, something went wrong.
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.
@CharlieL7 I think these two tests were from you, but Github is showing them as new to this PR. Did you mean to keep them, or not?
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 tests look the same to me, just moved around.