MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
TensorWriter.hpp
Go to the documentation of this file.
1#pragma once
2
4
5namespace MayaFlux::IO {
6
7/**
8 * @class TensorWriter
9 * @brief Single-shot writer of a TensorSet to one file format.
10 *
11 * Tensors are written at their native element type in dense C order, so
12 * strided tensors are gathered first. A format that cannot represent a tensor
13 * (an element type it has no name for, a name it cannot store) refuses the
14 * whole set and reports why through get_last_error().
15 */
16class MAYAFLUX_API TensorWriter {
17public:
18 virtual ~TensorWriter() = default;
19
20 /**
21 * @brief Write every tensor in the set to a file.
22 * @param filepath Destination path.
23 * @param tensors Tensors with unique, non-empty names.
24 * @return True only if the complete file was written.
25 */
26 virtual bool write(const std::string& filepath, const Kakshya::TensorSet& tensors) = 0;
27
28 /** @brief Reason the last write failed, or empty. */
29 [[nodiscard]] virtual std::string get_last_error() const = 0;
30
31 /** @brief Extensions this format writes, without dots. */
32 [[nodiscard]] virtual std::vector<std::string> get_supported_extensions() const = 0;
33};
34
35}
virtual std::vector< std::string > get_supported_extensions() const =0
Extensions this format writes, without dots.
virtual std::string get_last_error() const =0
Reason the last write failed, or empty.
virtual bool write(const std::string &filepath, const Kakshya::TensorSet &tensors)=0
Write every tensor in the set to a file.
virtual ~TensorWriter()=default
Single-shot writer of a TensorSet to one file format.
Named tensors that belong together, such as a model's weights or I/O.
Definition Tensor.hpp:167