calix.hagen.multiplication.Multiplication
-
class
calix.hagen.multiplication.
Multiplication
(synram: pyhalco_hicann_dls_vx_v3.SynramOnDLS = SynramOnDLS(0), *, num_sends: int = 1, wait_period: int = 4, signed_mode: bool = True) Bases:
object
Handles multiplication of vector and matrix with integration on the synaptic input lines.
Requirements: * CADCs are calibrated and connected to the neuron readout. You can
use calix.common.cadc.calibrate() and calix.hagen.neuron_helpers.configure_chip() to achieve this.
Synapse DAC bias is calibrated.
Synapse drivers are calibrated.
- Variables
synram_selection_bit – Position of bit in event label that selects whether an SPL1 event reaches the top or bottom synram. You can choose one of bits 11 to 13 (default).
_synram_coord – Coordinate of synapse array to use.
num_sends – Number of sends of the vector, values greater than one indicate repetitions of the input events.
wait_period – Number of clock cycles to wait between events.
signed_mode – Decide whether the multiplication is using signed weights. This affects the shape of the matrix: in unsigned mode, i.e. signed_mode = False, weights are shaped (256, 256). If using signed weights, the shape is reduced to (128, 256), i.e. 256 inputs are mapped to 128 results.
cached_reset_synin – Cached builder containing instructions to reset synaptic input lines. Contains a call to reset_synin().
-
__init__
(synram: pyhalco_hicann_dls_vx_v3.SynramOnDLS = SynramOnDLS(0), *, num_sends: int = 1, wait_period: int = 4, signed_mode: bool = True) Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
([synram, num_sends, wait_period, …])Initialize self.
auto_multiply
(connection, vectors, matrix, *)Multiply given vectors with the given matrix.
configure_for_integration
(config)Set static configuration for integration on excitatory synaptic input lines.
get_synapse_matrix
(matrix)Return a suitable lola SynapseMatrix depending on the requested weights.
multiply
(connection, vectors, matrix)Multiply given vectors with the given matrix, return results.
preconfigure
(connection)Configure synapse drivers, neurons, crossbar and external DAC.
preconfigure_crossbar
(builder)Configure the crossbar such that the upper bits in an event label select target hemisphere and PADI bus.
preconfigure_dac
(builder)Connect the external DAC to the synapse debug lines, supplying a voltage of 1.2 V.
reset_synin
(builder)Connect synapse lines to the debug lines shortly.
Attributes
Get the synram to perform MAC operations on.
-
auto_multiply
(connection: pyhxcomm_vx.ConnectionHandle, vectors: numpy.ndarray, matrix: numpy.ndarray, *, n_row_repeats: Union[int, str] = 1) → numpy.ndarray Multiply given vectors with the given matrix.
Handle input shape of the matrix automatically, i.e. split large matrices (containing many inputs) up into multiple runs or repeat small matrices multiple times in order to increase signal. The outer dimension (i.e. number of outputs) has to fit on the width of the synapse array, it is not handled here.
- Parameters
connection – Connection to the chip to run on.
vectors – Array of vectors to be multiplied. We expect row vectors, with the inner dimension (columns) holding the individual entries of each vector.
matrix – Weight matrix to be multiplied.
n_row_repeats – Number of repetitions of the weight matrix. In contrast to vector resends, the matrix rows are repeated, which also compensates fixed-pattern noise. Defaults to 1. Select “auto” to fill up the synapse array with a small matrix.
- Returns
Numpy array with the result of multiplication.
-
static
configure_for_integration
(config: pylola_vx_v3.AtomicNeuron) → None Set static configuration for integration on excitatory synaptic input lines.
- Parameters
config – Configuration container to be altered.
-
get_synapse_matrix
(matrix: numpy.ndarray) → pylola_vx_v3.SynapseMatrix Return a suitable lola SynapseMatrix depending on the requested weights.
- Parameters
matrix – Weight matrix as a numpy array.
- Returns
lola.SynapseMatrix with addresses and weights set.
-
multiply
(connection: pyhxcomm_vx.ConnectionHandle, vectors: numpy.ndarray, matrix: numpy.ndarray) → numpy.ndarray Multiply given vectors with the given matrix, return results.
The matrix shape has to match the synapse array exactly, there is no splitting or merging of matrix shapes.
- Parameters
connection – Connection to the chip to run on.
vectors – Array of vectors to be multiplied. We expect row vectors, with the inner dimension (columns) holding the individual entries of each vector.
matrix – Array of weights.
- Returns
Array of results of the MAC operation.
-
preconfigure
(connection: pyhxcomm_vx.ConnectionHandle) → None Configure synapse drivers, neurons, crossbar and external DAC.
The previously configured hagen dac offsets and STP ramp offsets are kept unchanged.
- Parameters
connection – Connection to the chip to run on.
-
classmethod
preconfigure_crossbar
(builder: calix.common.base.WriteRecordingPlaybackProgramBuilder) → None Configure the crossbar such that the upper bits in an event label select target hemisphere and PADI bus. Also enable SPL1 events in the PADI buses.
- Parameters
builder – Builder to append instructions to.
-
static
preconfigure_dac
(builder: calix.common.base.WriteRecordingPlaybackProgramBuilder) → None Connect the external DAC to the synapse debug lines, supplying a voltage of 1.2 V.
The potential will be used for resetting potentials on the synapse lines before integration.
- Parameters
builder – Builder to append instructions to.
-
reset_synin
(builder: calix.common.base.WriteRecordingPlaybackProgramBuilder) Connect synapse lines to the debug lines shortly.
The switches for excitatory and inhibitory synaptic currents are enabled.
- Parameters
builder – Builder to append instructions to.
-
property
synram_coord
Get the synram to perform MAC operations on.
-
synram_selection_bit
= 13