Skip to content

Commit bace537

Browse files
author
ssjia
committed
[ET-VK][qconv] Read weight buffer as int in pack_q8_conv2d_weights shader
The shader previously declared the input weight buffer as int8, requiring the GL_EXT_shader_8bit_storage extension which is not supported on all devices. Replace with an int (int32) buffer and extract individual bytes via shift-and-mask, the same technique used in nchw_to_int8x4_buffer.glsl. This makes the shader functional on devices without 8-bit buffer support. Differential Revision: [D94314255](https://our.internmc.facebook.com/intern/diff/D94314255/) [ghstack-poisoned]
1 parent 63f9724 commit bace537

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
#version 450 core
1010

11-
${define_required_extensions("buffer", "int8")}
12-
1311
#define PRECISION ${PRECISION}
1412

1513
${define_active_storage_type(STORAGE)}
@@ -19,7 +17,7 @@ ${define_active_storage_type(STORAGE)}
1917
layout(std430) buffer;
2018

2119
${layout_declare_tensor(B, "w", "t_packed_int8_weight", "int", STORAGE, is_scalar_array=False)}
22-
${layout_declare_tensor(B, "r", "t_int8_weight", "int8", "buffer")}
20+
${layout_declare_tensor(B, "r", "t_int8_weight", "int", "buffer")}
2321

2422
layout(push_constant) uniform restrict Block {
2523
ivec4 qmat2_sizes;
@@ -65,7 +63,9 @@ void main() {
6563
ivec4 weight_vals = ivec4(0);
6664
for (int col = 0; col < 4; col++) {
6765
if (ic + col < orig_sizes.w) {
68-
weight_vals[col] = int(t_int8_weight[buf_idx + col]);
66+
const int byte_idx = buf_idx + col;
67+
const int byte_pos = byte_idx & 3;
68+
weight_vals[col] = (t_int8_weight[byte_idx >> 2] >> (byte_pos * 8)) & 0xFF;
6969
}
7070
}
7171
packed_block[row] = pack_into_int32(weight_vals);

0 commit comments

Comments
 (0)