spynnaker.pyNN.models.neuron package

Subpackages

Submodules

spynnaker.pyNN.models.neuron.key_space_tracker module

class spynnaker.pyNN.models.neuron.key_space_tracker.KeySpaceTracker[source]

Bases: pacman.utilities.algorithm_utilities.element_allocator_algorithm.ElementAllocatorAlgorithm

Tracks keys used to determine key overlap

allocate_keys(r_info)[source]
Allocate all the keys in the routing information
NOTE assumes masks are all 1s followed by all 0s
Parameters:r_info (PartitionRoutingInfo) – The routing information to add
static count_trailing_0s(mask)[source]
Count bitwise zeros at the LSB end of a number
NOTE assumes a 32-bit number
Parameters:mask – The mask to be checked
is_allocated(key, n_keys)[source]
Determine if any of the keys in the mask are allocated
NOTE assumes mask is all 1s followed by all 0s
Parameters:
  • key (int) – The key at the start of the allocation
  • n_keys (int) – The number of keys to check
Return type:

bool

spynnaker.pyNN.models.neuron.master_pop_table module

class spynnaker.pyNN.models.neuron.master_pop_table.MasterPopTableAsBinarySearch[source]

Bases: object

Master population table, implemented as binary search master.

MAX_ROW_LENGTH_ERROR_MSG = 'Only rows of up to 256 entries are allowed'
OUT_OF_RANGE_ERROR_MESSAGE = 'Address {} is out of range for this population table!'
UPPER_BOUND_FUDGE = 2
add_application_entry(block_start_addr, row_length, key_and_mask, core_mask, core_shift, n_neurons)[source]

Add an entry for an application-edge to the population table.

Parameters:
  • block_start_addr (int) – where the synaptic matrix block starts
  • row_length (int) – how long in words each row is
  • key_and_mask (BaseKeyAndMask) – the key and mask for this master pop entry
  • core_mask (int) – Mask for the part of the key that identifies the core
  • core_shift (int) – The shift of the mask to get to the core_mask
  • n_neurons (int) – The number of neurons in each machine vertex (bar the last)
  • is_single (bool) – Flag that states if the entry is a direct entry for a single row.
Returns:

The index of the entry, to be used to retrieve it

Return type:

int

Raises:

SynapticConfigurationException – If a bad address is used.

add_invalid_entry(key_and_mask, core_mask=0, core_shift=0, n_neurons=0)[source]
Add an entry to the table that doesn’t point to anywhere. Used
to keep indices in synchronisation between e.g. normal and delay entries and between entries on different cores.
Parameters:
  • key_and_mask (BaseKeyAndMask) – a key_and_mask object used as part of describing an edge that will require being received to be stored in the master pop table; the whole edge will become multiple calls to this function
  • core_mask (int) – Mask for the part of the key that identifies the core
  • core_shift (int) – The shift of the mask to get to the core_mask
  • n_neurons (int) – The number of neurons in each machine vertex (bar the last)
Returns:

The index of the added entry

Return type:

int

add_machine_entry(block_start_addr, row_length, key_and_mask, is_single=False)[source]

Add an entry for a machine-edge to the population table.

Parameters:
  • block_start_addr (int) – where the synaptic matrix block starts
  • row_length (int) – how long in words each row is
  • key_and_mask (BaseKeyAndMask) – the key and mask for this master pop entry
  • is_single (bool) – Flag that states if the entry is a direct entry for a single row.
Returns:

The index of the entry, to be used to retrieve it

Return type:

int

Raises:

SynapticConfigurationException – If a bad address is used.

finish_master_pop_table(spec, master_pop_table_region)[source]

Complete the master pop table in the data specification.

Parameters:
  • spec (DataSpecificationGenerator) – the data specification to write the master pop entry to
  • master_pop_table_region (int) – the region to which the master pop table is being stored
get_allowed_row_length(row_length)[source]
Parameters:row_length (int) – the row length being considered
Returns:the row length available
Return type:int
Raises:SynapseRowTooBigException – If the row won’t fit
get_master_population_table_size(in_edges)[source]

Get the size of the master population table in SDRAM.

Parameters:in_edges (iterable(ApplicationEdge)) – The edges arriving at the vertex that are to be handled by this table
Returns:the size the master pop table will take in SDRAM (in bytes)
Return type:int
get_next_allowed_address(next_address)[source]

Get the next allowed address.

Parameters:next_address (int) – The next address that would be used
Returns:The next address that can be used following next_address
Return type:int
Raises:SynapticConfigurationException – if the address is out of range
initialise_table()[source]

Initialise the master pop data structure.

max_core_mask

The maximum core mask supported when n_neurons is > 0; this is the maximum number of cores that can be supported in a joined mask.

Return type:int
max_index

The maximum index of a synaptic connection

Return type:int
max_n_neurons_per_core

The maximum number of neurons per core supported when a core-mask is > 0.

Return type:int
write_padding(spec, next_block_start_address)[source]

Write padding to the data spec needed between blocks to align addresses correctly.

Parameters:
Returns:

The address we finish at after the padding

Return type:

int

spynnaker.pyNN.models.neuron.synapse_io module

class spynnaker.pyNN.models.neuron.synapse_io.MaxRowInfo(undelayed_max_n_synapses, delayed_max_n_synapses, undelayed_max_bytes, delayed_max_bytes, undelayed_max_words, delayed_max_words)[source]

Bases: object

Information about the maximums for rows in a synaptic matrix.

Parameters:
  • undelayed_max_n_synapses (int) – Maximum number of synapses in a row of the undelayed matrix
  • delayed_max_n_synapses (int) – Maximum number of synapses in a row of the delayed matrix
  • undelayed_max_bytes (int) – Maximum number of bytes, including headers, in a row of the undelayed matrix, or 0 if no synapses
  • delayed_max_bytes (int) – Maximum number of bytes, including headers, in a row of the delayed matrix, or 0 if no synapses
  • undelayed_max_words (int) – Maximum number of words, excluding headers, in a row of the undelayed matrix
  • delayed_max_words (int) – Maximum number of words, excluding headers, in a row of the delayed matrix
delayed_max_bytes

Maximum number of bytes, including headers, in a row of the delayed matrix

Return type:int
delayed_max_n_synapses

Maximum number of synapses in a row of the delayed matrix

Return type:int
delayed_max_words

Maximum number of words, excluding headers, in a row of the undelayed matrix

Return type:int
undelayed_max_bytes

Maximum number of bytes, including headers, in a row of the undelayed matrix

Return type:int
undelayed_max_n_synapses

Maximum number of synapses in a row of the undelayed matrix

Return type:int
undelayed_max_words

Maximum number of words, excluding headers, in a row of the undelayed matrix

Return type:int
class spynnaker.pyNN.models.neuron.synapse_io.SynapseIORowBased[source]

Bases: object

A SynapseRowIO implementation that uses a row for each source neuron, where each row consists of a fixed region, a plastic region, and a fixed-plastic region (this is the bits of the plastic row that don’t actually change). The plastic region structure is determined by the synapse dynamics of the connector.

convert_to_connections(synapse_info, pre_vertex_slice, post_vertex_slice, max_row_length, n_synapse_types, weight_scales, data, delayed, post_vertex_max_delay_ticks)[source]

Read the synapses for a given projection synapse information object out of the given data and convert to connection data

Parameters:
  • synapse_info (SynapseInformation) – The synapse information of the synapses
  • pre_vertex_slice (Slice) – The slice of the source neurons of the synapses in the data
  • post_vertex_slice (Slice) – The slice of the target neurons of the synapses in the data
  • max_row_length (int) – The length of each row in the data
  • n_synapse_types (int) – The number of synapse types in total
  • weight_scales (list(float)) – The weight scaling of each synapse type
  • data (bytearray) – The raw data containing the synapses
  • delayed (bool) – True if the data should be considered delayed
  • post_vertex_max_delay_ticks (int) – max delayed ticks supported from post vertex
Returns:

The connections read from the data; the dtype is AbstractSynapseDynamics.NUMPY_CONNECTORS_DTYPE

Return type:

ndarray

get_block_n_bytes(max_row_n_words, n_rows)[source]

Get the number of bytes in a block

Parameters:
  • max_row_n_words (int) – The maximum row length in words, excluding headers
  • n_rows (int) – The number of rows in the block
Return type:

int

get_max_row_info(synapse_info, post_vertex_slice, n_delay_stages, population_table, in_edge)[source]

Get the information about the maximum lengths of delayed and undelayed rows in bytes (including header), words (without header) and number of synapses

Parameters:
  • synapse_info (SynapseInformation) – The synapse information to get the row data for
  • post_vertex_slice (Slice) – The slice of the machine vertex being represented
  • n_delay_stages (int) – The number of delay stages on the edge
  • population_table (MasterPopTableAsBinarySearch) – The population table to be used
  • in_edge (ProjectionApplicationEdge) – The incoming edge on which the synapse information is held
Return type:

MaxRowInfo

Raises:

SynapseRowTooBigException – If the synapse information can’t be represented

get_maximum_delay_supported_in_ms(post_vertex_max_delay_ticks)[source]

Get the maximum delay supported by the synapse representation before extensions are required, or None if any delay is supported

Parameters:post_vertex_max_delay_ticks (int) – post vertex max delay
Return type:int
get_synapses(synapse_info, n_delay_stages, n_synapse_types, weight_scales, machine_edge, max_row_info, gen_undelayed, gen_delayed, app_edge)[source]

Get the synapses as an array of words for non-delayed synapses and an array of words for delayed synapses. This is used to prepare information for deployment to SpiNNaker.

Parameters:
  • synapse_info (SynapseInformation) – The synapse information to convert to synapses
  • n_delay_stages (int) – The number of delay stages in total to be represented
  • n_synapse_types (int) – The number of synapse types in total to be represented
  • weight_scales (list(float)) – The scaling of the weights for each synapse type
  • machine_edge (MachineEdge) – The incoming machine edge that the synapses are on
  • app_edge (ProjectionApplicationEdge) –
  • max_row_info (MaxRowInfo) – The maximum row information for the synapses
  • gen_undelayed (bool) – Whether to generate undelayed data
  • gen_delayed (bool) – Whether to generate delayed data
Returns:

(row_data, delayed_row_data, delayed_source_ids, stages) where:

  • row_data is the undelayed connectivity data arranged into a
    row per source, each row the same length
  • delayed_row_data is the delayed connectivity data arranged
    into a row per source per delay stage, each row the same length
  • delayed_source_ids is the machine-vertex-local source neuron
    id of each connection of the delayed vertices
  • stages is the delay stage of each delayed connection

Return type:

tuple(ndarray, ndarray, ndarray, ndarray)

read_all_synapses(data, delayed_data, synapse_info, n_synapse_types, weight_scales, machine_edge, max_row_info)[source]

Read the synapses for a given projection synapse information object out of the given delayed and undelayed data.

Parameters:
  • data (bytearray) – The raw data containing the undelayed synapses
  • delayed_data (bytearray) – The raw data containing the delayed synapses
  • synapse_info (SynapseInformation) – The synapse info that generated the synapses
  • n_synapse_types (int) – The total number of synapse types available
  • weight_scales (list(float)) – A weight scale for each synapse type
  • machine_edge (MachineEdge) – The incoming machine edge that the synapses were generated from
  • max_row_info (MaxRowInfo) – The maximum information for each of the rows
Returns:

The connections read from the data; the dtype is AbstractSynapseDynamics.NUMPY_CONNECTORS_DTYPE

Return type:

ndarray

spynnaker.pyNN.models.neuron.synaptic_matrices module

class spynnaker.pyNN.models.neuron.synaptic_matrices.SynapticMatrices(post_vertex_slice, n_synapse_types, all_single_syn_sz, synapse_io, synaptic_matrix_region, direct_matrix_region, poptable_region)[source]

Bases: object

Handler of synaptic matrices for a core of a population vertex

Parameters:
  • post_vertex_slice (Slice) – The slice of the post vertex that these matrices are for
  • n_synapse_types (int) – The number of synapse types available
  • all_single_syn_sz (int) – The space available for “direct” or “single” synapses
  • synapse_io (SynapseIORowBased) – How to read and write synapses
  • synaptic_matrix_region (int) – The region where synaptic matrices are stored
  • direct_matrix_region (int) – The region where “direct” or “single” synapses are stored
  • poptable_region (int) – The region where the population table is stored
clear_connection_cache()[source]

Clear any values read from the machine

gen_on_machine

Whether any matrices need to be generated on the machine

Return type:bool
get_connections_from_machine(transceiver, placement, app_edge, synapse_info)[source]

Get the synaptic connections from the machine

Parameters:
Returns:

A list of arrays of connections, each with dtype AbstractSynapseDynamics.NUMPY_CONNECTORS_DTYPE

Return type:

ndarray

get_index(app_edge, synapse_info, machine_edge)[source]

Get the index of an incoming projection in the population table

Parameters:
host_generated_block_addr

The address within the synaptic region after the last block written by the on-host synaptic generation

on_chip_generated_block_addr

The address within the synaptic region after the last block reserved for the on-machine synaptic generation

read_generated_connection_holders(transceiver, placement)[source]
Fill in any pre-run connection holders for data which is generated
on the machine, after it has been generated
Parameters:
  • transceiver (Transceiver) – How to read the data from the machine
  • placement (Placement) – where the data is to be read from
size(app_edges)[source]

The size required by all parts of the matrices

Parameters:app_edges (iterable(ApplicationEdge)) – The incoming application edges
Return type:int
synapses_size(app_edges)[source]

The size of the synaptic blocks in bytes

Parameters:app_edges (iterable(ApplicationEdge)) – The incoming application edges
Return type:int
write_synaptic_matrix_and_master_population_table(spec, machine_vertex, all_syn_block_sz, weight_scales, routing_info, machine_graph)[source]
Simultaneously generates both the master population table and
the synaptic matrix.
Parameters:
  • spec (DataSpecificationGenerator) – The spec to write to
  • machine_vertex (MachineVertex) – The machine vertex to write for
  • all_syn_block_sz (int) – The size in bytes of the space reserved for synapses
  • weight_scales (list(float)) – The weight scale of each synapse
  • routing_info (RoutingInfo) – The routing information for all edges
  • machine_graph (MachineGraph) – The machine graph
Returns:

A list of generator data to be written elsewhere

Return type:

list(GeneratorData)

spynnaker.pyNN.models.neuron.synaptic_matrix module

class spynnaker.pyNN.models.neuron.synaptic_matrix.SynapticMatrix(synapse_io, poptable, synapse_info, machine_edge, app_edge, n_synapse_types, max_row_info, routing_info, delay_routing_info, weight_scales, all_syn_block_sz, all_single_syn_sz)[source]

Bases: object

Synaptic matrix/matrices for an incoming machine edge

Parameters:
  • synapse_io (SynapseIORowBased) – The reader and writer of synapses
  • poptable (MasterPopTableAsBinarySearch) – The master population table
  • synapse_info (SynapseInformation) – The projection synapse information
  • machine_edge (MachineEdge) – The projection machine edge
  • app_edge (ProjectionApplicationEdge) – The projection application edge
  • n_synapse_types (int) – The number of synapse types accepted
  • max_row_info (MaxRowInfo) – Maximum row length information
  • routing_info (PartitionRoutingInfo) – Routing information for the edge
  • delay_routing_info (PartitionRoutingInfo) – Routing information for the delay edge if any
  • weight_scales (list(float)) – Weight scale for each synapse type
  • all_syn_block_sz – The space available for all synaptic matrices
  • all_single_syn_sz (int) – The space available for “direct” or “single” synapses
clear_connection_cache()[source]

Clear the saved connections

delay_index

The index of the delayed matrix within the master population table

Return type:int
get_generator_data(syn_mat_offset, d_mat_offset, max_delay_per_stage)[source]

Get the generator data for this matrix

Parameters:
  • syn_mat_offset (int) – The synaptic matrix offset to write the data to
  • d_mat_offset (int) – The synaptic matrix offset to write the delayed data to
  • max_delay_per_stage (int) – around of timer ticks each delay stage holds.
Return type:

GeneratorData

get_row_data()[source]

Generate the row data for a synaptic matrix from the description

Returns:The data and the delayed data
Return type:tuple(ndarray or None, ndarray or None)
index

The index of the matrix within the master population table

Return type:int
is_delayed

Is there a delay matrix?

Return type:bool
is_direct(single_addr)[source]

Determine if the given connection can be done with a “direct” synaptic matrix - this must have an exactly 1 entry per row

Parameters:single_addr (int) – The current offset of the direct matrix
Returns:A tuple of a boolean indicating if the matrix is direct and the next offset of the single matrix
Return type:(bool, int)
next_app_delay_on_chip_address(app_block_addr, max_app_addr)[source]

Allocate a machine-level address of a delayed matrix from within an app-level allocation

Parameters:
  • app_block_addr (int) – The current position in the application block
  • max_app_addr (int) – The position of the end of the allocation
Returns:

The address after the allocation and the allocated address

Return type:

int, int

next_app_on_chip_address(app_block_addr, max_app_addr)[source]

Allocate a machine-level address of a matrix from within an app-level allocation

Parameters:
  • app_block_addr (int) – The current position in the application block
  • max_app_addr (int) – The position of the end of the allocation
Returns:

The address after the allocation and the allocated address

Return type:

int, int

next_delay_on_chip_address(block_addr)[source]

Allocate an address for a delayed machine matrix and add it to the population table

Parameters:block_addr (int) – The address at which to start the allocation
Returns:The address after the allocation and the allocated address
Return type:int, int
next_on_chip_address(block_addr)[source]

Allocate an address for a machine matrix and add it to the population table

Parameters:block_addr (int) – The address at which to start the allocation
Returns:The address after the allocation and the allocated address
Return type:int, int
read_connections(transceiver, placement, synapses_address, single_address)[source]

Read the connections from the machine

Parameters:
  • transceiver (Transceiver) – How to read the data from the machine
  • placement (Placement) – Where the matrix is on the machine
  • synapses_address (int) – The base address of the synaptic matrix region
  • single_address (int) – The base address of the “direct” or “single” matrix region
Returns:

A list of arrays of connections, each with dtype AbstractSynapseDynamics.NUMPY_CONNECTORS_DTYPE

Return type:

ndarray

write_delayed_machine_matrix(spec, block_addr, row_data)[source]

Write a delayed matrix for an incoming machine vertex

Parameters:
  • spec (DataSpecificationGenerator) – The specification to write to
  • block_addr (int) – The address in the synaptic matrix region to start writing at
  • row_data (ndarray) – The data to write
Returns:

The updated block address

Return type:

int

write_machine_matrix(spec, block_addr, single_synapses, single_addr, row_data)[source]

Write a matrix for the incoming machine vertex

Parameters:
  • spec (DataSpecificationGenerator) – The specification to write to
  • block_addr (int) – The address in the synaptic matrix region to start writing at
  • single_addr (int) – The address in the “direct” or “single” matrix to start at
  • single_synapses (list) – A list of “direct” or “single” synapses to write to
  • row_data (ndarray) – The data to write
Returns:

The updated block and single addresses

Return type:

tuple(int, int)

spynnaker.pyNN.models.neuron.synaptic_matrix_app module

class spynnaker.pyNN.models.neuron.synaptic_matrix_app.SynapticMatrixApp(synapse_io, poptable, synapse_info, app_edge, n_synapse_types, all_single_syn_sz, post_vertex_slice, synaptic_matrix_region, direct_matrix_region)[source]

Bases: object

The synaptic matrix (and delay matrix if applicable) for an incoming app edge

Parameters:
  • synapse_io (SynapseIORowBased) – The reader and writer of synapses
  • poptable (MasterPopTableAsBinarySearch) – The master population table
  • synapse_info (SynapseInformation) – The projection synapse information
  • app_edge (ProjectionApplicationEdge) – The projection application edge
  • n_synapse_types (int) – The number of synapse types accepted
  • all_single_syn_sz (int) – The space available for “direct” or “single” synapses
  • post_vertex_slice (Slice) – The slice of the post-vertex the matrix is for
  • synaptic_matrix_region (int) – The region where synaptic matrices are stored
  • direct_matrix_region (int) – The region where “direct” or “single” synapses are stored
add_delayed_matrix_size(addr)[source]

Add the bytes required by the delayed synaptic matrices

Parameters:addr (int) – The initial address
Returns:The final address after adding synapses
Return type:int
add_matrix_size(addr)[source]

Add the bytes required by the synaptic matrices

Parameters:addr (int) – The initial address
Returns:The final address after adding synapses
Return type:int
can_generate_on_machine(single_addr)[source]

Determine if an app edge can be generated on the machine

Parameters:single_addr (int) – The address for “direct” or “single” synapses so far
Return type:bool
clear_connection_cache()[source]

Clear saved connections

generator_info_size

The number of bytes required by the generator information

Return type:int
get_connections(transceiver, placement)[source]

Get the connections for this matrix from the machine

Parameters:
  • transceiver (Transceiver) – How to read the data from the machine
  • placement (Placement) – Where the matrix is on the machine
Returns:

A list of arrays of connections, each with dtype AbstractSynapseDynamics.NUMPY_CONNECTORS_DTYPE

Return type:

ndarray

get_delay_index(machine_edge)[source]
Get the index in the master population table of the delayed matrix
for a machine edge
Parameters:machine_edge (MachineEdge) – The edge to get the index for
Return type:int
get_index(machine_edge)[source]
Get the index in the master population table of the matrix for a
machine edge
Parameters:machine_edge (MachineEdge) – The edge to get the index for
Return type:int
read_generated_connection_holders(transceiver, placement)[source]

Read any pre-run connection holders after data has been generated

Parameters:
  • transceiver (Transceiver) – How to read the data from the machine
  • placement (Placement) – Where the matrix is on the machine
set_info(all_syn_block_sz, app_key_info, delay_app_key_info, routing_info, weight_scales, m_edges)[source]
Set extra information that isn’t necessarily available when the
class is created.
Parameters:
  • all_syn_block_sz (int) – The space available for all synaptic matrices on the core
  • app_key_info (_AppKeyInfo) – Application-level routing key information for undelayed vertices
  • delay_app_key_info (_AppKeyInfo) – Application-level routing key information for delayed vertices
  • routing_info (RoutingInfo) – Routing key information for all incoming edges
  • weight_scales (list(float)) – Weight scale for each synapse edge
  • m_edges (list(MachineEdge)) – The machine edges incoming to this vertex
write_matrix(spec, block_addr, single_addr, single_synapses)[source]

Write a synaptic matrix from host

Parameters:
  • spec (DataSpecificationGenerator) – The specification to write to
  • block_addr (int) – The address in the synaptic matrix region to start writing at
  • single_addr (int) – The address in the “direct” or “single” matrix to start at
  • single_synapses (list(int)) – A list of “direct” or “single” synapses to write to
Returns:

The updated block_addr and single_addr

Return type:

tuple(int, int)

write_on_chip_matrix_data(generator_data, block_addr)[source]

Prepare to write a matrix using an on-chip generator

Parameters:
  • generator_data (list(GeneratorData)) – List of data to add to
  • block_addr (int) – The address in the synaptic matrix region to start writing at
Returns:

The updated block address

Return type:

int

Module contents

class spynnaker.pyNN.models.neuron.AbstractPopulationVertex(n_neurons, label, constraints, max_atoms_per_core, spikes_per_second, ring_buffer_sigma, incoming_spike_buffer_size, neuron_impl, pynn_model, drop_late_spikes, splitter)[source]

Bases: spinn_front_end_common.abstract_models.impl.tdma_aware_application_vertex.TDMAAwareApplicationVertex, spynnaker.pyNN.models.abstract_models.abstract_contains_units.AbstractContainsUnits, spynnaker.pyNN.models.common.abstract_spike_recordable.AbstractSpikeRecordable, spynnaker.pyNN.models.common.abstract_neuron_recordable.AbstractNeuronRecordable, spynnaker.pyNN.models.common.abstract_event_recordable.AbstractEventRecordable, spinn_front_end_common.abstract_models.abstract_provides_outgoing_partition_constraints.AbstractProvidesOutgoingPartitionConstraints, spynnaker.pyNN.models.abstract_models.abstract_population_initializable.AbstractPopulationInitializable, spynnaker.pyNN.models.abstract_models.abstract_population_settable.AbstractPopulationSettable, spinn_front_end_common.abstract_models.abstract_changable_after_run.AbstractChangableAfterRun, spynnaker.pyNN.models.abstract_models.abstract_accepts_incoming_synapses.AbstractAcceptsIncomingSynapses, spinn_front_end_common.abstract_models.impl.provides_key_to_atom_mapping_impl.ProvidesKeyToAtomMappingImpl, spinn_front_end_common.abstract_models.abstract_can_reset.AbstractCanReset

Underlying vertex model for Neural Populations. Not actually abstract.

Parameters:
  • n_neurons (int) – The number of neurons in the population
  • label (str) – The label on the population
  • constraints (list(AbstractConstraint)) – Constraints on where a population’s vertices may be placed.
  • max_atoms_per_core (int) – The maximum number of atoms (neurons) per SpiNNaker core.
  • spikes_per_second (float or None) – Expected spike rate
  • ring_buffer_sigma (float or None) – How many SD above the mean to go for upper bound of ring buffer size; a good starting choice is 5.0. Given length of simulation we can set this for approximate number of saturation events.
  • incoming_spike_buffer_size (int or None) –
  • drop_late_spikes (bool) – control flag for dropping late packets.
  • neuron_impl (AbstractNeuronImpl) – The (Python side of the) implementation of the neurons themselves.
  • pynn_model (AbstractPyNNNeuronModel) – The PyNN neuron model that this vertex is working on behalf of.
  • splitter (None or AbstractSplitterCommon) – splitter object
BYTES_TILL_START_OF_GLOBAL_PARAMETERS = 20
clear_connection_cache()[source]

Clear the connection data stored in the vertex so far.

clear_event_recording(buffer_manager, placements)[source]

Clear the recorded data from the object

Parameters:
Return type:

None

clear_recording(variable, buffer_manager, placements)[source]

Clear the recorded data from the object

Parameters:
  • variable (str) – PyNN name of the variable
  • buffer_manager (BufferManager) – the buffer manager object
  • placements (Placements) – the placements object
Return type:

None

clear_spike_recording(buffer_manager, placements)[source]

Clear the recorded data from the object

Parameters:
Return type:

None

conductance_based
Return type:bool
describe()[source]

Get a human-readable description of the cell or synapse type.

The output may be customised by specifying a different template together with an associated template engine (see pyNN.descriptions).

If template is None, then a dictionary containing the template context will be returned.

Return type:dict(str, ..)
get_connections_from_machine(transceiver, placements, app_edge, synapse_info)[source]

Get the connections from the machine post-run.

Parameters:
get_data(variable, n_machine_time_steps, placements, buffer_manager)[source]

Get the recorded data

Parameters:
Returns:

(data, recording_indices, sampling_interval)

Return type:

tuple(ndarray,list(int),float)

get_events(variable, placements, buffer_manager)[source]

Get the recorded events from the object

Parameters:
  • variable (str) – The variable to get the event data for
  • placements (Placements) – the placements object
  • buffer_manager (BufferManager) – the buffer manager object
Returns:

A numpy array of 2-element arrays of (neuron_id, time) ordered by time, one element per event

Return type:

ndarray(tuple(int,int))

get_events_sampling_interval(variable)[source]

Return the current sampling interval for events

Parameters:variable (str) – The variable to get the sampling interval for
Returns:Sampling interval in microseconds
Return type:float
get_expected_n_rows(n_machine_time_steps, sampling_rate, vertex, variable)[source]

Returns the number of expected rows for a given runtime

Parameters:
  • n_machine_time_steps (int) – map of vertex to steps.
  • sampling_rate (int) – the sampling rate for this vertex
  • vertex (MachineVertex) – the machine vertex
  • variable (str) – the variable being recorded
Returns:

int the number of rows expected.

get_initial_value(variable, selector=None)[source]

Gets the value for any variable whose in initialize_parameters.keys

Should return the current value not the default one.

Must support the variable as listed in initialize_parameters.keys, ideally also with _init removed or added.

Parameters:
Returns:

A list or an Object which act like a list

Return type:

iterable

get_neuron_sampling_interval(variable)[source]

Returns the current sampling interval for this variable

Parameters:variable (str) – PyNN name of the variable
Returns:Sampling interval in microseconds
Return type:float
get_outgoing_partition_constraints(partition)[source]

Get constraints to be added to the given edge partition that comes out of this vertex.

Parameters:
  • partition (AbstractOutgoingEdgePartition) – An edge that comes out of this vertex
  • partition – the partition that leaves this vertex
Returns:

A list of constraints

Return type:

list(AbstractConstraint) Gets the constraints for partitions going out of this vertex.

Returns:

list of constraints

get_recordable_variables()[source]

Returns a list of the PyNN names of variables this model is expected to collect

Return type:list(str)
get_sdram_usage_for_neuron_params(vertex_slice)[source]

Calculate the SDRAM usage for just the neuron parameters region.

Parameters:vertex_slice (Slice) – the slice of atoms.
Returns:The SDRAM required for the neuron region
get_spikes(placements, buffer_manager)[source]

Get the recorded spikes from the object

Parameters:
Returns:

A numpy array of 2-element arrays of (neuron_id, time) ordered by time, one element per event

Return type:

ndarray(tuple(int,int))

get_spikes_sampling_interval()[source]

Return the current sampling interval for spikes

Returns:Sampling interval in microseconds
Return type:float
get_synapse_id_by_target(target)[source]

Get the ID of a synapse given the name.

Parameters:target (str) – The name of the synapse
Return type:int
get_units(variable)[source]

Get units for a given variable.

Parameters:variable (str) – the variable to find units from
Returns:the units as a string.
Return type:str
get_value(key)[source]

Get a property

Parameters:key (str) – the name of the property
Return type:Any or float or int or list(float) or list(int) Get a property of the overall model.
incoming_spike_buffer_size
initialize(variable, value, selector=None)[source]

Set the initial value of one of the state variables of the neurons in this population.

Parameters:
  • variable (str) – The name of the variable to set
  • value (float or int or Any) – The value of the variable to set
initialize_parameters

The names of parameters that have default initial values.

Return type:iterable(str)
is_recording(variable)[source]

Determines if variable is being recorded.

Parameters:variable (str) – PyNN name of the variable
Returns:True if variable are being recorded, False otherwise
Return type:bool
is_recording_events(variable)[source]

Determine if events are being recorded

Parameters:variable (str) – The variable to check
Returns:True if events are recorded for the variable, False otherwise
Return type:bool
is_recording_spikes()[source]

Determine if spikes are being recorded

Returns:True if spikes are being recorded, False otherwise
Return type:bool
mark_no_changes()[source]

Marks the point after which changes are reported, so that new changes can be detected before the next check.

n_atoms

The number of atoms in the vertex

Return type:int
n_profile_samples
neuron_impl
neuron_recorder
parameters
requires_data_generation

True if changes that have been made require that data generation be performed. By default this returns False but can be overridden to indicate changes that require data regeneration.

Return type:bool
requires_mapping

True if changes that have been made require that mapping be performed. By default this returns False but can be overridden to indicate changes that require mapping.

Return type:bool
reset_ring_buffer_shifts()[source]
reset_to_first_timestep()[source]

Reset the object to first time step.

ring_buffer_sigma
set_has_run()[source]

Set the flag has run so initialize only affects state variables

Return type:None
set_recording(variable, new_state=True, sampling_interval=None, indexes=None)[source]

Sets variable to being recorded

Parameters:
  • variable (str) – PyNN name of the variable
  • new_state (bool) –
  • sampling_interval (int or None) –
  • indexes (list or None) – Which indices are to be recorded (or None for all)
set_recording_events(variable, new_state=True, sampling_interval=None, indexes=None)[source]

Set events to being recorded. If new_state is false all other parameters are ignored.

Parameters:
  • variable (str) – The variable to set recording
  • new_state (bool) – Set if the events are recording or not
  • sampling_interval (int or None) – The interval at which events are recorded. Must be a whole multiple of the timestep. None will be taken as the timestep.
  • indexes (list(int) or None) – The indexes of the neurons that will record events. If None the assumption is all neurons are recording
set_recording_spikes(new_state=True, sampling_interval=None, indexes=None)[source]

Set spikes to being recorded. If new_state is false all other parameters are ignored.

Parameters:
  • new_state (bool) – Set if the spikes are recording or not
  • sampling_interval (int or None) – The interval at which spikes are recorded. Must be a whole multiple of the timestep. None will be taken as the timestep.
  • indexes (list(int) or None) – The indexes of the neurons that will record spikes. If None the assumption is all neurons are recording
set_synapse_dynamics(synapse_dynamics)[source]
Parameters:synapse_dynamics (AbstractSynapseDynamics) –
set_value(key, value)[source]

Set a property

Parameters:
  • key (str) – the name of the parameter to change
  • value (Any or float or int or list(float) or list(int) Set a property of the overall model.) – the new value of the parameter to assign
spikes_per_second
state_variables
synapse_dynamics
Return type:AbstractSynapseDynamics
synapse_manager
weight_scale
Return type:float
class spynnaker.pyNN.models.neuron.AbstractPyNNNeuronModel(model)[source]

Bases: spynnaker.pyNN.models.abstract_pynn_model.AbstractPyNNModel

Parameters:model (AbstractNeuronImpl) – The model implementation
create_vertex(n_neurons, label, constraints, spikes_per_second, ring_buffer_sigma, incoming_spike_buffer_size, drop_late_spikes, splitter)[source]

Create a vertex for a population of the model

Parameters:
  • n_neurons (int) – The number of neurons in the population
  • label (str) – The label to give to the vertex
  • constraints (list(AbstractConstraint) or None) – A list of constraints to give to the vertex, or None
Returns:

An application vertex for the population

Return type:

ApplicationVertex

default_population_parameters = {'drop_late_spikes': None, 'incoming_spike_buffer_size': None, 'ring_buffer_sigma': None, 'spikes_per_second': None, 'splitter': None}
classmethod get_max_atoms_per_core()[source]

Get the maximum number of atoms per core for this model

Return type:int
classmethod set_model_max_atoms_per_core(n_atoms=256)[source]

Set the maximum number of atoms per core for this model

Parameters:n_atoms (int or None) – The new maximum, or None for the largest possible
class spynnaker.pyNN.models.neuron.AbstractPyNNNeuronModelStandard(model_name, binary, neuron_model, input_type, synapse_type, threshold_type, additional_input_type=None)[source]

Bases: spynnaker.pyNN.models.neuron.abstract_pynn_neuron_model.AbstractPyNNNeuronModel

A neuron model that follows the sPyNNaker standard composed model pattern for point neurons.

Parameters:
create_vertex(n_neurons, label, constraints, spikes_per_second, ring_buffer_sigma, incoming_spike_buffer_size, n_steps_per_timestep, drop_late_spikes, splitter)[source]

Create a vertex for a population of the model

Parameters:
  • n_neurons (int) – The number of neurons in the population
  • label (str) – The label to give to the vertex
  • constraints (list(AbstractConstraint) or None) – A list of constraints to give to the vertex, or None
Returns:

An application vertex for the population

Return type:

ApplicationVertex

default_population_parameters = {'drop_late_spikes': None, 'incoming_spike_buffer_size': None, 'n_steps_per_timestep': 1, 'ring_buffer_sigma': None, 'spikes_per_second': None, 'splitter': None}
class spynnaker.pyNN.models.neuron.ConnectionHolder(data_items_to_return, as_list, n_pre_atoms, n_post_atoms, connections=None, fixed_values=None, notify=None)[source]

Bases: object

Holds a set of connections to be returned in a PyNN-specific format

Parameters:
  • data_items_to_return (list(int) or tuple(int) or None) – A list of data fields to be returned
  • as_list (bool) – True if the data will be returned as a list, False if it is to be returned as a matrix (or series of matrices)
  • n_pre_atoms (int) – The number of atoms in the pre-vertex
  • n_post_atoms (int) – The number of atoms in the post-vertex
  • connections (list(ndarray) or None) – Any initial connections, as a numpy structured array of source, target, weight and delay
  • fixed_values (list(tuple(str,int)) or None) – A list of tuples of field names and fixed values to be appended to the other fields per connection, formatted as [(field_name, value), …]. Note that if the field is to be returned, the name must also appear in data_items_to_return, which determines the order of items in the result
  • notify (callable(ConnectionHolder, None) or None) – A callback to call when the connections have all been added. This should accept a single parameter, which will contain the data requested
add_connections(connections)[source]

Add connections to the holder to be returned

Parameters:connections (ndarray) – The connection to add, as a numpy structured array of source, target, weight and delay
connections

The connections stored

Return type:list(ndarray)
finish()[source]

Finish adding connections

class spynnaker.pyNN.models.neuron.PopulationMachineVertex(resources_required, recorded_region_ids, label, constraints, app_vertex, vertex_slice, drop_late_spikes, binary_file_name)[source]

Bases: pacman.model.graphs.machine.machine_vertex.MachineVertex, spinn_front_end_common.interface.buffer_management.buffer_models.abstract_receive_buffers_to_host.AbstractReceiveBuffersToHost, spinn_front_end_common.abstract_models.abstract_has_associated_binary.AbstractHasAssociatedBinary, spinn_front_end_common.interface.provenance.provides_provenance_data_from_machine_impl.ProvidesProvenanceDataFromMachineImpl, spinn_front_end_common.interface.profiling.abstract_has_profile_data.AbstractHasProfileData, spinn_front_end_common.abstract_models.abstract_supports_bit_field_generation.AbstractSupportsBitFieldGeneration, spinn_front_end_common.abstract_models.abstract_supports_bit_field_routing_compression.AbstractSupportsBitFieldRoutingCompression, spinn_front_end_common.abstract_models.abstract_generates_data_specification.AbstractGeneratesDataSpecification, spynnaker.pyNN.models.abstract_models.abstract_synapse_expandable.AbstractSynapseExpandable, spinn_front_end_common.abstract_models.abstract_rewrites_data_specification.AbstractRewritesDataSpecification, spynnaker.pyNN.models.abstract_models.abstract_read_parameters_before_set.AbstractReadParametersBeforeSet

Parameters:
  • resources_required (ResourceContainer) –
  • recorded_region_ids (iterable(int)) –
  • label (str) –
  • drop_late_spikes (bool) – control flag for dropping packets.
  • constraints (list(AbstractConstraint)) –
  • app_vertex (AbstractPopulationVertex) – The associated application vertex
  • vertex_slice (Slice) – The slice of the population that this implements
  • binary_file_name (str) – binary name to be run for this verte
BIT_FIELDS_NOT_READ = 'N bit fields not able to be read into DTCM'
BIT_FIELD_FILTERED_PACKETS = 'How many packets were filtered by the bitfield filterer.'
DMA_COMPLETE = "DMA's that were completed"
class EXTRA_PROVENANCE_DATA_ENTRIES[source]

Bases: enum.IntEnum

Entries for the provenance data generated by standard neuron models.

BIT_FIELD_FILTERED_COUNT = 10
BUFFER_OVERFLOW_COUNT = 2

The number of times there was a buffer overflow

CURRENT_TIMER_TIC = 3

The current timer tick

DMA_COMPLETES = 7
FAILED_TO_READ_BIT_FIELDS = 6
GHOST_POP_TABLE_SEARCHES = 5
INPUT_BUFFER_FILLED_SIZE = 13

The max filled size of the input buffer

INVALID_MASTER_POP_HITS = 9
MAX_BACKGROUND_QUEUED = 15
N_BACKGROUND_OVERLOADS = 16
N_LATE_SPIKES = 12

The number of packets that were dropped as they arrived too late to be processed

N_REWIRES = 11
PLASTIC_SYNAPTIC_WEIGHT_SATURATION_COUNT = 4

The number of times the plastic synapses saturated during weight calculation

PRE_SYNAPTIC_EVENT_COUNT = 0

The number of pre-synaptic events

SATURATION_COUNT = 1

The number of times the synapse arithmetic saturated

SPIKE_PROGRESSING_COUNT = 8
TDMA_MISSES = 14

The number of TDMA misses

GHOST_SEARCHES = 'Number of failed pop table searches'
INPUT_BUFFER_FULL_NAME = 'Times_the_input_buffer_lost_packets'
INVALID_MASTER_POP_HITS = 'Invalid Master Pop hits'
LAST_TIMER_TICK = 'Last_timer_tic_the_core_ran_to'
LAST_TIMER_TICK_NAME = 'Last_timer_tic_the_core_ran_to'
LOST_INPUT_BUFFER_PACKETS = 'Times_the_input_buffer_lost_packets'
N_ADDITIONAL_PROVENANCE_DATA_ITEMS = 17
N_RE_WIRES_NAME = 'Number_of_rewires'
PLASTIC_WEIGHT_SATURATION = 'Times_plastic_synaptic_weights_have_saturated'
SATURATED_PLASTIC_WEIGHTS_NAME = 'Times_plastic_synaptic_weights_have_saturated'
SATURATION_COUNT_NAME = 'Times_synaptic_weights_have_saturated'
SPIKES_PROCESSED = 'how many spikes were processed'
TOTAL_PRE_SYNAPTIC_EVENTS = 'Total_pre_synaptic_events'
TOTAL_PRE_SYNAPTIC_EVENT_NAME = 'Total_pre_synaptic_events'
bit_field_base_address(transceiver, placement)[source]

Returns the SDRAM address for the bit field table data.

Parameters:
Returns:

the SDRAM address for the bitfield address

Return type:

int

bit_field_builder_region(transceiver, placement)[source]

returns the SDRAM address for the bit field builder data

Parameters:
Returns:

the SDRAM address for the bitfield builder data

Return type:

int

gen_on_machine()[source]

True if the synapses of a the slice of this vertex should be generated on the machine.

Note

The typical implementation for this method will be to ask the app_vertex’s synapse_manager

Return type:bool
generate_data_specification(spec, placement, application_graph, machine_graph, routing_info, data_n_time_steps, n_key_map)[source]

Generate a data specification.

Parameters:
  • spec (DataSpecificationGenerator) – The data specification to write to
  • placement (Placement) – The placement the vertex is located at
  • application_graph – (injected)
  • machine_graph – (injected)
  • routing_info – (injected)
  • data_n_time_steps – (injected)
  • n_key_map – (injected)
Return type:

None

get_binary_file_name()[source]

Get the binary name to be run for this vertex.

Return type:str
get_binary_start_type()[source]

Get the start type of the binary to be run.

Return type:ExecutableType
get_profile_data(transceiver, placement)[source]

Get the profile data recorded during simulation

Parameters:
Return type:

ProfileData

get_provenance_data_from_machine(transceiver, placement)[source]

Retrieve the provenance data.

Parameters:
  • transceiver (Transceiver) – How to talk to the machine
  • placement (Placement) – Which vertex are we retrieving from, and where was it
Return type:

Iterable(ProvenanceDataItem)

get_recorded_region_ids()[source]

Get the recording region IDs that have been recorded using buffering

Returns:The region numbers that have active recording
Return type:iterable(int)
get_recording_region_base_address(txrx, placement)[source]

Get the recording region base address

Parameters:
  • txrx (Transceiver) – the SpiNNMan instance
  • placement (Placement) – the placement object of the core to find the address of
Returns:

the base address of the recording region

Return type:

int

key_to_atom_map_region_base_address(transceiver, placement)[source]

Returns the SDRAM address for the region that contains key-to-atom data.

Parameters:
Returns:

the SDRAM address for the key-to-atom data

Return type:

int

static neuron_region_sdram_address(placement, transceiver)[source]
read_generated_connection_holders(transceiver, placement)[source]

Fill in the connection holders

Note

The typical implementation for this method will be to ask the app_vertex’s synapse_manager

Parameters:
  • transceiver (Transceiver) – How the data is to be read
  • placement (Placement) – Where the data is on the machine
read_parameters_from_machine(transceiver, placement, vertex_slice)[source]

Read the parameters from the machine before any are changed.

Parameters:
  • transceiver (Transceiver) – the SpinnMan interface
  • placement (Placement) – the placement of a vertex
  • vertex_slice (Slice) – the slice of atoms for this vertex
Return type:

None

regeneratable_sdram_blocks_and_sizes(transceiver, placement)[source]

Returns the SDRAM addresses and sizes for the cores’ SDRAM that are available (borrowed) for generating bitfield tables.

Parameters:
Returns:

list of tuples containing (the SDRAM address for the cores SDRAM address’s for the core’s SDRAM that can be used to generate bitfield tables loaded, and the size of memory chunks located there)

Return type:

list(tuple(int,int))

regenerate_data_specification(spec, placement, routing_info)[source]

Regenerate the data specification, only generating regions that have changed and need to be reloaded

Parameters:
reload_required()[source]

Return true if any data region needs to be reloaded

Return type:bool
resources_required

The resources required by the vertex

Return type:ResourceContainer
set_on_chip_generatable_area(offset, size)[source]
set_reload_required(new_value)[source]

Indicate that the regions have been reloaded

Parameters:new_value – the new value
Return type:None
class spynnaker.pyNN.models.neuron.SynapticManager(n_synapse_types, ring_buffer_sigma, spikes_per_second, drop_late_spikes)[source]

Bases: object

Deals with synapses

Parameters:
  • n_synapse_types (int) – number of synapse types on a neuron (e.g., 2 for excitatory and inhibitory)
  • ring_buffer_sigma (float or None) – How many SD above the mean to go for upper bound; a good starting choice is 5.0. Given length of simulation we can set this for approximate number of saturation events.
  • spikes_per_second (float or None) – Estimated spikes per second
  • drop_late_spikes (bool) – control flag for dropping late packets.
FUDGE = 0
INDEXS_DONT_MATCH_ERROR_MESSAGE = 'Delay index {} and normal index {} do not match'
NOT_EXACT_SLICES_ERROR_MESSAGE = 'The splitter {} is returning estimated slices during DSG. This is deemed an error. Please fix and try again'
NO_DELAY_EDGE_FOR_SRC_IDS_MESSAGE = 'Found delayed source IDs but no delay machine edge for {}'
STATIC_SYNAPSE_MATRIX_SDRAM_IN_BYTES = 8
TOO_MUCH_WRITTEN_SYNAPTIC_DATA = 'Too much synaptic memory has been written: {} of {} '
changes_during_run

Whether the synapses being managed change during running.

Return type:bool
clear_all_caches()[source]

Clears all cached data in the case that a reset requires remapping which might change things

clear_connection_cache()[source]

Flush the cache of connection information; needed for a second run

drop_late_spikes
gen_on_machine(post_vertex_slice)[source]

True if the synapses should be generated on the machine

Parameters:post_vertex_slice (Slice) – The slice of the vertex to determine the generation status of
Return type:bool
get_connections_from_machine(transceiver, placements, app_edge, synapse_info)[source]

Read the connections from the machine for a given projection

Parameters:
  • transceiver (Transceiver) – Used to read the data from the machine
  • placements (Placements) – Where the vertices are on the machine
  • app_edge (ProjectionApplicationEdge) – The application edge of the projection
  • synapse_info (SynapseInformation) – The synapse information of the projection
Returns:

The connections from the machine, with dtype AbstractSynapseDynamics.NUMPY_CONNECTORS_DTYPE

Return type:

ndarray

get_dtcm_usage_in_bytes()[source]
Return type:int
get_n_cpu_cycles()[source]
Return type:int
get_sdram_usage_in_bytes(post_vertex_slice, application_graph, app_vertex)[source]

Get the SDRAM usage of a slice of atoms of this vertex

Parameters:
Return type:

int

host_written_matrix_size(post_vertex_slice)[source]

The size of the matrix written by the host for a given machine vertex

Parameters:post_vertex_slice – The slice of the vertex to get the size of
Return type:int
on_chip_written_matrix_size(post_vertex_slice)[source]

The size of the matrix that will be written on the machine for a given machine vertex

Parameters:post_vertex_slice – The slice of the vertex to get the size of
Return type:int
read_generated_connection_holders(transceiver, placement)[source]
Fill in any pre-run connection holders for data which is generated
on the machine, after it has been generated
Parameters:
  • transceiver (Transceiver) – How to read the data from the machine
  • placement (Placement) – where the data is to be read from
reset_ring_buffer_shifts()[source]

Reset the ring buffer shifts; needed if projection data changes between runs

ring_buffer_sigma

The sigma in the estimation of the maximum summed ring buffer weights. Settable.

Return type:float
spikes_per_second

The assumed maximum spikes per second of an incoming population. Used when calculating the ring buffer weight scaling. Settable.

Return type:float
synapse_dynamics

The synapse dynamics used by the synapses e.g. plastic or static. Settable.

Return type:AbstractSynapseDynamics or None
vertex_executable_suffix

The suffix of the executable name due to the type of synapses in use.

Return type:str
write_data_spec(spec, application_vertex, post_vertex_slice, machine_vertex, machine_graph, application_graph, routing_info, weight_scale)[source]
Parameters: