16[[nodiscard]]
size_t component_bytes(Kakshya::TensorDType dtype) noexcept;
22[[nodiscard]] std::optional<Kakshya::TensorDType>
safetensors_dtype(std::string_view name) noexcept;
25[[nodiscard]] std::optional<std::string_view>
safetensors_name(Kakshya::TensorDType dtype) noexcept;
37[[nodiscard]] std::optional<NpyTypestr>
npy_dtype(std::string_view typestr, std::string& why);
49[[nodiscard]] std::optional<FileHead>
read_file_head(
const std::string& path,
size_t limit);
61[[nodiscard]] std::optional<std::span<const std::byte>>
dense_bytes(
Owning host tensor: a TensorSpec and the bytes it describes.
std::string lower_extension(const std::string &path)
Lowercase extension of a path without its dot.
size_t component_bytes(Kakshya::TensorDType dtype) noexcept
Bytes of one independently ordered component of an element.
std::optional< std::string > npy_typestr(Kakshya::TensorDType dtype)
Little-endian numpy type string for an element type, when numpy has one.
std::optional< Kakshya::TensorDType > safetensors_dtype(std::string_view name) noexcept
Element type for a safetensors dtype name such as F32 or BF16.
std::optional< std::span< const std::byte > > dense_bytes(const Kakshya::TensorData &tensor, std::optional< Kakshya::TensorData > &dense)
Elements of a tensor as dense C-order bytes.
void swap_components(std::span< std::byte > data, size_t component_bytes) noexcept
Reverse the byte order of every component in place.
std::optional< std::string_view > safetensors_name(Kakshya::TensorDType dtype) noexcept
Safetensors dtype name for an element type, when the format has one.
bool host_is_little_endian() noexcept
Whether this machine stores multi-byte values least significant byte first.
std::optional< NpyTypestr > npy_dtype(std::string_view typestr, std::string &why)
Parse a numpy type string such as <f4, >i8 or |b1.
std::optional< FileHead > read_file_head(const std::string &path, size_t limit)
Read up to limit leading bytes of a file, or std::nullopt if it cannot be opened.
std::vector< std::byte > bytes
First bytes of a file together with its total size.
Kakshya::TensorDType dtype
Element type and byte order read from a numpy type string.
Element type as kind, bit width and lane count.