pub struct ConvolutionDescriptor {
pub padding: Vec<u32>,
pub stride: Vec<u32>,
pub dilation: Vec<u32>,
pub groups: u32,
}Expand description
Describes a convolution operation’s hyper-parameters.
All vectors are indexed by spatial dimension (e.g. for 2-D convolutions they have length 2, for 3-D length 3).
Fields§
§padding: Vec<u32>Zero-padding applied to each spatial dimension (symmetric).
stride: Vec<u32>Stride of the convolution kernel in each spatial dimension.
dilation: Vec<u32>Dilation factor in each spatial dimension.
groups: u32Number of groups for grouped/depthwise convolution.
Implementations§
Source§impl ConvolutionDescriptor
impl ConvolutionDescriptor
Sourcepub fn conv2d(
pad_h: u32,
pad_w: u32,
stride_h: u32,
stride_w: u32,
dilation_h: u32,
dilation_w: u32,
groups: u32,
) -> DnnResult<Self>
pub fn conv2d( pad_h: u32, pad_w: u32, stride_h: u32, stride_w: u32, dilation_h: u32, dilation_w: u32, groups: u32, ) -> DnnResult<Self>
Creates a standard 2-D convolution descriptor.
§Errors
Returns DnnError::InvalidArgument if stride or dilation contains
a zero value, or if groups is zero.
Sourcepub fn spatial_dims(&self) -> usize
pub fn spatial_dims(&self) -> usize
Returns the number of spatial dimensions this descriptor covers.
Sourcepub fn output_size(
input: u32,
kernel: u32,
pad: u32,
stride: u32,
dilation: u32,
) -> DnnResult<u32>
pub fn output_size( input: u32, kernel: u32, pad: u32, stride: u32, dilation: u32, ) -> DnnResult<u32>
Computes the output spatial size for a single dimension.
Formula: floor((input + 2*pad - dilation*(kernel-1) - 1) / stride) + 1
§Errors
Returns DnnError::InvalidDimension if the computation underflows
(i.e. the kernel is too large for the padded input).
Trait Implementations§
Source§impl Clone for ConvolutionDescriptor
impl Clone for ConvolutionDescriptor
Source§fn clone(&self) -> ConvolutionDescriptor
fn clone(&self) -> ConvolutionDescriptor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more