mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Use C++17 Convention Methods in PyTorch (#137958)
Detailed Descriptions: - `std::is_same<X, Y>::value` -> `std::is_same_v<X, Y>` - `std::enable_if<C, T>::type` -> `std::enable_if_t<C, T>` - and so on Pull Request resolved: https://github.com/pytorch/pytorch/pull/137958 Approved by: https://github.com/janeyx99
This commit is contained in:
@ -106,7 +106,7 @@ inline void _init(scalar_t* self_ptr, at::opmath_type<scalar_t>* buffer_ptr, int
|
||||
}
|
||||
|
||||
template <typename scalar_t>
|
||||
inline typename std::enable_if<!std::is_same<scalar_t, Vec2>::value, scalar_t>::type
|
||||
inline std::enable_if_t<!std::is_same_v<scalar_t, Vec2>, scalar_t>
|
||||
_max(const scalar_t& x, const scalar_t& y) {
|
||||
return at::_isnan(y) ? y : std::max(x, y);
|
||||
}
|
||||
@ -118,14 +118,14 @@ inline Vectorized<scalar_t> _max(const Vectorized<scalar_t>& x, const Vectorized
|
||||
}
|
||||
|
||||
template <typename vec_t>
|
||||
inline typename std::enable_if<std::is_same<vec_t, Vec2>::value, Vec2>::type
|
||||
inline std::enable_if_t<std::is_same_v<vec_t, Vec2>, Vec2>
|
||||
_max(const vec_t& x, const vec_t& y) {
|
||||
// vec::maximum propagates NaN
|
||||
return maximum(x, y);
|
||||
}
|
||||
|
||||
template <typename scalar_t>
|
||||
inline typename std::enable_if<!std::is_same<scalar_t, Vec2>::value, scalar_t>::type
|
||||
inline std::enable_if_t<!std::is_same_v<scalar_t, Vec2>, scalar_t>
|
||||
_min(const scalar_t& x, const scalar_t& y) {
|
||||
return at::_isnan(y) ? y : std::min(x, y);
|
||||
}
|
||||
@ -137,7 +137,7 @@ inline Vectorized<scalar_t> _min(const Vectorized<scalar_t>& x, const Vectorized
|
||||
}
|
||||
|
||||
template <typename vec_t>
|
||||
inline typename std::enable_if<std::is_same<vec_t, Vec2>::value, Vec2>::type
|
||||
inline std::enable_if_t<std::is_same_v<vec_t, Vec2>, Vec2>
|
||||
_min(const vec_t& x, const vec_t& y) {
|
||||
// vec::minimum propagates NaN
|
||||
return minimum(x, y);
|
||||
|
Reference in New Issue
Block a user