From 204fe7dd6aeb61c73bf889b8e935e6eade7d0d7a Mon Sep 17 00:00:00 2001 From: Jack Elliott Date: Thu, 23 Jul 2026 14:52:47 +1200 Subject: [PATCH] [HLSL] Correct LinAlg OuterProduct accumulator use Use the shared MatrixUse parameter for the OuterProduct result and set it to Accumulator, matching proposal 0035 and the public dx::linalg API. Add a host-side invariant to prevent the legacy A-use declaration from returning. Assisted-by: GitHub Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 83725f5d-8e98-4c1d-91ee-ad47629e007b --- tools/clang/unittests/HLSLExec/LinAlgTests.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/clang/unittests/HLSLExec/LinAlgTests.cpp b/tools/clang/unittests/HLSLExec/LinAlgTests.cpp index 8db0c67733..ea3391b5d1 100644 --- a/tools/clang/unittests/HLSLExec/LinAlgTests.cpp +++ b/tools/clang/unittests/HLSLExec/LinAlgTests.cpp @@ -1395,7 +1395,6 @@ static D3D12_LINEAR_ALGEBRA_DATATYPE toLinAlgDataType(ComponentType CT) { } static const char OuterProductShader[] = R"( - #define USE_A 0 #define SCOPE_THREAD 0 RWByteAddressBuffer Input : register(u0); @@ -1416,7 +1415,7 @@ static const char OuterProductShader[] = R"( } __builtin_LinAlgMatrix - [[__LinAlgMatrix_Attributes(COMP_TYPE, M_DIM, N_DIM, USE_A, SCOPE_THREAD)]] + [[__LinAlgMatrix_Attributes(COMP_TYPE, M_DIM, N_DIM, USE, SCOPE_THREAD)]] Mat; __builtin_LinAlg_MatrixOuterProduct(Mat, VecA, VecB); @@ -1434,6 +1433,8 @@ static void runOuterProduct(ID3D12Device *Device, VERIFY_IS_TRUE( Params.Layout == MatrixLayout::OuterProductOptimal, "Outer product must output its matrix in OuterProductOptimal layout"); + VERIFY_IS_TRUE(Params.Use == MatrixUse::Accumulator, + "Outer product must output an accumulator matrix"); const size_t NumVecElements = Params.M + Params.N; const size_t InBuffSize = NumVecElements * elementSize(Params.CompType); const size_t NumMatElements = Params.totalElements(); @@ -1502,6 +1503,7 @@ void DxilConf_SM610_LinAlg::OuterProduct_Thread_16x16_F16() { Params.CompType = ComponentType::F16; Params.M = 16; Params.N = 16; + Params.Use = MatrixUse::Accumulator; Params.Scope = MatrixScope::Thread; Params.Layout = MatrixLayout::OuterProductOptimal; Params.NumThreads = 1;