"src/include/base.hpp" did not exist on "f6cb5b846d1eff1d1e35ab58273becfd40bd0831"
Commit bd5f5a0d authored by Rostyslav Geyyer's avatar Rostyslav Geyyer
Browse files

Add an element-wise op

parent a997a51d
...@@ -281,6 +281,24 @@ struct ConvertF8SR ...@@ -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 struct Scale
{ {
__host__ __device__ Scale(float scale) : scale_(scale) {} __host__ __device__ Scale(float scale) : scale_(scale) {}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment