发布时间:2026/7/17 16:53:35
CANN/asc-devkit幂运算接口 Power【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言原生支持C和C标准规范主要由类库和语言扩展层构成提供多层级API满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkit产品支持情况Ascend 950PR/Ascend 950DT支持Atlas A3 训练系列产品/Atlas A3 推理系列产品支持Atlas A2 训练系列产品/Atlas A2 推理系列产品支持Atlas 200I/500 A2 推理产品不支持Atlas 推理系列产品AI Core支持Atlas 推理系列产品Vector Core不支持Atlas 训练系列产品不支持功能说明实现按元素做幂运算功能提供3类接口处理逻辑如下函数原型Power(dstTensor, src0Tensor, src1Tensor)通过sharedTmpBuffer入参传入临时空间源操作数Tensor全部/部分参与计算template typename T, bool isReuseSource false, const PowerConfig config defaultPowerConfig __aicore__ inline void Power(const LocalTensorT dstTensor, const LocalTensorT src0Tensor, const LocalTensorT src1Tensor, const LocalTensoruint8_t sharedTmpBuffer, uint32_t calCount)源操作数Tensor全部参与计算template typename T, bool isReuseSource false, const PowerConfig config defaultPowerConfig __aicore__ inline void Power(const LocalTensorT dstTensor, const LocalTensorT src0Tensor, const LocalTensorT src1Tensor, const LocalTensoruint8_t sharedTmpBuffer)接口框架申请临时空间源操作数Tensor全部/部分参与计算template typename T, bool isReuseSource false, const PowerConfig config defaultPowerConfig __aicore__ inline void Power(const LocalTensorT dstTensor, const LocalTensorT src0Tensor, const LocalTensorT src1Tensor, uint32_t calCount)源操作数Tensor全部参与计算template typename T, bool isReuseSource false, const PowerConfig config defaultPowerConfig __aicore__ inline void Power(const LocalTensorT dstTensor, const LocalTensorT src0Tensor, const LocalTensorT src1Tensor)Power(dstTensor, src0Tensor, src1Scalar)通过sharedTmpBuffer入参传入临时空间源操作数Tensor全部/部分参与计算template typename T, bool isReuseSource false, const PowerConfig config defaultPowerConfig __aicore__ inline void Power(const LocalTensorT dstTensor, const LocalTensorT src0Tensor, const T src1Scalar, const LocalTensoruint8_t sharedTmpBuffer, uint32_t calCount)源操作数Tensor全部参与计算template typename T, bool isReuseSource false, const PowerConfig config defaultPowerConfig __aicore__ inline void Power(const LocalTensorT dstTensor, const LocalTensorT src0Tensor, const T src1Scalar, const LocalTensoruint8_t sharedTmpBuffer)接口框架申请临时空间源操作数Tensor全部/部分参与计算template typename T, bool isReuseSource false, const PowerConfig config defaultPowerConfig __aicore__ inline void Power(const LocalTensorT dstTensor, const LocalTensorT src0Tensor, const T src1Scalar, uint32_t calCount)源操作数Tensor全部参与计算template typename T, bool isReuseSource false, const PowerConfig config defaultPowerConfig __aicore__ inline void Power(const LocalTensorT dstTensor, const LocalTensorT src0Tensor, const T src1Scalar)Power(dstTensor, src0Scalar, src1Tensor)通过sharedTmpBuffer入参传入临时空间源操作数Tensor全部/部分参与计算template typename T, bool isReuseSource false, const PowerConfig config defaultPowerConfig __aicore__ inline void Power(const LocalTensorT dstTensor, const T src0Scalar, const LocalTensorT src1Tensor, const LocalTensoruint8_t sharedTmpBuffer, uint32_t calCount)源操作数Tensor全部参与计算template typename T, bool isReuseSource false, const PowerConfig config defaultPowerConfig __aicore__ inline void Power(const LocalTensorT dstTensor, const T src0Scalar, const LocalTensorT src1Tensor, const LocalTensoruint8_t sharedTmpBuffer)接口框架申请临时空间源操作数Tensor全部/部分参与计算template typename T, bool isReuseSource false, const PowerConfig config defaultPowerConfig __aicore__ inline void Power(const LocalTensorT dstTensor, const T src0Scalar, const LocalTensorT src1Tensor, uint32_t calCount)源操作数Tensor全部参与计算template typename T, bool isReuseSource false, const PowerConfig config defaultPowerConfig __aicore__ inline void Power(const LocalTensorT dstTensor, const T src0Scalar, const LocalTensorT src1Tensor)由于该接口的内部实现中涉及复杂的数学计算需要额外的临时空间来存储计算过程中的中间变量。临时空间支持接口框架申请和开发者通过sharedTmpBuffer入参传入两种方式。接口框架申请临时空间开发者无需申请但是需要预留临时空间的大小。通过sharedTmpBuffer入参传入使用该tensor作为临时空间进行处理接口框架不再申请。该方式开发者可以自行管理sharedTmpBuffer内存空间并在接口调用完成后复用该部分内存内存不会反复申请释放灵活性较高内存利用率也较高。接口框架申请的方式开发者需要预留临时空间通过sharedTmpBuffer传入的情况开发者需要为sharedTmpBuffer申请空间。临时空间大小BufferSize的获取方式如下通过GetPowerMaxMinTmpSize中提供的GetPowerMaxMinTmpSize接口获取需要预留空间的范围大小。参数说明表1模板参数说明参数名描述T操作数的数据类型。不同型号支持的数据类型请参考支持的数据类型。isReuseSource是否允许修改源操作数。该参数预留传入默认值false即可。config该参数仅支持Ascend 950PR/Ascend 950DT。Power计算的相关配置。此参数可选配PowerConfig类型具体定义如下方代码所示其中参数的含义为algo不同的数据类型支持的不同Power算法。该参数支持的取值如下INTRINSIC默认值。如果数据类型是整型INTRINSIC算法使用快速幂算法实现Power计算支持的数据类型为uint8_t、int8_t、uint16_t、int16_t、uint32_t、int32_t。如果数据类型是浮点数类型INTRINSIC算法按照公式Power(x, y) exp(y * ln(x))进行Power计算支持的数据类型为half、float。DOUBLE_FLOAT_TECHDOUBLE_FLOAT_TECH算法是高精度浮点数算法将源操作数的精度提升后按照公式Power(x, y) exp(y * ln(x))进行Power计算减少计算过程中的精度损失支持的数据类型为bfloat16_t、half、float。enum class PowerAlgo { INTRINSIC 0, DOUBLE_FLOAT_TECH, }; struct PowerConfig { PowerAlgo algo PowerAlgo::INTRINSIC; };表2接口参数说明参数名输入/输出描述dstTensor输出目的操作数。类型为LocalTensor支持的TPosition为VECIN/VECCALC/VECOUT。src0Tensor输入源操作数。类型为LocalTensor支持的TPosition为VECIN/VECCALC/VECOUT。源操作数的数据类型需要与目的操作数保持一致。src1Tensor输入源操作数。类型为LocalTensor支持的TPosition为VECIN/VECCALC/VECOUT。源操作数的数据类型需要与目的操作数保持一致。src0Scalar/src1Scalar输入源操作数类型为Scalar。源操作数的数据类型需要与目的操作数保持一致。sharedTmpBuffer输入临时内存空间。类型为LocalTensor支持的TPosition为VECIN/VECCALC/VECOUT。针对3个power接口不同输入数据类型情况下临时空间大小BufferSize的获取方式请参考GetPowerMaxMinTmpSize。calCount输入参与计算的元素个数。返回值说明无约束说明不支持源操作数与目的操作数地址重叠。对于Atlas 推理系列产品AI Core幂运算的指数必须小于231-1。操作数地址对齐要求请参见通用地址对齐约束。支持的数据类型Ascend 950PR/Ascend 950DT支持的数据类型为uint8_t、int8_t、uint16_t、int16_t、uint32_t、int32_t、half、bfloat16_t、float。Atlas A3 训练系列产品/Atlas A3 推理系列产品支持的数据类型为half、float、int32_t。Atlas A2 训练系列产品/Atlas A2 推理系列产品支持的数据类型为half、float、int32_t。Atlas 推理系列产品AI Core支持的数据类型为half、float、int32_t。调用示例完整的调用样例请参考Power样例。// dstLocal: 存放计算结果的Tensor // srcLocalExp: Power计算使用的指数Tensor // srcLocalBase: Power计算使用的底数Tensor // 使用srcLocalBase做底数对srcLocalExp中的全部元素做幂运算 AscendC::PowerT, false(dstLocal, srcLocalBase, srcLocalExp); // scalarValueBase: Power计算使用的底数 T scalarValueBase srcLocalBase.GetValue(0); // 使用同一个底数scalarValueBase对srcLocalExp中的全部元素做幂运算 AscendC::PowerT, false(dstLocal, scalarValueBase, srcLocalExp); // scalarValueExp: Power计算使用的指数 T scalarValueExp srcLocalExp.GetValue(0); // 使用同一个指数scalarValueExp对srcLocalBase中的全部元素做幂运算 AscendC::PowerT, false(dstLocal, srcLocalBase, scalarValueExp); // static constexpr AscendC::PowerConfig config { AscendC::PowerAlgo::DOUBLE_FLOAT_TECH }; // AscendC::PowersrcType, false, config(dstLocal, scalarValue, srcLocal2);AscendC::PowerT, false(dstLocal, srcLocalBase, srcLocalExp)示例数据如下输入数据(srcLocalBase): [2 3 4 5 6 7 8 9] 输入数据(srcLocalExp): [4 3 2 1 4 3 2 1] 输出数据(dstLocal): [16 27 16 5 1296 343 64 9]AscendC::PowerT, false(dstLocal, scalarValueBase, srcLocalExp)示例数据如下输入数据(scalarValueBase): 2 输入数据(srcLocalExp): [4 3 2 1 4 3 2 1] 输出数据(dstLocal): [16 8 4 2 16 8 4 2]AscendC::PowerT, false(dstLocal, srcLocalBase, scalarValueExp)示例数据如下输入数据(srcLocalBase): [2 3 4 5 6 7 8 9] 输入数据(scalarValueExp): 4 输出数据(dstLocal): [16 81 256 625 1296 2401 4096 6561]【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言原生支持C和C标准规范主要由类库和语言扩展层构成提供多层级API满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkit创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

相关新闻

2026/7/17 16:53:34

分布式快照隔离的实现与代价:MVCC时间戳到全局事务ID的全链路

分布式快照隔离的实现与代价:MVCC时间戳到全局事务ID的全链路 一、Read Committed不够用,Serializable又太贵 隔离级别是事务型数据库最核心也最容易被误用的特性。Read Committed避免了脏读但允许不可重复读和幻读,在金融对账、库存扣减等场…

2026/7/17 16:48:33

Continue开源AI编程助手:JetBrains终极配置与实战指南

Continue开源AI编程助手:JetBrains终极配置与实战指南 【免费下载链接】continue open-source coding agent 项目地址: https://gitcode.com/GitHub_Trending/co/continue 还在为复杂代码调试而头疼?是否渴望一个能理解你编程意图的智能助手&…

2026/7/17 16:48:33

CANN/asc-devkit:bfloat16精度转换函数

__bfloat162ll_rz 【免费下载链接】asc-devkit 本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言,原生支持C和C标准规范,主要由类库和语言扩展层构成,提供多层级API,满足多维场景算子开发诉求。 项目地址: https://gitco…

2026/7/17 18:13:52

全志V851se芯片Linux 6.1 + Debian 12镜像构建指南

1. 项目背景与目标在嵌入式开发领域,全志V851se芯片因其出色的性价比和丰富的外设接口备受开发者青睐。TinyVision作为基于该芯片的典型开发板,其官方提供的系统镜像往往无法满足开发者对最新内核和定制化系统的需求。手动构建Linux 6.1 Debian 12镜像的…

2026/7/17 18:13:52

基于GH6108指纹识别与树莓派的智能棋盘:硬件集成与AI部署实战

1. 项目概述:当传统棋盘遇上AI与生物识别最近在捣鼓一个挺有意思的玩意儿:把一块普通的棋盘,改造成能“认人”的智能设备。听起来有点科幻?其实核心思路很简单,就是给棋盘加上一个“眼睛”和一个“大脑”。“眼睛”负责…

2026/7/17 18:13:52

SpringBoot-Scan路线图:构建下一代SpringBoot应用安全扫描平台

1. 项目概述:SpringBoot-Scan是什么,以及我们为什么要规划它的未来如果你是一名Java开发者,尤其是深度使用SpringBoot框架的工程师,那么“安全”这个词,在你日常的编码、测试和部署中,一定是个绕不开的坎。…

2026/7/17 18:13:52

CANN/asc-devkit HCCL v1 TilingData接口

v1版本TilingData(废弃) 【免费下载链接】asc-devkit 本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言,原生支持C和C标准规范,主要由类库和语言扩展层构成,提供多层级API,满足多维场景算子开发诉求…

2026/7/17 18:08:51

Deemix WebUI详细教程:打造云端音乐下载管理平台

Deemix WebUI详细教程:打造云端音乐下载管理平台 【免费下载链接】deemix 项目地址: https://gitcode.com/gh_mirrors/de/deemix 想要打造一个属于自己的云端音乐下载管理平台吗?Deemix WebUI就是你的终极解决方案!🚀 这款…

2026/7/17 5:59:06

3步解锁音乐自由:ncmdumpGUI终极NCM文件解密转换指南

3步解锁音乐自由:ncmdumpGUI终极NCM文件解密转换指南 【免费下载链接】ncmdumpGUI C#版本网易云音乐ncm文件格式转换,Windows图形界面版本 项目地址: https://gitcode.com/gh_mirrors/nc/ncmdumpGUI 你是否曾在网易云音乐下载了心爱的歌曲&#…

2026/7/17 1:21:45

CANoe 19 SP3 配置 GB/T 27930-2023 A类系统:3步搭建BMS仿真测试环境

CANoe 19 SP3 配置 GB/T 27930-2023 A类系统:3步搭建BMS仿真测试环境随着新能源汽车行业的快速发展,充电通信协议的标准化和测试验证变得尤为重要。GB/T 27930-2023作为中国智能充电协议的最新版本,对充电机与电动汽车之间的通信提出了更严格…

2026/7/17 7:39:19

3步搞定RTL8852BE驱动:从零开始配置Wi-Fi 6网卡

3步搞定RTL8852BE驱动:从零开始配置Wi-Fi 6网卡 【免费下载链接】rtl8852be Realtek Linux WLAN Driver for RTL8852BE 项目地址: https://gitcode.com/gh_mirrors/rt/rtl8852be 还在为Linux系统无法识别RTL8852BE Wi-Fi 6网卡而烦恼吗?&#x1f…

2026/7/17 0:04:23

BiSheng JDK-build性能调优:构建速度提升30%的优化策略

BiSheng JDK-build性能调优:构建速度提升30%的优化策略 【免费下载链接】bishengjdk-build BiSheng JDK build and test scripts - common across all releases/versions 项目地址: https://gitcode.com/openeuler/bishengjdk-build 前往项目官网免费下载&am…

2026/7/17 14:59:44

3个高效策略:快速掌握Axure中文界面配置

3个高效策略:快速掌握Axure中文界面配置 【免费下载链接】axure-cn Chinese language file for Axure RP. Axure RP 简体中文语言包。支持 Axure 11、10、9。不定期更新。 项目地址: https://gitcode.com/gh_mirrors/ax/axure-cn 还在为Axure RP的英文界面感…