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

Owns one tensor and serves N-dimensional regions of it. More...

#include <TensorContainer.hpp>

Inheritance diagram for MayaFlux::Kakshya::TensorContainer:
Collaboration diagram for MayaFlux::Kakshya::TensorContainer:

Public Member Functions

void add_region_group (const RegionGroup &group) override
 Store or replace a named region group.
void clear () override
 Become an empty tensor of the same dtype and name, and drop all region groups.
uint64_t coordinates_to_linear_index (const std::vector< uint64_t > &coordinates) const override
 Row-major logical index of a coordinate, independent of strides.
std::unordered_map< std::string, RegionGroup > get_all_region_groups () const override
 Copy all named region groups.
const TensorData & get_data () const noexcept
 Borrow the tensor.
std::vector< DataDimension > get_dimensions () const override
 Describe the tensor's axes with their sizes and stride magnitudes.
uint64_t get_frame_size () const override
 Elements in one slice along the leading axis.
MemoryLayout get_memory_layout () const override
 Column-major when the strides are exactly Fortran order, otherwise row-major.
uint64_t get_num_frames () const override
 Extent of the leading axis.
const void * get_raw_data () const override
 Borrow element zero, or nullptr when empty.
std::vector< TensorData > get_region_data (const Region &region) const override
 Copy the box a Region selects into an owning dense tensor.
RegionGroup get_region_group (const std::string &name) const override
 Return a named region group, or an empty group if absent.
std::vector< TensorData > get_region_group_data (const RegionGroup &group) const override
 Copy the boxes of a group into separate tensors.
std::vector< TensorData > get_segments_data (const std::vector< RegionSegment > &segments) const override
 Copy segments into separate tensors.
const ContainerDataStructure & get_structure () const override
 Structure metadata.
ContainerDataStructure & get_structure () override
 Mutable structure metadata.
uint64_t get_total_elements () const override
 Number of elements in the tensor.
bool has_data () const override
 Whether the tensor contains any elements.
TensorInsertion insert () noexcept
 Create an insertion adapter for the tensor.
bool is_region_loaded (const Region &region) const override
 Whether the region selects a valid box.
std::vector< uint64_t > linear_index_to_coordinates (uint64_t linear_index) const override
 Coordinate of a row-major logical index.
void load_region (const Region &) override
 The tensor is resident.
void remove_region_group (const std::string &name) override
 Remove a named region group if present.
void set_memory_layout (MemoryLayout) override
 The layout is described by the tensor's strides and is not changed here.
void set_region_data (const Region &region, const std::vector< TensorData > &data) override
 Overwrite the box a Region selects.
void set_structure (ContainerDataStructure structure) override
 Replace structure metadata.
 TensorContainer (TensorData data)
 Take ownership of a tensor.
 TensorContainer (TensorSpec spec)
 Allocate a zero-filled tensor for a spec.
void unload_region (const Region &) override
 The tensor stays resident until clear() is called.
std::optional< TensorAccess > view () const
 Borrow the whole tensor.
std::optional< TensorAccess > view (const Region &region) const
 Borrow the box a Region selects, without copying.
 ~TensorContainer () override
Public Member Functions inherited from MayaFlux::Kakshya::NDDataContainer< TensorData >
virtual ~NDDataContainer ()=default

Private Attributes

TensorData m_data
std::unordered_map< std::string, RegionGroup > m_region_groups
ContainerDataStructure m_structure { DataModality::TENSOR_ND, OrganizationStrategy::INTERLEAVED }

Detailed Description

Owns one tensor and serves N-dimensional regions of it.

A Region is an inclusive box in the tensor's index space. Trailing axes the region does not name span their full extent. view() borrows the box as a strided TensorAccess without copying; the get_*_data calls copy boxes into independent dense tensors; set_region_data writes a tensor of the box's shape back in place.

Specializes NDDataContainer<TensorData> directly, not SignalSourceContainer, so it carries no ProcessingState and no DataProcessor lifecycle. Frames are slices along the leading axis.

Usage:

auto weights = TensorData::from_values<float>(values, { 64, 3, 7, 7 }, "conv1");
TensorContainer container(std::move(*weights));
auto filter = container.view(Region({ 5 }, { 5 }));
auto rows = container.get_region_data(Region({ 0, 0 }, { 9, 1 }));
Owns one tensor and serves N-dimensional regions of it.
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.
Definition Tensor.hpp:75
Represents a point or span in N-dimensional space.
Definition Region.hpp:74
Note
Views borrow the container's storage. Replacing the tensor through insert() or clear() invalidates them.

Definition at line 43 of file TensorContainer.hpp.


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