未验证 提交 bebaee37 编写于 作者: N niuliling123 提交者: GitHub

Add return in initial function (#42823)

上级 1f64c42e
...@@ -55,21 +55,21 @@ struct DivideFunctor { ...@@ -55,21 +55,21 @@ struct DivideFunctor {
inline DivideFunctor() { n_inv = static_cast<Tx>(1.0f); } inline DivideFunctor() { n_inv = static_cast<Tx>(1.0f); }
explicit inline DivideFunctor(int n) explicit inline DivideFunctor(int n)
: n_inv(static_cast<Tx>(((float)1.0) / (static_cast<float>(n)))) {} : n_inv(static_cast<Tx>(1.0f / (static_cast<float>(n)))) {}
inline Ty operator()(const Tx& x) const { return static_cast<Ty>(x * n_inv); } inline Ty operator()(const Tx& x) const { return static_cast<Ty>(x * n_inv); }
__device__ inline DivideFunctor() { n_inv = static_cast<Tx>(1.0f); } __device__ inline DivideFunctor() { n_inv = static_cast<Tx>(1.0f); }
__device__ inline DivideFunctor(int n) __device__ inline DivideFunctor(int n)
: n_inv(static_cast<Tx>(((float)1.0) / (static_cast<float>(n)))) {} : n_inv(static_cast<Tx>(1.0f / (static_cast<float>(n)))) {}
__device__ inline Ty operator()(const Tx& x) const { __device__ inline Ty operator()(const Tx& x) const {
return static_cast<Ty>(x * n_inv); return static_cast<Ty>(x * n_inv);
} }
__device__ inline void SetDiv(int n) { __device__ inline void SetDiv(int n) {
n_inv = static_cast<Tx>(((float)1.0) / (static_cast<float>(n))); n_inv = static_cast<Tx>(1.0f / (static_cast<float>(n)));
} }
private: private:
...@@ -97,8 +97,7 @@ struct SquareFunctor { ...@@ -97,8 +97,7 @@ struct SquareFunctor {
*/ */
template <typename T> template <typename T>
struct MinFunctor { struct MinFunctor {
inline T initial() { /*return static_cast<T>(std::numeric_limits<T>::max());*/ inline T initial() { return static_cast<T>(std::numeric_limits<T>::max()); }
}
__device__ T operator()(const T& a, const T& b) const { __device__ T operator()(const T& a, const T& b) const {
return (b < a) ? b : a; return (b < a) ? b : a;
...@@ -111,7 +110,7 @@ struct MinFunctor { ...@@ -111,7 +110,7 @@ struct MinFunctor {
template <typename T> template <typename T>
struct MaxFunctor { struct MaxFunctor {
inline T initial() { inline T initial() {
// return static_cast<T>(std::numeric_limits<T>::lowest()); return static_cast<T>(std::numeric_limits<T>::lowest());
} }
__device__ T operator()(const T& a, const T& b) const { __device__ T operator()(const T& a, const T& b) const {
...@@ -124,8 +123,7 @@ struct MaxFunctor { ...@@ -124,8 +123,7 @@ struct MaxFunctor {
*/ */
template <typename T> template <typename T>
struct AddFunctor { struct AddFunctor {
inline T initial() { /*return static_cast<T>(0.0f);*/ inline T initial() { return static_cast<T>(0.0f); }
}
__device__ T operator()(const T a, const T b) const { return b + a; } __device__ T operator()(const T a, const T b) const { return b + a; }
}; };
...@@ -135,8 +133,7 @@ struct AddFunctor { ...@@ -135,8 +133,7 @@ struct AddFunctor {
*/ */
template <typename T> template <typename T>
struct MulFunctor { struct MulFunctor {
inline T initial() { /*return static_cast<T>(1.0f);*/ inline T initial() { return static_cast<T>(1.0f); }
}
__device__ T operator()(const T& a, const T& b) const { return b * a; } __device__ T operator()(const T& a, const T& b) const { return b * a; }
}; };
...@@ -146,8 +143,7 @@ struct MulFunctor { ...@@ -146,8 +143,7 @@ struct MulFunctor {
*/ */
template <typename T> template <typename T>
struct LogicalOrFunctor { struct LogicalOrFunctor {
inline T initial() { /*return static_cast<T>(false);*/ inline T initial() { return static_cast<T>(false); }
}
__device__ T operator()(const T& a, const T& b) const { return b || a; } __device__ T operator()(const T& a, const T& b) const { return b || a; }
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册