Mul【免费下载链接】atvossATVOSSAscend C Templates for Vector Operator Subroutines是一套基于Ascend C开发的Vector算子库致力于为昇腾硬件上的Vector类融合算子提供极简、高效、高性能、高拓展的编程方式。项目地址: https://gitcode.com/cann/atvoss功能说明乘法运算支持张量*张量张量*标量标量*张量。所属头文件链接/include/operators/math_expression.h函数原型templatetypename T, typename U struct OpMul : BinaryOpT, U templatetypename T, typename U __host_aicore__ constexpr auto operator*(ExpressionT lhs, ExpressionU rhs) templatetypename T, typename U __host_aicore__ constexpr auto operator*(ExpressionT lhs, U rhs) templatetypename T, typename U __host_aicore__ constexpr auto operator*(T lhs, ExpressionU rhs)参数说明参数名称参数类型输入/输出数据类型参数说明默认值T模板参数输入NA乘法左操作数数据类型NAU模板参数输入NA乘法右操作数数据类型NAlhs函数形参输入NA乘法左操作数当类型是ExpressionT时是张量当类型是T时是标量NArhs函数形参输入NA乘法右操作数当类型是ExpressionU时是张量当类型是U时是标量NA返回值说明返回值数据类型返回值说明Expression 返回一个OpMul的表达式约束说明不支持广播使用示例template typename InputDtype, typename OutputDtype struct Config { struct Compute { template template typename class Tensor __host_aicore__ constexpr auto Compute() const { auto in1 Atvoss::PlaceHolder1, TensorInputDtype, Atvoss::ParamUsage::IN(); auto in2 Atvoss::PlaceHolder2, TensorInputDtype, Atvoss::ParamUsage::IN(); auto out Atvoss::PlaceHolder3, TensorOutputDtype, 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::PlaceHolder1, TensorInputDtype, Atvoss::ParamUsage::IN(); auto scalar Atvoss::PlaceHolder2, InputDtype, Atvoss::ParamUsage::IN(); auto out Atvoss::PlaceHolder3, TensorOutputDtype, 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::PlaceHolder1, TensorInputDtype, Atvoss::ParamUsage::IN(); auto scalar Atvoss::PlaceHolder2, InputDtype, Atvoss::ParamUsage::IN(); auto out Atvoss::PlaceHolder3, TensorOutputDtype, Atvoss::ParamUsage::OUT(); // 使用示例 return (out scalar * in); // 使用示例 }; }; };【免费下载链接】atvossATVOSSAscend C Templates for Vector Operator Subroutines是一套基于Ascend C开发的Vector算子库致力于为昇腾硬件上的Vector类融合算子提供极简、高效、高性能、高拓展的编程方式。项目地址: https://gitcode.com/cann/atvoss创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考