GeNN  4.9.0
GPU enhanced Neuronal Networks (GeNN)
InitSparseConnectivitySnippet::Conv2D Class Reference

#include <initSparseConnectivitySnippet.h>

Inheritance diagram for InitSparseConnectivitySnippet::Conv2D:
InitSparseConnectivitySnippet::Base Snippet::Base

Public Member Functions

 DECLARE_SNIPPET (Conv2D, 12)
 
virtual StringVec getParamNames () const override
 Gets names of of (independent) model parameters. More...
 
 SET_ROW_BUILD_STATE_VARS ({{"inRow", "int", "($(id_pre) / (int)$(conv_ic)) / (int)$(conv_iw)"}, {"inCol", "int", "($(id_pre) / (int)$(conv_ic)) % (int)$(conv_iw)"}, {"inChan", "int", "$(id_pre) % (int)$(conv_ic)"}, {"outRow", "int", "min((int)$(conv_oh), max(0, 1 + (int)floor((inRow + $(conv_padh) - $(conv_kh)) / $(conv_sh))))"}, {"maxOutRow", "int", "min((int)$(conv_oh), max(0, 1 + ((inRow + (int)$(conv_padh)) / (int)$(conv_sh))))"}, {"minOutCol", "int", "min((int)$(conv_ow), max(0, 1 + (int)floor((inCol + $(conv_padw) - $(conv_kw)) / $(conv_sw))))"}, {"maxOutCol", "int", "min((int)$(conv_ow), max(0, 1 + ((inCol + (int)$(conv_padw)) / (int)$(conv_sw))))"}})
 
 SET_ROW_BUILD_CODE ("if($(outRow) == $(maxOutRow)) {\ " $(endRow);\" "}\" "const int strideRow=($(outRow) *(int)$(conv_sh)) -(int)$(conv_padh);\" "const int kernRow=$(inRow) - strideRow;\" "for(int outCol=$(minOutCol);outCol< $(maxOutCol);outCol++) {\" " const int strideCol=(outCol *(int)$(conv_sw)) -(int)$(conv_padw);\" " const int kernCol=$(inCol) - strideCol;\" " for(unsigned int outChan=0;outChan<(unsigned int)$(conv_oc);outChan++) {\" " const int idPost=(($(outRow) *(int)$(conv_ow) *(int)$(conv_oc))+\" "(outCol *(int)$(conv_oc))+\" " outChan);\" " $(addSynapse, idPost, kernRow, kernCol, $(inChan), outChan);\" " }\" "}\" "$(outRow)++;\")
 
 SET_CALC_MAX_ROW_LENGTH_FUNC ([](unsigned int, unsigned int, const std::vector< double > &pars) { const double conv_kh=pars[0];const double conv_kw=pars[1];const double conv_sh=pars[2];const double conv_sw=pars[3];const unsigned int conv_oc=(unsigned int) pars[11];return(unsigned int) std::ceil(conv_kh/conv_sh) *(unsigned int) std::ceil(conv_kw/conv_sw) *conv_oc;})
 
 SET_CALC_KERNEL_SIZE_FUNC ([](const std::vector< double > &pars) ->std::vector< unsigned int > { return {(unsigned int) pars[0],(unsigned int) pars[1],(unsigned int) pars[8],(unsigned int) pars[11]};})
 
- Public Member Functions inherited from InitSparseConnectivitySnippet::Base
virtual std::string getRowBuildCode () const
 
virtual ParamValVec getRowBuildStateVars () const
 
virtual std::string getColBuildCode () const
 
virtual ParamValVec getColBuildStateVars () const
 
virtual std::string getHostInitCode () const
 
virtual CalcMaxLengthFunc getCalcMaxRowLengthFunc () const
 Get function to calculate the maximum row length of this connector based on the parameters and the size of the pre and postsynaptic population. More...
 
virtual CalcMaxLengthFunc getCalcMaxColLengthFunc () const
 Get function to calculate the maximum column length of this connector based on the parameters and the size of the pre and postsynaptic population. More...
 
virtual CalcKernelSizeFunc getCalcKernelSizeFunc () const
 Get function to calculate kernel size required for this conenctor based on its parameters. More...
 
boost::uuids::detail::sha1::digest_type getHashDigest () const
 Update hash from snippet. More...
 
void validate () const
 Validate names of parameters etc. More...
 
- Public Member Functions inherited from Snippet::Base
virtual ~Base ()
 
virtual DerivedParamVec getDerivedParams () const
 
virtual EGPVec getExtraGlobalParams () const
 
size_t getExtraGlobalParamIndex (const std::string &paramName) const
 Find the index of a named extra global parameter. More...
 

Additional Inherited Members

- Public Types inherited from InitSparseConnectivitySnippet::Base
typedef std::function< unsigned int(unsigned int, unsigned int, const std::vector< double > &)> CalcMaxLengthFunc
 
typedef std::function< std::vector< unsigned int >const std::vector< double > &)> CalcKernelSizeFunc
 
- Public Types inherited from Snippet::Base
typedef std::vector< std::string > StringVec
 
typedef std::vector< EGPEGPVec
 
typedef std::vector< ParamValParamValVec
 
typedef std::vector< DerivedParamDerivedParamVec
 
- Protected Member Functions inherited from Snippet::Base
void updateHash (boost::uuids::detail::sha1 &hash) const
 
void validate () const
 Validate names of parameters etc. More...
 
- Static Protected Member Functions inherited from Snippet::Base
template<typename T >
static size_t getNamedVecIndex (const std::string &name, const std::vector< T > &vec)
 

Detailed Description

Initialises convolutional connectivity Row build state variables are used to convert presynaptic neuron index to rows, columns and channels and, from these, to calculate the range of postsynaptic rows, columns and channels connections will be made within.

This sparse connectivity snippet does not support multiple threads per neuron

Member Function Documentation

◆ DECLARE_SNIPPET()

InitSparseConnectivitySnippet::Conv2D::DECLARE_SNIPPET ( Conv2D  ,
12   
)

◆ getParamNames()

virtual StringVec InitSparseConnectivitySnippet::Conv2D::getParamNames ( ) const
inlineoverridevirtual

Gets names of of (independent) model parameters.

Reimplemented from Snippet::Base.

◆ SET_CALC_KERNEL_SIZE_FUNC()

InitSparseConnectivitySnippet::Conv2D::SET_CALC_KERNEL_SIZE_FUNC ( [] (const std::vector< double > &pars) ->std::vector< unsigned int > { return {(unsigned int) pars[0],(unsigned int) pars[1],(unsigned int) pars[8],(unsigned int) pars[11]};}  )

◆ SET_CALC_MAX_ROW_LENGTH_FUNC()

InitSparseConnectivitySnippet::Conv2D::SET_CALC_MAX_ROW_LENGTH_FUNC ( [] (unsigned int, unsigned int, const std::vector< double > &pars) { const double conv_kh=pars[0];const double conv_kw=pars[1];const double conv_sh=pars[2];const double conv_sw=pars[3];const unsigned int conv_oc=(unsigned int) pars[11];return(unsigned int) std::ceil(conv_kh/conv_sh) *(unsigned int) std::ceil(conv_kw/conv_sw) *conv_oc;}  )

◆ SET_ROW_BUILD_CODE()

InitSparseConnectivitySnippet::Conv2D::SET_ROW_BUILD_CODE ( )

◆ SET_ROW_BUILD_STATE_VARS()

InitSparseConnectivitySnippet::Conv2D::SET_ROW_BUILD_STATE_VARS ( {{"inRow", "int", "($(id_pre) / (int)$(conv_ic)) / (int)$(conv_iw)"}, {"inCol", "int", "($(id_pre) / (int)$(conv_ic)) % (int)$(conv_iw)"}, {"inChan", "int", "$(id_pre) % (int)$(conv_ic)"}, {"outRow", "int", "min((int)$(conv_oh), max(0, 1 + (int)floor((inRow + $(conv_padh) - $(conv_kh)) / $(conv_sh))))"}, {"maxOutRow", "int", "min((int)$(conv_oh), max(0, 1 + ((inRow + (int)$(conv_padh)) / (int)$(conv_sh))))"}, {"minOutCol", "int", "min((int)$(conv_ow), max(0, 1 + (int)floor((inCol + $(conv_padw) - $(conv_kw)) / $(conv_sw))))"}, {"maxOutCol", "int", "min((int)$(conv_ow), max(0, 1 + ((inCol + (int)$(conv_padw)) / (int)$(conv_sw))))"}}  )

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