Power
功能说明
幂运算。
所属头文件链接
/include/operators/math_expression.h
函数原型
template<auto scalarValue, typename T>
struct OpPower : UnaryOp<T>
template<auto scalarValue, typename T>
__host_aicore__ constexpr auto Power(Expression<T> lhs)
template<auto scalarValue, typename T>
__host_aicore__ constexpr auto Power(T &&lhs)
参数说明
| 参数名称 | 参数类型 | 输入/输出 | 数据类型 | 参数说明 | 默认值 |
|---|---|---|---|---|---|
| scalarValue | 模板参数 | 输入 | NA | Power操作的幂次 | NA |
| T | 模板参数 | 输入 | NA | Power操作数的数据类型 | NA |
| lhs | 函数形参 | 输入 | NA | Power操作数,当类型是Expression<T>时,是张量,当类型是T时,是标量 | NA |
返回值说明
| 返回值数据类型 | 返回值说明 |
|---|---|
| Expression> | 返回一个OpPower的表达式 |
约束说明
NA
使用示例
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 out = Atvoss::PlaceHolder<2, Tensor<OutputDtype>, Atvoss::ParamUsage::OUT>();
// 🔥🔥🔥 使用示例 🔥🔥🔥
return (out = Power<2>(in));
// 🔥🔥🔥 使用示例 🔥🔥🔥
};
};
};
template <typename InputDtype, typename OutputDtype>
struct Config {
struct Compute {
template <template <typename> class Tensor>
__host_aicore__ constexpr auto Compute() const
{
auto scalar = Atvoss::PlaceHolder<1, InputDtype, Atvoss::ParamUsage::IN>();
auto out = Atvoss::PlaceHolder<2, Tensor<OutputDtype>, Atvoss::ParamUsage::OUT>();
// 🔥🔥🔥 使用示例 🔥🔥🔥
return (out = Power<2>(scalar));
// 🔥🔥🔥 使用示例 🔥🔥🔥
};
};
};