Skip to content

[SM6.10] LinAlg Validation: Convert - #8837

Open
Ashley Coleman (V-FEXrt) wants to merge 2 commits into
linalg-vali-matrixloadfrommemoryfrom
linalg-vali-convert
Open

[SM6.10] LinAlg Validation: Convert#8837
Ashley Coleman (V-FEXrt) wants to merge 2 commits into
linalg-vali-matrixloadfrommemoryfrom
linalg-vali-convert

Conversation

@V-FEXrt

Copy link
Copy Markdown
Collaborator

Fixes #8509

Implements LinAlg Convert validation rules


Stack created with GitHub Stacks CLIGive Feedback 💬

Fixes #8509

Implements LinAlg Convert validation rules
@github-actions

github-actions Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff 29da40966bad93f2880bda4e544938a2f898d382 9cbd1daea10ac89a5891ad690beee4c4dd175ad0 -- lib/DxilValidation/DxilValidation.cpp lib/DxilValidation/DxilValidationUtils.cpp lib/DxilValidation/DxilValidationUtils.h
View the diff from clang-format here.
diff --git a/lib/DxilValidation/DxilValidation.cpp b/lib/DxilValidation/DxilValidation.cpp
index 01af6469..0db601d2 100644
--- a/lib/DxilValidation/DxilValidation.cpp
+++ b/lib/DxilValidation/DxilValidation.cpp
@@ -1553,56 +1553,66 @@ static void ValidateLinAlgConvert(CallInst *CI, ValidationContext &ValCtx) {
   VectorType *InVecTy = cast<VectorType>(Op.get_inputVector()->getType());
 
   // Input interp must be a immarg of allowed ComponentType
-  std::optional<uint64_t> InputInterpV = ValidateConstantIntGetValue(
-      CI, Op.get_inputInterpretation(), ValCtx, "InputInterpretation", "LinAlgConvert");
+  std::optional<uint64_t> InputInterpV =
+      ValidateConstantIntGetValue(CI, Op.get_inputInterpretation(), ValCtx,
+                                  "InputInterpretation", "LinAlgConvert");
   if (!InputInterpV)
     return;
-  DXIL::ComponentType InputInterp = static_cast<DXIL::ComponentType>(*InputInterpV);
+  DXIL::ComponentType InputInterp =
+      static_cast<DXIL::ComponentType>(*InputInterpV);
   ValidateLinAlgComponentType(CI, InputInterp, ValCtx, "InputInterpretation");
 
   // Output interp must be a immarg of allowed ComponentType
-  std::optional<uint64_t> OutputInterpV = ValidateConstantIntGetValue(
-      CI, Op.get_outputInterpretation(), ValCtx, "OutputInterpretation", "LinAlgConvert");
+  std::optional<uint64_t> OutputInterpV =
+      ValidateConstantIntGetValue(CI, Op.get_outputInterpretation(), ValCtx,
+                                  "OutputInterpretation", "LinAlgConvert");
   if (!OutputInterpV)
     return;
-  DXIL::ComponentType OutputInterp = static_cast<DXIL::ComponentType>(*OutputInterpV);
+  DXIL::ComponentType OutputInterp =
+      static_cast<DXIL::ComponentType>(*OutputInterpV);
   ValidateLinAlgComponentType(CI, OutputInterp, ValCtx, "OutputInterpretation");
 
   bool IsNativeInputInterp = IsComponentTypeNative(InputInterp);
   bool IsNativeOutputInterp = IsComponentTypeNative(OutputInterp);
 
-  // If input interp is native then input vector element type must match that type
-  if (IsNativeInputInterp && !IsComponentTypeSameNativeType(InputInterp, InVecTy->getElementType()))
+  // If input interp is native then input vector element type must match that
+  // type
+  if (IsNativeInputInterp &&
+      !IsComponentTypeSameNativeType(InputInterp, InVecTy->getElementType()))
     ValCtx.EmitInstrFormatError(
         CI, ValidationRule::InstrLinAlgMatrixVectorTypeMustMatch,
-        {"Input", TypeToString(InVecTy->getElementType()), "InputInterpretation",
-         ComponentTypeToString(InputInterp)});
+        {"Input", TypeToString(InVecTy->getElementType()),
+         "InputInterpretation", ComponentTypeToString(InputInterp)});
 
   // If input interp is non-native then input vector element type must be i32
   if (!IsNativeInputInterp && !InVecTy->getElementType()->isIntegerTy(32))
     ValCtx.EmitInstrFormatError(
         CI, ValidationRule::InstrLinAlgMatrixVectorTypeMustMatchPacked,
-        {"Input", TypeToString(InVecTy->getElementType()), "InputInterpretation",
-         ComponentTypeToString(InputInterp)});
+        {"Input", TypeToString(InVecTy->getElementType()),
+         "InputInterpretation", ComponentTypeToString(InputInterp)});
 
-  // If output interp is native then output vector element type must match that type
-  if (IsNativeOutputInterp && !IsComponentTypeSameNativeType(OutputInterp, RetVecTy->getElementType()))
+  // If output interp is native then output vector element type must match that
+  // type
+  if (IsNativeOutputInterp &&
+      !IsComponentTypeSameNativeType(OutputInterp, RetVecTy->getElementType()))
     ValCtx.EmitInstrFormatError(
         CI, ValidationRule::InstrLinAlgMatrixVectorTypeMustMatch,
-        {"Output", TypeToString(RetVecTy->getElementType()), "OutputInterpretation",
-         ComponentTypeToString(OutputInterp)});
+        {"Output", TypeToString(RetVecTy->getElementType()),
+         "OutputInterpretation", ComponentTypeToString(OutputInterp)});
 
   // If output interp is non-native then output vector element type must be i32
   if (!IsNativeOutputInterp && !RetVecTy->getElementType()->isIntegerTy(32))
     ValCtx.EmitInstrFormatError(
         CI, ValidationRule::InstrLinAlgMatrixVectorTypeMustMatchPacked,
-        {"Output", TypeToString(RetVecTy->getElementType()), "OutputInterpretation",
-         ComponentTypeToString(OutputInterp)});
+        {"Output", TypeToString(RetVecTy->getElementType()),
+         "OutputInterpretation", ComponentTypeToString(OutputInterp)});
 
   // output vector length must be properly converted from input length
-  unsigned InputElemCount = InVecTy->getNumElements() * ComponentTypeElementsPerScalar(InputInterp);
+  unsigned InputElemCount =
+      InVecTy->getNumElements() * ComponentTypeElementsPerScalar(InputInterp);
   unsigned OutputElemPerScalar = ComponentTypeElementsPerScalar(OutputInterp);
-  unsigned ExpectedOutVecSize = (InputElemCount + OutputElemPerScalar - 1) / OutputElemPerScalar;
+  unsigned ExpectedOutVecSize =
+      (InputElemCount + OutputElemPerScalar - 1) / OutputElemPerScalar;
   if (RetVecTy->getNumElements() != ExpectedOutVecSize)
     ValCtx.EmitInstrFormatError(
         CI, ValidationRule::InstrLinAlgMatrixDimVectorMismatch,
  • Check this box to apply formatting changes to this branch.

Copilot AI balanced review requested due to automatic review settings August 26, 2026 17:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements Shader Model 6.10 validation rules for LinAlg Convert operations.

Changes:

  • Validates interpretation constants, vector element types, and output dimensions.
  • Adds validation diagnostics and DXIL documentation.
  • Adds and updates validation/code-generation tests.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
lib/DxilValidation/DxilValidation.cpp Implements Convert validation.
lib/DxilValidation/DxilValidationUtils.cpp Identifies native component types.
lib/DxilValidation/DxilValidationUtils.h Declares the native-type helper.
utils/hct/hctdb.py Defines new validation messages.
docs/DXIL.rst Documents the new rules.
tools/clang/test/LitDXILValidation/LinAlgMatrix/linalgmatrix-convert.ll Tests validation failures.
tools/clang/test/CodeGenDXIL/hlsl/linalg/builtins/convert/nominal.hlsl Updates nominal inputs to valid interpretations.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

return;
DXIL::ComponentType InputInterp =
static_cast<DXIL::ComponentType>(*InputInterpV);
ValidateLinAlgComponentType(CI, InputInterp, ValCtx, "InputInterpretation");
(InputElemCount + OutputElemPerScalar - 1) / OutputElemPerScalar;
if (RetVecTy->getNumElements() != ExpectedOutVecSize)
ValCtx.EmitInstrFormatError(
CI, ValidationRule::InstrLinAlgMatrixDimVectorMismatch,
@@ -1547,6 +1547,77 @@ static void ValidateLinAlgMatrixAccumulateToMemory(CallInst *CI,

static void ValidateLinAlgConvert(CallInst *CI, ValidationContext &ValCtx) {
ValidateLinAlgOpParameters(CI, ValCtx);

@damyanp Damyan Pepper (damyanp) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, although some of the copilot comments look like they need addressing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

LinAlg Validation: Convert

3 participants