MulsCast(ISASI)
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
x |
|
x |
|
x |
|
x |
|
x |
|
x |
Function Usage
Multiplies the first count elements of the vector source operand by a scalar, converts the result to half type in CAST_ROUND mode, and stores the final result to dst. The scalar can be before or after the tensor. The formula is as follows:

The scalar input can also be a single element from a LocalTensor. idx indicates the position index of a LocalTensor single element.

Prototype
1 2 | template <typename T0 = BinaryDefaultType, typename T1 = BinaryDefaultType, const BinaryConfig &config = DEFAULT_BINARY_CONFIG, typename T2, typename T3, typename T4> __aicore__ inline void MulsCast(const T2 &dst, const T3 &src0, const T4 &src1, const uint32_t count) |
Parameters
Parameter |
Description |
||
|---|---|---|---|
T0 |
Data type of the destination operand. This parameter is reserved for future use. If this parameter needs to be specified, pass the default value BinaryDefaultType. |
||
T1 |
Data type of the source operands. This parameter is reserved for future use. If this parameter needs to be specified, pass the default value BinaryDefaultType. |
||
config |
Position of a single element. This parameter is of BinaryConfig type and takes effect when the scalar input is a LocalTensor single element. The default value is DEFAULT_BINARY_CONFIG, indicating that the scalar is after the tensor.
|
||
T2 |
LocalTensor data type. The data type is automatically inferred based on dst. Developers do not need to configure this parameter. Ensure that dst meets the data type requirements. |
||
T3 |
LocalTensor or scalar data type. The data type is automatically inferred based on src0. Developers do not need to configure this parameter. Ensure that src0 meets the data type requirements. |
||
T4 |
LocalTensor or scalar data type. The data type is automatically inferred based on src1. Developers do not need to configure this parameter. Ensure that src1 meets the data type requirements. |
Parameter |
Input/Output |
Description |
|---|---|---|
dst |
Output |
Destination operand. The type is LocalTensor, and TPosition can be VECIN, VECCALC, or VECOUT. The start address of LocalTensor must be 32-byte aligned. For the Atlas 350 Accelerator Card, the supported data type is half. For details about precision conversion rules for different data types, see Table 3. |
src0/src1 |
Input |
Source operands.
|
count |
Input |
Number of elements involved in the computation. |
Returns
None
Restrictions
- Either the left or right source operand must be a vector. Currently, the left and right operands cannot be scalars at the same time.
- If the scalar input is a LocalTensor single element, idx must be a compile-time constant. If it is a variable, it must be declared as constexpr.
Examples
1 2 3 4 5 6 | // The scalar is after the tensor. AscendC::MulsCast(dstLocal, src0Local, src1Local[0], 512); // The scalar is before the tensor. static constexpr AscendC::BinaryConfig config = { 0 }; AscendC::MulsCast<BinaryDefaultType, BinaryDefaultType, config>(dstLocal, src0Local[0], src1Local, 512); |
Input (src0Local): [6 5 11 ... ] Input (src1Local): 2 Output (dstLocal): [12 10 22 ... ]