Skip to content

Commit 4792e66

Browse files
committed
[ET-VK] Fixing out_limits_scaled calculation for conv2d pw ops.
The fix changing the calculation of `out_limits_scaled` from: ```glsl const int out_limits_scaled[2] = {out_limits.x + (TILE_SIZE_X - 1) * TILE_SIZE_X, out_limits.y + (TILE_SIZE_Y - 1) * TILE_SIZE_Y}; ``` to: ```glsl const int out_limits_scaled[2] = {(out_limits.x + (TILE_SIZE_X - 1)) / TILE_SIZE_X, (out_limits.y + (TILE_SIZE_Y - 1)) / TILE_SIZE_Y}; ``` This change ensures that `out_limits_scaled` is calculated correctly, taking into account the tile size and the output limits of the convolution operation. Differential Revision: [D75575662](https://our.internmc.facebook.com/intern/diff/D75575662/) [ghstack-poisoned]
1 parent 95e883c commit 4792e66

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ layout(local_size_x_id = 0, local_size_y_id = 1, local_size_z_id = 2) in;
4646
* size is only 1x1, making it easier to re-use loaded texels from t_kernel.
4747
*/
4848
void main() {
49-
const int out_limits_scaled[2] = {out_limits.x + (TILE_SIZE_X - 1) * TILE_SIZE_X, out_limits.y + (TILE_SIZE_Y - 1) * TILE_SIZE_Y};
49+
const int out_limits_scaled[2] = {(out_limits.x + (TILE_SIZE_X - 1)) / TILE_SIZE_X, (out_limits.y + (TILE_SIZE_Y - 1)) / TILE_SIZE_Y};
5050

5151
const int div_by_x = int(gl_GlobalInvocationID.x / out_limits_scaled[0]);
5252
const int out_pos[3] = {int(gl_GlobalInvocationID.x % out_limits_scaled[0]), div_by_x, int(gl_GlobalInvocationID.y)};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ layout(local_size_x_id = 0, local_size_y_id = 1, local_size_z_id = 2) in;
4848
* size is only 1x1, making it easier to re-use loaded texels from t_kernel.
4949
*/
5050
void main() {
51-
const int out_limits_scaled[2] = {out_limits.x + (TILE_SIZE_X - 1) * TILE_SIZE_X, out_limits.y + (TILE_SIZE_Y - 1) * TILE_SIZE_Y};
51+
const int out_limits_scaled[2] = {(out_limits.x + (TILE_SIZE_X - 1)) / TILE_SIZE_X, (out_limits.y + (TILE_SIZE_Y - 1)) / TILE_SIZE_Y};
5252

5353
const uint16_t div_by_x = uint16_t(gl_GlobalInvocationID.x / out_limits_scaled[0]);
5454
const uint16_t out_pos_xy[2] = {uint16_t(gl_GlobalInvocationID.x % out_limits_scaled[0]), div_by_x};

0 commit comments

Comments
 (0)