Description: Computes the sum of the product of α multiplied by mat1 and mat2 and the product of β multiplied by self.
Formula:
Example:
- For aclnnAddmm, the shape of self is [1, n], the shape of mat1 is [m, k], the shape of mat2 is [k, n], the shape of the matrix multiplication result of mat1 and mat2 is [m, n], and the shape of self can be broadcast to [m, n].
- For aclnnAddmm, the shape of self is [m, 1], the shape of mat1 is [m, k], the shape of mat2 is [k, n], the shape of the matrix multiplication result of mat1 and mat2 is [m, n], and the shape of self can be broadcast to [m, n].
- For aclnnAddmm, the shape of self is [m, n], the shape of mat1 is [m, k], the shape of mat2 is [k, n], and the shape of the matrix multiplication result of mat1 and mat2 is [m, n].
- For the aclnnInplaceAddmm API, the computation result is directly stored in the memory of the input tensor selfRef. The shape of selfRef is [m, n], the shape of mat1 is [m, k], and the shape of mat2 is [k, n].
- aclnnAddmm and aclnnInplaceAddmm implement the same function in different ways. Select a proper operator based on your requirements.
- aclnnAddmm: An output tensor object needs to be created to store the computation result.
- aclnnInplaceAddmm: No output tensor object needs to be created, and the computation result is stored in the memory of the input tensor.
- Each operator has calls. First, aclnnAddmmGetWorkspaceSize or aclnnInplaceAddmmGetWorkspaceSize is called to obtain input parameters and calculate the required workspace size based on the computation process. Then, aclnnAddmm or aclnnInplaceAddmm is called to perform computation.
[object Object]
[object Object]
[object Object]
[object Object]
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.
- cubeMathType=0 is not supported when the input data type is FLOAT32.
- cubeMathType=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=3 and 4 are not supported.
- [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]:
- cubeMathType=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.
- cubeMathType=2: If the input data type is BFLOAT16, this option is not supported.
- cubeMathType=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 and the input data type is FLOAT16 or BFLOAT16, the addmm process is computed with higher precision. In this case, the input self and the matmul computation result matrix cannot be broadcast. When the input data type is FLOAT32 and the k axis is greater than 2048, group accumulation is used for computation.
- Ascend 950PR/Ascend 950DT:
- cubeMathType=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.
- cubeMathType=2: If the input data type is BFLOAT16, this option is not supported.
- cubeMathType=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.
- cubeMathType=4 is not supported.
- [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]
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.
- cubeMathType=0 is not supported when the input data type is FLOAT32.
- cubeMathType=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=3 and 4 are not supported.
- [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]:
- cubeMathType=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.
- cubeMathType=2: If the input data type is BFLOAT16, this option is not supported.
- cubeMathType=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.
- If cubeMathType is set to 4 and the input data type is FLOAT16 or BFLOAT16, the addmm operation is performed with higher precision. In this case, the input self cannot be broadcast with the matrix computed by matmul. If the input data type is FLOAT32 and the k axis is greater than 2048, group accumulation is used for computation.
- Ascend 950PR/Ascend 950DT:
- cubeMathType=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.
- cubeMathType=2: If the input data type is BFLOAT16, this option is not supported.
- cubeMathType=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.
- cubeMathType=4 is not supported.
- [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]
Determinism:
- [object Object]Atlas training products[object Object] and [object Object]Atlas inference products[object Object]: aclnnAddmm&aclnnInplaceAddmm defaults to a non-deterministic implementation. You can call aclrtCtxSetSysParamOpt to enable deterministic compute.
- For the Ascend 950PR/Ascend 950DT, aclnnAddmm and aclnnInplaceAddmm are implemented in a deterministic manner by default.
Computational consistency description
- [object Object]Atlas training products[object Object] and [object Object]Atlas inference products[object Object]:
- If strong consistency compute is enabled, the compute result is deterministic, meaning that multiple executions will generate the same result. In addition, the compute result is irrelevant to the data location.
- aclnnAddmm&aclnnInplaceAddmm defaults to a non-consistent implementation. You can call aclrtCtxSetSysParamOpt to enable consistency compute.
- For example, when performing matrix multiplication, the order of accumulation across different basic blocks may vary, which may lead to slight differences in results for the same data in different rows. However, when strong consistency compute is enabled, the results will remain consistent across rows as long as the inputs are the same.
- [object Object]Atlas training products[object Object] and [object Object]Atlas inference products[object Object]:
The following example is for reference only. For details, see .
[object Object]