From f61234d6092224509f93ffe2adb064150dffdcb0 Mon Sep 17 00:00:00 2001 From: zhouwei25 Date: Mon, 13 Jun 2022 06:49:22 +0000 Subject: [PATCH] fix CI --- paddle/phi/kernels/sparse/CMakeLists.txt | 12 +----------- .../phi/kernels/sparse/gpu/sparse_mm_grad_kernel.cu | 2 ++ paddle/phi/kernels/sparse/gpu/sparse_mm_kernel.cu | 13 ++++++++++--- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/paddle/phi/kernels/sparse/CMakeLists.txt b/paddle/phi/kernels/sparse/CMakeLists.txt index 67e670b091532..6c5e7dee4cb35 100644 --- a/paddle/phi/kernels/sparse/CMakeLists.txt +++ b/paddle/phi/kernels/sparse/CMakeLists.txt @@ -10,14 +10,4 @@ set(SPARSE_KERNEL_DEPS math_function custom_kernel copy_kernel) - -set(MANUAL_BUILD_KERNELS sparse_mm_kernel sparse_mm_grad_kernel) - -register_kernels(EXCLUDES ${MANUAL_BUILD_KERNELS} DEPS ${SPARSE_KERNEL_DEPS} - SUB_DIR "sparse") - -message("===SPARSE======CUDA_VERSION:==${CUDA_VERSION}============") -if((WITH_GPU) AND (CUDA_VERSION GREATER_EQUAL 11.0)) - kernel_library(sparse_mm_kernel DEPS ${SPARSE_KERNEL_DEPS}) - kernel_library(sparse_mm_grad_kernel DEPS ${SPARSE_KERNEL_DEPS}) -endif() +register_kernels(DEPS ${SPARSE_KERNEL_DEPS} SUB_DIR "sparse") diff --git a/paddle/phi/kernels/sparse/gpu/sparse_mm_grad_kernel.cu b/paddle/phi/kernels/sparse/gpu/sparse_mm_grad_kernel.cu index de5696df5e9f9..1dcaba3a2c946 100644 --- a/paddle/phi/kernels/sparse/gpu/sparse_mm_grad_kernel.cu +++ b/paddle/phi/kernels/sparse/gpu/sparse_mm_grad_kernel.cu @@ -83,6 +83,7 @@ void CsrMaskedMatmulGradKernel(const Context& dev_ctx, const SparseCsrTensor& dout, DenseTensor* dx, DenseTensor* dy) { +#if CUDA_VERSION >= 11000 auto sparse_blas = phi::funcs::sparse::GetSparseBlas(dev_ctx); // dx{Dense} = dout{SparseCsr} * y'{Dense} @@ -123,6 +124,7 @@ void CsrMaskedMatmulGradKernel(const Context& dev_ctx, std::swap(axis[y_ndim - 1], axis[y_ndim - 2]); TransposeKernel(dev_ctx, trans_dy, axis, dy); } +#endif } } // namespace sparse diff --git a/paddle/phi/kernels/sparse/gpu/sparse_mm_kernel.cu b/paddle/phi/kernels/sparse/gpu/sparse_mm_kernel.cu index e2b94369b15f8..96bc8fe5c73b3 100644 --- a/paddle/phi/kernels/sparse/gpu/sparse_mm_kernel.cu +++ b/paddle/phi/kernels/sparse/gpu/sparse_mm_kernel.cu @@ -34,6 +34,7 @@ void CsrDenseMatmulKernel(const Context& dev_ctx, const SparseCsrTensor& x, const DenseTensor& y, DenseTensor* out) { +#if CUDA_VERSION >= 11000 std::vector xdim_vec = phi::vectorize(x.dims()); std::vector ydim_vec = phi::vectorize(y.dims()); auto x_ndims = xdim_vec.size(); @@ -80,6 +81,11 @@ void CsrDenseMatmulKernel(const Context& dev_ctx, auto sparse_blas = phi::funcs::sparse::GetSparseBlas(dev_ctx); sparse_blas.DSDMM( false, false, static_cast(1), x, y, static_cast(0), out); +#else + PADDLE_THROW( + phi::errors::Unimplemented(" forward of 'sparse.mm' use cusparseSpMM, " + "which is supported from CUDA 11.0")); +#endif } template @@ -174,9 +180,10 @@ void CsrMaskedMatmulKernel(const Context& dev_ctx, sparse_blas.SDDMM( false, false, static_cast(1), x, y, static_cast(0), out); #else - PADDLE_THROW(phi::errors::Unimplemented( - " forward of 'sparse.masked_mm' use cusparseSDDMM, Only support it from " - "CUDA 11.3")); + PADDLE_THROW( + phi::errors::Unimplemented(" forward of 'sparse.masked_mm' use " + "cusparseSDDMM, which is supported from " + "CUDA 11.3")); #endif }