CANN/asc-devkit LeakyReLU矢量计算API
asc_leakyrelu【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言原生支持C和C标准规范主要由类库和语言扩展层构成提供多层级API满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkit产品支持情况产品是否支持Atlas A3 训练系列产品/Atlas A3 推理系列产品√Atlas A2 训练系列产品/Atlas A2 推理系列产品√功能说明执行矢量Leaky Relu运算。计算公式如下$$ dst_i \begin{cases} src_i ,\quad src_i0\ \alpha src_i, \quad src_i\le0 \end{cases} $$函数原型前n个数据计算__aicore__ inline void asc_leakyrelu(__ubuf__ half* dst, __ubuf__ half* src, half value, uint32_t count) __aicore__ inline void asc_leakyrelu(__ubuf__ float* dst, __ubuf__ float* src, float value, uint32_t count)高维切分计算__aicore__ inline void asc_leakyrelu(__ubuf__ half* dst, __ubuf__ half* src, half value, uint8_t repeat, uint16_t dst_block_stride, uint16_t src_block_stride, uint16_t dst_repeat_stride, uint16_t src_repeat_stride) __aicore__ inline void asc_leakyrelu(__ubuf__ float* dst, __ubuf__ float* src, float value, uint8_t repeat, uint16_t dst_block_stride, uint16_t src_block_stride, uint16_t dst_repeat_stride, uint16_t src_repeat_stride)同步计算__aicore__ inline void asc_leakyrelu_sync(__ubuf__ half* dst, __ubuf__ half* src, half value, uint32_t count) __aicore__ inline void asc_leakyrelu_sync(__ubuf__ float* dst, __ubuf__ float* src, float value, uint32_t count)参数说明参数名输入/输出描述dst输出目的操作数向量的起始地址。src输入源操作数矢量的起始地址为待处理数据。value输入源操作数标量leaky_relu中alpha的值。count输入参与计算的元素个数。dst_block_stride输入目的操作数单次迭代内不同DataBlock间地址步长。src_block_stride输入源操作数0单次迭代内不同DataBlock间地址步长。dst_repeat_stride输入目的操作数相邻迭代间相同DataBlock的地址步长。src_repeat_stride输入源操作数0相邻迭代间相同DataBlock的地址步长。repeat输入迭代次数。返回值说明无流水类型PIPE_V约束说明操作数地址重叠约束请参考通用地址重叠约束。dst、src的起始地址需要32字节对齐。调用示例//total_length 指参与计算的数据长度 constexpr uint64_t total_length 64; half alpha 0.1; ___ubuf__ half src[total_length]; ___ubuf__ half dst[total_length]; asc_leakyrelu_sync(dst, src, alpha, total_length);【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言原生支持C和C标准规范主要由类库和语言扩展层构成提供多层级API满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkit创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考