spynnaker.pyNN.models.common package

Submodules

spynnaker.pyNN.models.common.param_generator_data module

spynnaker.pyNN.models.common.param_generator_data.MAX_PARAMS_BYTES = 16

At most, there are 4 words as param generator parameters

spynnaker.pyNN.models.common.param_generator_data.PARAM_TYPE_BY_NAME = {'exponential': 5, 'exponential_clipped': 6, 'normal': 2, 'normal_clipped': 3, 'normal_clipped_to_boundary': 4, 'uniform': 1, 'uniform_int': 1}

IDs of the random parameter generators supported by the synapse expander.

spynnaker.pyNN.models.common.param_generator_data.PARAM_TYPE_CONSTANT_ID = 0

ID of the constant parameter generator.

spynnaker.pyNN.models.common.param_generator_data.get_generator_type(data_type)[source]
Parameters:

data_type (DataType) –

Returns:

The generator parameter type code for the given data type.

Return type:

int

Raises:

TypeError – If an unsupported data type is given

spynnaker.pyNN.models.common.param_generator_data.is_param_generatable(value)[source]
Parameters:

value – The value to examine the type of.

Returns:

Whether the value is of a type that can be generated on chip.

Return type:

bool

spynnaker.pyNN.models.common.param_generator_data.param_generator_id(value)[source]
Parameters:

value – The value to examine the type of.

Returns:

The ID of the on-chip generator that handles the value.

Return type:

int

Raises:

TypeError – If an value of an unsupported data type is given

spynnaker.pyNN.models.common.param_generator_data.param_generator_params(values)[source]

Get the parameter generator parameters as a numpy array.

Parameters:

values (int or RandomDistribution) –

Return type:

ndarray

spynnaker.pyNN.models.common.param_generator_data.param_generator_params_size_in_bytes(values)[source]

Get the size of the parameter generator parameters in bytes.

Parameters:

values (int or RandomDistribution) –

Return type:

int

Raises:

TypeError – If values is of an unsupported data type

spynnaker.pyNN.models.common.param_generator_data.type_has_generator(data_type)[source]
Parameters:

data_type (DataType) –

Returns:

Whether there is a generator parameter type code for the given data type.

Return type:

bool

spynnaker.pyNN.models.common.recording_utils module

spynnaker.pyNN.models.common.recording_utils.make_missing_string(missing)[source]
Parameters:

missing (iterable(Placement)) –

Return type:

str

Module contents

class spynnaker.pyNN.models.common.EIEIOSpikeRecorder

Bases: object

Records spikes using EIEIO format.

property record
Return type:

bool

set_recording(new_state, sampling_interval=None)[source]
Parameters:
  • new_state (bool) –

  • sampling_interval (None) – not supported functionality

class spynnaker.pyNN.models.common.MultiSpikeRecorder

Bases: object

get_sdram_usage_in_bytes(n_neurons, spikes_per_timestep)[source]
Parameters:
  • n_neurons (int) –

  • spikes_per_timestep (float) –

Return type:

AbstractSDRAM

property record
Return type:

bool

class spynnaker.pyNN.models.common.NeuronRecorder(allowed_variables, data_types, bitfield_variables, n_neurons, per_timestep_variables, per_timestep_datatypes, events_per_core_variables, events_per_core_datatypes)

Bases: object

Parameters:
  • allowed_variables (list(str)) –

  • data_types (dict(str,DataType)) –

  • bitfield_variables (list(str)) –

  • n_neurons (int) –

  • per_timestep_variables (list(str)) –

  • per_timestep_datatypes (dict(str,DataType)) –

  • events_per_core_variables (list(str)) –

  • events_per_core_datatypes (dict(str,DataType)) –

MAX_REWIRES = 'max_rewires'
PACKETS = 'packets-per-timestep'
PACKETS_TYPE = 2
REWIRING = 'rewiring'
REWIRING_TYPE = 2
SPIKES = 'spikes'
add_region_offset(offset)[source]

Add an offset to the regions. Used when there are multiple recorders on a single core.

Parameters:

offset (int) – The offset to add

check_indexes(indexes)[source]
Parameters:

indexes (list(int)) –

get_buffer_data_type(variable)[source]
Parameters:

variable (str) –

Return type:

BufferDataType

get_buffered_sdram(variable, vertex_slice)[source]

Returns the SDRAM used for this many time steps for a variable.

If required the total is rounded up so the space will always fit.

Parameters:
  • variable (str) – The PyNN variable name to get buffered SDRAM of

  • vertex_slice (Slice) –

Returns:

data size

Return type:

int

get_buffered_sdram_per_record(variable, vertex_slice)[source]

Return the SDRAM used per record.

Parameters:
  • variable (str) – PyNN variable name

  • vertex_slice (Slice) –

Returns:

usage

Return type:

int

get_buffered_sdram_per_timestep(variable, vertex_slice)[source]

Return the SDRAM used per timestep.

In the case where sampling is used it returns the average for recording and none recording based on the recording rate

Parameters:
  • variable (str) – PyNN variable name

  • vertex_slice (Slice) –

Returns:

usage

Return type:

int

get_data_type(variable)[source]
Parameters:

variable (str) –

Return type:

DataType

get_event_recordable_variables()[source]
Return type:

iterable(str)

get_generator_data(vertex_slice=None)[source]

Get the recorded data as a generatable data set.

Parameters:

vertex_slice (Slice or None) – The slice to generate the data for, or None to generate for all neurons (assuming all the same, otherwise error)

Return type:

numpy.ndarray

get_generator_sdram_usage_in_bytes(n_atoms)[source]

Get the SDRAM usage of the generator data for recording metadata.

Parameters:

n_atoms (int) – The number of atoms to be recorded

Return type:

int

get_max_buffered_sdram_per_record(variable, n_atoms)[source]

Return the SDRAM used per record.

Parameters:
  • variable (str) – PyNN variable name

  • vertex_slice (Slice) –

Returns:

usage

Return type:

int

get_max_variable_sdram_usage(n_atoms)[source]
Parameters:

vertex_slice (Slice) –

Return type:

VariableSDRAM

get_metadata_sdram_usage_in_bytes(n_atoms)[source]

Get the SDRAM usage of the metadata for recording.

Parameters:

n_atoms (int) – The number of atoms to record

Return type:

int

get_recordable_variables()[source]
Return type:

iterable(str)

get_recorded_indices(application_vertex, variable)[source]

Get the indices being recorded for a given variable.

Parameters:
  • application_vertex (ApplicationVertex) – The vertex being recorded

  • variable (str) – The name of the variable to get the indices of

Return type:

list(int)

get_region(variable)[source]

Get the region of a variable.

Parameters:

variable (str) – The variable to get the region of

Return type:

int

get_region_sizes(vertex_slice)[source]

Get the sizes of the regions for the variables, whether they are recorded or not, with those that are not having a size of 0.

Parameters:

vertex_slice (Slice) –

Return type:

list(int)

get_sampling_interval_ms(variable)[source]

Get the sampling interval of a variable.

Parameters:

variable (str) – The variable to get the sampling interval of

Return type:

float

get_sampling_overflow_sdram(vertex_slice)[source]

Get the extra SDRAM that should be reserved if using per_timestep.

This is the extra that must be reserved if per_timestep is an average rather than fixed for every timestep.

When sampling the average * time_steps may not be quite enough. This returns the extra space in the worst case where time_steps is a multiple of sampling rate + 1, and recording is done in the first and last time_step

Parameters:

vertex_slice (Slice) –

Returns:

Highest possible overflow needed

Return type:

int

get_variable_sdram_usage(vertex_slice)[source]
Parameters:

vertex_slice (Slice) –

Return type:

VariableSDRAM

property is_global_generatable

Whether the data for all neurons the same, i.e., all or none of the neurons are recorded for all variables.

Return type:

bool

is_recordable(variable)[source]

Identify if the given variable can be recorded.

Parameters:

variable (str) – The variable to check for

Return type:

bool

is_recording(variable)[source]
Parameters:

variable (str) –

Return type:

bool

neurons_recording(variable, vertex_slice)[source]
Parameters:
  • variable (str) –

  • vertex_slice (Slice) –

Return type:

None or iterable(int)

recorded_ids_by_slice(vertex_slice)[source]
Parameters:

vertex_slice (Slice) –

Return type:

list(int)

property recorded_region_ids
Return type:

list(int)

property recording_variables
Return type:

list(str)

set_max_rewires_per_ts(max_rewires_per_ts)[source]
Parameters:

max_rewires_per_ts (int) – the maximum rewires per timestep

set_recording(variable, new_state, sampling_interval=None, indexes=None)[source]
Parameters:
  • variable (str) – PyNN variable name

  • new_state (bool) –

  • sampling_interval (int) –

  • indexes (iterable(int)) –

write_neuron_recording_region(spec, neuron_recording_region, vertex_slice)[source]

Recording data specification.

Parameters:
  • spec (DataSpecificationGenerator) – where to write the data specification

  • neuron_recording_region (int) – the recording region

  • vertex_slice (Slice) – the vertex slice

class spynnaker.pyNN.models.common.ParameterHolder(data_items_to_return, get_call, selector=None)

Bases: object

Holds a set of parameters and state variables to be returned in a PyNN-specific format.

Parameters:
  • data_items_to_return (list(str) or tuple(str)) – A list of data fields to be returned

  • get_call (callable(str, selector=None)->list) – A function to call to read a value

  • selector (None or slice or int or list(bool) or list(int)) – a description of the subrange to accept, or None for all. See: selector_to_ids()

items()[source]
keys()[source]
values()[source]
class spynnaker.pyNN.models.common.PopulationApplicationVertex(label: str | None = None, max_atoms_per_core: int | Tuple[int, ...] | None = None, splitter: AbstractSplitterCommon[Self] | None = None)

Bases: ApplicationVertex, HasCustomAtomKeyMap

A vertex that can be used in a Population.

Provides some default functions that can be overridden if the vertex supports these.

Parameters:
  • label (str) – The optional name of the vertex.

  • max_atoms_per_core (None or int or tuple(int,...)) – The max number of atoms that can be placed on a core for each dimension, used in partitioning. If the vertex is n-dimensional, with n > 1, the value must be a tuple with a value for each dimension. If it is single-dimensional the value can be a 1-tuple or an int.

  • splitter (None or AbstractSplitterCommon) – The splitter object needed for this vertex. Leave as None to delegate the choice of splitter to the selector.

property conductance_based

Whether the vertex models post-synaptic inputs as currents or conductance.

By default this is False; override if the model accepts conductance based input.

Return type:

bool

get_atom_key_map(pre_vertex, partition_id, routing_info)[source]

Get the mapping between atoms and keys for the given partition id, and for the given machine pre-vertex.

Parameters:
  • pre_vertex (MachineVertex) – The machine vertex to get the map for

  • partition_id (str) – The partition to get the map for

  • routing_info (RoutingInfo) – Routing information

Returns:

A list of (atom_id, key)

Return type:

list(tuple(int,int))

get_buffer_data_type(name)[source]

Get the type of data recorded by the buffer manager.

The buffer data type controls how data returned by the cores is handled in NeoBufferDatabase.

Parameters:

name (str) – The name of the variable recorded

Return type:

BufferDatabase

Raises:

KeyError – if the variable isn’t being recorded

get_current_state_values(names, selector=None)[source]

Get the current values of a state variable for the whole Population or a subset if the selector is used.

Parameters:
Return type:

ParameterHolder

Raises:

KeyError – if the variable is not something that can be read

get_data_type(name)[source]

Get the type data returned by a recording of the variable.

This is the type of data the C code is returning. For instance data such as spikes this will be None.

Parameters:

name (str) – The name of the variable to get the type of

Return type:

DataType or None

Raises:

KeyError – If the variable isn’t recordable

get_initial_state_values(names, selector=None)[source]

Get the initial values of a state variable for the whole Population or a subset if the selector is used.

Parameters:
Return type:

ParameterHolder

Raises:

KeyError – if the variable is not something that can be read

get_neurons_recording(name, vertex_slice)[source]

Gets the neurons being recorded on the core with this slice.

Typically vertex_slice.get_raster_ids(atoms_shape) but may be a sublist if doing selective recording.

Parameters:
  • name (str) – The name of the variable to get the region of

  • vertex_slice (Slice) –

Returns:

A list of the global raster IDs of the atoms in recording named variable within this slice

Return type:

list(int)

get_parameter_values(names, selector=None)[source]

Get the values of a parameter or parameters for the whole Population or a subset if the selector is used.

Parameters:
Return type:

ParameterHolder

Raises:

KeyError – if the parameter is not something that can be read

get_parameters()[source]

Get the names of all the parameters that can be obtained

Return type:

list(str)

get_recordable_variables()[source]

Get a list of the names and types of things that can be recorded.

This methods list the variable recorded via the Population.

Return type:

list(str)

get_recording_region(name)[source]

Gets the recording region for the named variable.

Parameters:

name (str) – The name of the variable to get the region of

Return type:

int

Raises:

KeyError – If the variable isn’t being recorded

get_recording_variables()[source]

Get a list of variables that are currently being recorded.

Return type:

list(str)

get_sampling_interval_ms(name)[source]

Get the sampling interval of the recording for the given variable.

The values is in ms and unless selective recording is used will be SpynnakerDataView.get_simulation_time_step_us()

Return type:

float

Raises:

KeyError – If the variable isn’t being recorded

get_state_variables()[source]

Get a list of supported state variables.

Return type:

list(str)

get_units(name)[source]

Get the units of the given parameter or state variable.

Parameters:

name (str) – the name of the parameter to get the units of

Return type:

str

Raises:

KeyError – if the name isn’t recognised or the units cannot be identified

inject(current_source, selector=None)[source]

Inject a current source into this population.

Parameters:
Raises:

ConfigurationException – if the population doesn’t support injection

abstract property n_atoms: int

The number of atoms in the vertex.

Return type:

int

property n_colour_bits

The number of colour bits sent by this vertex.

Assumed 0 unless overridden

Return type:

int

set_current_state_values(name, value, selector=None)[source]

Set the current values of a state variable for the whole Population or a subset if the selector is used.

Parameters:
Raises:

KeyError – if the variable is not something that can be changed

set_initial_state_values(name, value, selector=None)[source]

Set the initial values of a state variable for the whole Population or a subset if the selector is used.

Parameters:
Raises:

KeyError – if the variable is not something that can be changed

set_not_recording(name, indices=None)[source]

Set a variable not recording.

Parameters:
  • name (str) – The name of the variable to not record

  • indices (list(int) or None) – The list of neuron indices to not record or None for all

Raises:

KeyError – if the variable cannot be stopped from recording

set_parameter_values(name, value, selector=None)[source]

Set the values of a parameter for the whole Population or a subset if the selector is used.

Parameters:
Raises:

KeyError – if the parameter is not something that can be changed

set_recording(name, sampling_interval=None, indices=None)[source]

Set a variable recording.

Parameters:
  • name (str) – The name of the variable to set the status of

  • sampling_interval (float or None) – How often the variable should be recorded or None for every time step, in milliseconds

  • indices (list(int) or None) – The list of neuron indices to record or None for all

Raises:

KeyError – if the variable cannot be recorded