C++ header providing numeric limits for floating-point types, including specialized half-precision support for MLX. Use for hardware-accelerated math operations.
// Source: https://github.com/kellyvv/PhoneClaw | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
// Copyright © 2024 Apple Inc.
#pragma once
#include <limits>
#include "mlx/types/half_types.h"
namespace mlx::core {
template <typename T>
struct numeric_limits;
template <>
struct numeric_limits<float> : public std::numeric_limits<float> {};
template <>
struct numeric_limits<double> : public std::numeric_limits<double> {};
template <>
struct numeric_limits<float16_t> {
private:
union half_or_bits {
uint16_t bits;
float16_t value;
};
constexpr static float16_t bits_to_half(uint16_t v) {
return half_or_bits{v}.value;
}
public:
constexpr static float16_t lo
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key