Performs division based on elements using the following formula, where PAR indicates the number of elements that can be processed by the Vector Unit in one iteration.

Computation of the first n data elements of a tensor:
template <typename T> __aicore__ inline void Div(const LocalTensor<T>& dstLocal, const LocalTensor<T>& src0Local, const LocalTensor<T>& src1Local, const int32_t& calCount)
Table 1 Template parameters
| Parameter | Description |
|---|---|
| T | Operand data type. |
Table 2 Parameters
| Parameter | Input/Output | Description |
|---|---|---|
| dstLocal | Output | Destination operand. The type is LocalTensor, and the supported TPosition is VECIN, VECCALC, or VECOUT. The start address of the LocalTensor must be 32-byte aligned. For Kirin 9020, Kirin 9030, and Kirin X90 series processors, the supported data types include half and float. For Kirin X90 series processors, the supported data types include half and float. |
| src0Local and src1Local | Input | Source operand The type is LocalTensor, and the supported TPosition is VECIN, VECCALC, or VECOUT. The start address of the LocalTensor must be 32-byte aligned. Both source operands must have the same data type as the destination operand. For Kirin 9020, Kirin 9030, and Kirin X90 series processors, the supported data types include half and float. For Kirin X90 series processors, the supported data types include half and float. |
| calCount | Input | Number of elements of the input data. |
Kirin 9020 series processors
Kirin 9030 series processors
Kirin X90 series processors
Division by zero is not allowed.
For details about the alignment requirements of the operand address offset, see General Constraints.
Example of the first n data calculations of the tensor. (This example shows only part of the code in the computation process. To run the sample code, use it to replace the bold part of the Compute function in the preceding example.)
AscendC::Div(dstLocal, src0Local, src1Local, 512);
An example of the result is as follows:
Input (src0Local): [1.0 2.0 3.0 ... 512.0] Input (src1Local): [2.0 2.0 2.0 ... 2.0] Output (dstLocal): [0.5 1.0 1.5 ... 256.0]