diff --git a/paddle/phi/kernels/xpu/batch_norm_grad_kernel.cc b/paddle/phi/kernels/xpu/batch_norm_grad_kernel.cc index ccb9f601ed33296d34fd2a1d35663058aa775d40..af9fefc0cea40e85dec77163d6cef3e139f9119b 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 d29e56a7d7a026c93652f43a17abcd8ddf9df172..67c4e898b7f04f5f50ea1d8ee1eec63c1005c58c 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"); } }