Tannic
A C++ Tensor Library
Loading...
Searching...
No Matches
tannic::transformation Namespace Reference

Classes

struct  Composition
 Transformation composition (Known as Matrix Multiplication) operation. More...
 
struct  Concatenation
 Concatenation operation along a specified axis. More...
 
class  Convolution1D
 Expression for 1D convolution operations. More...
 
class  Convolution2D
 Expression for 2D convolution operations. More...
 
struct  Outer
 Represents the outer product operation between two vectors. More...
 
struct  Repack
 Repack operation (makes a tensor contiguous in memory) More...
 
struct  Repetition
 Repetition operation along a specified axis. More...
 
class  Transformation
 Expression template for tensor transformations. More...
 

Functions

template<Expression Signal, Expression Kernel>
constexpr auto convolve1D (Signal &&signal, Kernel &&kernel, std::size_t stride, std::size_t padding)
 Creates a 1D convolution expression with uniform stride and padding.
 
template<Expression Signal, Expression Kernel>
constexpr auto convolve1D (Signal &&signal, Kernel &&kernel, std::array< std::size_t, 1 > strides, std::array< std::size_t, 1 > padding)
 Creates a 1D convolution expression with explicit stride and padding arrays.
 
template<Expression Signal, Expression Kernel>
constexpr auto convolve2D (Signal &&signal, Kernel &&kernel, std::size_t stride, std::size_t padding)
 Creates a 2D convolution expression with uniform stride and padding.
 
template<Expression Signal, Expression Kernel>
constexpr auto convolve2D (Signal &&signal, Kernel &&kernel, std::array< std::size_t, 2 > strides, std::array< std::size_t, 2 > padding)
 Creates a 2D convolution expression with explicit stride and padding arrays.
 
template<Expression Outer, Expression Inner>
constexpr auto composition (Outer &&outer, Inner &&inner, double scale)
 Creates a composition (matrix multiplication) expression.
 
template<Expression First, Expression Second>
constexpr auto outer (First &&first, Second &&second)
 Creates an outer product expression.
 
template<Expression Source>
constexpr auto repeat (Source &&source, int repeats, int axis=0)
 Creates a repetition transformation.
 
template<Expression First, Expression Second>
constexpr auto concatenate (First &&first, Second &&second, int axis=0)
 Helper function to create a concatenation transformation.
 
template<Expression Source>
constexpr auto repack (Source &&source)
 Creates a repack transformation.
 
template<Expression Source, Integral ... Indexes>
constexpr auto reshape (Source &&source, Indexes ... indexes)
 Creates a view but always repacks the tensor into a contiguous layout.
 

Function Documentation

◆ composition()

template<Expression Outer, Expression Inner>
constexpr auto tannic::transformation::composition ( Outer &&  outer,
Inner &&  inner,
double  scale 
)
constexpr

Creates a composition (matrix multiplication) expression.

Template Parameters
OuterOuter tensor expression type
InnerInner tensor expression type
Parameters
outerOuter tensor operand
innerInner tensor operand
Returns
Transformation expression representing the composition

◆ concatenate()

template<Expression First, Expression Second>
constexpr auto tannic::transformation::concatenate ( First &&  first,
Second &&  second,
int  axis = 0 
)
constexpr

Helper function to create a concatenation transformation.

Template Parameters
FirstLeft tensor expression type.
SecondRight tensor expression type.
Parameters
firstLeft tensor operand.
secondRight tensor operand.
axisAxis along which to concatenate.
Returns
Transformation expression representing concatenation.

◆ convolve1D() [1/2]

template<Expression Signal, Expression Kernel>
constexpr auto tannic::transformation::convolve1D ( Signal &&  signal,
Kernel &&  kernel,
std::array< std::size_t, 1 >  strides,
std::array< std::size_t, 1 >  padding 
)
constexpr

Creates a 1D convolution expression with explicit stride and padding arrays.

Template Parameters
SignalInput signal expression type
KernelConvolution kernel expression type
Parameters
signalInput signal tensor operand
kernelConvolution kernel tensor operand
stridesArray of stride values (size = 1)
paddingArray of padding values (size = 1)
Returns
Transformation expression representing the 1D convolution operation
Exceptions
Exceptionif stride is zero

◆ convolve1D() [2/2]

template<Expression Signal, Expression Kernel>
constexpr auto tannic::transformation::convolve1D ( Signal &&  signal,
Kernel &&  kernel,
std::size_t  stride,
std::size_t  padding 
)
constexpr

Creates a 1D convolution expression with uniform stride and padding.

Template Parameters
SignalInput signal expression type
KernelConvolution kernel expression type
Parameters
signalInput signal tensor operand
kernelConvolution kernel tensor operand
strideStride value applied to the signal length
paddingPadding value applied to the signal length
Returns
Transformation expression representing the 1D convolution operation
Exceptions
Exceptionif stride is zero

◆ convolve2D() [1/2]

template<Expression Signal, Expression Kernel>
constexpr auto tannic::transformation::convolve2D ( Signal &&  signal,
Kernel &&  kernel,
std::array< std::size_t, 2 >  strides,
std::array< std::size_t, 2 >  padding 
)
constexpr

Creates a 2D convolution expression with explicit stride and padding arrays.

Template Parameters
SignalInput signal expression type
KernelConvolution kernel expression type
Parameters
signalInput signal tensor operand
kernelConvolution kernel tensor operand
stridesArray of stride values (size = 2: {stride_h, stride_w})
paddingArray of padding values (size = 2: {pad_h, pad_w})
Returns
Transformation expression representing the 2D convolution operation
Exceptions
Exceptionif any stride value is zero

◆ convolve2D() [2/2]

template<Expression Signal, Expression Kernel>
constexpr auto tannic::transformation::convolve2D ( Signal &&  signal,
Kernel &&  kernel,
std::size_t  stride,
std::size_t  padding 
)
constexpr

Creates a 2D convolution expression with uniform stride and padding.

Template Parameters
SignalInput signal expression type
KernelConvolution kernel expression type
Parameters
signalInput signal tensor operand
kernelConvolution kernel tensor operand
strideStride value applied uniformly to both spatial dimensions
paddingPadding value applied uniformly to both spatial dimensions
Returns
Transformation expression representing the 2D convolution operation
Exceptions
Exceptionif stride is zero

◆ outer()

template<Expression First, Expression Second>
constexpr auto tannic::transformation::outer ( First &&  first,
Second &&  second 
)
constexpr

Creates an outer product expression.

Template Parameters
FirstLeft tensor expression type
SecondRight tensor expression type
Parameters
firstLeft tensor operand
secondRight tensor operand
Returns
Transformation expression representing the outer product

◆ repack()

template<Expression Source>
constexpr auto tannic::transformation::repack ( Source &&  source)
constexpr

Creates a repack transformation.

Ensures the tensor is stored contiguously (row-major order). Does not change shape or dtype.

Template Parameters
SourceSource tensor expression type.
Parameters
sourceTensor to be repacked.
Returns
Transformation expression representing repack.

◆ repeat()

template<Expression Source>
constexpr auto tannic::transformation::repeat ( Source &&  source,
int  repeats,
int  axis = 0 
)
constexpr

Creates a repetition transformation.

Template Parameters
SourceSource tensor expression type.
Parameters
sourceTensor to be repeated.
repeatsNumber of repetitions.
axisAxis along which to repeat.
Returns
Transformation expression representing repetition.

◆ reshape()

template<Expression Source, Integral ... Indexes>
constexpr auto tannic::transformation::reshape ( Source &&  source,
Indexes ...  indexes 
)
constexpr

Creates a view but always repacks the tensor into a contiguous layout.

Template Parameters
SourceSource tensor expression type.
Parameters
sourceTensor to be reshaped.
Returns
Transformation expression representing reshape.