Rate This Document
Findability
Accuracy
Completeness
Readability

MatMul

Function

Perform multiplication operations on two matrices.

Prototype

1
int Matmul(T *blockA, T *blockB, T *output, MatMulParams<T> &M);
  • This API accepts only 1D tensors as inputs.
  • Template type T: float and double are supported.

  • The valid length of the pointer is determined by the user.
  • Ensure that the valid spaces of the input pointers do not overlap.

Parameters

Table 1 Parameters

Parameter

Input/Output

Description

Constraint

blockA

Input

Matrix used for multiplication operations.

This pointer is not null and only 1D tensors are accepted. Ensure the matrix contains no NaN or infinity values to avoid undefined calculation results.

blockB

Input

Matrix used for multiplication operations.

This pointer is not null and only 1D tensors are accepted. Ensure the matrix contains no NaN or infinity values to avoid undefined calculation results.

output

Input

Tensor used to store the calculation results as the output.

This pointer is not null and only 1D tensors are accepted.

M

Input

Parameter structure used for multiplication operations, including:

  • order: Matrix storage order (row-major or column-major order).
  • transA: indicates whether matrix A is transposed.
  • transB: indicates whether matrix B is transposed.
  • m: Number of rows in matrix A.
  • n: Number of columns in matrix B.
  • k: Number of columns in matrix A or number of rows in matrix B.
  • alpha: The alpha parameter.
  • lda: Storage stride of matrix A.
  • ldb: Storage stride of matrix B.
  • beta: The beta parameter.
  • ldc: Storage stride of matrix C.
  • m, n, and k are all greater than 0.
  • When order is set to row-major order:

    If transA is not transposed, lda is set to k.

    If transA is transposed, lda is set to m.

    If transB is not transposed, ldb is set to n.

    If transB is transposed, ldb is set to k and ldc is set to n.

  • When order is set to column-major order:

    If transA is not transposed, lda is set to m.

    If transA is transposed, lda is set to k.

    If transB is not transposed, ldb is set to k.

    If transB is transposed, ldb is set to n and ldc is set to m.

  • Ensure alpha and beta are not NaN or infinity values to avoid undefined calculation results.