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: Projection) Tuple[ColouredApplicationVertex, int, int, str][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 – The incoming projection to get the delay from

Returns:

The vertex, the local delay, the delay stage, the partition id

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

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

Parameters:

value – The value to be divided by

Returns:

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

spynnaker.pyNN.models.common.local_only_2d_common.get_first_and_last_slice(pre_vertex: ApplicationVertex) Tuple[Slice, Slice] | Tuple[MDSlice, MDSlice][source]
Parameters:

pre_vertex – The source vertex

Returns:

The first and last slice of an application vertex.

spynnaker.pyNN.models.common.local_only_2d_common.get_rinfo_for_spike_source(pre_vertex: ApplicationVertex, partition_id: str) Tuple[AppVertexRoutingInfo, int, int][source]

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

Parameters:
  • pre_vertex – The source of incoming data

  • partition_id – The partition ID to get the routing info from

Returns:

Routing information, core mask, core mask shift

spynnaker.pyNN.models.common.local_only_2d_common.get_sources_for_target(app_vertex: PopulationVertex) Dict[Tuple[ColouredApplicationVertex, str], List[Source]][source]

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

Parameters:

app_vertex – The vertex being targeted

Returns:

A dict of source ApplicationVertex to list of source information

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

Returns:

The generator parameter type code for the given data type.

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.

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.

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[tuple[Any, ...], dtype[uint32]][source]
Parameters:

values

Returns:

The parameter generator parameters as a numpy array.

spynnaker.pyNN.models.common.param_generator_data.param_generator_params_size_in_bytes(values: int | float | RandomDistribution) int[source]
Parameters:

values

Returns:

The size of the parameter generator parameters in bytes.

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

Returns:

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

spynnaker.pyNN.models.common.recording_utils module

spynnaker.pyNN.models.common.recording_utils.make_missing_string(missing: Iterable[Placement]) str[source]

Unused likely to be removed.

Parameters:

missing

Returns:

A String with the X, Y and P of each placement

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[tuple[Any, …], dtype[floating]] | RandomDistribution | int | Sequence[int] | Sequence[Sequence[int]] | ndarray[tuple[Any, …], dtype[integer]]

spynnaker.pyNN.models.common.types.Values

Type of normal values of parameters and state variables.

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

Module contents

class spynnaker.pyNN.models.common.EIEIOSpikeRecorder

Bases: object

Records spikes using EIEIO format.

property record: bool

If the recorder is set to record

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

  • spikes_per_timestep

Returns:

SDRAm cost for saving the recordings

property record: bool

If this recorder is recording or not

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

  • data_types

  • bitfield_variables

  • n_neurons

  • per_timestep_variables

  • per_timestep_datatypes

  • events_per_core_variables

  • events_per_core_datatypes

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

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

Parameters:

offset – The offset to add

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

variable – Name of variable to get type for

Returns:

Type of data for this variable. Defaults to MATRIX even if the variable in unknown

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 – The PyNN variable name to get buffered SDRAM of

  • vertex_slice

Returns:

data size

get_buffered_sdram_per_record(variable: str, vertex_slice: Slice) int[source]

Return the SDRAM used per record.

Parameters:
  • variable – PyNN variable name

  • vertex_slice

Returns:

usage

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 – PyNN variable name

  • vertex_slice

Returns:

usage

get_data_type(variable: str) DataType | None[source]
Parameters:

variable

Returns:

Type of the Data for this variable or None if unknown

get_event_recordable_variables() List[str][source]
Returns:

Names of event variables being recorded

get_generator_data(vertex_slice: Slice | None = None) ndarray[tuple[Any, ...], dtype[uint32]][source]
Parameters:

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

Returns:

The recorded data as a generatable data set.

get_generator_sdram_usage_in_bytes(n_atoms: int) int[source]
Parameters:

n_atoms – The number of atoms to be recorded

Returns:

The SDRAM usage of the generator data for recording metadata.

get_max_buffered_sdram_per_record(variable: str, n_atoms: int) int[source]

Return the SDRAM used per record.

Parameters:
  • variable – PyNN variable name

  • n_atoms – number of atoms recording

Returns:

usage

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

n_atoms

Returns:

SDRAM cost EXCLUDING fix cost for saving the recordings

get_metadata_sdram_usage_in_bytes(n_atoms: int) int[source]
Parameters:

n_atoms – The number of atoms to record

Returns:

The SDRAM usage of the metadata for recording.

get_recordable_variables() List[str][source]
Returns:

Names of variables that can be recorded

get_recorded_indices(application_vertex: ApplicationVertex, variable: str) Iterable[int][source]
Parameters:
  • application_vertex – The vertex being recorded

  • variable – The name of the variable to get the indices of

Returns:

The indices being recorded for a given variable.

get_region(variable: str) int[source]
Parameters:

variable – The variable to get the region of

Returns:

The region of a variable.

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

Returns:

List of size of each region including ones not recoding

get_sampling_interval_ms(variable: str) float[source]

Get the sampling interval of a variable.

Parameters:

variable – The variable to get the sampling interval of

Returns:

Sampling interval in microseconds

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

Returns:

Highest possible overflow needed

get_variable_sdram_usage(vertex_slice: Slice) AbstractSDRAM[source]
Parameters:

vertex_slice

Returns:

SDRAM cost including fix cost for saving the recordings

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.

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

variable – The variable to check for

Returns:

True if the given variable can be recorded, regardless if it is actually recording or not.

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

variable

Returns:

True if the variable is being recorded, False if the variable is not being recorded or not recordable

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

  • vertex_slice

Returns:

The indexes of the neurons recording or None if the variable is unknown

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

vertex_slice

Returns:

list of the IDs of the variables actually recording. Editing this list will not change recording settings.

property recorded_region_ids: Iterable[int]

The ids of the regions for each variable being recorded.

property recording_variables: Iterable[str]

Names of the variables recording

set_max_rewires_per_ts(max_rewires_per_ts: int) None[source]

Sets the the maximum rewires per timestep

Parameters:

max_rewires_per_ts – the maximum rewires per timestep

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

Turns on the requested recording

Parameters:
  • variable – PyNN variable name

  • new_state

  • sampling_interval

  • indexes

write_neuron_recording_region(spec: DataSpecificationBase, neuron_recording_region: int, vertex_slice: Slice) None[source]

Recording data specification.

Parameters:
  • spec – where to write the data specification

  • neuron_recording_region – the recording region

  • vertex_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[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 – A list of data fields to be returned

  • get_call – A function to call to read a value

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

items() Iterable[Tuple[str, List[float]]][source]
Returns:

Iterable of the names and matching values of the data

keys() Iterable[str][source]
Returns:

The names of the data

values() Iterable[List[float]][source]
Returns:

The values of the data

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

Bases: ColouredApplicationVertex, 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 – The optional name of the vertex.

  • max_atoms_per_core – 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 – 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.

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 – The machine vertex to get the map for

  • partition_id – The partition to get the map for

  • routing_info – Routing information

Returns:

A list of (atom_id, key)

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 – The name of the variable recorded

Raises:

KeyError – if the variable isn’t being recorded

Returns:

Data type in the Buffer Database

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]
Parameters:
  • names – The name or names of the variable to get

  • selector – a description of the subrange to accept, or None for all. See: :py:meth:`~spinn_utilities.ranged.AbstractSized.selector_to_ids

Returns:

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

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 – The name of the variable to get the type of

Returns:

The data type used by the C code

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]
Parameters:
  • names – The name or names of the variable to get

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

Returns:

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

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 – The name of the variable to get the region of

  • vertex_slice

Returns:

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

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]
Parameters:
  • names – The name or names of the parameter to get

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

Returns:

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

Raises:

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

get_parameters() List[str][source]
Returns:

The names of all the parameters that can be obtained

get_recordable_variables() List[str][source]

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

This methods list the variable recorded via the Population.

Includes both neuron and synapse recordable things

Returns:

List of variable names

get_recording_region(name: str) int[source]
Parameters:

name – The name of the variable to get the region of

Returns:

The recording region for the named variable.

Raises:

KeyError – If the variable isn’t being recorded

get_recording_variables() List[str][source]
Returns:

A list of variables that are currently being recorded.

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()

Parameters:

name – The name of the variable

Returns:

Sampling rate in milliseconds for this variable

Raises:

KeyError – If the variable isn’t being recorded

get_state_variables() List[str][source]
Returns:

A list of supported state variables.

get_units(name: str) str[source]

Get the units of the given parameter or state variable.

Parameters:

name – the name of the parameter to get the units of

Returns:

The unit or this variable. For example ‘mV’ or ‘uS’. Will be an empty string for things like spikes and probability

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

Inject a current source into this population.

Parameters:
  • current_source – the current source to be injected

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

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

set_current_state_values(name: str, value: float | Sequence[float] | ndarray[tuple[Any, ...], dtype[floating]] | RandomDistribution, selector: None | int | integer | SupportsInt | slice | Sequence[bool | bool] | Sequence[int | integer | SupportsInt] = None) None[source]

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

Parameters:
  • name – The name of the variable to set

  • value – The new value

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

Raises:

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

set_initial_state_values(name: str, value: float | Sequence[float] | ndarray[tuple[Any, ...], dtype[floating]] | RandomDistribution, selector: None | int | integer | SupportsInt | slice | Sequence[bool | bool] | Sequence[int | integer | SupportsInt] = None) None[source]

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

Parameters:
  • name – The name of the variable to set

  • value – The new value

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

Raises:

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

set_not_recording(name: str, indices: Collection[int] | None = None) None[source]

Set a variable not recording.

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

  • indices – 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[tuple[Any, ...], dtype[floating]] | RandomDistribution, selector: None | int | integer | SupportsInt | slice | Sequence[bool | bool] | Sequence[int | integer | SupportsInt] = None) None[source]

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

Parameters:
  • name – The name of the parameter to set

  • value – The new value

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

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

Set a variable recording.

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

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

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

Raises:

KeyError – if the variable cannot be recorded