From b1f1dd0523c59ba39ea246e8e9f92a6f6b2a8bd6 Mon Sep 17 00:00:00 2001 From: Chen Weihang Date: Tue, 6 Sep 2022 10:38:40 +0800 Subject: [PATCH] polish xpu enforce msg, test=kunlun (#45749) --- .../phi/kernels/xpu/batch_norm_grad_kernel.cc | 24 ++++--------------- paddle/phi/kernels/xpu/batch_norm_kernel.cc | 15 ++---------- 2 files changed, 6 insertions(+), 33 deletions(-) diff --git a/paddle/phi/kernels/xpu/batch_norm_grad_kernel.cc b/paddle/phi/kernels/xpu/batch_norm_grad_kernel.cc index ccb9f601ed3..af9fefc0cea 100644 --- a/paddle/phi/kernels/xpu/batch_norm_grad_kernel.cc +++ b/paddle/phi/kernels/xpu/batch_norm_grad_kernel.cc @@ -183,13 +183,8 @@ void BatchNormGradKernel(const Context &dev_ctx, C, epsilon_data, global_inv_std_data); - PADDLE_ENFORCE_EQ(r1, - XPU_SUCCESS, - phi::errors::External("XPU API(batch_norm_grad " - "CalculateInvVar function) " - "return wrong value[%d %s]", - r1, - XPUAPIErrorMsg[r1])); + PADDLE_ENFORCE_XDNN_SUCCESS(r1, + "batch_norm_grad CalculateInvVar function"); } // Here is a trick, x is a const input, @@ -209,13 +204,7 @@ void BatchNormGradKernel(const Context &dev_ctx, C, H * W, x.data()); - PADDLE_ENFORCE_EQ(r2, - XPU_SUCCESS, - phi::errors::External("XPU API(batch_norm_grad " - "CalculateInvBNY function) " - "return wrong value[%d %s]", - r2, - XPUAPIErrorMsg[r2])); + PADDLE_ENFORCE_XDNN_SUCCESS(r2, "batch_norm_grad CalculateInvBNY function"); } int r3; @@ -263,12 +252,7 @@ void BatchNormGradKernel(const Context &dev_ctx, bias_grad_data, is_nchw); } - PADDLE_ENFORCE_EQ(r3, - XPU_SUCCESS, - phi::errors::External("XPU API(batch_norm_grad) return " - "wrong value[%d %s]", - r3, - XPUAPIErrorMsg[r3])); + PADDLE_ENFORCE_XDNN_SUCCESS(r3, "batch_norm_grad"); } } // namespace phi diff --git a/paddle/phi/kernels/xpu/batch_norm_kernel.cc b/paddle/phi/kernels/xpu/batch_norm_kernel.cc index d29e56a7d7a..67c4e898b7f 100644 --- a/paddle/phi/kernels/xpu/batch_norm_kernel.cc +++ b/paddle/phi/kernels/xpu/batch_norm_kernel.cc @@ -102,12 +102,7 @@ void BatchNormKernel(const Context& dev_ctx, mean_out_data, variance_out_data, is_nchw); - PADDLE_ENFORCE_EQ(r, - xpu::Error_t::SUCCESS, - phi::errors::External( - "The batch_norm XPU API return wrong value[%d %s]", - r, - XPUAPIErrorMsg[r])); + PADDLE_ENFORCE_XDNN_SUCCESS(r, "batch_norm"); } else { const auto* mean_data = mean.data(); const auto* variance_data = variance.data(); @@ -124,13 +119,7 @@ void BatchNormKernel(const Context& dev_ctx, mean_data, variance_data, is_nchw); - PADDLE_ENFORCE_EQ( - r, - xpu::Error_t::SUCCESS, - phi::errors::External( - "The batch_norm_infer XPU API return wrong value[%d %s]", - r, - XPUAPIErrorMsg[r])); + PADDLE_ENFORCE_XDNN_SUCCESS(r, "batch_norm_infer"); } } -- GitLab