Skip to content

SparsePropagator

class SparsePropagator

RAII wrapper for cuSPARSE SpMV propagation with prebuilt CSR matrices.

Functions

Name Description
init Initializes the cuSPARSE handle if it has not been created.
destroy Releases allocated matrices and destroys the cuSPARSE handle.
buildCSR Build CSR from (Xn, X, W) triplets.
propagate Propagate preLayer state -> postLayer input using a named CSR.

Function Details

buildCSR

void buildCSR(const thrust::device_vector<int>& X, const thrust::device_vector<int>& Xn, const thrust::device_vector<float>& W, const std::string& name, int num_pre, int num_post, cudaStream_t stream = 0)

Build CSR from (Xn, X, W) triplets. Build CSR from (Xn, X, W) triplets.

X
Presynaptic indices.
Xn
Postsynaptic indices.
W
Connection weights.
name
Key used to reference the built matrix.
num_pre
Number of presynaptic neurons.
num_post
Number of postsynaptic neurons.
stream
CUDA stream for preprocessing.

destroy

void destroy()

Releases allocated matrices and destroys the cuSPARSE handle.

init

void init()

Initializes the cuSPARSE handle if it has not been created.

propagate

template<size_t stateVar, typename PreStateTypes, typename PostStateTypes> void propagate(genericLayer<PreStateTypes>& preLayer, genericLayer<PostStateTypes>& postLayer, const std::string& name, InputBehavior behavior = InputBehavior::INPUT_OVERRIDE, cudaStream_t stream = 0)

Propagate preLayer state -> postLayer input using a named CSR. Propagate preLayer state -> postLayer input using a named CSR.

stateVar
Index of the presynaptic state variable to propagate.
PreStateTypes
Tuple type for the presynaptic layer.
PostStateTypes
Tuple type for the postsynaptic layer.
preLayer
Source layer.
postLayer
Destination layer.
name
Key of the CSR matrix to use.
behavior
Input accumulation behavior.
stream
CUDA stream for the SpMV call.