|
MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
|
Owning host tensor: a TensorSpec and the bytes it describes. More...
#include <Tensor.hpp>
Public Member Functions | |
| std::optional< TensorAccess > | access () const |
| Borrow the tensor, or std::nullopt when it holds nothing valid. | |
| size_t | byte_size () const noexcept |
| Storage size in bytes. | |
| bool | is_valid () const noexcept |
| Whether the tensor holds a consistent spec and its storage. | |
| TensorData & | operator= (const TensorData &other) |
| TensorData & | operator= (TensorData &&) noexcept=default |
| const TensorSpec & | spec () const noexcept |
| Layout of the stored bytes. | |
| std::span< const std::byte > | storage () const noexcept |
| The whole stored block. | |
| std::span< std::byte > | storage () noexcept |
| The whole stored block, writable. | |
| TensorData ()=default | |
| TensorData (const TensorData &other) | |
| TensorData (TensorData &&) noexcept=default | |
| std::optional< DataVariant > | to_variant () const |
| Copy into a flat DataVariant when the dtype has an alternative. | |
| template<DataVariantElement T> | |
| std::optional< std::vector< T > > | to_vector () const |
| Copy into a vector of T. | |
| ~TensorData ()=default | |
Static Public Member Functions | |
| static std::optional< TensorData > | allocate (TensorSpec spec) |
| Zero-filled tensor for a spec. | |
| static std::optional< TensorData > | copy_of (const TensorAccess &view) |
| Dense C-ordered copy of any tensor view. | |
| static std::optional< TensorData > | from_bytes (TensorSpec spec, std::span< const std::byte > bytes) |
Tensor holding a copy of bytes. | |
| template<TensorElement T> | |
| static std::optional< TensorData > | from_values (std::span< const T > values, std::vector< uint64_t > shape={}, std::string name={}) |
| Contiguous tensor holding a copy of typed values. | |
| static std::optional< TensorData > | from_variant (const DataVariant &variant, std::vector< uint64_t > shape={}, std::string name={}) |
| Tensor holding a copy of a DataVariant. | |
Private Attributes | |
| detail::AlignedBytes | m_data |
| size_t | m_size {} |
| TensorSpec | m_spec |
Friends | |
| class | TensorInsertion |
Owning host tensor: a TensorSpec and the bytes it describes.
Storage is one 256-byte aligned byte block, copied deeply with the object. Any element type the spec can name is stored the same way, so half, int8, int64 and the rest need no DataVariant alternative. A DataVariant is an optional bridge: from_variant() and to_variant() / to_vector() copy to and from it where the element types agree.
Usage:
Definition at line 42 of file Tensor.hpp.