From bf7ef40e3dc8a56366580b1ea0eb00d0038eb91a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20S=C5=82uszniak?= Date: Sun, 13 Sep 2026 13:17:12 +0200 Subject: [PATCH] Vulkan: halve the pointwise conv spatial tile conv2d_pw_tiled is generated only at TILE_M=4. TILE_M=2 is faster on every model and both GPU vendors measured, and the tile size is otherwise unchanged, so this just moves the generated variant. Mali-G76 (Galaxy S10+), conv2d_pw / whole-graph GPU, median of interleaved rounds: lraspp-mobilenet-v3-large fp16 @520 71.5 -> 43.8 ms (1.63x) and 99.3 -> 71.7 ms (1.38x); selfie-segmentation fp16 @256 4.21 -> 2.32 ms (1.82x) and 8.46 -> 6.54 ms (1.29x). Adreno 840 (Galaxy S26 Ultra): lraspp 5.35 -> 5.00 ms (1.07x) and 10.95 -> 10.59 ms (1.03x); selfie 0.530 -> 0.435 ms (1.22x) and 1.050 -> 0.956 ms (1.10x); PP-OCRv6 fp16 neutral at 1.00x / 0.99x. Going the other way is much worse, which is what makes 2 the optimum rather than a local accident: TILE_M=1 is 0.97x, TILE_M=8 0.24x, TILE_N4=2 0.16x and TILE_N4=4 0.06x on Mali. Output is bit identical at every tile size tested. --- backends/vulkan/runtime/graph/ops/glsl/conv2d_pw_tiled.yaml | 2 +- backends/vulkan/runtime/graph/ops/impl/Conv2dPW.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backends/vulkan/runtime/graph/ops/glsl/conv2d_pw_tiled.yaml b/backends/vulkan/runtime/graph/ops/glsl/conv2d_pw_tiled.yaml index 037dfc35c89..82a6dcd24e2 100644 --- a/backends/vulkan/runtime/graph/ops/glsl/conv2d_pw_tiled.yaml +++ b/backends/vulkan/runtime/graph/ops/glsl/conv2d_pw_tiled.yaml @@ -11,7 +11,7 @@ conv2d_pw_tiled: TILE_M4: 1 TILE_K4: 1 TILE_N4: 1 - TILE_M: 4 + TILE_M: 2 generate_variant_forall: DTYPE: - VALUE: float diff --git a/backends/vulkan/runtime/graph/ops/impl/Conv2dPW.cpp b/backends/vulkan/runtime/graph/ops/impl/Conv2dPW.cpp index 7c5f9f0bc0a..3c227448cf2 100644 --- a/backends/vulkan/runtime/graph/ops/impl/Conv2dPW.cpp +++ b/backends/vulkan/runtime/graph/ops/impl/Conv2dPW.cpp @@ -79,8 +79,8 @@ GlobalWorkGrid pick_conv2d_pw_tiled_gwg( uint32_t C_out = graph->size_at(-3, out); uint32_t M = H * W; uint32_t N4 = utils::div_up_4(C_out); - // TILE_N4=1, TILE_M=4 - return GlobalWorkGrid({N4, utils::div_up(M, 4u), 1u}, kTiledWorkGrid); + // TILE_N4=1, TILE_M=2. Must match conv2d_pw_tiled.yaml. + return GlobalWorkGrid({N4, utils::div_up(M, 2u), 1u}, kTiledWorkGrid); } //