Source code for spynnaker.pyNN.models.abstract_models.receives_synaptic_inputs_over_sdram

# Copyright (c) 2020 The University of Manchester
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# See the License for the specific language governing permissions and
# limitations under the License.
from six import add_metaclass
from spinn_utilities.abstract_base import (
    AbstractBase, abstractmethod, abstractproperty)
from spinn_utilities.overrides import overrides
from pacman.model.graphs import AbstractSupportsSDRAMEdges
from pacman.model.graphs.machine import SDRAMMachineEdge
from spinn_front_end_common.utilities.constants import BYTES_PER_SHORT

class ReceivesSynapticInputsOverSDRAM(AbstractSupportsSDRAMEdges):
    An object that receives synaptic inputs over SDRAM.

    The number of neurons to be sent per synapse type is rounded up to be
    a power of 2.  A sender must send N_BYTES_PER_INPUT of data for each
    synapse type for each neuron, formatted as all the data for each neuron
    for the first synapse type, followed by all the data for each neuron
    for the second, and so on for each synapse type.  Each input is an
    accumulated weight value for the timestep, scaled with the given weight

    # The size of each input in bytes

    def weight_scales(self):
        A list of scale factors to be applied to weights that get passed
        over SDRAM, one for each synapse type.

        :rtype: list(int)

    def n_bytes_for_transfer(self):
        The number of bytes to be sent over the channel.  This will be
        calculated using the above numbers, but also rounded up to a number
        of words, and with the number of neurons rounded up to a power of 2.

        :rtype: int

[docs] @abstractmethod @overrides(AbstractSupportsSDRAMEdges.sdram_requirement) def sdram_requirement(self, sdram_machine_edge: SDRAMMachineEdge) -> int: raise NotImplementedError