Skip to content
版 本

asc_get_reduce_max_cnt

产 品 支 持 情 况

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

功 能 说 明

此 接 口 用 于 获 取 执 行asc_repeat_reduce_max操 作 后 的 最 大 值,以 及 第 一 个 最 大 值 时 的 索 引。

函 数 原 型

C++
__aicore__ inline void asc_get_reduce_max_cnt(half& val, uint32_t& index)
__aicore__ inline void asc_get_reduce_max_cnt(float& val, uint32_t& index)

参 数 说 明

参 数 名输 入/输 出描 述
val输 出最 大 值。
index输 出第 一 个 最 大 值 时 的 索 引。

返 回 值 说 明

流 水 类 型

PIPE_S

约 束 说 明

  • 需 和asc_repeat_reduce_max操 作 配 合 使 用。
  • 需 通 过 同 步 操 作 确 保asc_repeat_reduce_max执 行 完 成 后 再 调 用 本 接 口 获 取 结 果。

调 用 示 例

C++
// 示 例 计 算256个half的 最 大 值 和 索 引,分2次 迭 代 完 成,计 算 结 果 为2组value_index
constexpr uint32_t total_length = 256;
__ubuf__ half src[total_length];
constexpr uint32_t dst_length = 4;
__ubuf__ half dst[dst_length];

asc_repeat_reduce_max_value_index(dst, src, total_length);
asc_sync();

half maxValue;
uint32_t maxIndex;
asc_get_reduce_max_cnt(maxValue, maxIndex);

结 果 示 例:

Text
输 入 数 据src:[1, 2, 3, ..., 128, 129, ..., 256]
maxValue: 256.0
maxIndex: 255

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