MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::IO::RawTensorReader Class Reference

Reader for headerless binary files whose layout the caller supplies. More...

#include <RawTensorReader.hpp>

Inheritance diagram for MayaFlux::IO::RawTensorReader:
Collaboration diagram for MayaFlux::IO::RawTensorReader:

Public Member Functions

bool can_read (const std::string &filepath) const override
 Check if a file can be read by this reader.
void close () override
 Close the currently open file.
std::vector< Kakshya::TensorSpec > describe () const override
 Specs of every tensor in the open file, in file order, without reading data.
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.
bool is_open () const override
 Check if a file is currently open.
bool open (const std::string &filepath, FileReadOptions options=FileReadOptions::ALL) override
 Open a file for reading.
RawTensorReader & operator= (const RawTensorReader &)=delete
 RawTensorReader ()=default
 RawTensorReader (const RawTensorReader &)=delete
std::optional< Kakshya::TensorData > read (std::string_view name) override
 Read one tensor by name.
bool set_layout (std::vector< RawTensorEntry > entries)
 Declare the tensors the file holds.
 ~RawTensorReader () override
Public Member Functions inherited from MayaFlux::IO::TensorReader
std::shared_ptr< Kakshya::SignalSourceContainer > create_container () override
 Create and initialize a container from the file.
std::optional< Kakshya::TensorSpec > find_spec (std::string_view name) const
 Spec of one tensor by name, without reading data.
std::type_index get_container_type () const override
 Get the container type this reader creates.
std::type_index get_data_type () const override
 Get the data type this reader produces.
std::vector< uint64_t > get_dimension_sizes () const override
 Get size of each dimension in the file data.
std::string get_last_error () const override
 Get the last error message.
std::optional< FileMetadata > get_metadata () const override
 Get metadata from the open file.
size_t get_num_dimensions () const override
 Get the dimensionality of the file data.
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.
std::vector< FileRegion > get_regions () const override
 Get semantic regions from the file.
bool load_into_container (std::shared_ptr< Kakshya::SignalSourceContainer >) override
 Load file data into an existing container.
std::vector< Kakshya::DataVariant > read_all () override
 Read all data from the file into memory.
std::vector< Kakshya::DataVariant > read_region (const FileRegion &) override
 Read a specific region of data.
std::optional< Kakshya::TensorSet > read_tensors (const TensorReadOptions &options={})
 Read a selection of tensors together with the file's metadata.
bool seek (const std::vector< uint64_t > &) override
 Seek to a specific position in the file.
bool supports_streaming () const override
 Check if streaming is supported for the current file.
virtual std::map< std::string, std::string > tensor_metadata () const
 Free-form string metadata stored in the file, empty if the format has none.
 ~TensorReader () override=default
Public Member Functions inherited from MayaFlux::IO::FileReader
virtual ~FileReader ()=default

Private Attributes

std::ifstream m_file
std::vector< RawTensorEntry > m_layout
std::vector< uint64_t > m_offsets
bool m_open {}

Additional Inherited Members

Static Public Member Functions inherited from MayaFlux::IO::FileReader
static std::string resolve_path (const std::string &filepath)
 Resolve a filepath against the project source root if not found as-is.
Protected Member Functions inherited from MayaFlux::IO::TensorReader
bool fail (std::string reason)
 Record a failure reason and return false.
Static Protected Member Functions inherited from MayaFlux::IO::FileReader
static std::unordered_map< std::string, Kakshya::RegionGroup > regions_to_groups (const std::vector< FileRegion > &regions)
 Convert file regions to region groups.
Protected Attributes inherited from MayaFlux::IO::TensorReader
std::string m_last_error
std::string m_path

Detailed Description

Reader for headerless binary files whose layout the caller supplies.

Covers raw dumps, simple custom formats and any data whose layout lives in a sidecar the caller has already parsed. It is chosen explicitly, never by detection, because a raw file identifies nothing about itself.

Usage:

reader.set_layout({ { TensorSpec::contiguous(TensorDType::of<float>(), { 480, 640 }, "depth"), 0 } });
reader.open("depth.bin");
auto depth = reader.read("depth");
bool open(const std::string &filepath, FileReadOptions options=FileReadOptions::ALL) override
Open a file for reading.
std::optional< Kakshya::TensorData > read(std::string_view name) override
Read one tensor by name.
bool set_layout(std::vector< RawTensorEntry > entries)
Declare the tensors the file holds.

Definition at line 38 of file RawTensorReader.hpp.


The documentation for this class was generated from the following files: