You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[ET-VK] Add nchw_to_int8x4_buffer shader for prepacking int8 staging data
Pull Request resolved: #17392
This adds a GLSL compute shader and supporting C++ dispatch logic to transfer
int8 tensor data from a staging buffer (in NCHW contiguous order) to a GPU
buffer in any PackedInt8 layout (4W, 4C, 4W4C, 4H4W, 4C1W).
Previously there was no prepack path for kInt8x4 tensors, so constant int8
tensors (TensorRef inputs) could not be transferred to GPU buffers. This is
needed to support constant quantized weights in q8ta operators.
The shader uses texel-level dispatch where each thread writes one texel (one
int32 = 4 packed int8 values). It decomposes the texel index into block-space
coordinates using BufferMetadata strides and hashed_layout dim_order, then reads
the corresponding int8 bytes from the staging buffer (interpreted as int32 for
device compatibility, avoiding the need for 8-bit buffer support).
New files:
- nchw_to_int8x4_buffer.glsl: Compute shader handling all PackedInt8 layouts
- nchw_to_int8x4_buffer.yaml: Shader variant config
- Q8taStaging.h/cpp: C++ dispatch function creating the PrepackNode
Modified files:
- Staging.cpp: Routes kInt8x4 tensors in prepack_op() to the new function
- TestQ8taBinary.cpp: Prepacks TensorRef inputs before quantization
- test_q8ta_binary.cpp: Adds const_b test cases for constant tensor B inputs
This diff was authored with Claude.
ghstack-source-id: 341022576
@exported-using-ghexport
Differential Revision: [D93000169](https://our.internmc.facebook.com/intern/diff/D93000169/)
0 commit comments