Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add return in initial function #42823

Merged
merged 3 commits into from
May 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions paddle/phi/kernels/primitive/functor_primitives_xpu2.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,21 @@ struct DivideFunctor {
inline DivideFunctor() { n_inv = static_cast<Tx>(1.0f); }

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); }

__device__ inline DivideFunctor() { n_inv = static_cast<Tx>(1.0f); }

__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 {
return static_cast<Ty>(x * n_inv);
}

__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:
Expand Down Expand Up @@ -97,8 +97,7 @@ struct SquareFunctor {
*/
template <typename T>
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 {
return (b < a) ? b : a;
Expand All @@ -111,7 +110,7 @@ struct MinFunctor {
template <typename T>
struct MaxFunctor {
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 {
Expand All @@ -124,8 +123,7 @@ struct MaxFunctor {
*/
template <typename T>
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; }
};
Expand All @@ -135,8 +133,7 @@ struct AddFunctor {
*/
template <typename T>
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; }
};
Expand All @@ -146,8 +143,7 @@ struct MulFunctor {
*/
template <typename T>
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; }
};
Expand Down