#include "op_plugin/utils/Version.h"
#if VERSION_BETWEEN(V2R11, VERSION_NEWEST)
#include <ATen/Functions.h>
#include <ATen/native/BinaryOps.h>
namespace at {
namespace native {
namespace {
at::Tensor _pow2(const at::Tensor& self, const at::Tensor& exponent)
{
const auto self_dtype = self.scalar_type();
if (at::isIntegralType(self_dtype, true) || self_dtype == at::kFloat) {
return at::pow(2.0, exponent);
}
return at::full({}, 2.0, self.options()).pow(exponent);
}
}
void ldexp_kernel_npu(at::TensorIteratorBase& iter)
{
const auto& self = iter.input(0);
const auto& exponent = iter.input(1);
auto out = iter.output();
at::mul_out(out, self, _pow2(self, exponent));
}
REGISTER_PRIVATEUSE1_DISPATCH(ldexp_stub, &ldexp_kernel_npu);
}
}
#endif