#include "op_plugin/AclOpsInterface.h"
#include "op_plugin/utils/OpAdapter.h"
namespace acl_op {
using npu_preparation = at_npu::native::OpPreparation;
using npu_utils = at_npu::native::NpuUtils;
namespace {
at::Tensor &ilshift_out_npu(at::Tensor &result, at::Tensor &self, at::Scalar other)
{
at::Tensor other_tensor = npu_preparation::apply_tensor(self);
at::Tensor other_broadcast = acl_op::fill_(other_tensor, other);
at_npu::native::OpCommand cmd;
cmd.Name("LeftShift").Input(self).Input(other_broadcast).Output(result).Run();
return result;
}
at::Tensor &ilshift_out_npu(at::Tensor &result, at::Tensor &self, const at::Tensor &other)
{
at::Tensor other_broadcast = other.expand(self.sizes());
at_npu::native::OpCommand cmd;
cmd.Name("LeftShift").Input(self).Input(other_broadcast).Output(result).Run();
return result;
}
}
at::Tensor &__ilshift__(at::Tensor &self, const at::Tensor &other)
{
if (!npu_utils::check_match(&self)) {
at::Tensor contiguous_self = npu_utils::format_contiguous(self);
ilshift_out_npu(contiguous_self, contiguous_self, other);
npu_utils::format_fresh_view(self, contiguous_self);
} else {
ilshift_out_npu(self, self, other);
}
return self;
}
at::Tensor &__ilshift__(at::Tensor &self, const at::Scalar &other)
{
if (!npu_utils::check_match(&self)) {
at::Tensor contiguous_self = npu_utils::format_contiguous(self);
ilshift_out_npu(contiguous_self, contiguous_self, other);
npu_utils::format_fresh_view(self, contiguous_self);
} else {
ilshift_out_npu(self, self, other);
}
return self;
}
}