46 [[nodiscard]]
virtual std::vector<Kakshya::TensorSpec>
describe()
const = 0;
49 [[nodiscard]]
virtual std::map<std::string, std::string>
tensor_metadata()
const {
return {}; }
55 [[nodiscard]]
virtual std::optional<Kakshya::TensorData>
read(std::string_view name) = 0;
64 [[nodiscard]] std::optional<Kakshya::TensorSpec> find_spec(std::string_view name)
const;
66 [[nodiscard]] std::optional<FileMetadata> get_metadata()
const override;
67 [[nodiscard]] std::vector<FileRegion>
get_regions()
const override {
return {}; }
68 std::vector<Kakshya::DataVariant> read_all()
override;
69 std::vector<Kakshya::DataVariant> read_region(
const FileRegion&)
override;
71 bool load_into_container(std::shared_ptr<Kakshya::SignalSourceContainer>)
override;
73 bool seek(
const std::vector<uint64_t>&)
override {
return false; }
74 [[nodiscard]] std::type_index get_data_type()
const override;
75 [[nodiscard]] std::type_index get_container_type()
const override;
84 bool fail(std::string reason)
Abstract interface for reading various file formats into containers.
std::string get_last_error() const override
Get the last error message.
std::vector< FileRegion > get_regions() const override
Get semantic regions from the file.
uint64_t get_preferred_chunk_size() const override
Get the preferred chunk size for streaming.
std::vector< uint64_t > get_read_position() const override
Get current read position in primary dimension.
virtual std::map< std::string, std::string > tensor_metadata() const
Free-form string metadata stored in the file, empty if the format has none.
virtual std::vector< Kakshya::TensorSpec > describe() const =0
Specs of every tensor in the open file, in file order, without reading data.
bool fail(std::string reason)
Record a failure reason and return false.
virtual std::optional< Kakshya::TensorData > read(std::string_view name)=0
Read one tensor by name.
bool supports_streaming() const override
Check if streaming is supported for the current file.
~TensorReader() override=default
virtual std::string format_name() const =0
Format identifier such as safetensors or npy.
std::optional< Kakshya::TensorSet > read_tensors(const TensorReadOptions &options={})
Read a selection of tensors together with the file's metadata.
std::vector< uint64_t > get_dimension_sizes() const override
Get size of each dimension in the file data.
bool seek(const std::vector< uint64_t > &) override
Seek to a specific position in the file.
size_t get_num_dimensions() const override
Get the dimensionality of the file data.
Typed FileReader boundary for formats that store named tensors.
auto create_container(Args &&... args) -> std::shared_ptr< ContainerType >
creates a new container of the specified type
Generic region descriptor for any file type.
std::vector< std::string > names
Tensors to read, in this order.
Selection for TensorReader::read_tensors().