diff --git a/torch_npu/csrc/aten/ops/LogSumExpKernelNpu.cpp b/torch_npu/csrc/aten/ops/LogSumExpKernelNpu.cpp index 6f9eaa480c106a32cd6a9df06e6cdcd927fccc50..a14ddfbb4ad38bd29d2e83cae119f43b9c6ee7e5 100644 --- a/torch_npu/csrc/aten/ops/LogSumExpKernelNpu.cpp +++ b/torch_npu/csrc/aten/ops/LogSumExpKernelNpu.cpp @@ -45,7 +45,7 @@ at::Tensor& NPUNativeFunctions::logsumexp_out(const at::Tensor& self, at::IntArr at::Tensor NPUNativeFunctions::logsumexp(const at::Tensor& self, at::IntArrayRef dims, bool keepdim) { auto outputSize = logsumexp_npu_output_size(self, dims, keepdim); - at::Tensor result = OpPreparation::ApplyTensorWithSizes(outputSize, self.options()); + at::Tensor result = OpPreparation::ApplyTensor(self, outputSize); return logsumexp_out_nocheck(self, dims, keepdim, result); } diff --git a/torch_npu/csrc/aten/ops/QuantizePerChannelKernelNpu.cpp b/torch_npu/csrc/aten/ops/QuantizePerChannelKernelNpu.cpp index e7248a57b5beace3a103c563e4c5c7f1c2b783b7..2ce7443defd8c7a368077895a5d79bcd6f315f2a 100644 --- a/torch_npu/csrc/aten/ops/QuantizePerChannelKernelNpu.cpp +++ b/torch_npu/csrc/aten/ops/QuantizePerChannelKernelNpu.cpp @@ -83,9 +83,10 @@ at::Tensor NPUNativeFunctions::quantize_per_channel( } else if (dtype == at::ScalarType::QInt32) { outputDtype = at::kInt; } - at::Tensor result = OpPreparation::ApplyTensorWithSizes( + at::Tensor result = OpPreparation::ApplyTensorWithFormat( outputSize, - self.options().dtype(outputDtype)); + self.options().dtype(outputDtype), + CalcuOpUtil::get_tensor_npu_format(self)); quantize_per_channel_out_nocheck(result, self, scales, zero_points, axis, dtype); return result; } diff --git a/torch_npu/csrc/aten/ops/QuantizePerTensorKernelNpu.cpp b/torch_npu/csrc/aten/ops/QuantizePerTensorKernelNpu.cpp index ce83ad715fb29a4bf1686281e9dede99b0ff4b14..c2afae426b244a1278c13f1f28bc16f29c6447a0 100644 --- a/torch_npu/csrc/aten/ops/QuantizePerTensorKernelNpu.cpp +++ b/torch_npu/csrc/aten/ops/QuantizePerTensorKernelNpu.cpp @@ -59,17 +59,20 @@ at::Tensor NPUNativeFunctions::quantize_per_tensor( } else if (dtype == at::ScalarType::QInt32) { outputDtype = at::kInt; } - at::Tensor scaleTensor = OpPreparation::ApplyTensorWithSizes( + at::Tensor scaleTensor = OpPreparation::ApplyTensorWithFormat( {1}, - self.options().dtype(at::kFloat)); + self.options().dtype(at::kFloat), + CalcuOpUtil::get_tensor_npu_format(self)); scaleTensor[0] = scaleFloat; - at::Tensor zpTensor = OpPreparation::ApplyTensorWithSizes( + at::Tensor zpTensor = OpPreparation::ApplyTensorWithFormat( {1}, - self.options().dtype(at::kInt)); + self.options().dtype(at::kInt), + CalcuOpUtil::get_tensor_npu_format(self)); zpTensor[0] = zero_point; - at::Tensor result = OpPreparation::ApplyTensorWithSizes( + at::Tensor result = OpPreparation::ApplyTensorWithFormat( outputSize, - self.options().dtype(outputDtype)); + self.options().dtype(outputDtype), + CalcuOpUtil::get_tensor_npu_format(self)); quantize_per_tensor_out_nocheck(result, self, scaleTensor, zpTensor, dtype); return result; } diff --git a/torch_npu/csrc/aten/ops/RenormKernelNpu.cpp b/torch_npu/csrc/aten/ops/RenormKernelNpu.cpp index 96572651f5ed279ebfd33409e1936cf44cdf216f..3ec5d26a4c1751e92ca5a858b4226d21c7abad2e 100644 --- a/torch_npu/csrc/aten/ops/RenormKernelNpu.cpp +++ b/torch_npu/csrc/aten/ops/RenormKernelNpu.cpp @@ -68,9 +68,10 @@ at::Tensor& renorm_out_nocheck( } dim = CalcuOpUtil::make_wrap_dim(dim, self.dim()); auto outputSize = renorm_npu_output_size(self, dim); - at::Tensor result_bak = OpPreparation::ApplyTensorWithSizes( + at::Tensor result_bak = OpPreparation::ApplyTensorWithFormat( outputSize, - self.options().dtype(at::kFloat)); + self.options().dtype(at::kFloat), + CalcuOpUtil::get_tensor_npu_format(self)); if(ori_type == c10::ScalarType::Half) { at::Tensor self_no_name = self.rename(c10::nullopt); at::Tensor result_no_name = result.rename(c10::nullopt); @@ -131,9 +132,7 @@ at::Tensor& NPUNativeFunctions::renorm_out( at::Tensor NPUNativeFunctions::renorm(const at::Tensor& self, at::Scalar p, int64_t dim, at::Scalar maxnorm) { // calculate the output size auto outputSize = input_same_output_size(self); - at::Tensor result = OpPreparation::ApplyTensorWithSizes( - outputSize, - self.options()); + at::Tensor result = OpPreparation::ApplyTensor(self); return renorm_out_nocheck(result, self, p, dim, maxnorm); } diff --git a/torch_npu/csrc/aten/ops/RepeatInterLeaveKernelNpu.cpp b/torch_npu/csrc/aten/ops/RepeatInterLeaveKernelNpu.cpp index db0f0d80f9d524b198649177ea1fd50ebbd09be3..acb1e1494ee18c0732d32cdd80d337f884048604 100644 --- a/torch_npu/csrc/aten/ops/RepeatInterLeaveKernelNpu.cpp +++ b/torch_npu/csrc/aten/ops/RepeatInterLeaveKernelNpu.cpp @@ -48,9 +48,7 @@ at::Tensor NPUNativeFunctions::repeat_interleave( } auto outputSize = repeat_interleave_npu_output_size(selfTensor, repeats, realDim); - at::Tensor result = OpPreparation::ApplyTensorWithSizes( - outputSize, - selfTensor.options()); + at::Tensor result = OpPreparation::ApplyTensor(selfTensor, outputSize); repeat_interleave_out_npu(result, selfTensor, repeats, realDim); return result;