mirror of
https://github.com/ROCm/composable_kernel.git
synced 2026-05-03 05:01:25 +00:00
Switch default f8 conversion to stochastic rounding (#1048)
* Switch default f8 conversion to stochastic rounding * Refactor f8-related type_converts * Add an element-wise op
This commit is contained in:
@@ -281,6 +281,24 @@ struct ConvertF8SR
|
||||
}
|
||||
};
|
||||
|
||||
struct ConvertF8RNE
|
||||
{
|
||||
// convert to fp8 using rounding to nearest even
|
||||
template <typename Y, typename X>
|
||||
__host__ __device__ void operator()(Y& y, const X& x) const
|
||||
{
|
||||
// check Y datatype
|
||||
static_assert(is_same<Y, f8_t>::value || is_same<Y, bf8_t>::value,
|
||||
"Data type is not supported by this operation!");
|
||||
|
||||
// check X datatype
|
||||
static_assert(is_same<X, float>::value || is_same<X, half_t>::value,
|
||||
"Data type is not supported by this operation!");
|
||||
|
||||
y = f8_convert_rne<Y>(x);
|
||||
}
|
||||
};
|
||||
|
||||
struct Scale
|
||||
{
|
||||
__host__ __device__ Scale(float scale) : scale_(scale) {}
|
||||
|
||||
Reference in New Issue
Block a user