Rate This Document
Findability
Accuracy
Completeness
Readability

MatMul

Function

Perform multiplication operations on two matrices.

Prototype

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. The matrix does not contain NaN or infinity, which must be checked by the user to prevent undefined calculation results.

blockB

Input

Matrix used for multiplication operations.

This pointer is not null and only 1D tensors are accepted. The matrix does not contain NaN or infinity, which must be checked by the user to prevent 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 equal to k; if transA is transposed, lda is equal to m. Similarly, if transB is not transposed, ldb is equal to n; if transB is transposed, ldb is equal to k;

    ldc is equal to n.

  • When order is set to column-major order:

    If transA is not transposed, lda is equal to m; if transA is transposed, lda is equal to k. Similarly, if transB is not transposed, ldb is equal to k; if transB is transposed, ldb is equal to n;

    ldc is equal to m.

  • alpha and beta are not NaN or infinity, which must be checked by the user to prevent undefined calculation results.