- Description: Performs matrix multiplication on tensors self and mat2 (matrix multiplication from one to six dimensions is supported). Similar APIs include aclnnMm (matrix multiplication with two-dimensional tensors as inputs) and aclnnBatchMatmul (matrix multiplication with only three-dimensional tensors as inputs, where the first dimension is batch).
- Formula:
Each operator has calls. First, aclnnMatmulGetWorkspaceSize is called to obtain the workspace size required for computation and the executor that contains the operator computation process. Then, aclnnMatmul is called to perform computation.
Parameters:
[object Object]- [object Object]Atlas training products[object Object] and [object Object]Atlas inference products[object Object]:
- The data type BFLOAT16 is not supported.
- When the input data type is FLOAT32, cubeMathType cannot be set to 0.
- When cubeMathType is set to 1, if the input data type is FLOAT32, it is converted to FLOAT16 for computation. If the input data type is not FLOAT32, no processing is performed.
- cubeMathType cannot be set to 3.
- When cubeMathType is set to 4, no processing is performed.
- [object Object]Atlas A2 training products/Atlas A2 inference products[object Object] and [object Object]Atlas A3 training products/Atlas A3 inference products[object Object]:
- When cubeMathType is set to 1, if the input data type is FLOAT32, it is converted to HFLOAT32 for computation. If the input data type is not FLOAT32, no processing is performed.
- When cubeMathType is set to 2, this option is not supported if the input data type is BFLOAT16.
- When cubeMathType is set to 3, if the input data type is FLOAT32, it is converted to HFLOAT32 for computation. If the input data type is not FLOAT32, this option is not supported.
- When cubeMathType is set to 4, if the input data type is FLOAT32 and the k-axis is greater than 2048, grouped accumulation is used for computation. If the input data type is not FLOAT32 or the k-axis is less than 2048, no processing is performed.
- Ascend 950PR/Ascend 950DT:
- When cubeMathType is set to 1, if the input data type is FLOAT32, it is converted to HFLOAT32 for computation. If the input data type is not FLOAT32, no processing is performed.
- When cubeMathType is set to 2, this option is not supported if the input data type is BFLOAT16.
- When cubeMathType is set to 3, if the input data type is FLOAT32, it is converted to HFLOAT32 for computation. If the input data type is not FLOAT32, this option is not supported.
- When cubeMathType is set to 4, no processing is performed.
- [object Object]Atlas training products[object Object] and [object Object]Atlas inference products[object Object]:
Returns:
[object Object]: status code. For details, see .The first-phase API implements input parameter verification. The following errors may be thrown:
[object Object]
Deterministic description:
- [object Object]Atlas training products[object Object] and [object Object]Atlas inference products[object Object]: aclnnMatmul defaults to a deterministic implementation.
- Ascend 950PR/Ascend 950DT: The default implementation of aclnnMatmul is deterministic.
Computing consistency description:
- [object Object]Atlas training products[object Object] and [object Object]Atlas inference products[object Object]:
- If strong consistency is enabled, the computation becomes deterministic, meaning that multiple executions will generate the same result. In addition, the computation result is independent of the data location.
- aclnnMatmul defaults to a non-consistent implementation. You can call aclrtCtxSetSysParamOpt to enable consistency compute.
- For example, during matrix multiplication, the accumulation sequence may vary across different basic blocks, potentially causing slight differences in the computation results of the same data in different rows. However, when strong consistency is enabled, the computation results will be the same even in different rows, as long as the inputs are identical.
- [object Object]Atlas training products[object Object] and [object Object]Atlas inference products[object Object]:
[object Object]Atlas A2 training products/Atlas A2 inference products[object Object] and [object Object]Atlas A3 training products/Atlas A3 inference products[object Object]: If one input is BFLOAT16 and the other is FLOAT16, the data type cannot be deduced. If one input is BFLOAT16 and the other is FLOAT32, the data type cannot be deduced.
When self and mat2 are both one-dimensional, cubeMathType does not take effect.
The following example is for reference only. For details, see .