@@ -56,6 +56,12 @@ struct absolute_value_op {
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct absolute_value_op<float> {
|
||||
CUTLASS_HOST_DEVICE
|
||||
float operator()(float lhs) const { return fabs(lhs); }
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct plus {
|
||||
CUTLASS_HOST_DEVICE
|
||||
@@ -83,6 +89,30 @@ struct multiplies {
|
||||
}
|
||||
};
|
||||
|
||||
// Maximum with nan propogation
|
||||
// To propgate the NANs, the "max" of a two element that contains NaNs should also return a NaN
|
||||
template <typename T>
|
||||
struct maximum_with_nan_propogation {
|
||||
CUTLASS_HOST_DEVICE
|
||||
T operator()(T const &lhs, T const &rhs) const {
|
||||
return lhs > rhs or std::isnan(lhs) ? lhs : rhs;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct maximum_with_nan_propogation<float> {
|
||||
CUTLASS_HOST_DEVICE
|
||||
float operator()(float const lhs, float const rhs) const {
|
||||
float res;
|
||||
#if defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 800)
|
||||
asm volatile("max.NaN.f32 %0, %1, %2;\n" : "=f"(res) : "f"(lhs), "f"(rhs));
|
||||
#else
|
||||
res = lhs > rhs or std::isnan(lhs) ? lhs : rhs;
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
/// Squares with optional conversion
|
||||
template <typename T, typename Output = T>
|
||||
struct square {
|
||||
|
||||
Reference in New Issue
Block a user