tesseract++ 0.0.1
N-dimensional tensor library for embedded systems
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
FusedTensorND< T, Dims > Class Template Reference

#include <fused_tensor.h>

Inheritance diagram for FusedTensorND< T, Dims >:
Inheritance graph
[legend]
Collaboration diagram for FusedTensorND< T, Dims >:
Collaboration graph
[legend]

Public Types

using value_type = T
 
using Self = FusedTensorND< T, Dims... >
 
using Layout = StridedLayoutConstExpr< typename AccessPolicy::PadPolicy >
 

Public Member Functions

 FusedTensorND () noexcept=default
 
 FusedTensorND (T initValue) noexcept
 
 FusedTensorND (const FusedTensorND &other) noexcept
 
 FusedTensorND (FusedTensorND &&other) noexcept
 
template<typename Output >
bool may_alias (const Output &output) const noexcept
 
template<typename Expr >
FusedTensorNDoperator= (const BaseExpr< Expr > &expr)
 
template<typename T_ , my_size_t Bits, typename Arch >
Microkernel< T_, Bits, Arch >::VecType evalu (my_size_t flat) const noexcept
 
template<typename T_ , my_size_t Bits, typename Arch >
FORCE_INLINE Microkernel< T_, Bits, Arch >::VecType logical_evalu (my_size_t logical_flat) const noexcept
 Evaluate at a LOGICAL flat index.
 
FusedTensorNDoperator= (const FusedTensorND &other) noexcept
 
FusedTensorNDoperator= (FusedTensorND &&other) noexcept
 
template<typename... Indices>
requires (sizeof...(Indices) == NumDims)
T & operator() (Indices... indices) TESSERACT_CONDITIONAL_NOEXCEPT
 
template<typename... Indices>
requires (sizeof...(Indices) == NumDims)
const T & operator() (Indices... indices) const TESSERACT_CONDITIONAL_NOEXCEPT
 
T & operator() (const my_size_t *indices) TESSERACT_CONDITIONAL_NOEXCEPT
 
const T & operator() (const my_size_t *indices) const TESSERACT_CONDITIONAL_NOEXCEPT
 
T & operator() (my_size_t(&indices)[NumDims]) TESSERACT_CONDITIONAL_NOEXCEPT
 
const T & operator() (my_size_t(&indices)[NumDims]) const TESSERACT_CONDITIONAL_NOEXCEPT
 
bool isIdentity () const
 
template<my_size_t... Perm>
FORCE_INLINE auto transpose_view () const noexcept
 
FORCE_INLINE auto transpose_view (void) const noexcept
 
std::string getShape () const
 
FusedTensorNDsetToZero (void) noexcept
 
FusedTensorNDsetHomogen (T _val) noexcept
 
FusedTensorNDsetRandom (T _maxRand, T _minRand)
 
FusedTensorNDsetDiagonal (T _val)
 
FusedTensorNDsetIdentity (void)
 
FusedTensorNDsetSequencial (void)
 
template<my_size_t DiagonalSize>
void getDiagonalEntries (FusedTensorND< T, DiagonalSize, 1 > &diagonalEntries) const
 
void print (bool with_padding=false) const
 
void printND (bool showPadding=false) const
 Print tensor of arbitrary dimensions.
 
void printLayoutInfo () const
 
void print_access_policy_info () const
 
void print_flat_data () const
 
FORCE_INLINE constexpr const T * data () const noexcept
 
FORCE_INLINE constexpr T * data () noexcept
 
- Public Member Functions inherited from BaseExpr< FusedTensorND< T, Dims... > >
const FusedTensorND< T, Dims... > & derived () const
 

Static Public Member Functions

static constexpr bool areDimsEqual ()
 
static FORCE_INLINE constexpr my_size_t getTotalSize () noexcept
 
static FORCE_INLINE constexpr my_size_t getNumDims () noexcept
 
template<typename LeftExpr , typename RightExpr >
requires (expression::traits<LeftExpr>::IsPhysical && expression::traits<RightExpr>::IsPhysical)
static FusedTensorND einsum (const BaseExpr< LeftExpr > &_tensor1, const BaseExpr< RightExpr > &_tensor2, const my_size_t a, const my_size_t b)
 Contract two tensors along specified axes using SIMD dot products.
 
static FORCE_INLINE constexpr my_size_t getDim (my_size_t i) TESSERACT_CONDITIONAL_NOEXCEPT
 
static FORCE_INLINE constexpr my_size_t getStride (my_size_t i) TESSERACT_CONDITIONAL_NOEXCEPT
 

Static Public Attributes

static constexpr my_size_t NumDims = sizeof...(Dims)
 
static constexpr my_size_t Dim [] = {Dims...}
 
static constexpr my_size_t TotalSize = (Dims * ...)
 

Friends

template<typename , my_size_t... >
class PermutedViewConstExpr
 

Member Typedef Documentation

◆ Layout

template<typename T , my_size_t... Dims>
using FusedTensorND< T, Dims >::Layout = StridedLayoutConstExpr<typename AccessPolicy::PadPolicy>

◆ Self

template<typename T , my_size_t... Dims>
using FusedTensorND< T, Dims >::Self = FusedTensorND<T, Dims...>

◆ value_type

template<typename T , my_size_t... Dims>
using FusedTensorND< T, Dims >::value_type = T

Constructor & Destructor Documentation

◆ FusedTensorND() [1/4]

template<typename T , my_size_t... Dims>
FusedTensorND< T, Dims >::FusedTensorND ( )
defaultnoexcept

◆ FusedTensorND() [2/4]

template<typename T , my_size_t... Dims>
FusedTensorND< T, Dims >::FusedTensorND ( initValue)
inlineexplicitnoexcept

◆ FusedTensorND() [3/4]

template<typename T , my_size_t... Dims>
FusedTensorND< T, Dims >::FusedTensorND ( const FusedTensorND< T, Dims > &  other)
inlinenoexcept
Here is the call graph for this function:

◆ FusedTensorND() [4/4]

template<typename T , my_size_t... Dims>
FusedTensorND< T, Dims >::FusedTensorND ( FusedTensorND< T, Dims > &&  other)
inlinenoexcept
Here is the call graph for this function:

Member Function Documentation

◆ areDimsEqual()

template<typename T , my_size_t... Dims>
static constexpr bool FusedTensorND< T, Dims >::areDimsEqual ( )
inlinestaticconstexpr
Here is the call graph for this function:

◆ data() [1/2]

template<typename T , my_size_t... Dims>
FORCE_INLINE constexpr const T * FusedTensorND< T, Dims >::data ( ) const
inlineconstexprnoexcept

◆ data() [2/2]

template<typename T , my_size_t... Dims>
FORCE_INLINE constexpr T * FusedTensorND< T, Dims >::data ( )
inlineconstexprnoexcept

◆ einsum()

template<typename T , my_size_t... Dims>
template<typename LeftExpr , typename RightExpr >
requires (expression::traits<LeftExpr>::IsPhysical && expression::traits<RightExpr>::IsPhysical)
static FusedTensorND FusedTensorND< T, Dims >::einsum ( const BaseExpr< LeftExpr > &  _tensor1,
const BaseExpr< RightExpr > &  _tensor2,
const my_size_t  a,
const my_size_t  b 
)
inlinestatic

Contract two tensors along specified axes using SIMD dot products.

For 2D tensors, always dispatches to register-blocked GEMM by materializing transposed copies when needed. The O(N²) transpose cost is negligible vs O(N³) multiply, and the materialized tensor has proper SIMD-aligned padding for aligned K::load in the micro-kernel.

For higher-dimensional tensors, falls back to generic stride-mapped per-element dot products.


2D GEMM — 4 CASES (contract axis a from tensor1, axis b from tensor2)

a=1, b=0: C[M,N] = A[M,K] × B[K,N] — favorable, no transpose a=0, b=0: C[K,N] = A^T[K,M] × B[M,N] — transpose A a=1, b=1: C[M,K] = A[M,N] × B^T[N,K] — transpose B a=0, b=1: C[K,K'] = A^T × B^T — transpose both


Here is the call graph for this function:

◆ evalu()

template<typename T , my_size_t... Dims>
template<typename T_ , my_size_t Bits, typename Arch >
Microkernel< T_, Bits, Arch >::VecType FusedTensorND< T, Dims >::evalu ( my_size_t  flat) const
inlinenoexcept
Here is the call graph for this function:

◆ getDiagonalEntries()

template<typename T , my_size_t... Dims>
template<my_size_t DiagonalSize>
void FusedTensorND< T, Dims >::getDiagonalEntries ( FusedTensorND< T, DiagonalSize, 1 > &  diagonalEntries) const
inline
Here is the call graph for this function:

◆ getDim()

template<typename T , my_size_t... Dims>
static FORCE_INLINE constexpr my_size_t FusedTensorND< T, Dims >::getDim ( my_size_t  i)
inlinestaticconstexpr
Here is the call graph for this function:

◆ getNumDims()

template<typename T , my_size_t... Dims>
static FORCE_INLINE constexpr my_size_t FusedTensorND< T, Dims >::getNumDims ( )
inlinestaticconstexprnoexcept

◆ getShape()

template<typename T , my_size_t... Dims>
std::string FusedTensorND< T, Dims >::getShape ( ) const
inline
Here is the call graph for this function:

◆ getStride()

template<typename T , my_size_t... Dims>
static FORCE_INLINE constexpr my_size_t FusedTensorND< T, Dims >::getStride ( my_size_t  i)
inlinestaticconstexpr
Here is the call graph for this function:

◆ getTotalSize()

template<typename T , my_size_t... Dims>
static FORCE_INLINE constexpr my_size_t FusedTensorND< T, Dims >::getTotalSize ( )
inlinestaticconstexprnoexcept

◆ isIdentity()

template<typename T , my_size_t... Dims>
bool FusedTensorND< T, Dims >::isIdentity ( void  ) const
inline
Here is the call graph for this function:

◆ logical_evalu()

template<typename T , my_size_t... Dims>
template<typename T_ , my_size_t Bits, typename Arch >
FORCE_INLINE Microkernel< T_, Bits, Arch >::VecType FusedTensorND< T, Dims >::logical_evalu ( my_size_t  logical_flat) const
inlinenoexcept

Evaluate at a LOGICAL flat index.

Unlike evalu (which takes physical offsets), this converts logical flat → physical flat via Layout, handling padding gaps. Uses gather for SIMD widths > 1 since consecutive logical flats are not contiguous in physical memory when padding exists.

Here is the call graph for this function:

◆ may_alias()

template<typename T , my_size_t... Dims>
template<typename Output >
bool FusedTensorND< T, Dims >::may_alias ( const Output &  output) const
inlinenoexcept

◆ operator()() [1/6]

template<typename T , my_size_t... Dims>
const T & FusedTensorND< T, Dims >::operator() ( const my_size_t indices) const
inline
Here is the call graph for this function:

◆ operator()() [2/6]

template<typename T , my_size_t... Dims>
T & FusedTensorND< T, Dims >::operator() ( const my_size_t indices)
inline
Here is the call graph for this function:

◆ operator()() [3/6]

template<typename T , my_size_t... Dims>
template<typename... Indices>
requires (sizeof...(Indices) == NumDims)
const T & FusedTensorND< T, Dims >::operator() ( Indices...  indices) const
inline
Here is the call graph for this function:

◆ operator()() [4/6]

template<typename T , my_size_t... Dims>
template<typename... Indices>
requires (sizeof...(Indices) == NumDims)
T & FusedTensorND< T, Dims >::operator() ( Indices...  indices)
inline
Here is the call graph for this function:

◆ operator()() [5/6]

template<typename T , my_size_t... Dims>
const T & FusedTensorND< T, Dims >::operator() ( my_size_t(&)  indices[NumDims]) const
inline
Here is the call graph for this function:

◆ operator()() [6/6]

template<typename T , my_size_t... Dims>
T & FusedTensorND< T, Dims >::operator() ( my_size_t(&)  indices[NumDims])
inline
Here is the call graph for this function:

◆ operator=() [1/3]

template<typename T , my_size_t... Dims>
template<typename Expr >
FusedTensorND & FusedTensorND< T, Dims >::operator= ( const BaseExpr< Expr > &  expr)
inline
Here is the call graph for this function:

◆ operator=() [2/3]

template<typename T , my_size_t... Dims>
FusedTensorND & FusedTensorND< T, Dims >::operator= ( const FusedTensorND< T, Dims > &  other)
inlinenoexcept
Here is the call graph for this function:

◆ operator=() [3/3]

template<typename T , my_size_t... Dims>
FusedTensorND & FusedTensorND< T, Dims >::operator= ( FusedTensorND< T, Dims > &&  other)
inlinenoexcept
Here is the call graph for this function:

◆ print()

template<typename T , my_size_t... Dims>
void FusedTensorND< T, Dims >::print ( bool  with_padding = false) const
inline
Here is the call graph for this function:

◆ print_access_policy_info()

template<typename T , my_size_t... Dims>
void FusedTensorND< T, Dims >::print_access_policy_info ( ) const
inline
Here is the call graph for this function:

◆ print_flat_data()

template<typename T , my_size_t... Dims>
void FusedTensorND< T, Dims >::print_flat_data ( ) const
inline
Here is the call graph for this function:

◆ printLayoutInfo()

template<typename T , my_size_t... Dims>
void FusedTensorND< T, Dims >::printLayoutInfo ( ) const
inline
Here is the call graph for this function:

◆ printND()

template<typename T , my_size_t... Dims>
void FusedTensorND< T, Dims >::printND ( bool  showPadding = false) const
inline

Print tensor of arbitrary dimensions.

Convention: last 2 dims are (rows, cols), earlier dims are slice indices. For 1D: prints a single row. For 2D: prints a matrix. For 3D+: prints labeled 2D slices.

Parameters
showPaddingIf true, show padding elements after a '|' separator.
Here is the call graph for this function:

◆ setDiagonal()

template<typename T , my_size_t... Dims>
FusedTensorND & FusedTensorND< T, Dims >::setDiagonal ( _val)
inline
Here is the call graph for this function:

◆ setHomogen()

template<typename T , my_size_t... Dims>
FusedTensorND & FusedTensorND< T, Dims >::setHomogen ( _val)
inlinenoexcept

Safe to fill entire physical buffer with the same value

◆ setIdentity()

template<typename T , my_size_t... Dims>
FusedTensorND & FusedTensorND< T, Dims >::setIdentity ( void  )
inline
Here is the call graph for this function:

◆ setRandom()

template<typename T , my_size_t... Dims>
FusedTensorND & FusedTensorND< T, Dims >::setRandom ( _maxRand,
_minRand 
)
inline
Here is the call graph for this function:

◆ setSequencial()

template<typename T , my_size_t... Dims>
FusedTensorND & FusedTensorND< T, Dims >::setSequencial ( void  )
inline
Here is the call graph for this function:

◆ setToZero()

template<typename T , my_size_t... Dims>
FusedTensorND & FusedTensorND< T, Dims >::setToZero ( void  )
inlinenoexcept

◆ transpose_view() [1/2]

template<typename T , my_size_t... Dims>
template<my_size_t... Perm>
FORCE_INLINE auto FusedTensorND< T, Dims >::transpose_view ( ) const
inlinenoexcept

◆ transpose_view() [2/2]

template<typename T , my_size_t... Dims>
FORCE_INLINE auto FusedTensorND< T, Dims >::transpose_view ( void  ) const
inlinenoexcept

Friends And Related Symbol Documentation

◆ PermutedViewConstExpr

template<typename T , my_size_t... Dims>
template<typename , my_size_t... >
friend class PermutedViewConstExpr
friend

Member Data Documentation

◆ Dim

template<typename T , my_size_t... Dims>
constexpr my_size_t FusedTensorND< T, Dims >::Dim[] = {Dims...}
staticconstexpr

◆ NumDims

template<typename T , my_size_t... Dims>
constexpr my_size_t FusedTensorND< T, Dims >::NumDims = sizeof...(Dims)
staticconstexpr

◆ TotalSize

template<typename T , my_size_t... Dims>
constexpr my_size_t FusedTensorND< T, Dims >::TotalSize = (Dims * ...)
staticconstexpr

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