32 static void register_with_registry();
35 [[nodiscard]]
static bool probe(std::span<const std::byte> head, uint64_t file_size);
37 [[nodiscard]]
bool can_read(
const std::string& filepath)
const override;
39 void close()
override;
43 [[nodiscard]] std::string
format_name()
const override {
return "safetensors"; }
44 [[nodiscard]] std::vector<Kakshya::TensorSpec> describe()
const override;
46 [[nodiscard]] std::optional<Kakshya::TensorData> read(std::string_view name)
override;
55 bool reject(std::string reason);
void close() override
Close the currently open file.
std::vector< Entry > m_entries
std::map< std::string, std::string > tensor_metadata() const override
Free-form string metadata stored in the file, empty if the format has none.
bool is_open() const override
Check if a file is currently open.
std::string format_name() const override
Format identifier such as safetensors or npy.
std::vector< std::string > get_supported_extensions() const override
Get supported file extensions for this reader.
SafetensorsReader()=default
std::map< std::string, std::string > m_metadata
~SafetensorsReader() override
std::vector< std::string > get_supported_extensions() const override
Extensions this format writes, without dots.
std::string get_last_error() const override
Reason the last write failed, or empty.
bool write(const std::string &filepath, const Kakshya::TensorSet &tensors) override
Write every tensor in the set to a file.
Writer for the safetensors format.
Typed FileReader boundary for formats that store named tensors.
Single-shot writer of a TensorSet to one file format.
FileReadOptions
Generic options for file reading behavior.
@ ALL
All options enabled.
Named tensors that belong together, such as a model's weights or I/O.
Complete description of a tensor: type, shape, layout, meaning.