Computes the natural exponent 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 Exp(const LocalTensor<T>& dstLocal, const LocalTensor<T>& srcLocal, 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. |
| srcLocal | 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. The source operand 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. |
| calCount | Input | Number of elements of the input data. |
Kirin 9020 series processors
Kirin 9030 series processors
Kirin X90 series processors
For details about the alignment requirements of the operand address offset, see General Constraints.
This example shows only part of the code used in the computation process (Compute). In this example, srcLocal and dstLocal are of the half type and occupy 16 bits.
To run the sample code, copy the code snippet to replace some code of the Compute function in Sample Template.
Example of computing the first n data elements of a tensor:
AscendC::Exp(dstLocal, srcLocal, 512);
An example of the result is as follows:
Input (srcLocal): [0.0 1.0 2.0 3.0 ...] Output (dstLocal): [1.0 2.719 7.391 20.08 ...]