Skip to content

Commit

Permalink
[ET-VK] Changing texture access pattern for conv2d dw ops to improve …
Browse files Browse the repository at this point in the history
…performance. (#7505)

* [ET-VK] Reduced int precision for all int storage in conv pw op to improve performance.

Pull Request resolved: #7447

This diff reduces the precision of all int storage in the conv pw op to improve performance. The code changes include adding the extension GL_EXT_shader_explicit_arithmetic_types_int16 and changing the data type of ints to uint16.

ghstack-source-id: 260166244
@exported-using-ghexport

Differential Revision: [D67674212](https://our.internmc.facebook.com/intern/diff/D67674212/)

* [ET-VK] Minor fix to conv 2d op using wg_size from create_conv2d_global_wg_size to determine local wg size.

Pull Request resolved: #7450

This diff contains changes to the Convolution.cpp file in the Vulkan backend of Executorch. The changes involve updating the code to use the create_conv2d_global_wg_size function to determine the local workgroup size for the convolution operation. This is done to ensure that the correct workgroup size is used for the operation, which can improve performance.

ghstack-source-id: 260166246
@exported-using-ghexport

Differential Revision: [D67676422](https://our.internmc.facebook.com/intern/diff/D67676422/)

* [ET-VK] Modify conv 2d pw op shader and dispatch settings to linearly dispatch work accounting for linearity texture to improve performance.

Pull Request resolved: #7452

This diff modifies the convolution 2D pointwise op shader and dispatch settings to linearly dispatch work accounting for linearity texture to improve performance.
ghstack-source-id: 260166247
@exported-using-ghexport

Differential Revision: [D67683411](https://our.internmc.facebook.com/intern/diff/D67683411/)

* [ET-VK] Using vec2 to store output positions to reudce shader register footprint.

Pull Request resolved: #7474

The diff changes the use of `u16vec3` to `u16vec2` to store output positions in the conv2d_pw op. This change is made to reduce the shader register footprint and improve performance.
ghstack-source-id: 260166245
@exported-using-ghexport

Differential Revision: [D67726229](https://our.internmc.facebook.com/intern/diff/D67726229/)

* [ET-VK] Using shared variable to store calculated output pose to free up registers and improve performance.

Pull Request resolved: #7475

This diff introduces a shared variable to store calculated output pose in conv2d_pw op to free up registers and improve performance. The code changes include adding a shared variable to hold calculated positions and modifying the existing code to use the shared variable.
ghstack-source-id: 260166242

Differential Revision: [D67742567](https://our.internmc.facebook.com/intern/diff/D67742567/)

* [ET-VK] Changing texture access pattern for conv2d pw op to improve performance.

Pull Request resolved: #7476

This diff changes the texture access pattern for conv2d pw op to iterate first on x axis then y and then z to improve performance.
ghstack-source-id: 260166241
@exported-using-ghexport

Differential Revision: [D67769100](https://our.internmc.facebook.com/intern/diff/D67769100/)

* [ET-VK] Changing texture access pattern for conv2d dw op to improve performance.

Pull Request resolved: #7477

This diff changes the texture access pattern for convolutional depthwise (DW) operations in Executorch's Vulkan backend to iterate first on x axis then y and then z to improve performance.
ghstack-source-id: 260166240
@exported-using-ghexport

Differential Revision: [D67770160](https://our.internmc.facebook.com/intern/diff/D67770160/)

---------

Co-authored-by: Vivek Trivedi <5340687+trivedivivek@users.noreply.github.com>
  • Loading branch information
pytorchbot and trivedivivek authored Jan 4, 2025
1 parent 3508421 commit ee05e63
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion backends/vulkan/runtime/graph/ops/glsl/conv2d_dw.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ layout(local_size_x_id = 0, local_size_y_id = 1, local_size_z_id = 2) in;
* output at a single output location.
*/
void main() {
const ivec3 pos = ivec3(gl_GlobalInvocationID);
const ivec3 pos = ivec3(
gl_GlobalInvocationID.x % out_limits.x,
(gl_GlobalInvocationID.x / out_limits.x) % out_limits.y,
gl_GlobalInvocationID.x / (out_limits.x * out_limits.y));

if (any(greaterThanEqual(pos, out_limits))) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ layout(local_size_x_id = 0, local_size_y_id = 1, local_size_z_id = 2) in;
* output at a single output location.
*/
void main() {
const u16vec3 pos = u16vec3(gl_GlobalInvocationID);
const u16vec3 pos = u16vec3(
gl_GlobalInvocationID.x % out_limits.x,
(gl_GlobalInvocationID.x / out_limits.x) % out_limits.y,
gl_GlobalInvocationID.x / (out_limits.x * out_limits.y));

if (any(greaterThanEqual(pos, out_limits))) {
return;
Expand Down
2 changes: 1 addition & 1 deletion backends/vulkan/runtime/graph/ops/impl/Convolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ void add_conv2d_node(

utils::uvec3 wg_size = create_conv2d_global_wg_size(graph, method, out);

if (method == Conv2dMethod::Pointwise) {
if (method == Conv2dMethod::Pointwise || method == Conv2dMethod::Depthwise) {
wg_size = {wg_size[0] * wg_size[1] * wg_size[2], 1, 1};
}

Expand Down

0 comments on commit ee05e63

Please sign in to comment.