batmat 0.0.14
Batched linear algebra routines
Loading...
Searching...
No Matches
batmat::matrix::Layout< I, S, D, L, O > Struct Template Reference

#include <batmat/matrix/layout.hpp>

Detailed Description

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
struct batmat::matrix::Layout< I, S, D, L, O >

Shape and strides describing a batch of matrices, independent of any storage.

Template Parameters
IIndex type.
SInner stride (batch size).
DDepth type.
LLayer stride type.
OStorage order (column or row major).

Definition at line 45 of file layout.hpp.

Compile-time properties

using index_type = I
using batch_size_type = S
using depth_type = D
using layer_stride_type = L
using standard_stride_type
static constexpr StorageOrder storage_order = O
static constexpr bool is_column_major = O == StorageOrder::ColMajor
static constexpr bool is_row_major = O == StorageOrder::RowMajor

Layout description

depth_type depth
index_type rows
index_type cols
index_type outer_stride
batch_size_type batch_size
layer_stride_type layer_stride

Initialization

constexpr Layout (PlainLayout p={})

Classes

struct  PlainLayout

Public Member Functions

constexpr index_type outer_size () const
constexpr index_type inner_size () const
constexpr index_type num_batches () const
constexpr index_type ceil_depth (index_type n) const
 Round up the given size n to a multiple of batch_size.
constexpr index_type ceil_depth () const
 Round up the depth to a multiple of batch_size.
constexpr index_type floor_depth (index_type n) const
 Round down the given size n to a multiple of batch_size.
constexpr index_type floor_depth () const
 Round down the depth to a multiple of batch_size.
constexpr auto get_layer_stride () const
constexpr bool has_full_layer_stride () const
constexpr bool has_full_outer_stride () const
constexpr bool has_full_inner_stride () const
constexpr index_type layer_index (index_type l, index_type s) const
constexpr index_type layer_index (index_type l) const
template<class T>
guanaqo::MatrixView< T, I, standard_stride_type, storage_orderoperator() (T *data, index_type l) const
template<class T>
T & operator() (T *data, index_type l, index_type r, index_type c) const
index_type size () const
 Total number of elements in the view (excluding padding).
index_type padded_size () const

Static Public Member Functions

static standard_stride_type convert_to_standard_stride (auto s)

Class Documentation

◆ batmat::matrix::Layout::PlainLayout

struct batmat::matrix::Layout::PlainLayout
Class Members
depth_type depth = guanaqo::default_stride<depth_type>::value
index_type rows = 0
index_type cols = rows == 0 ? 0 : 1
index_type outer_stride = is_row_major ? cols : rows
batch_size_type batch_size
layer_stride_type layer_stride

Member Typedef Documentation

◆ index_type

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
using batmat::matrix::Layout< I, S, D, L, O >::index_type = I

Definition at line 48 of file layout.hpp.

◆ batch_size_type

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
using batmat::matrix::Layout< I, S, D, L, O >::batch_size_type = S

Definition at line 49 of file layout.hpp.

◆ depth_type

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
using batmat::matrix::Layout< I, S, D, L, O >::depth_type = D

Definition at line 50 of file layout.hpp.

◆ layer_stride_type

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
using batmat::matrix::Layout< I, S, D, L, O >::layer_stride_type = L

Definition at line 51 of file layout.hpp.

◆ standard_stride_type

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
using batmat::matrix::Layout< I, S, D, L, O >::standard_stride_type
Initial value:
std::conditional_t<requires {
S::value;
}, std::integral_constant<index_t, S::value>, index_t>

Definition at line 56 of file layout.hpp.

Constructor & Destructor Documentation

◆ Layout()

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
batmat::matrix::Layout< I, S, D, L, O >::Layout ( PlainLayout< I, S, D, L, O > p = {})
inlineconstexpr

Definition at line 87 of file layout.hpp.

Member Function Documentation

◆ outer_size()

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
index_type batmat::matrix::Layout< I, S, D, L, O >::outer_size ( ) const
inlinenodiscardconstexpr

Definition at line 93 of file layout.hpp.

◆ inner_size()

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
index_type batmat::matrix::Layout< I, S, D, L, O >::inner_size ( ) const
inlinenodiscardconstexpr

Definition at line 94 of file layout.hpp.

◆ num_batches()

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
index_type batmat::matrix::Layout< I, S, D, L, O >::num_batches ( ) const
inlinenodiscardconstexpr

Definition at line 95 of file layout.hpp.

◆ ceil_depth() [1/2]

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
index_type batmat::matrix::Layout< I, S, D, L, O >::ceil_depth ( index_type n) const
inlinenodiscardconstexpr

Round up the given size n to a multiple of batch_size.

Definition at line 101 of file layout.hpp.

◆ ceil_depth() [2/2]

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
index_type batmat::matrix::Layout< I, S, D, L, O >::ceil_depth ( ) const
inlinenodiscardconstexpr

Round up the depth to a multiple of batch_size.

Definition at line 106 of file layout.hpp.

◆ floor_depth() [1/2]

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
index_type batmat::matrix::Layout< I, S, D, L, O >::floor_depth ( index_type n) const
inlinenodiscardconstexpr

Round down the given size n to a multiple of batch_size.

Definition at line 110 of file layout.hpp.

◆ floor_depth() [2/2]

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
index_type batmat::matrix::Layout< I, S, D, L, O >::floor_depth ( ) const
inlinenodiscardconstexpr

Round down the depth to a multiple of batch_size.

Definition at line 115 of file layout.hpp.

◆ get_layer_stride()

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
auto batmat::matrix::Layout< I, S, D, L, O >::get_layer_stride ( ) const
inlinenodiscardconstexpr

Definition at line 118 of file layout.hpp.

◆ has_full_layer_stride()

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
bool batmat::matrix::Layout< I, S, D, L, O >::has_full_layer_stride ( ) const
inlinenodiscardconstexpr

Definition at line 124 of file layout.hpp.

◆ has_full_outer_stride()

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
bool batmat::matrix::Layout< I, S, D, L, O >::has_full_outer_stride ( ) const
inlinenodiscardconstexpr

Definition at line 128 of file layout.hpp.

◆ has_full_inner_stride()

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
bool batmat::matrix::Layout< I, S, D, L, O >::has_full_inner_stride ( ) const
inlinenodiscardconstexpr

Definition at line 131 of file layout.hpp.

◆ layer_index() [1/2]

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
index_type batmat::matrix::Layout< I, S, D, L, O >::layer_index ( index_type l,
index_type s ) const
inlinenodiscardconstexpr

Definition at line 132 of file layout.hpp.

◆ layer_index() [2/2]

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
index_type batmat::matrix::Layout< I, S, D, L, O >::layer_index ( index_type l) const
inlinenodiscardconstexpr

Definition at line 138 of file layout.hpp.

◆ convert_to_standard_stride()

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
standard_stride_type batmat::matrix::Layout< I, S, D, L, O >::convert_to_standard_stride ( auto s)
inlinestatic

Definition at line 142 of file layout.hpp.

◆ operator()() [1/2]

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
template<class T>
guanaqo::MatrixView< T, I, standard_stride_type, storage_order > batmat::matrix::Layout< I, S, D, L, O >::operator() ( T * data,
index_type l ) const
inlinenodiscard

Definition at line 151 of file layout.hpp.

◆ operator()() [2/2]

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
template<class T>
T & batmat::matrix::Layout< I, S, D, L, O >::operator() ( T * data,
index_type l,
index_type r,
index_type c ) const
inlinenodiscard

Definition at line 159 of file layout.hpp.

◆ size()

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
index_type batmat::matrix::Layout< I, S, D, L, O >::size ( ) const
inlinenodiscard

Total number of elements in the view (excluding padding).

Definition at line 165 of file layout.hpp.

◆ padded_size()

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
index_type batmat::matrix::Layout< I, S, D, L, O >::padded_size ( ) const
inlinenodiscard

Definition at line 166 of file layout.hpp.

Member Data Documentation

◆ storage_order

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
StorageOrder batmat::matrix::Layout< I, S, D, L, O >::storage_order = O
staticconstexpr

Definition at line 52 of file layout.hpp.

◆ is_column_major

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
bool batmat::matrix::Layout< I, S, D, L, O >::is_column_major = O == StorageOrder::ColMajor
staticconstexpr

Definition at line 53 of file layout.hpp.

◆ is_row_major

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
bool batmat::matrix::Layout< I, S, D, L, O >::is_row_major = O == StorageOrder::RowMajor
staticconstexpr

Definition at line 54 of file layout.hpp.

◆ depth

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
depth_type batmat::matrix::Layout< I, S, D, L, O >::depth

Definition at line 64 of file layout.hpp.

◆ rows

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
index_type batmat::matrix::Layout< I, S, D, L, O >::rows

Definition at line 65 of file layout.hpp.

◆ cols

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
index_type batmat::matrix::Layout< I, S, D, L, O >::cols

Definition at line 66 of file layout.hpp.

◆ outer_stride

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
index_type batmat::matrix::Layout< I, S, D, L, O >::outer_stride

Definition at line 67 of file layout.hpp.

◆ batch_size

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
batch_size_type batmat::matrix::Layout< I, S, D, L, O >::batch_size

Definition at line 68 of file layout.hpp.

◆ layer_stride

template<class I = index_t, class S = std::integral_constant<I, 1>, class D = I, class L = DefaultStride, StorageOrder O = StorageOrder::ColMajor>
layer_stride_type batmat::matrix::Layout< I, S, D, L, O >::layer_stride

Definition at line 69 of file layout.hpp.


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