Skip to content

Commit 969ebaf

Browse files
committed
[ET-VK] Changing texture access pattern for conv2d dw ops to improve performance.
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. Differential Revision: [D67770160](https://our.internmc.facebook.com/intern/diff/D67770160/) [ghstack-poisoned]
1 parent 4d9679f commit 969ebaf

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

backends/vulkan/runtime/graph/ops/glsl/conv2d_dw.glsl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ layout(local_size_x_id = 0, local_size_y_id = 1, local_size_z_id = 2) in;
3535
* output at a single output location.
3636
*/
3737
void main() {
38-
const ivec3 pos = ivec3(gl_GlobalInvocationID);
38+
const ivec3 pos = ivec3(
39+
gl_GlobalInvocationID.x % out_limits.x,
40+
(gl_GlobalInvocationID.x / out_limits.x) % out_limits.y,
41+
gl_GlobalInvocationID.x / (out_limits.x * out_limits.y));
3942

4043
if (any(greaterThanEqual(pos, out_limits))) {
4144
return;

backends/vulkan/runtime/graph/ops/glsl/conv2d_dw_output_tile.glsl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ layout(local_size_x_id = 0, local_size_y_id = 1, local_size_z_id = 2) in;
3939
* output at a single output location.
4040
*/
4141
void main() {
42-
const u16vec3 pos = u16vec3(gl_GlobalInvocationID);
42+
const u16vec3 pos = u16vec3(
43+
gl_GlobalInvocationID.x % out_limits.x,
44+
(gl_GlobalInvocationID.x / out_limits.x) % out_limits.y,
45+
gl_GlobalInvocationID.x / (out_limits.x * out_limits.y));
4346

4447
if (any(greaterThanEqual(pos, out_limits))) {
4548
return;

backends/vulkan/runtime/graph/ops/impl/Convolution.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ void add_conv2d_node(
372372

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

375-
if (method == Conv2dMethod::Pointwise) {
375+
if (method == Conv2dMethod::Pointwise || method == Conv2dMethod::Depthwise) {
376376
wg_size = {wg_size[0] * wg_size[1] * wg_size[2], 1, 1};
377377
}
378378

0 commit comments

Comments
 (0)