CANN/atvoss除法运算API文档
2026/5/9 12:18:30 网站建设 项目流程

Div

【免费下载链接】atvossATVOSS(Ascend C Templates for Vector Operator Subroutines)是一套基于Ascend C开发的Vector算子库,致力于为昇腾硬件上的Vector类融合算子提供极简、高效、高性能、高拓展的编程方式。项目地址: https://gitcode.com/cann/atvoss

功能说明

除法运算,支持张量/张量,张量/标量,标量/张量。

所属头文件链接

/include/operators/math_expression.h

函数原型

template<typename T, typename U> struct OpDiv : BinaryOp<T, U> template<typename T, typename U> __host_aicore__ constexpr auto operator/(Expression<T> lhs, Expression<U> rhs) template<typename T, typename U> __host_aicore__ constexpr auto operator/(Expression<T> lhs, U &&rhs) template<typename T, typename U> __host_aicore__ constexpr auto operator/(T &&lhs, Expression<U> rhs)

参数说明

参数名称参数类型输入/输出数据类型参数说明默认值
T模板参数输入NA除法左操作数数据类型NA
U模板参数输入NA除法右操作数数据类型NA
lhs函数形参输入NA除法左操作数,当类型是Expression<T>时,是张量,当类型是T时,是标量NA
rhs函数形参输入NA除法右操作数,当类型是Expression<U>时,是张量,当类型是U时,是标量NA

返回值说明

返回值数据类型返回值说明
Expression >返回一个OpDiv的表达式

约束说明

不支持广播

使用示例

template <typename InputDtype, typename OutputDtype> struct Config { struct Compute { template <template <typename> class Tensor> __host_aicore__ constexpr auto Compute() const { auto in1 = Atvoss::PlaceHolder<1, Tensor<InputDtype>, Atvoss::ParamUsage::IN>(); auto in2 = Atvoss::PlaceHolder<2, Tensor<InputDtype>, Atvoss::ParamUsage::IN>(); auto out = Atvoss::PlaceHolder<3, Tensor<OutputDtype>, Atvoss::ParamUsage::OUT>(); // 🔥🔥🔥 使用示例 🔥🔥🔥 return (out = in1 / in2); // 🔥🔥🔥 使用示例 🔥🔥🔥 }; }; }; template <typename InputDtype, typename OutputDtype> struct Config { struct Compute { template <template <typename> class Tensor> __host_aicore__ constexpr auto Compute() const { auto in = Atvoss::PlaceHolder<1, Tensor<InputDtype>, Atvoss::ParamUsage::IN>(); auto scalar = Atvoss::PlaceHolder<2, InputDtype, Atvoss::ParamUsage::IN>(); auto out = Atvoss::PlaceHolder<3, Tensor<OutputDtype>, Atvoss::ParamUsage::OUT>(); // 🔥🔥🔥 使用示例 🔥🔥🔥 return (out = in / scalar); // 🔥🔥🔥 使用示例 🔥🔥🔥 }; }; }; template <typename InputDtype, typename OutputDtype> struct Config { struct Compute { template <template <typename> class Tensor> __host_aicore__ constexpr auto Compute() const { auto in = Atvoss::PlaceHolder<1, Tensor<InputDtype>, Atvoss::ParamUsage::IN>(); auto scalar = Atvoss::PlaceHolder<2, InputDtype, Atvoss::ParamUsage::IN>(); auto out = Atvoss::PlaceHolder<3, Tensor<OutputDtype>, Atvoss::ParamUsage::OUT>(); // 🔥🔥🔥 使用示例 🔥🔥🔥 return (out = scalar / in); // 🔥🔥🔥 使用示例 🔥🔥🔥 }; }; };

【免费下载链接】atvossATVOSS(Ascend C Templates for Vector Operator Subroutines)是一套基于Ascend C开发的Vector算子库,致力于为昇腾硬件上的Vector类融合算子提供极简、高效、高性能、高拓展的编程方式。项目地址: https://gitcode.com/cann/atvoss

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询