Skip to content

Commit 6fd4cb4

Browse files
authored
use funcs/cub.h [fluid_ops] (#76674)
1 parent 46d9db3 commit 6fd4cb4

34 files changed

+43
-252
lines changed

paddle/phi/kernels/fusion/gpu/mmha_util.cu.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,14 @@
5959
#include <hip/hip_bf16.h>
6060
#include <hip/hip_fp16.h>
6161
#include <hip/hip_runtime.h>
62-
#include <hipcub/hipcub.hpp>
63-
namespace cub = hipcub;
6462
#define __nv_bfloat16 __hip_bfloat16
6563
#define __nv_bfloat162 __hip_bfloat162
6664
#else
6765
#include <cuda_fp16.h>
6866
#include <float.h>
69-
#include <cub/cub.cuh>
7067
#endif
71-
7268
#include "paddle/phi/common/datatype_traits.h"
69+
#include "paddle/phi/kernels/funcs/cub.h"
7370
#include "paddle/phi/kernels/funcs/math_function.h"
7471

7572
#ifdef PADDLE_WITH_HIP

paddle/phi/kernels/gpu/affine_channel_grad_kernel.cu

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,11 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#ifdef __NVCC__
16-
#include "cub/cub.cuh"
17-
#endif
18-
19-
#ifdef __HIPCC__
20-
#include <hipcub/hipcub.hpp>
21-
namespace cub = hipcub;
22-
#endif
15+
#include "paddle/phi/kernels/affine_channel_grad_kernel.h"
2316
#include "paddle/phi/backends/gpu/gpu_context.h"
2417
#include "paddle/phi/backends/gpu/gpu_primitives.h"
2518
#include "paddle/phi/core/kernel_registry.h"
26-
#include "paddle/phi/kernels/affine_channel_grad_kernel.h"
19+
#include "paddle/phi/kernels/funcs/cub.h"
2720

2821
namespace phi {
2922

paddle/phi/kernels/gpu/affine_channel_kernel.cu

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,11 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#ifdef __NVCC__
16-
#include "cub/cub.cuh"
17-
#endif
18-
19-
#ifdef __HIPCC__
20-
#include <hipcub/hipcub.hpp>
21-
namespace cub = hipcub;
22-
#endif
15+
#include "paddle/phi/kernels/affine_channel_kernel.h"
2316
#include "paddle/phi/backends/gpu/gpu_context.h"
2417
#include "paddle/phi/backends/gpu/gpu_primitives.h"
2518
#include "paddle/phi/core/kernel_registry.h"
26-
#include "paddle/phi/kernels/affine_channel_kernel.h"
19+
#include "paddle/phi/kernels/funcs/cub.h"
2720

2821
namespace phi {
2922

paddle/phi/kernels/gpu/arg_min_max_kernel.cu

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,10 @@
1919

2020
#if defined(__NVCC__) || defined(__HIPCC__)
2121

22-
#ifdef __NVCC__
23-
#include "cub/cub.cuh"
24-
#endif
25-
#ifdef __HIPCC__
26-
#include <hipcub/hipcub.hpp>
27-
namespace cub = hipcub;
28-
#endif
2922
#include <limits>
30-
3123
#include "paddle/common/ddim.h"
3224
#include "paddle/phi/core/utils/data_type.h"
25+
#include "paddle/phi/kernels/funcs/cub.h"
3326
#include "paddle/phi/kernels/funcs/math_function.h"
3427
namespace phi {
3528

paddle/phi/kernels/gpu/argsort_grad_kernel.cu

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,10 @@
1717
#include <thrust/sequence.h>
1818
#include <thrust/sort.h>
1919

20-
#include "paddle/phi/kernels/argsort_kernel.h"
21-
#ifdef __NVCC__
22-
#include "cub/cub.cuh"
23-
#endif
24-
#ifdef __HIPCC__
25-
#include <hipcub/hipcub.hpp>
26-
namespace cub = hipcub;
27-
#endif
28-
2920
#include "paddle/phi/backends/gpu/gpu_context.h"
3021
#include "paddle/phi/core/kernel_registry.h"
22+
#include "paddle/phi/kernels/argsort_kernel.h"
23+
#include "paddle/phi/kernels/funcs/cub.h"
3124
#include "paddle/phi/kernels/funcs/math_function.h"
3225
#include "paddle/phi/kernels/primitive/functor_primitives.h"
3326
#include "paddle/phi/kernels/transpose_kernel.h"

paddle/phi/kernels/gpu/argsort_kernel.cu

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,12 @@
1818
#include <thrust/execution_policy.h>
1919
#include <thrust/sequence.h>
2020
#include <thrust/sort.h>
21-
#ifdef __NVCC__
22-
#include "cub/cub.cuh"
23-
#endif
24-
#ifdef __HIPCC__
25-
#include <hipcub/hipcub.hpp>
26-
namespace cub = hipcub;
27-
#endif
28-
2921
#include "paddle/phi/backends/gpu/gpu_context.h"
3022
#include "paddle/phi/backends/gpu/gpu_info.h"
3123
#include "paddle/phi/backends/gpu/gpu_launch_config.h"
3224
#include "paddle/phi/core/kernel_registry.h"
3325
#include "paddle/phi/kernels/funcs/blas/blas.h"
26+
#include "paddle/phi/kernels/funcs/cub.h"
3427
#include "paddle/phi/kernels/funcs/math_function.h"
3528
#include "paddle/phi/kernels/primitive/functor_primitives.h"
3629
#include "paddle/phi/kernels/transpose_kernel.h"

paddle/phi/kernels/gpu/batch_norm_kernel.cu

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,17 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#ifdef __NVCC__
16-
#include "cub/cub.cuh"
17-
#endif
18-
#ifdef __HIPCC__
19-
#include <hipcub/hipcub.hpp>
20-
namespace cub = hipcub;
21-
#endif
22-
15+
#include "paddle/phi/kernels/batch_norm_kernel.h"
2316
#include "glog/logging.h"
24-
2517
#include "paddle/common/flags.h"
2618
#include "paddle/common/layout.h"
2719
#include "paddle/phi/backends/gpu/gpu_context.h"
2820
#include "paddle/phi/backends/gpu/gpu_dnn.h"
2921
#include "paddle/phi/core/enforce.h"
3022
#include "paddle/phi/core/kernel_registry.h"
31-
#include "paddle/phi/kernels/batch_norm_kernel.h"
3223
#include "paddle/phi/kernels/full_kernel.h"
3324
#include "paddle/phi/kernels/funcs/batch_norm_utils.h"
25+
#include "paddle/phi/kernels/funcs/cub.h"
3426
#include "paddle/phi/kernels/funcs/eigen/common.h"
3527
#include "paddle/phi/kernels/funcs/norm_utils.cu.h"
3628
#include "paddle/phi/kernels/funcs/norm_utils.h"

paddle/phi/kernels/gpu/class_center_sample_kernel.cu

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,19 @@
1515
#ifdef PADDLE_WITH_HIP
1616
#include <hiprand.h>
1717
#include <hiprand_kernel.h>
18-
19-
#include <hipcub/hipcub.hpp>
2018
typedef hiprandState curandState;
21-
namespace cub = hipcub;
2219
#else
2320
#include <curand.h>
2421
#include <curand_kernel.h>
25-
26-
#include <cub/cub.cuh>
2722
#endif
2823

2924
#include <iterator>
3025
#include <random>
31-
3226
#include "paddle/phi/common/memory_utils.h"
3327
#include "paddle/phi/core/enforce.h"
3428
#include "paddle/phi/core/tensor_utils.h"
3529
#include "paddle/phi/kernels/class_center_sample_kernel.h"
30+
#include "paddle/phi/kernels/funcs/cub.h"
3631

3732
#if defined(PADDLE_WITH_NCCL) || defined(PADDLE_WITH_RCCL)
3833
#include "paddle/common/flags.h"

paddle/phi/kernels/gpu/collect_fpn_proposals_kernel.cu

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,18 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#ifdef __NVCC__
16-
#include "cub/cub.cuh"
17-
#endif
18-
#ifdef __HIPCC__
19-
#include <hipcub/hipcub.hpp>
20-
namespace cub = hipcub;
21-
#endif
22-
15+
#include "paddle/phi/kernels/gpu/collect_fpn_proposals_kernel.h"
2316
#include "paddle/phi/backends/gpu/gpu_primitives.h"
2417
#include "paddle/phi/common/memory_utils.h"
2518
#include "paddle/phi/core/allocator.h"
2619
#include "paddle/phi/core/kernel_registry.h"
2720
#include "paddle/phi/core/mixed_vector.h"
2821
#include "paddle/phi/kernels/funcs/concat_and_split_functor.h"
22+
#include "paddle/phi/kernels/funcs/cub.h"
2923
#include "paddle/phi/kernels/funcs/detection/bbox_util.h"
3024
#include "paddle/phi/kernels/funcs/for_range.h"
3125
#include "paddle/phi/kernels/funcs/gather.cu.h"
3226
#include "paddle/phi/kernels/funcs/strided_memcpy.h"
33-
#include "paddle/phi/kernels/gpu/collect_fpn_proposals_kernel.h"
3427
#include "paddle/phi/kernels/impl/collect_fpn_proposals_kernel_impl.h"
3528
#include "paddle/utils/optional.h"
3629

paddle/phi/kernels/gpu/cross_entropy_bwd_w_downcast.cu

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,15 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License. */
1414

15-
#include "paddle/phi/kernels/cross_entropy_grad_kernel.h"
16-
17-
#ifdef __NVCC__
18-
#include "cub/cub.cuh"
19-
#endif
20-
#ifdef __HIPCC__
21-
#include <hipcub/hipcub.hpp>
22-
namespace cub = hipcub;
23-
#endif
24-
2515
#include "paddle/phi/backends/gpu/gpu_device_function.h"
2616
#include "paddle/phi/backends/gpu/gpu_dnn.h"
2717
#include "paddle/phi/common/amp_type_traits.h"
2818
#include "paddle/phi/core/kernel_registry.h"
2919
#include "paddle/phi/core/tensor_utils.h"
3020
#include "paddle/phi/core/visit_type.h"
21+
#include "paddle/phi/kernels/cross_entropy_grad_kernel.h"
3122
#include "paddle/phi/kernels/funcs/axis_utils.h"
23+
#include "paddle/phi/kernels/funcs/cub.h"
3224
#include "paddle/phi/kernels/funcs/for_range.h"
3325
#include "paddle/phi/kernels/funcs/math_function.h"
3426
#include "paddle/phi/kernels/funcs/softmax.h"

0 commit comments

Comments
 (0)