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

Expression for 1D convolution operations. More...

#include <convolutions.hpp>

Public Member Functions

constexpr type promote (type signal, type kernel) const
 Type promotion for 1D convolution.
 
constexpr Shape transform (Shape const &signal, Shape const &kernel) const
 Computes output shape for 1D convolution.
 
void forward (Tensor const &signal, Tensor const &kernel, Tensor &result) const
 Performs the forward pass of 1D convolution.
 

Public Attributes

std::array< std::size_t, 1 > strides
 Stride values for the convolution operation.
 
std::array< std::size_t, 1 > padding
 Padding values for the convolution operation.
 

Detailed Description

Expression for 1D convolution operations.

Implements 1D convolution with:

  • Input and kernel dtype validation
  • Automatic output shape calculation
  • Support for strides and padding

Member Function Documentation

◆ forward()

void tannic::transformation::Convolution1D::forward ( Tensor const &  signal,
Tensor const &  kernel,
Tensor result 
) const

Performs the forward pass of 1D convolution.

Parameters
signalInput signal tensor
kernelConvolution kernel tensor
resultOutput tensor to store convolution result

◆ promote()

constexpr type tannic::transformation::Convolution1D::promote ( type  signal,
type  kernel 
) const
inlineconstexpr

Type promotion for 1D convolution.

Requires both signal and kernel to have identical data types.

Parameters
signalData type of the input signal tensor
kernelData type of the kernel tensor
Returns
Data type (same as inputs)
Exceptions
Exceptionif signal and kernel dtypes don't match

◆ transform()

constexpr Shape tannic::transformation::Convolution1D::transform ( Shape const &  signal,
Shape const &  kernel 
) const
inlineconstexpr

Computes output shape for 1D convolution.

Calculates the output shape based on input signal shape, kernel shape, strides, and padding using the standard convolution formula.

Parameters
signalShape of the input signal tensor (N, C_in, L_in)
kernelShape of the kernel tensor (C_out, K_in, K_len)
Returns
Output shape after 1D convolution (N, C_out, L_out)
Exceptions
Exceptionif input ranks are not 3 or channel dimensions don't match

Expected input shapes:

  • Signal: [batch_size, input_channels, signal_length]
  • Kernel: [output_channels, input_channels, kernel_length]
  • Output: [batch_size, output_channels, output_length]

Output length formula: L_out = (L_in + 2*padding - K_len) / stride + 1

Member Data Documentation

◆ padding

std::array<std::size_t, 1> tannic::transformation::Convolution1D::padding

Padding values for the convolution operation.

◆ strides

std::array<std::size_t, 1> tannic::transformation::Convolution1D::strides

Stride values for the convolution operation.


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