From df5d55bb95903933d5160267d7a68c9c45269f5d Mon Sep 17 00:00:00 2001 From: Zhang Ting Date: Wed, 12 Jan 2022 12:47:20 +0800 Subject: [PATCH] [part 1]change type of function args (#38885) --- paddle/fluid/operators/abs_op.cu | 4 ++-- paddle/fluid/operators/bce_loss_op.cu | 4 ++-- paddle/fluid/operators/clip_op.h | 2 +- paddle/fluid/operators/p_norm_op.cu | 8 ++++---- paddle/fluid/operators/renorm_op.cu | 2 +- paddle/pten/kernels/gpu/cast_kernel.cu | 2 +- paddle/pten/kernels/gpu/scale_kernel.cu | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/paddle/fluid/operators/abs_op.cu b/paddle/fluid/operators/abs_op.cu index 94b0a3ae72..86748d4505 100644 --- a/paddle/fluid/operators/abs_op.cu +++ b/paddle/fluid/operators/abs_op.cu @@ -24,14 +24,14 @@ struct CudaAbsFunctor; template struct CudaAbsFunctor>> { - __device__ __forceinline__ math::Real operator()(const T& x) const { + __device__ __forceinline__ math::Real operator()(const T x) const { return abs(x); } }; template struct CudaAbsFunctor>> { - __device__ __forceinline__ T operator()(const T& x) const { + __device__ __forceinline__ T operator()(const T x) const { return std::abs(x); } }; diff --git a/paddle/fluid/operators/bce_loss_op.cu b/paddle/fluid/operators/bce_loss_op.cu index 18562b2432..da96aa92cd 100644 --- a/paddle/fluid/operators/bce_loss_op.cu +++ b/paddle/fluid/operators/bce_loss_op.cu @@ -28,8 +28,8 @@ template struct BCELossGradFunctor { T one = static_cast(1.0f); T eps = static_cast(1e-12); - __device__ __forceinline__ T operator()(const T& x, const T& label, - const T& dout) const { + __device__ __forceinline__ T operator()(const T x, const T label, + const T dout) const { T term1 = max((one - x) * x, eps); return (dout * (x - label) / term1); } diff --git a/paddle/fluid/operators/clip_op.h b/paddle/fluid/operators/clip_op.h index f08a7b2d57..3672fa983e 100644 --- a/paddle/fluid/operators/clip_op.h +++ b/paddle/fluid/operators/clip_op.h @@ -32,7 +32,7 @@ template class ClipFunctor { public: explicit ClipFunctor(const T min, const T max) : min_(min), max_(max) {} - HOSTDEVICE T operator()(const T& x) const { + HOSTDEVICE T operator()(const T x) const { return x < min_ ? min_ : x > max_ ? max_ : x; } diff --git a/paddle/fluid/operators/p_norm_op.cu b/paddle/fluid/operators/p_norm_op.cu index 1db6f6e517..b2a9ca6f93 100644 --- a/paddle/fluid/operators/p_norm_op.cu +++ b/paddle/fluid/operators/p_norm_op.cu @@ -63,7 +63,7 @@ __device__ __forceinline__ double inline_pow(double base, double exponent) { template struct NonzeroFunctor { HOSTDEVICE explicit inline NonzeroFunctor() {} - HOSTDEVICE inline T operator()(const T& x) const { + HOSTDEVICE inline T operator()(const T x) const { return static_cast(static_cast(x) != 0); } }; @@ -71,7 +71,7 @@ struct NonzeroFunctor { template struct AbsFunctor { HOSTDEVICE explicit inline AbsFunctor() {} - HOSTDEVICE inline T operator()(const T& x) const { + HOSTDEVICE inline T operator()(const T x) const { return static_cast(inline_abs(x)); } }; @@ -81,7 +81,7 @@ struct UnsignedPowFunctor { HOSTDEVICE explicit inline UnsignedPowFunctor(float porder) { this->porder = porder; } - HOSTDEVICE inline Ty operator()(const Tx& x) const { + HOSTDEVICE inline Ty operator()(const Tx x) const { return static_cast(inline_pow(inline_abs(x), static_cast(porder))); } float porder; @@ -90,7 +90,7 @@ struct UnsignedPowFunctor { template struct PowFunctor { HOSTDEVICE explicit inline PowFunctor(float porder) { this->porder = porder; } - HOSTDEVICE inline Ty operator()(const Tx& x) const { + HOSTDEVICE inline Ty operator()(const Tx x) const { return static_cast(inline_pow(x, static_cast(porder))); } float porder; diff --git a/paddle/fluid/operators/renorm_op.cu b/paddle/fluid/operators/renorm_op.cu index 1798faa759..b21b9fde56 100644 --- a/paddle/fluid/operators/renorm_op.cu +++ b/paddle/fluid/operators/renorm_op.cu @@ -42,7 +42,7 @@ struct UnsignedPowFunctor { HOSTDEVICE explicit inline UnsignedPowFunctor(float porder) { this->porder = porder; } - HOSTDEVICE inline Ty operator()(const Tx& x) const { + HOSTDEVICE inline Ty operator()(const Tx x) const { return static_cast(inline_pow(inline_abs(x), static_cast(porder))); } float porder; diff --git a/paddle/pten/kernels/gpu/cast_kernel.cu b/paddle/pten/kernels/gpu/cast_kernel.cu index 9f65400f93..0bbe7a3a13 100644 --- a/paddle/pten/kernels/gpu/cast_kernel.cu +++ b/paddle/pten/kernels/gpu/cast_kernel.cu @@ -30,7 +30,7 @@ namespace pten { template struct CastFuctor { - __device__ __forceinline__ OutT operator()(const InT& x) const { + __device__ __forceinline__ OutT operator()(const InT x) const { return static_cast(x); } }; diff --git a/paddle/pten/kernels/gpu/scale_kernel.cu b/paddle/pten/kernels/gpu/scale_kernel.cu index f4bb5c5dbf..68574c063e 100644 --- a/paddle/pten/kernels/gpu/scale_kernel.cu +++ b/paddle/pten/kernels/gpu/scale_kernel.cu @@ -34,7 +34,7 @@ struct ScaleFunctor { bias_after_scale = is_bias_after_sacle; } - __device__ __forceinline__ InT operator()(const InT& x) const { + __device__ __forceinline__ InT operator()(const InT x) const { if (bias_after_scale) { return scale * x + bias; } else { -- GitLab