asc_add_relu
产 品 支 持 情 况
| 产 品 | 是 否 支 持 |
|---|---|
| √ | |
| √ |
功 能 说 明
按 元 素 求 和,再 进 行Relu计 算(结 果 和0对 比 取 较 大 值),并 提 供 转 换 最 终 结 果 的 数 据 类 型 的 功 能(s162s8、f322f16、f162s8)。计 算 公 式 如 下:
$$ dst_i = relu(src0_i + src1_i) $$
函 数 原 型
前n个 数 据 计 算
C++__aicore__ inline void asc_add_relu(__ubuf__ half* dst, __ubuf__ half* src0, __ubuf__ half* src1, uint32_t count) __aicore__ inline void asc_add_relu(__ubuf__ float* dst, __ubuf__ float* src0, __ubuf__ float* src1, uint32_t count) __aicore__ inline void asc_add_relu(__ubuf__ int16_t* dst, __ubuf__ int16_t* src0, __ubuf__ int16_t* src1, uint32_t count) __aicore__ inline void asc_add_relu(__ubuf__ int8_t* dst, __ubuf__ int16_t* src0, __ubuf__ int16_t* src1, uint32_t count) __aicore__ inline void asc_add_relu(__ubuf__ half* dst, __ubuf__ float* src0, __ubuf__ float* src1, uint32_t count) __aicore__ inline void asc_add_relu(__ubuf__ int8_t* dst, __ubuf__ half* src0, __ubuf__ half* src1, uint32_t count)高 维 切 分 计 算
C++__aicore__ inline void asc_add_relu(__ubuf__ half* dst, __ubuf__ half* src0, __ubuf__ half* src1, uint8_t repeat, uint8_t dst_block_stride, uint8_t src0_block_stride, uint8_t src1_block_stride, uint8_t dst_repeat_stride, uint8_t src0_repeat_stride, uint8_t src1_repeat_stride) __aicore__ inline void asc_add_relu(__ubuf__ float* dst, __ubuf__ float* src0, __ubuf__ float* src1, uint8_t repeat, uint8_t dst_block_stride, uint8_t src0_block_stride, uint8_t src1_block_stride, uint8_t dst_repeat_stride, uint8_t src0_repeat_stride, uint8_t src1_repeat_stride) __aicore__ inline void asc_add_relu(__ubuf__ int16_t* dst, __ubuf__ int16_t* src0, __ubuf__ int16_t* src1, uint8_t repeat, uint8_t dst_block_stride, uint8_t src0_block_stride, uint8_t src1_block_stride, uint8_t dst_repeat_stride, uint8_t src0_repeat_stride, uint8_t src1_repeat_stride) __aicore__ inline void asc_add_relu(__ubuf__ int8_t* dst, __ubuf__ int16_t* src0, __ubuf__ int16_t* src1, uint8_t repeat, uint8_t dst_block_stride, uint8_t src0_block_stride, uint8_t src1_block_stride, uint8_t dst_repeat_stride, uint8_t src0_repeat_stride, uint8_t src1_repeat_stride) __aicore__ inline void asc_add_relu(__ubuf__ half* dst, __ubuf__ float* src0, __ubuf__ float* src1, uint8_t repeat, uint8_t dst_block_stride, uint8_t src0_block_stride, uint8_t src1_block_stride, uint8_t dst_repeat_stride, uint8_t src0_repeat_stride, uint8_t src1_repeat_stride) __aicore__ inline void asc_add_relu(__ubuf__ int8_t* dst, __ubuf__ half* src0, __ubuf__ half* src1, uint8_t repeat, uint8_t dst_block_stride, uint8_t src0_block_stride, uint8_t src1_block_stride, uint8_t dst_repeat_stride, uint8_t src0_repeat_stride, uint8_t src1_repeat_stride)同 步 计 算
C++__aicore__ inline void asc_add_relu_sync(__ubuf__ half* dst, __ubuf__ half* src0, __ubuf__ half* src1, uint32_t count) __aicore__ inline void asc_add_relu_sync(__ubuf__ float* dst, __ubuf__ float* src0, __ubuf__ float* src1, uint32_t count) __aicore__ inline void asc_add_relu_sync(__ubuf__ int16_t* dst, __ubuf__ int16_t* src0, __ubuf__ int16_t* src1, uint32_t count) __aicore__ inline void asc_add_relu_sync(__ubuf__ int8_t* dst, __ubuf__ int16_t* src0, __ubuf__ int16_t* src1, uint32_t count) __aicore__ inline void asc_add_relu_sync(__ubuf__ half* dst, __ubuf__ float* src0, __ubuf__ float* src1, uint32_t count) __aicore__ inline void asc_add_relu_sync(__ubuf__ int8_t* dst, __ubuf__ half* src0, __ubuf__ half* src1, uint32_t count)
参 数 说 明
| 参 数 名 | 输 入/输 出 | 描 述 |
|---|---|---|
| dst | 输 出 | 目 的 操 作 数(矢 量)的 起 始 地 址。 |
| src0、src1 | 输 入 | 源 操 作 数(矢 量)的 起 始 地 址。 |
| count | 输 入 | 参 与 计 算 的 元 素 个 数。 |
| repeat | 输 入 | 迭 代 次 数。 |
| dst_block_stride | 输 入 | 目 的 操 作 数 单 次 迭 代 内 不 同DataBlock间 地 址 步 长。 |
| src0_block_stride | 输 入 | 源 操 作 数0单 次 迭 代 内 不 同DataBlock间 地 址 步 长。 |
| src1_block_stride | 输 入 | 源 操 作 数1单 次 迭 代 内 不 同DataBlock间 地 址 步 长。 |
| dst_repeat_stride | 输 入 | 目 的 操 作 数 相 邻 迭 代 间 相 同DataBlock的 地 址 步 长。 |
| src0_repeat_stride | 输 入 | 源 操 作 数0相 邻 迭 代 间 相 同DataBlock的 地 址 步 长。 |
| src1_repeat_stride | 输 入 | 源 操 作 数1相 邻 迭 代 间 相 同DataBlock的 地 址 步 长。 |
返 回 值 说 明
无
流 水 类 型
PIPE_V
约 束 说 明
- dst、src0、src1的 起 始 地 址 需 要32字 节 对 齐。
- 操 作 数 地 址 重 叠 约 束 请 参 考通 用 地 址 重 叠 约 束。
调 用 示 例
C++
// 目 的 操 作 数 和 源 操 作 数 的 数 据 类 型 一 致
// total_length指 参 与 计 算 的 数 据 总 长 度
constexpr uint64_t total_length = 128;
__ubuf__ half src0[total_length];
__ubuf__ half src1[total_length];
__ubuf__ half dst[total_length];
asc_add_relu(dst, src0, src1, total_length);
C++
// 目 的 操 作 数 和 源 操 作 数 的 数 据 类 型 不 一 致(s162s8)
// total_length指 参 与 计 算 的 数 据 长 度
constexpr uint32_t total_length = 32;
__ubuf__ int8_t dst[total_length];
__ubuf__ int16_t src0[total_length];
__ubuf__ int16_t src1[total_length];
asc_add_relu(dst, src0, src1, total_length);