Trying to pass float16 type explicitly via macro(ugly method)

This commit is contained in:
Vladyslav Baranovskyi
2025-02-19 19:08:48 +02:00
parent 4bd2d89379
commit 6f2b637113
2 changed files with 6 additions and 9 deletions

View File

@@ -324,18 +324,12 @@ struct fmt::formatter<OpenVulkano::Math::Timestamp>
}; };
template<> template<>
struct fmt::formatter<float16> struct fmt::formatter<UNDERLYING_FLOAT16_TYPE> : fmt::formatter<float>
{ {
template<typename ParseContext>
constexpr auto parse(ParseContext& ctx)
{
return fmt::formatter<float>{}.parse(ctx);
}
template<typename FormatContext> template<typename FormatContext>
auto format(const float16& f, FormatContext& ctx) const auto format(const UNDERLYING_FLOAT16_TYPE& f, FormatContext& ctx) const
{ {
return fmt::formatter<float>{}.format(static_cast<float>(f), ctx); return fmt::formatter<float>::format(static_cast<float>(f), ctx);
} }
}; };

View File

@@ -15,10 +15,13 @@
// map a half float type, if available, to float16 // map a half float type, if available, to float16
#if __has_keyword(_Float16) #if __has_keyword(_Float16)
typedef _Float16 float16; typedef _Float16 float16;
#define UNDERLYING_FLOAT16_TYPE _Float16
#elif __has_keyword(__fp16) #elif __has_keyword(__fp16)
typedef __fp16 float16; typedef __fp16 float16;
#define UNDERLYING_FLOAT16_TYPE __fp16
#else #else
#define USING_CUSTOM_FLOAT16 #define USING_CUSTOM_FLOAT16
#define UNDERLYING_FLOAT16_TYPE float16
class float16 class float16
{ {