#include "op_plugin/AclOpsInterface.h"
#include "op_plugin/OpApiInterface.h"
#include "op_plugin/utils/op_api_common.h"
namespace op_api {
using npu_preparation = at_npu::native::OpPreparation;
at::Tensor& eq_out(const at::Tensor& self, const at::Tensor& other, at::Tensor& result) {
DO_COMPATIBILITY(aclnnEqTensor, acl_op::eq_out(self, other, result));
std::vector<at::Tensor> tensor_list = {self, other};
auto maybe_names = op_plugin::utils::compute_names_npu(tensor_list);
if (npu_preparation::IsCPUScalar(other)) {
return op_api::eq_out(self, other.item(), result);
} else if (npu_preparation::IsCPUScalar(self)) {
return op_api::eq_out(other, self.item(), result);
}
auto output_size = op_infer::broadcast_ops_npu_output_size(self, other);
npu_preparation::check_tensor({self, other}, result, at::IntArrayRef(output_size));
EXEC_NPU_CMD(aclnnEqTensor, self, other, result);
at::namedinference::propagate_names_if_nonempty(result, maybe_names);
return result;
}
at::Tensor eq(const at::Tensor& self, const at::Tensor& other) {
DO_COMPATIBILITY(aclnnEqTensor, acl_op::eq(self, other));
std::vector<at::Tensor> tensor_list = {self, other};
auto maybe_names = op_plugin::utils::compute_names_npu(tensor_list);
if (npu_preparation::IsCPUScalar(other)) {
return op_api::eq(self, other.item());
} else if (npu_preparation::IsCPUScalar(self)) {
return op_api::eq(other, self.item());
}
auto output_size = op_infer::broadcast_ops_npu_output_size(self, other);
at::Tensor result =
npu_preparation::apply_tensor_without_format(output_size, self.options().dtype(at::kBool));
EXEC_NPU_CMD(aclnnEqTensor, self, other, result);
at::namedinference::propagate_names_if_nonempty(result, maybe_names);
return result;
}
at::Tensor& eq_out_npu_scalar(at::Tensor& result, const at::Tensor& self, at::Scalar other) {
EXEC_NPU_CMD(aclnnEqScalar, self, other, result);
at::namedinference::propagate_names(result, self);
return result;
}
at::Tensor eq(const at::Tensor& self, const at::Scalar& other) {
DO_COMPATIBILITY(aclnnEqScalar, acl_op::eq(self, other));
auto output_size = op_infer::input_same_output_size(self);
at::Tensor result =
npu_preparation::apply_tensor_without_format(output_size, self.options().dtype(at::kBool));
eq_out_npu_scalar(result, self, other);
return result;
}
at::Tensor& eq_out(const at::Tensor& self, const at::Scalar& other, at::Tensor& result) {
DO_COMPATIBILITY(aclnnEqScalar, acl_op::eq_out(self, other, result));
npu_preparation::check_tensor({self}, result, self.sizes());
eq_out_npu_scalar(result, self, other);
return result;
}
at::Tensor& eq_(at::Tensor &self, const at::Tensor &other) {
DO_COMPATIBILITY(aclnnInplaceEqTensor, acl_op::eq_(self, other));
const std::initializer_list<at::Tensor> inputs = {self, other};
const std::initializer_list<at::Tensor> outputs = {self};
npu_preparation::check_memory(inputs, outputs);
EXEC_NPU_CMD(aclnnInplaceEqTensor, self, other);
return self;
}
at::Tensor& eq_(at::Tensor &self, const at::Scalar& other) {
DO_COMPATIBILITY(aclnnInplaceEqScalar, acl_op::eq_(self, other));
EXEC_NPU_CMD(aclnnInplaceEqScalar, self, other);
return self;
}
}