Unify saturates<> implementation

This commit is contained in:
Po Yen Chen
2024-04-09 12:49:07 +00:00
parent ecc64bce12
commit a66409cfd9

View File

@@ -56,20 +56,9 @@ struct saturates
CK_TILE_HOST_DEVICE constexpr auto operator()(const From& from) const
-> std::enable_if_t<std::is_arithmetic_v<From>, From>
{
if constexpr(std::is_floating_point_v<To> || std::is_same_v<To, half_t> ||
std::is_same_v<To, bfloat16_t> || std::is_same_v<To, fp8_t> ||
std::is_same_v<To, bf8_t>)
{
return clamp(from,
type_convert<From>(numeric<To>::lowest()),
type_convert<From>(numeric<To>::max()));
}
else
{
return clamp(from,
type_convert<From>(numeric<To>::min()),
type_convert<From>(numeric<To>::max()));
}
return clamp(from,
type_convert<From>(numeric<To>::lowest()),
type_convert<From>(numeric<To>::max()));
}
};