bitorch_engine.layers.qconv.binary.cpp.layer.BinaryConv2dForward
- class bitorch_engine.layers.qconv.binary.cpp.layer.BinaryConv2dForward(*args, **kwargs)[source]
A custom autograd function to perform forward pass of a 2D binary convolution.
This class implements a static method forward to carry out the convolution operation using binary weights and activations. The operation is performed using a custom C++ backend for efficiency.
- - No class-level attributes.
- - forward
Performs the forward pass of the binary convolution.
Methods
Forward pass for the 2D binary convolution.
Attributes
- static forward(ctx, activations: Tensor, weights: Tensor, m: int, n: int, k: int, kernel_size: int, stride: int, padding: int, dilation: int, output_edge: int) Tensor [source]
Forward pass for the 2D binary convolution.
Utilizes a C++ backend implemented in binary_conv_cpp.forward to perform the operation. This method is statically defined and automatically integrated with PyTorch’s autograd mechanism.
- Parameters:
ctx (-) – Context object that can be used to stash information for backward computation. You can cache arbitrary objects for use in the backward pass using the save_for_backward method.
activations (-) – The input feature map or activation tensor.
weights (-) – The binary weights tensor.
m (-) – Dimensions of the input, specifically: - m: The number of output channels. - n: The number of input channels. - k: The spatial size of the output feature map.
n (int) – Dimensions of the input, specifically: - m: The number of output channels. - n: The number of input channels. - k: The spatial size of the output feature map.
k (int) – Dimensions of the input, specifically: - m: The number of output channels. - n: The number of input channels. - k: The spatial size of the output feature map.
kernel_size (-) – Size of the conv kernel.
stride (-) – Stride of the convolution.
padding (-) – Zero-padding added to both sides of the input.
dilation (-) – Spacing between kernel elements.
output_edge (-) – The size of the output edge to ensure the output dimension matches expectations.
- Returns:
The output feature map resulting from the binary convolution operation.
- Return type:
Tensor
Note
This method is part of the forward pass and needs to be paired with a corresponding backward method to enable gradient computation.