From 8d4f88a0004fc2b74b2a920b932a1fb9324d8ef7 Mon Sep 17 00:00:00 2001 From: CaiZhi Date: Wed, 16 Aug 2023 10:58:13 +0800 Subject: [PATCH] [MTAI-484] feat(build): fix code style for cpp lint --- paddle/phi/backends/CMakeLists.txt | 4 +++- paddle/phi/backends/dynload/mublas.cc | 1 - paddle/phi/backends/dynload/musa_driver.h | 1 - paddle/phi/core/hostdevice.h | 3 ++- paddle/phi/kernels/funcs/layer_norm_impl.cu.h | 8 ++++---- paddle/phi/kernels/gpu/check_numerics_kernel.cu | 2 +- paddle/phi/kernels/impl/elementwise_kernel_impl.h | 3 ++- paddle/phi/kernels/impl/matmul_kernel_impl.h | 1 - 8 files changed, 12 insertions(+), 11 deletions(-) diff --git a/paddle/phi/backends/CMakeLists.txt b/paddle/phi/backends/CMakeLists.txt index beb0f88e3efcfb..5e14c15e8cb266 100644 --- a/paddle/phi/backends/CMakeLists.txt +++ b/paddle/phi/backends/CMakeLists.txt @@ -7,7 +7,9 @@ if(NOT APPLE AND NOT WIN32) list(APPEND BACKENDS_SRCS device_code.cc) endif() -if(WITH_GPU OR WITH_ROCM OR WITH_MUSA) +if(WITH_GPU + OR WITH_ROCM + OR WITH_MUSA) list(APPEND BACKENDS_SRCS gpu/gpu_context.cc gpu/gpu_info.cc gpu/gpu_resources.cc) if(WITH_GPU) diff --git a/paddle/phi/backends/dynload/mublas.cc b/paddle/phi/backends/dynload/mublas.cc index 5952fb0f2f422f..72c0e9954311e1 100644 --- a/paddle/phi/backends/dynload/mublas.cc +++ b/paddle/phi/backends/dynload/mublas.cc @@ -25,4 +25,3 @@ MUBLAS_BLAS_ROUTINE_EACH(DEFINE_WRAP); } // namespace dynload } // namespace phi - diff --git a/paddle/phi/backends/dynload/musa_driver.h b/paddle/phi/backends/dynload/musa_driver.h index 69ce81ae99bf15..3534ab8213c936 100644 --- a/paddle/phi/backends/dynload/musa_driver.h +++ b/paddle/phi/backends/dynload/musa_driver.h @@ -61,7 +61,6 @@ extern bool HasCUDADriver(); __macro(muDeviceGetAttribute); \ __macro(muDeviceGet); - MUSA_ROUTINE_EACH(DECLARE_DYNAMIC_LOAD_MUSA_WRAP); #undef DECLARE_DYNAMIC_LOAD_MUSA_WRAP diff --git a/paddle/phi/core/hostdevice.h b/paddle/phi/core/hostdevice.h index 81e663fa20df6f..85feb0d060439d 100644 --- a/paddle/phi/core/hostdevice.h +++ b/paddle/phi/core/hostdevice.h @@ -30,7 +30,8 @@ #include "xpu/kernel/math.h" #endif -#if (defined(__CUDACC__) || defined(__HIPCC__) || defined(__MUSACC__) || defined(__xpu__)) +#if (defined(__CUDACC__) || defined(__HIPCC__) || defined(__MUSACC__) || \ + defined(__xpu__)) #define HOSTDEVICE __host__ __device__ #define DEVICE __device__ #define HOST __host__ diff --git a/paddle/phi/kernels/funcs/layer_norm_impl.cu.h b/paddle/phi/kernels/funcs/layer_norm_impl.cu.h index a810833c36ac39..6f73551ab67669 100644 --- a/paddle/phi/kernels/funcs/layer_norm_impl.cu.h +++ b/paddle/phi/kernels/funcs/layer_norm_impl.cu.h @@ -1353,8 +1353,8 @@ __global__ void LayerNormBackwardComputeGradInput(const T *__restrict__ dout, // WARP_SHFL_XOR(sum_loss, mask); sum_loss1 += __shfl_xor(sum_loss1, mask, warpSize); sum_loss2 += __shfl_xor(sum_loss2, mask, warpSize); -#else // CUDA and MUSA - // WARP_SHFL_XOR(sum_loss, mask); +#else // CUDA and MUSA + // WARP_SHFL_XOR(sum_loss, mask); sum_loss1 += __shfl_xor_sync(0xffffffff, sum_loss1, mask, warpSize); sum_loss2 += __shfl_xor_sync(0xffffffff, sum_loss2, mask, warpSize); #endif @@ -1504,8 +1504,8 @@ __global__ void LayerNormBackwardComputeGradInputWithSmallFeatureSize( // WARP_SHFL_XOR(sum_loss, mask); sum_loss1 += __shfl_xor(sum_loss1, mask, warpSize); sum_loss2 += __shfl_xor(sum_loss2, mask, warpSize); -#else // CUDA and MUSA - // WARP_SHFL_XOR(sum_loss, mask); +#else // CUDA and MUSA + // WARP_SHFL_XOR(sum_loss, mask); sum_loss1 += __shfl_xor_sync(0xffffffff, sum_loss1, mask, WarpSize); sum_loss2 += __shfl_xor_sync(0xffffffff, sum_loss2, mask, WarpSize); #endif diff --git a/paddle/phi/kernels/gpu/check_numerics_kernel.cu b/paddle/phi/kernels/gpu/check_numerics_kernel.cu index 3052e89820bec8..c69e3d13ff6846 100644 --- a/paddle/phi/kernels/gpu/check_numerics_kernel.cu +++ b/paddle/phi/kernels/gpu/check_numerics_kernel.cu @@ -503,7 +503,7 @@ void CheckNumericsKernel(const Context& ctx, #ifdef PADDLE_WITH_MUSA PADDLE_THROW(phi::errors::Unimplemented( "OP check_numerics is unsupported for MUSA backend now!")); -return; + return; #else int dev_id = tensor.place().device; VLOG(6) << "op_type=" << op_type << ", var_name=" << var_name diff --git a/paddle/phi/kernels/impl/elementwise_kernel_impl.h b/paddle/phi/kernels/impl/elementwise_kernel_impl.h index 742646ba05730f..d2992449e4b4e1 100644 --- a/paddle/phi/kernels/impl/elementwise_kernel_impl.h +++ b/paddle/phi/kernels/impl/elementwise_kernel_impl.h @@ -17,7 +17,8 @@ #include "paddle/phi/kernels/elementwise_kernel.h" #include "paddle/phi/kernels/funcs/elementwise_base.h" #include "paddle/phi/kernels/funcs/elementwise_functor.h" -#if defined(__NVCC__) || defined(__HIPCC__) || defined(__MUSACC__) || defined(__xpu__) +#if defined(__NVCC__) || defined(__HIPCC__) || defined(__MUSACC__) || \ + defined(__xpu__) #include "paddle/phi/kernels/funcs/broadcast_function.h" #endif diff --git a/paddle/phi/kernels/impl/matmul_kernel_impl.h b/paddle/phi/kernels/impl/matmul_kernel_impl.h index b88c1dffdd0185..fa96a63d955d9b 100644 --- a/paddle/phi/kernels/impl/matmul_kernel_impl.h +++ b/paddle/phi/kernels/impl/matmul_kernel_impl.h @@ -1006,7 +1006,6 @@ void MatmulWithFlattenKernel(const Context& dev_ctx, } auto blas = phi::funcs::GetBlas(dev_ctx); - blas.MatMul(x_matrix, y_matrix, out); if (z_dim.size() != 2) { out->Resize(z_dim);