Skip to content

Commit

Permalink
Replace paddle/fluid/platform/device/gpu/gpu_dnn.h (#63819)
Browse files Browse the repository at this point in the history
* Fix

* Fix

* Fix
  • Loading branch information
co63oc authored May 7, 2024
1 parent 6f2f9f7 commit 7a5992f
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 24 deletions.
2 changes: 1 addition & 1 deletion paddle/fluid/operators/cudnn_rnn_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License. */
#include <vector>

#include "paddle/fluid/framework/tensor.h"
#include "paddle/fluid/platform/device/gpu/gpu_dnn.h"
#include "paddle/phi/backends/gpu/gpu_dnn.h"

namespace paddle {
namespace operators {
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/detection/bbox_util.cu.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ limitations under the License. */
#include <hipcub/hipcub.hpp>
namespace cub = hipcub;
#endif
#include "paddle/fluid/platform/device/gpu/gpu_dnn.h"
#include "paddle/fluid/platform/for_range.h"
#include "paddle/phi/backends/gpu/gpu_dnn.h"
#include "paddle/phi/kernels/funcs/math_function.h"

namespace paddle {
Expand Down
9 changes: 5 additions & 4 deletions paddle/fluid/operators/fused/cudnn_bn_stats_finalize.cu.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,24 @@ limitations under the License. */
#pragma once

#include "paddle/fluid/operators/fused/cudnn_fusion_helper.h"
#include "paddle/fluid/platform/device/gpu/gpu_dnn.h"
#include "paddle/phi/backends/gpu/gpu_dnn.h"

namespace paddle {
namespace operators {

namespace dynload = phi::dynload;
template <typename T>
using BatchNormParamType =
typename platform::CudnnDataType<T>::BatchNormParamType;
typename phi::backends::gpu::CudnnDataType<T>::BatchNormParamType;

#if CUDNN_VERSION >= 8000

template <typename T>
struct BNStatsFinalizeArgs {
BNStatsFinalizeArgs() {
dtype = platform::CudnnDataType<T>::type;
param_dtype = platform::CudnnDataType<BatchNormParamType<T>>::type;
dtype = phi::backends::gpu::CudnnDataType<T>::type;
param_dtype =
phi::backends::gpu::CudnnDataType<BatchNormParamType<T>>::type;
format = CUDNN_TENSOR_NHWC;
}

Expand Down
9 changes: 5 additions & 4 deletions paddle/fluid/operators/fused/cudnn_norm_conv.cu.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ limitations under the License. */
#pragma once

#include "paddle/fluid/operators/fused/cudnn_fusion_helper.h"
#include "paddle/fluid/platform/device/gpu/gpu_dnn.h"
#include "paddle/phi/backends/gpu/gpu_dnn.h"

namespace paddle {
namespace operators {
namespace dynload = phi::dynload;

template <typename T>
using ScalingParamType = typename platform::CudnnDataType<T>::ScalingParamType;
using ScalingParamType =
typename phi::backends::gpu::CudnnDataType<T>::ScalingParamType;

#if CUDNN_VERSION >= 8000

Expand All @@ -31,9 +32,9 @@ static size_t RoundUp(int64_t a, int64_t b) { return (a + b - 1) / b * b; }
template <typename T>
struct NormConvolutionArgs {
NormConvolutionArgs() {
dtype = platform::CudnnDataType<T>::type;
dtype = phi::backends::gpu::CudnnDataType<T>::type;
format = CUDNN_TENSOR_NHWC;
compute_type = platform::CudnnDataType<float>::type;
compute_type = phi::backends::gpu::CudnnDataType<float>::type;
}

void Set(const phi::GPUContext &ctx,
Expand Down
11 changes: 6 additions & 5 deletions paddle/fluid/operators/fused/cudnn_scale_bias_add_relu.cu.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,25 @@ limitations under the License. */
#pragma once

#include "paddle/fluid/operators/fused/cudnn_fusion_helper.h"
#include "paddle/fluid/platform/device/gpu/gpu_dnn.h"
#include "paddle/phi/backends/gpu/gpu_dnn.h"

namespace paddle {
namespace operators {
template <typename T>
using CudnnDataType = platform::CudnnDataType<T>;
using CudnnDataType = phi::backends::gpu::CudnnDataType<T>;
namespace dynload = phi::dynload;
template <typename T>
using BatchNormParamType =
typename platform::CudnnDataType<T>::BatchNormParamType;
typename phi::backends::gpu::CudnnDataType<T>::BatchNormParamType;

#if CUDNN_VERSION >= 8000

template <typename T>
struct ScaleBiasAddReluArgs {
ScaleBiasAddReluArgs() {
dtype = platform::CudnnDataType<T>::type;
param_dtype = platform::CudnnDataType<BatchNormParamType<T>>::type;
dtype = phi::backends::gpu::CudnnDataType<T>::type;
param_dtype =
phi::backends::gpu::CudnnDataType<BatchNormParamType<T>>::type;
format = CUDNN_TENSOR_NHWC;
}

Expand Down
6 changes: 4 additions & 2 deletions paddle/fluid/operators/fused/fused_multi_transformer_op.cu
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ void FusedMultiTransformerKernel(
auto *padding_offset_data =
encoder_remove_padding ? padding_offset_tensor.data<int>() : nullptr;

auto ln_compute = AttnLayerNorm<T>(dev_ctx, epsilon, token_num, dim_embed);
auto ln_compute =
phi::fusion::AttnLayerNorm<T>(dev_ctx, epsilon, token_num, dim_embed);
phi::DenseTensor ln_mean, ln_var;
ln_mean.Resize({token_num});
auto *ln_mean_data =
Expand Down Expand Up @@ -800,7 +801,8 @@ void FusedMultiTransformerKernel(

// 1. layer norm

auto ln_compute = AttnLayerNorm<T>(dev_ctx, epsilon, token_num, dim_embed);
auto ln_compute =
phi::fusion::AttnLayerNorm<T>(dev_ctx, epsilon, token_num, dim_embed);
phi::DenseTensor ln_mean, ln_var;
ln_mean.Resize({token_num});
auto *ln_mean_data =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ limitations under the License. */
#include "paddle/fluid/operators/fused/attention_layer_norm.h"
#include "paddle/fluid/operators/fused/fmha_ref.h"
#include "paddle/fluid/operators/fused/fused_dropout_helper.h"
#include "paddle/fluid/platform/device/gpu/gpu_dnn.h"
#include "paddle/phi/api/include/tensor.h"
#include "paddle/phi/backends/dynload/cublasLt.h"
#include "paddle/phi/backends/gpu/gpu_device_function.h"
#include "paddle/phi/backends/gpu/gpu_dnn.h"
#include "paddle/phi/core/distributed/comm_context_manager.h"
#include "paddle/phi/kernels/funcs/fused_gemm_epilogue.h"
#include "paddle/phi/kernels/funcs/math_function.h"
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/operators/fused/resnet_unit_op.cu
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ResNetUnitKernel : public framework::OpKernel<T> {
platform::is_gpu_place(ctx.GetPlace()),
true,
phi::errors::PreconditionNotMet("It must use CUDAPlace."));
PADDLE_ENFORCE_EQ(platform::CudnnDataType<T>::type,
PADDLE_ENFORCE_EQ(phi::backends::gpu::CudnnDataType<T>::type,
CUDNN_DATA_HALF,
phi::errors::Unavailable(
"ResNetUnitOp only supports float16 for now."));
Expand Down Expand Up @@ -231,7 +231,7 @@ class ResNetUnitGradKernel : public framework::OpKernel<T> {
platform::is_gpu_place(ctx.GetPlace()),
true,
phi::errors::PreconditionNotMet("It must use CUDAPlace."));
PADDLE_ENFORCE_EQ(platform::CudnnDataType<T>::type,
PADDLE_ENFORCE_EQ(phi::backends::gpu::CudnnDataType<T>::type,
CUDNN_DATA_HALF,
phi::errors::Unavailable(
"ResNetUnitOp only supports float16 for now."));
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/grid_sampler_cudnn_op.cu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License. */
// HIP not support cudnnSpatialTfGridGeneratorForward

#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/platform/device/gpu/gpu_dnn.h"
#include "paddle/phi/backends/gpu/gpu_dnn.h"

namespace phi {
class DenseTensor;
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/math/prelu.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ limitations under the License. */
#pragma once
#include <vector>

#include "paddle/fluid/platform/device/gpu/gpu_dnn.h"
#include "paddle/phi/api/include/tensor.h"
#include "paddle/phi/backends/gpu/gpu_dnn.h"
#include "paddle/phi/kernels/funcs/math_function.h"

namespace paddle {
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/miopen_rnn_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License. */
#include <vector>

#include "paddle/fluid/framework/tensor.h"
#include "paddle/fluid/platform/device/gpu/gpu_dnn.h"
#include "paddle/phi/backends/gpu/gpu_dnn.h"

namespace paddle {
namespace operators {
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/sequence_ops/sequence_softmax_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License. */
#include <string>

#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
#include "paddle/fluid/platform/device/gpu/gpu_dnn.h"
#include "paddle/phi/backends/gpu/gpu_dnn.h"
#endif

namespace paddle {
Expand Down

0 comments on commit 7a5992f

Please sign in to comment.