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

Complete description of a tensor: type, shape, layout, meaning. More...

#include <TensorSpec.hpp>

Collaboration diagram for MayaFlux::Kakshya::TensorSpec:

Public Member Functions

std::optional< std::pair< uint64_t, uint64_t > > byte_range () const noexcept
 Storage bytes [first, last) the spec addresses, from storage start.
std::string diagnose () const
 Empty when the spec is self-consistent, otherwise the reason it is not.
std::vector< DataDimension > dimensions () const
 One DataDimension per axis, with size and stride taken from shape and strides.
std::optional< uint64_t > element_count () const noexcept
 Product of the shape, or std::nullopt on overflow.
bool is_contiguous () const noexcept
 Whether elements are laid out densely in C order.
bool is_valid () const
 Whether diagnose() reports no problem.
size_t rank () const noexcept
 Number of dimensions.
std::vector< int64_t > resolved_strides () const
 Element strides, with C order filled in when none are stored.
std::optional< TensorSpec > window (const Region &region) const
 Spec of the box a Region selects.
std::optional< TensorSpec > window (std::span< const uint64_t > origin, std::span< const uint64_t > extent) const
 Spec of the box that starts at origin and spans extent elements per axis.

Static Public Member Functions

static TensorSpec contiguous (TensorDType dtype, std::vector< uint64_t > shape, std::string name={})
 C-ordered spec with no offset, axes or quantization.

Public Attributes

std::vector< DataDimension > axes
uint64_t byte_offset {}
TensorDevice device
TensorDType dtype
std::string name
std::optional< TensorQuantization > quantization
std::vector< uint64_t > shape
std::vector< int64_t > strides

Detailed Description

Complete description of a tensor: type, shape, layout, meaning.

Follows the DLPack model. Strides are in elements and may be explicit, negative or broadcast (zero), so views, Fortran order and transposes are described without copying; empty strides mean C order. byte_offset locates element zero inside the storage. axes optionally gives each dimension a role and name, for example batch, channel and spatial axes.

Usage:

auto spec = TensorSpec::contiguous(TensorDType::of<float>(), { 1, 3, 224, 224 }, "input");
if (auto why = spec.diagnose(); !why.empty()) { }
static constexpr TensorDType of() noexcept
Type for a C++ scalar or complex element.
static TensorSpec contiguous(TensorDType dtype, std::vector< uint64_t > shape, std::string name={})
C-ordered spec with no offset, axes or quantization.

Definition at line 92 of file TensorSpec.hpp.


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