asgn
 
Loading...
Searching...
No Matches
dcnnsol::strided_conv_layer_base< SPI, SPO, KSP, PP > Struct Template Reference

Utility base class for the convolutional layer. More...

#include <dcnnelements.hpp>

Inheritance diagram for dcnnsol::strided_conv_layer_base< SPI, SPO, KSP, PP >:
dcnnsol::strided_conv_layer< SPI, SPO, KSP, permutation_policy >

Public Types

using CSPI = typename SPI::channel_policy
 
using CSPO = typename SPO::channel_policy
 
Data classes
using input_data = dcnnsol::image_data<SPI, PP>
 Input activations.
 
using weights = dcnnsol::conv_weights<KSP, CSPI, CSPO, PP>
 Model weights.
 
using output_data = dcnnsol::image_data<SPO, PP>
 Output activations.
 
Dimension tags
using height_in_tag = typename SPI::height_tag
 Input image height.
 
using width_in_tag = typename SPI::width_tag
 Input image width.
 
using channel_in_tag = typename SPI::channel_tag
 Input image channel.
 
using kernel_height_tag = typename KSP::kernel_height_tag
 Kernel height.
 
using kernel_width_tag = typename KSP::kernel_width_tag
 Kernel width.
 
using height_out_tag = typename SPO::height_tag
 Output image height.
 
using width_out_tag = typename SPO::width_tag
 Output image width.
 
using channel_out_tag = typename SPO::channel_tag
 Output image channel.
 

Static Public Member Functions

Check functions
static tagged::range_class< batch_tagforward_check (const input_data &ind, const weights &wtd, output_data &outd)
 Check argument compatibility for the forward function.
 

Static Public Attributes

static constexpr std::size_t fanin = khr.size() * kwr.size() * cir.size()
 Number of inputs for each output element.
 
Dimension ranges

Each dimension range allows enumeration of all indexes in that dimension, using the for(:) loop

static constexpr auto hir = SPI::hr
 Input image height range.
 
static constexpr auto wir = SPI::wr
 Input image width range.
 
static constexpr auto cir = SPI::cr
 Input image channel range.
 
static constexpr auto khr = KSP::khr
 Kernel height range.
 
static constexpr auto kwr = KSP::kwr
 Kernel width range.
 
static constexpr auto hor = SPO::hr
 Output image height range.
 
static constexpr auto wor = SPO::wr
 Output image width range.
 
static constexpr auto cor = SPO::cr
 Output image channel range.
 
Stride

Output coordinates are multiplied by HSTRIDE or WSTRIDE before conversion to input coordinates.

static constexpr std::size_t HSTRIDE = hir.size() / hor.size()
 
static constexpr std::size_t WSTRIDE = wir.size() / wor.size()
 
Input-kernel-output index convertors

Each quadruplet of functors serves for a different order of loop nesting, i.e. loops like

for ( auto top_index_value : top_index_range )
{ auto mapping_functor = mf(top_index_value)
for ( auto mid_index_value : rf(top_index_value) )
{
auto bottom_index_value = mapping_functor(mid_index_value);
/*...*/
}
}

Each -rf functor computes a mid-index range from a top-index value. The purpose is to handle clipping of valid index ranges at the borders of the images because output images have the same dimensions as the input images despite being generated by convolution from neighboring values. Thus, the available kernel-index range must be clipped for an output or input index at a border and vice versa.

Each -mf functor produces another functor from a top-index value that converts a mid-index value to a bottom-index value. The produced functor handles the required shifts (and sign changes) that result from the top-index value. In addition, it also handles the fact that kernels are indexed by [0,3) instead of [-1,1].

h- and w- functors work along image heights and widths, respectively.

static constexpr conv_ok_range_functor< tagged::selector< kernel_height_tag >, tagged::selector< height_out_tag >, hir.size(), khr.size(), HSTRIDE > hokrf {}
 output-height index to kernel-height range
 
static constexpr conv_oki_map_functor< tagged::selector< height_in_tag >, tagged::selector< kernel_height_tag >, tagged::selector< height_out_tag >, khr.size(), HSTRIDE > hokimf {}
 output-height index to kernel-height index to input-height index
 
static constexpr conv_ok_range_functor< tagged::selector< kernel_width_tag >, tagged::selector< width_out_tag >, wir.size(), kwr.size(), WSTRIDE > wokrf {}
 output-width index to kernel-width range
 
static constexpr conv_oki_map_functor< tagged::selector< width_in_tag >, tagged::selector< kernel_width_tag >, tagged::selector< width_out_tag >, kwr.size(), WSTRIDE > wokimf {}
 output-width index to kernel-width index to input-width index
 
static constexpr conv_ik_range_functor< tagged::selector< height_in_tag >, tagged::selector< kernel_height_tag >, hir.size(), khr.size(), HSTRIDE > hikrf {}
 input-height index to kernel-height range
 
static constexpr conv_iko_map_functor< tagged::selector< height_in_tag >, tagged::selector< kernel_height_tag >, tagged::selector< height_out_tag >, khr.size(), HSTRIDE > hikomf {}
 input-height index to kernel-height index to output-height index
 
static constexpr conv_ik_range_functor< tagged::selector< width_in_tag >, tagged::selector< kernel_width_tag >, wir.size(), kwr.size(), WSTRIDE > wikrf {}
 input-width index to kernel-width range
 
static constexpr conv_iko_map_functor< tagged::selector< width_in_tag >, tagged::selector< kernel_width_tag >, tagged::selector< width_out_tag >, kwr.size(), WSTRIDE > wikomf {}
 input-width index to kernel-width index to output-width index
 
static constexpr conv_ko_range_functor< tagged::selector< kernel_height_tag >, tagged::selector< height_out_tag >, hir.size(), khr.size(), HSTRIDE > hkorf {}
 kernel-height index to output-height range
 
static constexpr conv_koi_map_functor< tagged::selector< kernel_height_tag >, tagged::selector< height_out_tag >, tagged::selector< height_in_tag >, khr.size(), HSTRIDE > hkoimf {}
 kernel-height index to output-height index to input-height index
 
static constexpr conv_ko_range_functor< tagged::selector< kernel_width_tag >, tagged::selector< width_out_tag >, wir.size(), kwr.size(), WSTRIDE > wkorf {}
 kernel-width index to output-width range
 
static constexpr conv_koi_map_functor< tagged::selector< kernel_width_tag >, tagged::selector< width_out_tag >, tagged::selector< width_in_tag >, kwr.size(), WSTRIDE > wkoimf {}
 kernel-width index to output-width index to input-width index
 

Detailed Description

template<typename SPI, typename SPO, typename KSP, is_policy PP>
struct dcnnsol::strided_conv_layer_base< SPI, SPO, KSP, PP >

Utility base class for the convolutional layer.

Template Parameters
SPIInput size policy
SPOOutput size policy
KSPKernel size policy
PPPermutation policy

Member Function Documentation

◆ forward_check()

template<typename SPI, typename SPO, typename KSP, is_policy PP>
static tagged::range_class< batch_tag > dcnnasgn::strided_conv_layer_base< SPI, SPO, KSP, PP >::forward_check ( const input_data & ind,
const weights & wtd,
output_data & outd )
inlinestatic

Check argument compatibility for the forward function.

Parameters
indInput activations
wtdWeights
outdOutput activations
Returns
The minibatch range

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