Description: Computes the product of α and the matrix multiplication result of batch1 and batch2, and then sums the product with the product of β and self. Note: batch1 and batch2 must be 3D tensors. The two shapes can be broadcast only in aclnnBaddbmm. If the two shapes are broadcast in aclnnInplaceBaddbmm, the operation will be blocked. self must support broadcast with the result of batch1@batch2. (The broadcast mechanism refers to the process of expanding a smaller shape to a larger shape so that the two shapes are compatible. Currently, only broadcast of (1, n) is supported. That is, the dimensions of the two tensors must be the same or one of them must be 1.)
Formula:
Note: If β is 0, self is ignored and does not participate in the computation.
Example:
The shape of self is [1, M, K], the shape of batch1@batch2 is [A, M, 1], and the shape of the output out is [A, M, K]. The numbers in each dimension must be the same or one of them must be 1. If the shape of self is [2, M, K], the broadcast condition is not met and an error is reported.
- aclnnBaddbmm and aclnnInplaceBaddbmm implement the same function in different ways. Select a proper operator based on your requirements.
- aclnnBaddbmm: An output tensor object needs to be created to store the computation result.
- aclnnInplaceBaddbmm: 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, aclnnBaddbmmGetWorkspaceSize is called to obtain the input parameters and compute the required workspace size based on the process. Then, aclnnBaddbmm 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.
- 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=0: If the input data type is FLOAT16 or BFLOAT16, matrix multiplication uses FLOAT16/BFLOAT16 input and FLOAT32 output. If the input data type is not FLOAT16/BFLOAT16, no processing is performed.
- 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 FLOAT32, it is converted to FLOAT16 for computation. If the input data type is not FLOAT32, no processing is performed.
- cubeMathType=3: 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 4 and the input data type is FLOAT16 or BFLOAT16, the addmm process is performed with higher precision. In this case, the input self cannot be broadcast with the matrix computed by matmul.
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.
- When cubeMathType is set to 2 and the input data type is FLOAT32, the input is converted to FLOAT16 for computation. When the input data type is not FLOAT32, the input is not processed.
- cubeMathType=3: 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 4, no processing is performed.
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 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 is not supported.
- 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]:
- 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.
- When cubeMathType is set to 2 and the input data type is FLOAT32, the data type is converted to FLOAT16 for computation. When the input data type is not FLOAT32, the input data is not processed.
- cubeMathType=3: 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 4 and the input data type is FLOAT16 or BFLOAT16, the addmm operation is performed with higher precision. In this case, the input self and the matmul result matrix cannot be broadcast.
- 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.
- When cubeMathType is set to 2 and the input data type is FLOAT32, the data type is converted to FLOAT16 for computation. When the input data type is not FLOAT32, the input data is not processed.
- cubeMathType=3: 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 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]
Determinism: The default deterministic implementation of aclnnBaddbmm&aclnnInplaceBaddbmm is used.
[object Object]Atlas training products[object Object] and [object Object]Atlas inference products[object Object]: The Cube unit does not support FLOAT32 computation. The input data type FLOAT32 can be converted to FLOAT16 in the API for computation by setting cubeMathType to 1 (ALLOW_FP32_DOWN_PRECISION).
[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 of the inputs of batch1 and batch2 is BFLOAT16 and the other is FLOAT or FLOAT16, the data type cannot be deduced.
The following example is for reference only. For details, see .