I/O¶
-
namespace io¶
Enums
Functions
-
FileFormat detect_format(const std::string &filename)¶
Detect file format by examining magic bytes.
- Parameters:
filename – Path to file
- Returns:
Detected file format
-
std::string format_name(FileFormat format)¶
Get human-readable name for file format.
-
Tensor load(const std::string &filename, Device device = Device::CPU)¶
Load tensor from file, auto-detecting format.
Supports: .axfb (FlatBuffers), .npy (NumPy)
- Parameters:
filename – Path to input file
device – Target device (default: CPU)
- Returns:
Loaded tensor
-
std::map<std::string, Tensor> load_archive(const std::string &filename, Device device = Device::CPU)¶
Load multiple tensors from archive file.
For NumPy files, returns single tensor with filename as key.
- Parameters:
filename – Path to input file
device – Target device
- Returns:
Map of tensor names to loaded tensors
-
void save(const Tensor &tensor, const std::string &filename)¶
Save tensor to .axfb file (FlatBuffers format).
- Parameters:
tensor – The tensor to save
filename – Path to output file
-
void save_archive(const std::map<std::string, Tensor> &tensors, const std::string &filename)¶
Save multiple tensors to .axfb archive file.
- Parameters:
tensors – Map of tensor names to tensors
filename – Path to output archive
-
std::string to_string(const Tensor &tensor)¶
Get a NumPy-style string representation of the tensor.
- Parameters:
tensor – The tensor to format.
- Returns:
A string with the formatted tensor.
-
class SerializationError : public std::runtime_error¶
- #include <io.hpp>
Subclassed by axiom::io::FileFormatError
Public Functions
-
inline explicit SerializationError(const std::string &message)¶
-
inline explicit SerializationError(const std::string &message)¶
-
class FileFormatError : public axiom::io::SerializationError¶
- #include <io.hpp>
Public Functions
-
inline explicit FileFormatError(const std::string &message)¶
-
inline explicit FileFormatError(const std::string &message)¶
-
namespace flatbuffers¶
Functions
-
bool is_axfb_file(const std::string &filename)¶
Check if file is a valid Axiom FlatBuffers file.
- Parameters:
filename – Path to file
- Returns:
True if file has AXFB magic bytes
-
Tensor load(const std::string &filename, Device device = Device::CPU)¶
Load tensor from .axfb file.
- Parameters:
filename – Path to .axfb file
device – Target device
- Returns:
Loaded tensor (first tensor in archive)
-
std::map<std::string, Tensor> load_archive(const std::string &filename, Device device = Device::CPU)¶
Load all tensors from .axfb archive.
- Parameters:
filename – Path to .axfb file
device – Target device
- Returns:
Map of tensor names to loaded tensors
-
void save(const Tensor &tensor, const std::string &filename)¶
Save tensor to .axfb file.
- Parameters:
tensor – The tensor to save
filename – Path to output file
-
void save_archive(const std::map<std::string, Tensor> &tensors, const std::string &filename)¶
Save multiple tensors to .axfb archive.
- Parameters:
tensors – Map of tensor names to tensors
filename – Path to output file
-
std::vector<std::string> list_archive(const std::string &filename)¶
List tensor names in archive without loading data.
- Parameters:
filename – Path to archive file
- Returns:
Vector of tensor names
-
bool is_axfb_file(const std::string &filename)¶
-
namespace numpy¶
Functions
-
bool is_npy_file(const std::string &filename)¶
Check if file has NumPy magic bytes.
- Parameters:
filename – Path to file
- Returns:
True if file starts with NumPy magic (\x93NUMPY)
-
Tensor load(const std::string &filename, Device device = Device::CPU)¶
Load tensor from NumPy .npy file.
Supports:
All standard NumPy dtypes (float, int, uint, bool, complex)
Both little-endian and big-endian (with automatic conversion)
C-order (row major) and Fortran-order (column major) arrays
NPY format versions 1.0, 2.0, and 3.0
- Parameters:
filename – Path to .npy file
device – Target device (default: CPU)
- Returns:
Loaded tensor
-
bool is_npy_file(const std::string &filename)¶
-
namespace safetensors¶
-
FileFormat detect_format(const std::string &filename)¶