Fix SPIRV validation: use array ptr for cooperative vector ops#2
Merged
cmarcelo merged 1 commit intocmarcelo:cmat-cvec-ir-opsfrom Mar 31, 2026
Merged
Conversation
OpCooperativeVectorMatrixMulNV (and related NV ops) require the matrix/buffer operand to be a pointer to an array type. After SPIRV legalization, ByteAddressBuffer/StructuredBuffer global params become ptr-to-struct, which fails the SPIRV validator with "Pointer's Type must be an array type". Add emitBufferPtrAsArrayPtr() that emits OpAccessChain index 0 to pierce through the wrapper struct when needed. For Ptr<T[]> inputs that already point directly to an unsized array, the pointer is returned as-is. Apply the helper in emitCoopVecMatMulAdd (matrix and bias operands), emitCoopVecOuterProductAccumulate (matrix operand), and emitCoopVecReduceSumAccumulate (buffer operand).
7e5ac66 to
d3e24e5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
OpCooperativeVectorMatrixMulNV(and related NV cooperative vector ops) require the matrix/buffer operand to be a pointer to an array type, not a pointer to a structByteAddressBuffer/StructuredBufferglobal params becomeptr-to-struct{runtimeArray<T>}, which fails the SPIRV validator with:Pointer <id>'s Type must be an array typeemitBufferPtrAsArrayPtr()helper that emitsOpAccessChainindex 0 to pierce through the wrapper struct when needed; forPtr<T[]>inputs that already point directly to an unsized array, the pointer is returned as-isAffected functions
emitCoopVecMatMulAdd— matrix ptr and bias ptremitCoopVecOuterProductAccumulate— matrix ptremitCoopVecReduceSumAccumulate— buffer ptrTest
Before:
error: line 80: spv::Op::OpCooperativeVectorMatrixMulNV Pointer <id>'s Type must be an array type.After: compiles cleanly, generates correct
OpAccessChainbefore the matrix mul op.All 214 cooperative-vector tests pass.