Skip to content

[SM6.10][LinAlg] dx::linalg::Multiply takes the vector interpretation from the matrix type #8933

Description

@NealLou

Description

1.Fp16 vector × Fp16 matrix → Fp16 vector case.

This Multiply overload passes MatrixDT as the input interpretation operand of LinAlgMatVecMul.

template <typename OutputElTy, typename InputElTy, SIZE_TYPE M, SIZE_TYPE K,
ComponentEnum MatrixDT>
typename hlsl::enable_if<hlsl::is_arithmetic<InputElTy>::value,
vector<OutputElTy, M> >::type
Multiply(Matrix<MatrixDT, M, K, MatrixUse::A, MatrixScope::Thread> MatrixA,
vector<InputElTy, K> Vec) {
vector<OutputElTy, M> Result;
__builtin_LinAlg_MatrixVectorMultiply(Result, MatrixA.__handle,
hlsl::is_signed<OutputElTy>::value, Vec,
MatrixDT);
return Result;
}

But all 4 MultiplyAdd overloads derive the input interpretation from the vector — two from the vector's element type via TypeTraits<InputElTy>::CompType, two from InterpVec.Interpretation. None of them uses MatrixDT.

Is this Multiply's use of MatrixDT intentional, or an oversight?

2.Fp16 vector × Fp8 matrix → Fp16 vector case.

HLSL:
typedef Matrix<ComponentType::F8_E4M3FN, 4, 8, MatrixUse::A, MatrixScope::Thread> matrixType;
matrixType fp8Mat = matrixType::Load<MatrixLayout::MulOptimal>(buffer, 0, 0);

vector<float16_t, 8> vecIn = Inputs.Load<vector<float16_t, 8> >(tid * 16);

vector<float16_t, 4> vecOut =
      Multiply<float16_t>(fp8Mat, MakeInterpretedVector<ComponentType::F16>(vecIn));

DXIL:
  %11 = call <4 x half> @dx.op.linAlgMatVecMul.v4f16.mC21M4N8U0S0.v8f16(
            i32 -2147483623,
            %dx.types.LinAlgMatrixC21M4N8U0S0 %6,
            i1 true,
            <8 x half> %10,
            i32 8)                                  ; interpretation = F16

In DXIL, this interpretation operand (8=F16) doesn't carry the actual input interpretation type, which has to be parsed from the matrix(C21=F8_E4M3FN). Is that reasonable and clear?

Actual Behavior

Environment

  • DXC version
  • Host Operating System <!--- Host operating system and version --->

Activity

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

Metadata

Metadata

Labels

bugBug, regression, crashneeds-triageAwaiting triage

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions