Tannic
A C++ Tensor Library
|
Expression for 2D convolution operations. More...
#include <convolutions.hpp>
Public Member Functions | |
constexpr type | promote (type signal, type kernel) const |
Type promotion for 2D convolution. | |
constexpr Shape | transform (Shape const &signal, Shape const &kernel) const |
Computes output shape for 2D convolution. | |
void | forward (Tensor const &signal, Tensor const &kernel, Tensor &result) const |
Performs the forward pass of 2D convolution. | |
Public Attributes | |
std::array< std::size_t, 2 > | strides |
Stride values for height and width dimensions. | |
std::array< std::size_t, 2 > | padding |
Padding values for height and width dimensions. | |
Expression for 2D convolution operations.
Implements 2D convolution with:
void tannic::transformation::Convolution2D::forward | ( | Tensor const & | signal, |
Tensor const & | kernel, | ||
Tensor & | result | ||
) | const |
Performs the forward pass of 2D convolution.
signal | Input signal tensor |
kernel | Convolution kernel tensor |
result | Output tensor to store convolution result |
|
inlineconstexpr |
Type promotion for 2D convolution.
Requires both signal and kernel to have identical data types.
signal | Data type of the input signal tensor |
kernel | Data type of the kernel tensor |
Exception | if signal and kernel dtypes don't match |
|
inlineconstexpr |
Computes output shape for 2D convolution.
Calculates the output shape based on input signal shape, kernel shape, strides, and padding using the standard 2D convolution formula.
signal | Shape of the input signal tensor (N, C_in, H_in, W_in) |
kernel | Shape of the kernel tensor (C_out, K_in, K_h, K_w) |
Exception | if input ranks are not 4 or channel dimensions don't match |
Expected input shapes:
Output dimension formulas:
std::array<std::size_t, 2> tannic::transformation::Convolution2D::padding |
Padding values for height and width dimensions.
std::array<std::size_t, 2> tannic::transformation::Convolution2D::strides |
Stride values for height and width dimensions.