spynnaker.pyNN.models.common package

Submodules

spynnaker.pyNN.models.common.local_only_2d_common module

spynnaker.pyNN.models.common.local_only_2d_common.BITS_PER_BYTE = 8

The number of bits in a byte value

spynnaker.pyNN.models.common.local_only_2d_common.BITS_PER_SHORT = 16

The number of bits in a short value

spynnaker.pyNN.models.common.local_only_2d_common.KEY_INFO_SIZE = 16

Key info size in bytes

spynnaker.pyNN.models.common.local_only_2d_common.N_COLOUR_BITS_BITS = 3

The number of bits to represent n_colour_bits

class spynnaker.pyNN.models.common.local_only_2d_common.Source(projection, local_delay, delay_stage)

Bases: tuple

A source

delay_stage

Alias for field number 2

local_delay

Alias for field number 1

projection

Alias for field number 0

spynnaker.pyNN.models.common.local_only_2d_common.get_delay_for_source(incoming)[source]
Get the vertex which will send data from a given source projection,

along with the delay stage and locally-handled delay value

Parameters:

incoming (Projection) – The incoming projection to get the delay from

Returns:

The vertex, the local delay, the delay stage

Return type:

ApplicationVertex, int, int

spynnaker.pyNN.models.common.local_only_2d_common.get_div_const(value)[source]

Get the values used to perform fast division by an integer constant

Parameters:

value (int) – The value to be divided by

Returns:

The values required encoded as fields of a 32-bit integer

Return type:

int

spynnaker.pyNN.models.common.local_only_2d_common.get_first_and_last_slice(pre_vertex)[source]

Get the first and last slice of an application vertex.

Parameters:

pre_vertex (ApplicationVertex) – The source vertex

Return type:

tuple(Slice, Slice) or tuple(MDSlice, MDSlice)

spynnaker.pyNN.models.common.local_only_2d_common.get_rinfo_for_spike_source(pre_vertex)[source]

Get the routing information for the source of a projection in the SPIKE_PARTITION_ID partition.

Parameters:

pre_vertex (ApplicationVertex) – The source of incoming data

Returns:

Routing information, core mask, core mask shift

Return type:

AppVertexRoutingInfo, int, int

spynnaker.pyNN.models.common.local_only_2d_common.get_sources_for_target(app_vertex)[source]

Get all the application vertex sources that will hit the given application vertex.

Parameters:

app_vertex (AbstractPopulationVertex) – The vertex being targeted

Returns:

A dict of source ApplicationVertex to list of source information

Return type:

dict(ApplicationVertex, list(Source))

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: DataType) int[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: Any) bool[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: int | float | RandomDistribution) int[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: int | float | RandomDistribution) ndarray[Any, dtype[uint32]][source]

Get the parameter generator parameters as a numpy array.

Parameters:

values (float or RandomDistribution)

Return type:

ndarray

spynnaker.pyNN.models.common.param_generator_data.param_generator_params_size_in_bytes(values: int | float | RandomDistribution) int[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: DataType) bool[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: Iterable[Placement]) str[source]
Parameters:

missing (iterable(Placement))

Return type:

str

spynnaker.pyNN.models.common.types module

spynnaker.pyNN.models.common.types.Names

Type of names of parameters and state variables.

alias of str | List[str] | Tuple[str, …]

spynnaker.pyNN.models.common.types.Spikes

Type of spikes in spike sources.

alias of float | Sequence[float] | ndarray[Any, dtype[floating]] | RandomDistribution | int | Sequence[int] | Sequence[Sequence[int]] | ndarray[Any, dtype[integer]]

spynnaker.pyNN.models.common.types.Values

Type of normal values of parameters and state variables.

alias of float | Sequence[float] | ndarray[Any, dtype[floating]] | RandomDistribution

Module contents

class spynnaker.pyNN.models.common.EIEIOSpikeRecorder

Bases: object

Records spikes using EIEIO format.

property record: bool
Return type:

bool

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

  • sampling_interval (None) – not supported functionality

class spynnaker.pyNN.models.common.MultiSpikeRecorder

Bases: object

Support for recording more than one spike per timestep.

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

  • spikes_per_timestep (float)

Return type:

AbstractSDRAM

property record: bool
Return type:

bool

class spynnaker.pyNN.models.common.NeuronRecorder(allowed_variables: List[str], data_types: Mapping[str, DataType], bitfield_variables: Sequence[str], n_neurons: int, per_timestep_variables: Sequence[str], per_timestep_datatypes: Mapping[str, DataType], events_per_core_variables: Sequence[str], events_per_core_datatypes: Mapping[str, DataType])

Bases: object

Methods related to recording of neuron data.

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: int)[source]

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

Parameters:

offset (int) – The offset to add

get_buffer_data_type(variable: str) BufferDataType[source]
Parameters:

variable (str)

Return type:

BufferDataType

get_buffered_sdram(variable: str, vertex_slice: Slice) int[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: str, vertex_slice: Slice) int[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: str, vertex_slice: Slice) int[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: str) DataType | None[source]
Parameters:

variable (str)

Return type:

DataType

get_event_recordable_variables() List[str][source]
Return type:

list(str)

get_generator_data(vertex_slice: Slice | None = None) ndarray[Any, dtype[uint32]][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: int) int[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: str, n_atoms: int) int[source]

Return the SDRAM used per record.

Parameters:

variable (str) – PyNN variable name

Returns:

usage

Return type:

int

get_max_variable_sdram_usage(n_atoms: int) AbstractSDRAM[source]
Parameters:

vertex_slice (Slice)

Return type:

VariableSDRAM

get_metadata_sdram_usage_in_bytes(n_atoms: int) int[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() List[str][source]
Return type:

list(str)

get_recorded_indices(application_vertex: ApplicationVertex, variable: str) Iterable[int][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:

iterable(int)

get_region(variable: str) int[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: Slice) List[int][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: str) float[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: Slice) int[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: Slice) AbstractSDRAM[source]
Parameters:

vertex_slice (Slice)

Return type:

VariableSDRAM

property is_global_generatable: bool

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: str) bool[source]

Identify if the given variable can be recorded.

Parameters:

variable (str) – The variable to check for

Return type:

bool

is_recording(variable: str) bool[source]
Parameters:

variable (str)

Return type:

bool

neurons_recording(variable: str, vertex_slice: Slice) Collection[int] | None[source]
Parameters:
Return type:

None or iterable(int)

recorded_ids_by_slice(vertex_slice: Slice) List[int][source]
Parameters:

vertex_slice (Slice)

Return type:

list(int)

property recorded_region_ids: Iterable[int]
Return type:

iterable(int)

property recording_variables: Iterable[str]
Return type:

iterable(str)

set_max_rewires_per_ts(max_rewires_per_ts: int)[source]
Parameters:

max_rewires_per_ts (int) – the maximum rewires per timestep

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

  • new_state (bool)

  • sampling_interval (int)

  • indexes (iterable(int))

write_neuron_recording_region(spec: DataSpecificationBase, neuron_recording_region: int, vertex_slice: 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: str | Iterable[str], get_call: Callable[[str, None | int | integer | SupportsInt | slice | Sequence[bool | bool] | Sequence[int | integer | SupportsInt]], List[int] | List[float] | RandomDistribution], selector: None | int | integer | SupportsInt | slice | Sequence[bool | bool] | Sequence[int | integer | SupportsInt] = 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)->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() Iterable[Tuple[str, List[int] | List[float]]][source]

The names and values of the data

Return type:

iter(tuple(str, list(float)))

keys() Iterable[str][source]

The names of the data

Return type:

iter(str)

values() Iterable[List[int] | List[float]][source]

The names and values of the data

Return type:

iter(list(float))

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: bool

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: MachineVertex, partition_id: str, routing_info: RoutingInfo) Iterable[Tuple[int, int]][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: str) BufferDataType[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: str | List[str] | Tuple[str, ...], selector: None | int | integer | SupportsInt | slice | Sequence[bool | bool] | Sequence[int | integer | SupportsInt] = None) ParameterHolder[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: str) DataType | None[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: str | List[str] | Tuple[str, ...], selector: None | int | integer | SupportsInt | slice | Sequence[bool | bool] | Sequence[int | integer | SupportsInt] = None) ParameterHolder[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: str, vertex_slice: Slice) Collection[int] | None[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: str | List[str] | Tuple[str, ...], selector: None | int | integer | SupportsInt | slice | Sequence[bool | bool] | Sequence[int | integer | SupportsInt] = None) ParameterHolder[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() List[str][source]

Get the names of all the parameters that can be obtained

Return type:

list(str)

get_recordable_variables() List[str][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: str) int[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() List[str][source]

Get a list of variables that are currently being recorded.

Return type:

list(str)

get_sampling_interval_ms(name: str) float[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() List[str][source]

Get a list of supported state variables.

Return type:

list(str)

get_units(name: str) str[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: AbstractCurrentSource, selector: None | int | integer | SupportsInt | slice | Sequence[bool | bool] | Sequence[int | integer | SupportsInt] = None)[source]

Inject a current source into this population.

Parameters:
Raises:

ConfigurationException – if the population doesn’t support injection

property n_colour_bits: int

The number of colour bits sent by this vertex.

Assumed 0 unless overridden

Return type:

int

set_current_state_values(name: str, value: float | Sequence[float] | ndarray[Any, dtype[floating]] | RandomDistribution, selector: None | int | integer | SupportsInt | slice | Sequence[bool | bool] | Sequence[int | integer | SupportsInt] = 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: str, value: float | Sequence[float] | ndarray[Any, dtype[floating]] | RandomDistribution, selector: None | int | integer | SupportsInt | slice | Sequence[bool | bool] | Sequence[int | integer | SupportsInt] = 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: str, indices: Collection[int] | None = 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: str, value: float | Sequence[float] | ndarray[Any, dtype[floating]] | RandomDistribution, selector: None | int | integer | SupportsInt | slice | Sequence[bool | bool] | Sequence[int | integer | SupportsInt] = 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: str, sampling_interval: float | None = None, indices: Collection[int] | None = 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