NForge
Tensor library
Loading...
Searching...
No Matches
TensorLayout Struct Reference

#include <tensor_layout.h>

Public Member Functions

 TensorLayout ()
 Default constructor. Rank and offset are zero.
 
 TensorLayout (const Tensor::Shape &_shape)
 
 TensorLayout (const Tensor::Shape &_shape, const std::vector< size_t > &_strides)
 
 TensorLayout (const Tensor::Shape &_shape, const std::vector< size_t > &_strides, size_t _offset)
 
 TensorLayout (std::array< size_t, MAX_DIMS > _shape, std::array< size_t, MAX_DIMS > _strides, size_t _offset, size_t _rank)
 
bool operator== (const TensorLayout &rhs) const
 True if layouts have equal rank, offset, and active shape/stride entries.
 
bool operator!= (const TensorLayout &rhs) const
 Negation of operator==.
 

Public Attributes

std::array< size_t, MAX_DIMS > shape
 Shape extent per dimension. Only first rank entries active.
 
std::array< size_t, MAX_DIMS > strides
 Stride (element count) per dimension. Only first rank entries active.
 
size_t offset = 0
 Storage offset before indexing begins.
 
size_t rank = 0
 Number of active dimensions.
 

Detailed Description

Describes the memory layout of a tensor (shape, strides, offset, rank).

Only the first rank entries of shape and strides are active. 0 <= rank && rank <= MAX_DIMS.

Constructor & Destructor Documentation

◆ TensorLayout() [1/4]

TensorLayout::TensorLayout ( const Tensor::Shape _shape)

Contiguous (row-major) layout from a shape.

Precondition
_shape.getNumDims() <= MAX_DIMS

◆ TensorLayout() [2/4]

TensorLayout::TensorLayout ( const Tensor::Shape _shape,
const std::vector< size_t > &  _strides 
)

Layout from shape and explicit strides.

Precondition
_shape.getNumDims() <= MAX_DIMS
_strides.size() == _shape.getNumDims()

◆ TensorLayout() [3/4]

TensorLayout::TensorLayout ( const Tensor::Shape _shape,
const std::vector< size_t > &  _strides,
size_t  _offset 
)

Layout from shape, explicit strides, and storage offset.

Precondition
_shape.getNumDims() <= MAX_DIMS
_strides.size() == _shape.getNumDims()

◆ TensorLayout() [4/4]

TensorLayout::TensorLayout ( std::array< size_t, MAX_DIMS >  _shape,
std::array< size_t, MAX_DIMS >  _strides,
size_t  _offset,
size_t  _rank 
)

Layout from raw arrays and rank.

Precondition
_rank <= MAX_DIMS

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