38 [[nodiscard]]
bool can_read(
const std::string& filepath)
const override;
40 void close()
override;
44 [[nodiscard]] std::string
format_name()
const override {
return "npz"; }
45 [[nodiscard]] std::vector<Kakshya::TensorSpec> describe()
const override;
46 [[nodiscard]] std::optional<Kakshya::TensorData> read(std::string_view name)
override;
bool open(const std::string &filepath, FileReadOptions options=FileReadOptions::ALL) override
Open a file for reading.
static void register_with_registry()
Register the format, with its writer, in the TensorFormatRegistry.
void close() override
Close the currently open file.
std::vector< Entry > m_entries
bool is_open() const override
Check if a file is currently open.
NpzReader(const NpzReader &)=delete
std::unique_ptr< Detail::NpzArchive > m_archive
std::string format_name() const override
Format identifier such as safetensors or npy.
bool can_read(const std::string &filepath) const override
Check if a file can be read by this reader.
NpzReader & operator=(const NpzReader &)=delete
std::vector< std::string > get_supported_extensions() const override
Get supported file extensions for this reader.
bool write(const std::string &filepath, const Kakshya::TensorSet &tensors) override
Write every tensor in the set to a file.
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.
Writer for NumPy .npz archives, one stored (uncompressed) .npy entry per tensor.
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.