Skip to content
版 本

asc_mul_add

产 品 支 持 情 况

产 品是 否 支 持
Atlas A3 训 练 系 列 产 品/Atlas A3 推 理 系 列 产 品
Atlas A2 训 练 系 列 产 品/Atlas A2 推 理 系 列 产 品

功 能 说 明

执 行 矢 量 的 乘 加 运 算。计 算 公 式 如 下:

$$ dst_i = (src0_i * dst_i) + src1_i $$

函 数 原 型

  • 前n个 数 据 计 算

    C++
    __aicore__ inline void asc_mul_add(__ubuf__ half* dst, __ubuf__ half* src0, __ubuf__ half* src1, uint32_t count)
    __aicore__ inline void asc_mul_add(__ubuf__ float* dst, __ubuf__ float* src0, __ubuf__ float* src1, uint32_t count)
    
  • 高 维 切 分 计 算

    C++
    __aicore__ inline void asc_mul_add(__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_mul_add(__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)
    
  • 同 步 计 算

    C++
    __aicore__ inline void asc_mul_add_sync(__ubuf__ half* dst, __ubuf__ half* src0, __ubuf__ half* src1, uint32_t count)
    __aicore__ inline void asc_mul_add_sync(__ubuf__ float* dst, __ubuf__ float* src0, __ubuf__ float* 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

约 束 说 明

调 用 示 例

C++
constexpr uint64_t total_length = 128;    // total_length指 参 与 计 算 的 数 据 长 度
__ubuf__ half src0[total_length];
__ubuf__ half src1[total_length];
__ubuf__ half dst[total_length];
asc_mul_add(dst, src0, src1, total_length);    // dst = (src0 * dst) + src1
// src0 [1, 2, 3, ..., 128]
// src1 [1, 1, 1, ..., 1]
// 计 算 前dst [2, 2, 2, ..., 2]
// 计 算 后dst [3, 5, 7, ..., 257]

免 责 声 明:本 站 内 容 由 asc-devkit 仓 master 分 支 自 动 编 译 生 成,属 于 持 续 开 发 版 本,可 能 存 在 缺 陷,仅 供 预 览 与 参 考。如 需 稳 定 及 商 用 资 料,请 查 阅 官 方 昇 腾 社 区