vec_exp
Description
Computes the natural exponential element-wise: 

Prototype
vec_exp(mask, dst, src, repeat_times, dst_rep_stride, src_rep_stride)
Parameters
For details, see Parameters.
dst has the same data type as src.
Returns
None
Applicability
Restrictions
- For the
Atlas 200/300/500 Inference Product , even if the ex compute result meets the accuracy requirement, the ex – 1 compute result using this API with float16 input may fail to meet the dual-0.1% error limit (both the error ratio and relative error are within 0.1%) due to the subtraction error. If the accuracy requirement for the ex – 1 computation is high, the vec_expm1_high_preci API is preferred. - For the
Atlas Training Series Product , even if the ex compute result meets the accuracy requirement, the ex – 1 compute result using this API with float16 input may fail to meet the dual-0.1% error limit (both the error ratio and relative error are within 0.1%) due to the subtraction error. If the accuracy requirement for the ex – 1 computation is high, the vec_expm1_high_preci API is preferred. - For other restrictions, see Restrictions.
Example
This example applies to a small amount of data that can be moved at a time, helping you understand the API functions. For more complex samples with a large amount of data, see Example.
from tbe import tik
tik_instance = tik.Tik()
src_gm = tik_instance.Tensor("float16", (128,), name="src_gm", scope=tik.scope_gm)
src_ub = tik_instance.Tensor("float16", (128,), name="src_ub", scope=tik.scope_ubuf)
dst_gm = tik_instance.Tensor("float16", (128,), name="dst_gm", scope=tik.scope_gm)
dst_ub = tik_instance.Tensor("float16", (128,), name="dst_ub", scope=tik.scope_ubuf)
tik_instance.data_move(src_ub, src_gm, 0, 1, 8, 0, 0)
tik_instance.vec_exp(128, dst_ub, src_ub, 1, 8, 8)
tik_instance.data_move(dst_gm, dst_ub, 0, 1, 8, 0, 0)
tik_instance.BuildCCE(kernel_name="exp", inputs=[src_gm], outputs=[dst_gm])
Result example:
Input: [0, 1, 2, 3, ......] Output: [1.0, 2.719, 7.391, 20.08, ......]
Parent topic: Single Source (Gather Mode)