Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions include/dxc/DXIL/DxilInstructions.h
Original file line number Diff line number Diff line change
Expand Up @@ -10317,19 +10317,22 @@ struct DxilInst_LinAlgFillMatrix {
// Validation support
bool isAllowed() const { return true; }
bool isArgumentListValid() const {
if (2 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands())
if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands())
return false;
return true;
}
// Metadata
bool requiresUniformInputs() const { return false; }
// Operand indexes
enum OperandIdx {
arg_value = 1,
arg_isInputSigned = 1,
arg_value = 2,
};
// Accessors
llvm::Value *get_value() const { return Instr->getOperand(1); }
void set_value(llvm::Value *val) { Instr->setOperand(1, val); }
llvm::Value *get_isInputSigned() const { return Instr->getOperand(1); }
void set_isInputSigned(llvm::Value *val) { Instr->setOperand(1, val); }
llvm::Value *get_value() const { return Instr->getOperand(2); }
void set_value(llvm::Value *val) { Instr->setOperand(2, val); }
};

/// This instruction Converts and copies the element and use type of the source
Expand Down Expand Up @@ -10905,22 +10908,25 @@ struct DxilInst_LinAlgMatrixOuterProduct {
// Validation support
bool isAllowed() const { return true; }
bool isArgumentListValid() const {
if (3 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands())
if (4 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands())
return false;
return true;
}
// Metadata
bool requiresUniformInputs() const { return false; }
// Operand indexes
enum OperandIdx {
arg_vectorA = 1,
arg_vectorB = 2,
arg_isInputSigned = 1,
arg_vectorA = 2,
arg_vectorB = 3,
};
// Accessors
llvm::Value *get_vectorA() const { return Instr->getOperand(1); }
void set_vectorA(llvm::Value *val) { Instr->setOperand(1, val); }
llvm::Value *get_vectorB() const { return Instr->getOperand(2); }
void set_vectorB(llvm::Value *val) { Instr->setOperand(2, val); }
llvm::Value *get_isInputSigned() const { return Instr->getOperand(1); }
void set_isInputSigned(llvm::Value *val) { Instr->setOperand(1, val); }
llvm::Value *get_vectorA() const { return Instr->getOperand(2); }
void set_vectorA(llvm::Value *val) { Instr->setOperand(2, val); }
llvm::Value *get_vectorB() const { return Instr->getOperand(3); }
void set_vectorB(llvm::Value *val) { Instr->setOperand(3, val); }
};

/// This instruction Convert vector components from one interpretation to
Expand Down
14 changes: 13 additions & 1 deletion lib/DXIL/DxilOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6570,6 +6570,7 @@ Function *OP::GetOpFunc(OpCode opCode, Type *pOverloadType) {
case OpCode::LinAlgFillMatrix:
A(EXT(0));
A(pI32);
A(pI1);
A(EXT(1));
break;
case OpCode::LinAlgCopyConvertMatrix:
Expand Down Expand Up @@ -6693,6 +6694,7 @@ Function *OP::GetOpFunc(OpCode opCode, Type *pOverloadType) {
case OpCode::LinAlgMatrixOuterProduct:
A(EXT(0));
A(pI32);
A(pI1);
A(EXT(1));
A(EXT(2));
break;
Expand Down Expand Up @@ -7074,6 +7076,11 @@ llvm::Type *OP::GetOverloadType(OpCode opCode, llvm::Function *F) {
FT->getParamType(2), FT->getParamType(3)});

case OpCode::LinAlgFillMatrix:
if (FT->getNumParams() < 3)
return nullptr;
return llvm::StructType::get(Ctx,
{FT->getReturnType(), FT->getParamType(2)});

case OpCode::LinAlgCopyConvertMatrix:
case OpCode::LinAlgMatrixGetElement:
case OpCode::LinAlgConvert:
Expand Down Expand Up @@ -7106,7 +7113,6 @@ llvm::Type *OP::GetOverloadType(OpCode opCode, llvm::Function *F) {

case OpCode::LinAlgMatrixMultiply:
case OpCode::LinAlgMatrixAccumulate:
case OpCode::LinAlgMatrixOuterProduct:
if (FT->getNumParams() < 3)
return nullptr;
return llvm::StructType::get(
Expand All @@ -7119,6 +7125,12 @@ llvm::Type *OP::GetOverloadType(OpCode opCode, llvm::Function *F) {
{FT->getReturnType(), FT->getParamType(1),
FT->getParamType(3), FT->getParamType(5)});

case OpCode::LinAlgMatrixOuterProduct:
if (FT->getNumParams() < 4)
return nullptr;
return llvm::StructType::get(
Ctx, {FT->getReturnType(), FT->getParamType(2), FT->getParamType(3)});

// OPCODE-OLOAD-TYPES:END
default:
return Ty;
Expand Down
4 changes: 3 additions & 1 deletion lib/DxilContainer/DxilContainerAssembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -964,10 +964,12 @@ class DxilPSVWriter : public DxilPartWriter {
LinAlgMatrixInfo Result;
if (!GetLinAlgMatrixInfo(CI->getType(), Result))
break;
bool IsInputSigned =
cast<ConstantInt>(Op.get_isInputSigned())->getZExtValue() != 0;
PSVLinAlgOuterProduct0 Record = {
static_cast<uint8_t>(Result.Type),
static_cast<uint8_t>(GetVectorOrScalarComponentType(
Op.get_vectorA()->getType())),
Op.get_vectorA()->getType(), IsInputSigned)),
{0, 0}};
if (std::find_if(
m_LinAlgOuterProducts.begin(), m_LinAlgOuterProducts.end(),
Expand Down
19 changes: 19 additions & 0 deletions lib/DxilValidation/DxilValidation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1327,6 +1327,19 @@ static void ValidateLinAlgMatrixStoreToMemory(CallInst *CI,
}
}

static void ValidateLinAlgIsInputSigned(CallInst *CI, Value *IsInputSignedValue,
Type *InputTy,
ValidationContext &ValCtx,
const char *OpName) {
std::optional<uint64_t> IsInputSigned = ValidateConstantIntGetValue(
CI, IsInputSignedValue, ValCtx, "IsInputSigned", OpName);
Type *ScalarTy = InputTy->getScalarType();
if (IsInputSigned && ScalarTy->isFloatingPointTy() && *IsInputSigned != 1)
ValCtx.EmitInstrFormatError(
CI, ValidationRule::InstrLinAlgMatrixUnsignedFloatTypeNotAllowed,
{TypeToString(ScalarTy)});
}

static void ValidateLinAlgMatVecMul(CallInst *CI, ValidationContext &ValCtx,
const char *OpName = "LinAlgMatVecMul") {
ValidateLinAlgOpParameters(CI, ValCtx);
Expand Down Expand Up @@ -1695,6 +1708,10 @@ ValidateLinAlgVectorAccumulateToDescriptor(CallInst *CI,
static void ValidateLinAlgFillMatrix(CallInst *CI, ValidationContext &ValCtx) {
ValidateLinAlgOpReturnMatrix(CI, ValCtx);
ValidateLinAlgOpParameters(CI, ValCtx);
DxilInst_LinAlgFillMatrix Op(CI);
ValidateLinAlgIsInputSigned(CI, Op.get_isInputSigned(),
Op.get_value()->getType(), ValCtx,
"LinAlgFillMatrix");
std::optional<LinAlgTargetType> RetMat =
GetCheckedLATT(CI->getType(), ValCtx);
if (!RetMat)
Expand Down Expand Up @@ -2015,6 +2032,8 @@ static void ValidateLinAlgMatrixOuterProduct(CallInst *CI,
DxilInst_LinAlgMatrixOuterProduct Op(CI);
VectorType *AVecTy = cast<VectorType>(Op.get_vectorA()->getType());
VectorType *BVecTy = cast<VectorType>(Op.get_vectorB()->getType());
ValidateLinAlgIsInputSigned(CI, Op.get_isInputSigned(), AVecTy, ValCtx,
"LinAlgMatrixOuterProduct");
std::optional<LinAlgTargetType> RetMat =
GetCheckedLATT(CI->getType(), ValCtx);
if (!RetMat)
Expand Down
13 changes: 8 additions & 5 deletions lib/HLSL/HLOperationLower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6783,13 +6783,14 @@ Value *TranslateLinAlgFillMatrix(CallInst *CI, IntrinsicOp IOP,
Value *MatrixPtr = CI->getArgOperand(1);
DXASSERT_NOMSG(isa<PointerType>(MatrixPtr->getType()));
Type *MatrixType = MatrixPtr->getType()->getPointerElementType();
Value *Scalar = CI->getArgOperand(2);
Value *IsInputSigned = CI->getArgOperand(2);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In all the examples this value is an immediate val and from the validator it seems like it always has to be. Is that true? Can we create a compile time error if it isn't rather than relying on the validator? Maybe DXC doesn't have a precedent of doing so?

If it doesn't have to be a constant then maybe a test case for it would be good

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

DXC doesn't have a good way (nor precedent) to surface compile-time errors. Also, at this point we're mid-optimization so even if it isn't a constant (yet) it might be before we finalize the DXIL.

Value *Scalar = CI->getArgOperand(3);

Constant *OpArg = HlslOp->GetU32Const((unsigned)OpCode);
Function *DxilFunc =
HlslOp->GetOpFunc(OpCode, {MatrixType, Scalar->getType()});

Value *Matrix = Builder.CreateCall(DxilFunc, {OpArg, Scalar});
Value *Matrix = Builder.CreateCall(DxilFunc, {OpArg, IsInputSigned, Scalar});
Builder.CreateStore(Matrix, MatrixPtr);

return nullptr;
Expand Down Expand Up @@ -6913,14 +6914,16 @@ Value *TranslateLinAlgMatrixOuterProduct(
Value *MatrixPtr = CI->getArgOperand(1);
DXASSERT_NOMSG(isa<PointerType>(MatrixPtr->getType()));
Type *MatrixType = MatrixPtr->getType()->getPointerElementType();
Value *VecA = CI->getArgOperand(2);
Value *VecB = CI->getArgOperand(3);
Value *IsInputSigned = CI->getArgOperand(2);
Value *VecA = CI->getArgOperand(3);
Value *VecB = CI->getArgOperand(4);

Constant *OpArg = HlslOp->GetU32Const((unsigned)OpCode);
Function *DxilFunc =
HlslOp->GetOpFunc(OpCode, {MatrixType, VecA->getType(), VecB->getType()});

Value *Matrix = Builder.CreateCall(DxilFunc, {OpArg, VecA, VecB});
Value *Matrix =
Builder.CreateCall(DxilFunc, {OpArg, IsInputSigned, VecA, VecB});
Builder.CreateStore(Matrix, MatrixPtr);

return nullptr;
Expand Down
6 changes: 4 additions & 2 deletions tools/clang/lib/Headers/hlsl/dx/linalg.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ class Matrix {
typename hlsl::enable_if<hlsl::is_arithmetic<T>::value, Matrix>::type
Splat(T Val) {
Matrix Result;
__builtin_LinAlg_FillMatrix(Result.__handle, Val);
__builtin_LinAlg_FillMatrix(Result.__handle, hlsl::is_signed<T>::value,
Val);
Comment thread
V-FEXrt marked this conversation as resolved.
return Result;
}

Expand Down Expand Up @@ -674,7 +675,8 @@ template <ComponentEnum OutTy, typename InputElTy, SIZE_TYPE M, SIZE_TYPE N>
Matrix<OutTy, M, N, MatrixUse::Accumulator, MatrixScope::Thread> >::type
OuterProduct(vector<InputElTy, M> VecA, vector<InputElTy, N> VecB) {
Matrix<OutTy, M, N, MatrixUse::Accumulator, MatrixScope::Thread> Result;
__builtin_LinAlg_MatrixOuterProduct(Result.__handle, VecA, VecB);
__builtin_LinAlg_MatrixOuterProduct(
Result.__handle, hlsl::is_signed<InputElTy>::value, VecA, VecB);
return Result;
}

Expand Down
12 changes: 6 additions & 6 deletions tools/clang/test/CodeGenDXIL/hlsl/linalg/api/matrix-class.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ void main(uint ID : SV_GroupID)
// Matrix::Splat
//
// CHECK: %[[MATA1:.*]] = call %dx.types.LinAlgMatrixC9M4N4U0S1 @dx.op.linAlgFillMatrix.mC9M4N4U0S1.f32(
// CHECK-SAME: i32 -2147483636, float 1.000000e+00)
// CHECK-SAME: i32 -2147483636, i1 true, float 1.000000e+00)
MatrixATy MatA1 = MatrixATy::Splat(1.0f);

// CHECK: %[[MATB1:.*]] = call %dx.types.LinAlgMatrixC9M4N4U1S1 @dx.op.linAlgFillMatrix.mC9M4N4U1S1.f32(
// CHECK-SAME: i32 -2147483636, float 2.000000e+00)
// CHECK-SAME: i32 -2147483636, i1 true, float 2.000000e+00)
MatrixBTy MatB1;
MatB1 = MatrixBTy::Splat(2.0f);

// Matrix::Cast
//
// CHECK: %[[MAT48F:.*]] = call %dx.types.LinAlgMatrixC9M4N8U0S1 @dx.op.linAlgFillMatrix.mC9M4N8U0S1.f32(
// CHECK-SAME: i32 -2147483636, float 3.000000e+00) ; LinAlgFillMatrix(value)
// CHECK-SAME: i32 -2147483636, i1 true, float 3.000000e+00) ; LinAlgFillMatrix(isInputSigned,value)

// CHECK: call %dx.types.LinAlgMatrixC4M4N8U0S1 @dx.op.linAlgCopyConvertMatrix.mC4M4N8U0S1.mC9M4N8U0S1(
// CHECK-SAME: i32 -2147483635, %dx.types.LinAlgMatrixC9M4N8U0S1 %[[MAT48F]], i1 false)
Expand Down Expand Up @@ -142,7 +142,7 @@ void main(uint ID : SV_GroupID)
MatB4.Store(PackedArr, 0, 16, MatrixLayoutEnum::ColMajor);

// CHECK: %[[ACCUM0:.*]] = call %dx.types.LinAlgMatrixC9M4N4U2S1 @dx.op.linAlgFillMatrix.mC9M4N4U2S1.f32(
// CHECK-SAME: i32 -2147483636, float 1.400000e+01) ; LinAlgFillMatrix(value)
// CHECK-SAME: i32 -2147483636, i1 true, float 1.400000e+01) ; LinAlgFillMatrix(isInputSigned,value)
MatrixAccumTy AccMat1 = MatrixAccumTy::Splat(14.0f);

// Matrix::InterlockedAccumulate to resource descriptor
Expand Down Expand Up @@ -173,7 +173,7 @@ void main(uint ID : SV_GroupID)
// Matrix::InterlockedAccumulate supports thread-group scope
//
// CHECK: %[[TGACCUM:.*]] = call %dx.types.LinAlgMatrixC9M4N4U2S2 @dx.op.linAlgFillMatrix.mC9M4N4U2S2.f32(
// CHECK-SAME: i32 -2147483636, float 1.500000e+01)
// CHECK-SAME: i32 -2147483636, i1 true, float 1.500000e+01)
TGMatrixAccumTy TGAccMat = TGMatrixAccumTy::Splat(15.0f);
// CHECK: call void @dx.op.linAlgMatrixAccumulateToMemory.mC9M4N4U2S2.f32(i32 -2147483620,
// CHECK-SAME: %dx.types.LinAlgMatrixC9M4N4U2S2 %[[TGACCUM]],
Expand All @@ -185,7 +185,7 @@ void main(uint ID : SV_GroupID)
// Matrix::Accumulate
//
// CHECK: %[[ACCUM1:.*]] = call %dx.types.LinAlgMatrixC9M4N4U2S1 @dx.op.linAlgFillMatrix.mC9M4N4U2S1.f32(
// CHECK-SAME: i32 -2147483636, float 0.000000e+00) ; LinAlgFillMatrix(value)
// CHECK-SAME: i32 -2147483636, i1 true, float 0.000000e+00) ; LinAlgFillMatrix(isInputSigned,value)
MatrixAccumTy AccMat2 = MatrixAccumTy::Splat(0.0f);

// CHECK: %[[ACCUM2:.*]] = call %dx.types.LinAlgMatrixC9M4N4U2S1
Expand Down
19 changes: 12 additions & 7 deletions tools/clang/test/CodeGenDXIL/hlsl/linalg/api/matrix-multiply.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,25 @@ void main()
//
using MatrixAF16WTy = Matrix<ComponentType::F16, 3, 4, MatrixUse::A, MatrixScope::Wave>;
using MatrixAI32WTy = Matrix<ComponentType::I32, 3, 4, MatrixUse::A, MatrixScope::Wave>;
using MatrixAU32WTy = Matrix<ComponentType::U32, 3, 4, MatrixUse::A, MatrixScope::Wave>;
using MatrixBI32WTy = Matrix<ComponentType::I32, 4, 5, MatrixUse::B, MatrixScope::Wave>;
using MatrixAccF32WTy = Matrix<ComponentType::F32, 3, 5, MatrixUse::Accumulator, MatrixScope::Wave>;
using MatrixAccI32WTy = Matrix<ComponentType::I32, 3, 5, MatrixUse::Accumulator, MatrixScope::Wave>;

// CHECK: %[[MATA1:.*]] = call %dx.types.LinAlgMatrixC8M3N4U0S1 @dx.op.linAlgFillMatrix.mC8M3N4U0S1.f32(
// CHECK-SAME: i32 -2147483636, float 1.500000e+00) ; LinAlgFillMatrix(value)
// CHECK-SAME: i32 -2147483636, i1 true, float 1.500000e+00) ; LinAlgFillMatrix(isInputSigned,value)
MatrixAF16WTy MatA1 = MatrixAF16WTy::Splat(1.5f);

// CHECK: %[[MATA2:.*]] = call %dx.types.LinAlgMatrixC4M3N4U0S1 @dx.op.linAlgFillMatrix.mC4M3N4U0S1.i32(
// CHECK-SAME: i32 -2147483636, i32 45) ; LinAlgFillMatrix(value)
// CHECK-SAME: i32 -2147483636, i1 true, i32 45) ; LinAlgFillMatrix(isInputSigned,value)
MatrixAI32WTy MatA2 = MatrixAI32WTy::Splat(45);

// CHECK: call %dx.types.LinAlgMatrixC5M3N4U0S1 @dx.op.linAlgFillMatrix.mC5M3N4U0S1.i32(
// CHECK-SAME: i32 -2147483636, i1 false, i32 45) ; LinAlgFillMatrix(isInputSigned,value)
MatrixAU32WTy MatAU32 = MatrixAU32WTy::Splat(45u);

// CHECK: %[[MATB1:.*]] = call %dx.types.LinAlgMatrixC4M4N5U1S1 @dx.op.linAlgFillMatrix.mC4M4N5U1S1.i32(
// CHECK-SAME: i32 -2147483636, i32 13) ; LinAlgFillMatrix(value)
// CHECK-SAME: i32 -2147483636, i1 true, i32 13) ; LinAlgFillMatrix(isInputSigned,value)
MatrixBI32WTy MatB1 = MatrixBI32WTy::Splat(13);

// CHECK: %[[MATC1:.*]] = call %dx.types.LinAlgMatrixC9M3N5U2S1
Expand All @@ -35,7 +40,7 @@ void main()

// CHECK: %[[MATC2:.*]] = call %dx.types.LinAlgMatrixC4M3N5U2S1
// CHECK-SAME: @dx.op.linAlgMatrixMultiply.mC4M3N5U2S1.mC4M3N4U0S1.mC4M4N5U1S1(i32 -2147483625,
// CHECK-SAME: %dx.types.LinAlgMatrixC4M3N4U0S1 %2, %dx.types.LinAlgMatrixC4M4N5U1S1 %3)
// CHECK-SAME: %dx.types.LinAlgMatrixC4M3N4U0S1 %[[MATA2]], %dx.types.LinAlgMatrixC4M4N5U1S1 %[[MATB1]])
// CHECK-SAME: ; LinAlgMatrixMultiply(matrixA,matrixB)
MatrixAccI32WTy MatCInt1 = Multiply(MatA2, MatB1);

Expand All @@ -48,15 +53,15 @@ void main()
using MatrixAccI32TGTy = Matrix<ComponentType::I32, 3, 5, MatrixUse::Accumulator, MatrixScope::ThreadGroup>;

// CHECK: %[[MATA3:.*]] = call %dx.types.LinAlgMatrixC8M3N4U0S2 @dx.op.linAlgFillMatrix.mC8M3N4U0S2.f32(
// CHECK-SAME: i32 -2147483636, float 2.500000e+00) ; LinAlgFillMatrix(value)
// CHECK-SAME: i32 -2147483636, i1 true, float 2.500000e+00) ; LinAlgFillMatrix(isInputSigned,value)
MatrixAF16TGTy MatA3 = MatrixAF16TGTy::Splat(2.5f);

// CHECK: %[[MATA4:.*]] = call %dx.types.LinAlgMatrixC4M3N4U0S2 @dx.op.linAlgFillMatrix.mC4M3N4U0S2.i32(
// CHECK-SAME: i32 -2147483636, i32 23) ; LinAlgFillMatrix(value)
// CHECK-SAME: i32 -2147483636, i1 true, i32 23) ; LinAlgFillMatrix(isInputSigned,value)
MatrixAI32TGTy MatA4 = MatrixAI32TGTy::Splat(23);

// CHECK: %[[MATB3:.*]] = call %dx.types.LinAlgMatrixC4M4N5U1S2 @dx.op.linAlgFillMatrix.mC4M4N5U1S2.i32(
// CHECK-SAME: i32 -2147483636, i32 7) ; LinAlgFillMatrix(value)
// CHECK-SAME: i32 -2147483636, i1 true, i32 7) ; LinAlgFillMatrix(isInputSigned,value)
MatrixBI32TGTy MatB3 = MatrixBI32TGTy::Splat(7);

// CHECK: %[[MATC3:.*]] = call %dx.types.LinAlgMatrixC9M3N5U2S2
Expand Down
12 changes: 10 additions & 2 deletions tools/clang/test/CodeGenDXIL/hlsl/linalg/api/vectors.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ using namespace dx::linalg;
using MatrixATy = Matrix<ComponentType::F16, 8, 4, MatrixUse::A, MatrixScope::Thread>;
using MatrixAccum_8_8_Ty = Matrix<ComponentType::F16, 8, 8, MatrixUse::Accumulator, MatrixScope::Thread>;
using MatrixAccum_8_4_Ty = Matrix<ComponentType::F16, 8, 4, MatrixUse::Accumulator, MatrixScope::Thread>;
using MatrixAccum_U32_4_4_Ty = Matrix<ComponentType::U32, 4, 4, MatrixUse::Accumulator, MatrixScope::Thread>;
using Matrix_7_15_ATy = Matrix<ComponentType::F16, 7, 15, MatrixUse::A, MatrixScope::Thread>;
using MatrixPacked_7_15_ATy = Matrix<ComponentType::F8_E4M3FN, 7, 15, MatrixUse::A, MatrixScope::Thread>;
using MatrixA_BFloat = Matrix<ComponentType::BFloat16, 8, 4, MatrixUse::A, MatrixScope::Thread>;
Expand Down Expand Up @@ -78,13 +79,20 @@ void main(uint ID : SV_GroupID) {

// CHECK: %[[ACCUM1:.*]] = call %dx.types.LinAlgMatrixC8M8N8U2S0
// CHECK-SAME: @dx.op.linAlgMatrixOuterProduct.mC8M8N8U2S0.v8f16.v8f16(i32 -2147483619,
// CHECK-SAME: <8 x half> %[[VEC5]], <8 x half> %[[VEC6]]) ; LinAlgMatrixOuterProduct(vectorA,vectorB)
// CHECK-SAME: i1 true, <8 x half> %[[VEC5]], <8 x half> %[[VEC6]]) ; LinAlgMatrixOuterProduct(isInputSigned,vectorA,vectorB)
MatrixAccum_8_8_Ty AccumMatrix1 = OuterProduct<ComponentType::F16>(vec5, vec6);

// CHECK: %[[ACCUM2:.*]] = call %dx.types.LinAlgMatrixC8M8N4U2S0 @dx.op.linAlgMatrixOuterProduct.mC8M8N4U2S0.v8f16.v4f16(
// CHECK-SAME: i32 -2147483619, <8 x half> %[[VEC5]], <4 x half> %[[VEC20]]) ; LinAlgMatrixOuterProduct(vectorA,vectorB)
// CHECK-SAME: i32 -2147483619, i1 true, <8 x half> %[[VEC5]], <4 x half> %[[VEC20]]) ; LinAlgMatrixOuterProduct(isInputSigned,vectorA,vectorB)
MatrixAccum_8_4_Ty AccumMatrix2 = OuterProduct<ComponentType::F16>(vec5, vec20);

uint4 unsignedVec = {1, 2, 3, 4};
// CHECK: call %dx.types.LinAlgMatrixC5M4N4U2S0 @dx.op.linAlgMatrixOuterProduct.mC5M4N4U2S0.v4i32.v4i32(
// CHECK-SAME: i32 -2147483619, i1 false, <4 x i32> <i32 1, i32 2, i32 3, i32 4>, <4 x i32> <i32 1, i32 2, i32 3, i32 4>)
// CHECK-SAME: ; LinAlgMatrixOuterProduct(isInputSigned,vectorA,vectorB)
MatrixAccum_U32_4_4_Ty UnsignedAccum =
OuterProduct<ComponentType::U32>(unsignedVec, unsignedVec);

// CHECK: %[[CONV_VEC:.*]] = call <8 x float> @dx.op.linAlgConvert.v8f32.v8f16(i32 -2147483618,
// CHECK-SAME: <8 x half> %[[VEC6]], i32 8, i32 9) ; LinAlgConvert(inputVector,inputInterpretation,outputInterpretation)
InterpretedVector<float, 8, ComponentType::F32> convertedVec;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void main() {
__builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(2, 5, 4, 1, 2)]] mat1;
__builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(4, 5, 4, 1, 2)]] mat2;

__builtin_LinAlg_FillMatrix(mat1, 1);
__builtin_LinAlg_FillMatrix(mat1, true, 1);

__builtin_LinAlg_CopyConvertMatrix(mat2, mat1, false);
}
Loading
Loading