-
Notifications
You must be signed in to change notification settings - Fork 87
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 support for the dilations attribute to Pooling ops #2105
Conversation
For such changes, it would require tests inside and verify tests. which would run the operator/program on GPU and compare it with the reference implementation. Looks like MIOpen doesn't support dilations so we won't have GPU implementation. |
@umangyadav Is there a way we can insert some other operators to get the same dilation result on the GPU, similar to how we do for non-symmetrical padding? Like using step or reshape/broadcast/reshape? |
We updated the test part where dilations where missing, and added new tests as well. |
implementation.
8250a47
to
53a10bc
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## develop #2105 +/- ##
==========================================
Coverage ? 91.39%
==========================================
Files ? 440
Lines ? 16591
Branches ? 0
==========================================
Hits ? 15162
Misses ? 1429
Partials ? 0 ☔ View full report in Codecov by Sentry. |
cc @pfultz2 |
734ebf1
to
d639171
Compare
You would insert a step operator with the same value as the dilation, and using the axes for the image. Like `make_op("step", {{"axes", {2, 3}}, {"steps", {dilation_for_h, dilation_for_w}}}). |
{ | ||
if(idx_w[axis] % dilations[axis]) | ||
{ | ||
pool_size -= 1; |
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.
pool_size
should be adjusted before calling shape_for_each
.
@@ -390,7 +411,15 @@ struct pooling | |||
// this is a padding element. Padding locations | |||
// don't contribute to average or max pooling total but can play in | |||
// lpnorm pooling. | |||
output_val = op(output_val, 0); |
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.
This should just be output_val = op(output_val, op.template init<Type>());
. Using 0
is a bug.
|
||
private: | ||
void replace_with_reduce(module& m, instruction_ref ins) const; | ||
void replace_dilations_with_gather_pooling(module& m, instruction_ref ins) const; |
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.
These should be static functions defined in rewrite_pooling.cpp file.
for(const auto& d : op.dilations) | ||
ss << d << ","; | ||
ss << "]"; | ||
MIGRAPHX_THROW(ss.str()); |
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.
Just do MIGRAPHX_THROW("Unsupported dilations for pooling: [" + to_string_range(op.dilations) + "]")
instead.
Addressed requested changes, except this:
I tried to calculate it beforehand, but did not managed to resolve the dyn pad cases properly 😞 ( |
84b4676
to
d8de555
Compare
@@ -80,6 +81,483 @@ TEST_CASE(rewrite_pooling_test) | |||
migraphx::make_op("reduce_max", {{"axes", {2, 3, 4}}})); | |||
} | |||
|
|||
TEST_CASE(rewrite_pooling_dialtions_test) |
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.
TEST_CASE(rewrite_pooling_dialtions_test) | |
TEST_CASE(rewrite_pooling_dilations_test) |
auto result = p.eval({}).back(); | ||
std::vector<float> results_vector; | ||
result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); | ||
std::vector<float> gold{0.7812, 1.0449, 2.7666, 2.6859}; |
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.
How are you getting these gold values? Want to make sure that we know these are correct.
dilations
attribute