Skip to content

Commit 81732ce

Browse files
committed
Update on "[ET-VK] Using push constants for buffer to image prepack nodes."
This diff enables the use of push constants for buffer to image prepack nodes in the Vulkan runtime graph. Push constants are a more efficient way to pass small amounts of data to shaders, compared to using uniform buffers. * The `nchw_to_*.yaml` files have been updated to include the `USE_PUSH_CONST` flag which is `True` by default, and enables the use of push constants for all `nchw_to_*` operations. * New variants of the `nchw_to_*` operation have been added with suffix `_no_pc`, which do not use push constants. These variants are used for compatibility with testing and utility functions. * The `Convolution.cpp` and `Staging.cpp` files have been updated to pass empty parameter buffers and instead use push constants. Differential Revision: [D70102398](https://our.internmc.facebook.com/intern/diff/D70102398/) [ghstack-poisoned]
2 parents eb9986f + 3c2081f commit 81732ce

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ 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] =
50+
{(out_limits.x + (TILE_SIZE_X - 1)) / TILE_SIZE_X,
51+
(out_limits.y + (TILE_SIZE_Y - 1)) / TILE_SIZE_Y};
5052

5153
const int div_by_x = int(gl_GlobalInvocationID.x / out_limits_scaled[0]);
5254
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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ 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] =
52+
{(out_limits.x + (TILE_SIZE_X - 1)) / TILE_SIZE_X,
53+
(out_limits.y + (TILE_SIZE_Y - 1)) / TILE_SIZE_Y};
5254

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

backends/vulkan/test/utils/test_utils.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ void record_nchw_to_image_op(
7474

7575
context->submit_compute_job(
7676
get_nchw_to_tensor_shader(
77-
v_dst, context->adapter_ptr()->has_full_int8_buffers_support(), false),
77+
v_dst,
78+
context->adapter_ptr()->has_full_int8_buffers_support(),
79+
false),
7880
pipeline_barrier,
7981
v_dst.logical_limits(),
8082
adaptive_work_group_size(v_dst.logical_limits()),

0 commit comments

Comments
 (0)