未验证 提交 df5d55bb 编写于 作者: Z Zhang Ting 提交者: GitHub

[part 1]change type of function args (#38885)

上级 f5166284
......@@ -24,14 +24,14 @@ struct CudaAbsFunctor;
template <typename T>
struct CudaAbsFunctor<T, math::Complex<T, math::Real<T>>> {
__device__ __forceinline__ math::Real<T> operator()(const T& x) const {
__device__ __forceinline__ math::Real<T> operator()(const T x) const {
return abs(x);
}
};
template <typename T>
struct CudaAbsFunctor<T, math::NoComplex<T, math::Real<T>>> {
__device__ __forceinline__ T operator()(const T& x) const {
__device__ __forceinline__ T operator()(const T x) const {
return std::abs(x);
}
};
......
......@@ -28,8 +28,8 @@ template <typename T>
struct BCELossGradFunctor {
T one = static_cast<T>(1.0f);
T eps = static_cast<T>(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);
}
......
......@@ -32,7 +32,7 @@ template <typename T>
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;
}
......
......@@ -63,7 +63,7 @@ __device__ __forceinline__ double inline_pow(double base, double exponent) {
template <typename T>
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<T>(static_cast<double>(x) != 0);
}
};
......@@ -71,7 +71,7 @@ struct NonzeroFunctor {
template <typename T>
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<T>(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<Ty>(inline_pow(inline_abs(x), static_cast<Tx>(porder)));
}
float porder;
......@@ -90,7 +90,7 @@ struct UnsignedPowFunctor {
template <typename Tx, typename Ty = Tx>
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<Ty>(inline_pow(x, static_cast<Tx>(porder)));
}
float porder;
......
......@@ -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<Ty>(inline_pow(inline_abs(x), static_cast<Tx>(porder)));
}
float porder;
......
......@@ -30,7 +30,7 @@ namespace pten {
template <typename InT, typename OutT>
struct CastFuctor {
__device__ __forceinline__ OutT operator()(const InT& x) const {
__device__ __forceinline__ OutT operator()(const InT x) const {
return static_cast<OutT>(x);
}
};
......
......@@ -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 {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册