template<sizet Sign, sizet Mantissa, sizet Exponent, int Bias = Exponent ? (1 <<…
- User
template<size_t Sign, size_t Mantissa, size_t Exponent, int Bias = Exponent ? (1 << (Exponent - 1)) - 1 : 0> requires (Sign + Mantissa + Exponent <= 8 && Sign + Mantissa + Exponent > 0) class f_t : public data_type::interface { public: static constexpr size_t Bits = Sign + Mantissa + Exponent; inline static const std::string Name = [] { return std::string{"f"} + std::to_string(Bits); }(); static constexpr size_t BitSize = Bits;
struct binary { uint8_t s:Sign; uint8_t m:Mantissa; uint8_t e:Exponent; }; static_assert(sizeof(binary) == 1); using storage_t = uint8_t; using native_t = float32_t; using ptr_t = ptr_t_<native_t, std::decay_t<f_t<Sign, Mantissa, Exponent>>>; static native_t load(const storage_t* data, const size_t offset) requires (Bits == 8) { binary b = *(binary*)(data + offset); return b.m * std::exp2f(b.e - Bias); } static void store(storage_t* data, const size_t offset, const native_t value) requires (Bits == 8) { // ??? } [[nodiscard]] std::string_view name() const override { return Name; } [[nodiscard]] size_t bit_size() const override { return BitSize; } };}
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.