-
Notifications
You must be signed in to change notification settings - Fork 641
[ET-VK] Add 2D Reduction to Vulkan Backend #12860
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
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/12860
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ❌ 2 New Failures, 1 Unrelated FailureAs of commit 3ca809f with merge base 9d86cbe ( NEW FAILURES - The following jobs have failed:
BROKEN TRUNK - The following job failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
@pytorchbot label "release notes: vulkan" |
Co-authored-by: Mateusz Sluszniak <[email protected]>
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.
LGTM with some small comments. Thanks for working on this!
// with the accumulator. | ||
#define POSTPROCESS(accum) ${POSTPROCESS} | ||
|
||
void reduce_2d(const ivec2 tid, ivec3 scan_pos) { |
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.
As I understand it, this implementation doesn't currently support reduction among the elements of a texel,.
So for example for a tensor of size (channels = 4, height = 16, width = 16)
where reading one texel returns 4 channels, this function would only be able to handle reduction along the height and width dims, but not if channels is one of the dims being reduced - is that correct?
If so, we can leave the more generalized implementation for later, but we should add some checks to make sure we don't lower unsupported cases to Vulkan 😛
Would also recommend renaming this function to reduce_2d_non_texel_dim
or reduce_2d_non_packed_dim
.
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.
Yup you're right, this doesn't support reduction among the elements of a texel. Just changed to reduce_2d_non_packed_dim. Let me know if you're aligned
reduce_dim1 = nchw_dim_to_whcn_dim(reduce_dim1, ndim); | ||
reduce_dim2 = nchw_dim_to_whcn_dim(reduce_dim2, ndim); | ||
|
||
// Check that the concat dim is not one of the reduction dims |
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.
should also add a check that graph.packed_dim_of(in)
and graph.packed_dim_of(out)
is not one of the reduction dims.
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 added above this comment. Let me know if you're aligned
Summary: This change adds 2D reduction to the Vulkan delegate. Prior to this change, only 1D reduction was implemented. Models like MobileNetV3 and ResNet do 2D reduction, and their performance was being negatively impacted by the lack of a 2D reduction Vulkan implementation.
cc @SS-JIA @manuelcandales @cbilgin