samna.speck2f.configuration#

Submodules#

Module content#

class samna.speck2f.configuration.CnnLayerConfig#

Bases: pybind11_object

Configuration options for CNN layers.

property biases#

Contains bias values for features in a layer.

Formatted as [feature].

Type:

tensor array

property destinations#

List of 2 CnnLayerDestination which describe target destination layers for events produced in this layer.

Type:

Array of 2 fixed length

property dimensions#

Specifies padding, stride, kernel size and I/O shape of the layer.

Type:

Instance of CnnLayerDimensions

from_json(self: samna.speck2f.configuration.CnnLayerConfig, arg0: str) None#
property input_congestion_balancer_enable#

Enable input congestion balancer (default False).

In Speck 2f, each convolutional layer is equipped with a congestion balancer block at its data path input. The congestion balancer enables dropping of input spikes at any time when the convolutional core of the layer is busy processing previous data. Specifically, if a train of spikes is sent to the layer, a number of them will be accepted (via some buffering) and the convolution computation starts. If, for example, the kernel is very large and a new spike arrives while the layer input is busy, this new spike will be dropped. As soon as the layer is again available, a incoming spike will be processed.

This block is then able to adapt the spike input frequency to the convolution by capping it to the maximum that the layer can process.

When disabled, the block will let all spikes through.

Type:

bool

property leak_enable#

Enable leak/bias processing for this layer (default False).

A slow clk must be provided to SLOW_CLK pin.

CAUTION: May impact performance significantly.

Type:

bool

property leak_internal_slow_clk_enable#

forward internally generated slow clock to convolutional layers’ leak generator to replace the need of external slow clk.

The leak_enable must be set to True first

Type:

bool

property monitor_enable#

Enable monitoring of this layer (default False).

When True, all events produced by this layer will also be output on the monitoring bus. If False, events will only go to layers selected in the layer list.

Monitoring should only be enabled on development kits that support fast readout of events.

Type:

bool

property neurons_initial_value#

Contains initial neuron membrane potential values for neurons in a layer.

Formatted as [feature][x][y].

Type:

tensor array

property output_decimator_enable#

Enable output decimator (default False).

In Speck 2f, each convolutional layer is equipped with a decimator block at its data path output. The decimator block enables the user to reduce the spike rate at the output of a convolutional layer. When disabled, the block will let all spikes through. The spike rate can be reduced by setting output_decimator_interval

Type:

bool

property output_decimator_interval#

Output decimator block interval (default is 1 spike passed every 2).

value

Description

0b000

1 spike passed every 2

0b001

1 spike passed every 4

0b010

1 spike passed every 8

0b011

1 spike passed every 16

0b100

1 spike passed every 32

0b101

1 spike passed every 128

0b110

1 spike passed every 256

0b111

1 spike passed every 512

Type:

int

property return_to_zero#

If True, neurons in this layer will return to 0 when firing. Otherwise their threshold will be subtracted from the value their membrane potential reached before firing (default False).

Type:

bool

property threshold_high#

Set the high threshold (default 0), can be in range [0, 32767].

When the neuron’s membrane potential becomes equal to or greater than this value the neuron will fire.

Type:

int

property threshold_low#

Set the low threshold (default -1), can be in range [-32768, -1].

The minimum value of the neuron membrane potential which cannot be surpassed by leak.

Type:

int

to_json(self: samna.speck2f.configuration.CnnLayerConfig) str#
property weights#

4 dimensional list of lists representing kernel parameters.

Formatted as [feature][channel][x][y].

Type:

tensor array

class samna.speck2f.configuration.CnnLayerDestination#

Bases: pybind11_object

Configuration options for CNN layer destinations.

property enable#

Enable this destination (default False).

If False no events will be forwarded, if True all events will be forwarded to this destination.

Type:

bool

property feature_shift#

Shift feature IDs (default 0).

The feature ID observed in the target layer will be the ID in this layer + feature_shift.

Type:

int

from_json(self: samna.speck2f.configuration.CnnLayerDestination, arg0: str) None#
property layer#

Target layer ID (default 0).

Allowed values [0, 8] and 12, where [0, 8] are the CNN layers and layer 12 is the readout layer.

Type:

int

property pooling#

Pooling will be applied to events before reaching the selected destination layer (default 1).

Allowed values: {1, 2, 4}

Type:

int

to_json(self: samna.speck2f.configuration.CnnLayerDestination) str#
class samna.speck2f.configuration.CnnLayerDimensions#

Bases: pybind11_object

Describes the dimensions of a Cnn layer as the configurable parameters.

from_json(self: samna.speck2f.configuration.CnnLayerDimensions, arg0: str) None#
get_biases_array_dimensions(self: samna.speck2f.configuration.CnnLayerDimensions) List[int[1]]#

Function to get the dimension of the bias array.

Returns:

A list of the dimension in the format of [feature].

get_neuron_states_array_dimensions(self: samna.speck2f.configuration.CnnLayerDimensions) List[int[3]]#

Function to get the dimension of the neuron states array.

Returns:

A list of the dimension in the format of [feature, x, y].

get_weights_array_dimensions(self: samna.speck2f.configuration.CnnLayerDimensions) List[int[4]]#

Function to get the dimension of the weights array.

Returns:

A list of the dimension in the format of [feature, channel, x, y].

property input_shape#

Shape of features on the input of this layer.

Type:

Instance of IOShape

property kernel_size#

Kernel size for all features in this layer. All kernels are square (default 1).

Allowed values [1, 16]

Type:

int

property output_shape#

Shape of features on the output of this layer.

Type:

Instance of IOShape

property padding#

Padding of all features in this layer (default (0, 0)).

Allowed values [0, 7].

Type:

Instance of Vec2

property stride#

Stride for all features in this layer (default (1, 1)).

Allowed values {1, 2, 4, 8}.

Type:

Instance of Vec2

to_json(self: samna.speck2f.configuration.CnnLayerDimensions) str#
class samna.speck2f.configuration.DvsFilterConfig#

Bases: pybind11_object

The DVS Filter Block is included in the DVS pre-processing layer of Speck 2f in order to filter events depending on neighboring pixel activity. In general, an event at position (x,y) is forwarded by the filter when at least one pixel in the vicinity of (x,y) has spiked in a defined time window before the (x,y) event.

property enable#

Enable the filter (default False).

A clock (<1KHz) must be provided to SLOW_CLK pin if internal_slow_clk is False.

Type:

bool

property filter_size#

Filter window size in the X/Y dimension (default (1, 1)).

Type:

Instance of Vec2

from_json(self: samna.speck2f.configuration.DvsFilterConfig, arg0: str) None#
property hot_pixel_filter_enable#

Enable hot pixel filtering, default is enabled (default True).

The enable has to be set True first.

Type:

bool

property internal_slow_clk#

Forward internally generated slow clock to DVS filter to replace the need of external slow clk (default False).

The enable must be set to True first.

Type:

bool

property low_pass_mode_enable#

When enabled, the filter works as a low-pass filter.

property threshold#

Defines the threshold of the filter (default 5).

This value is used to compare the current counter value with the value of the pixels neighboring the current spiking pixel. If any of the neighboring pixels has a value difference within the delta value, the filter emits the current spike. Otherwise, the current spike is blocked.

Type:

int

to_json(self: samna.speck2f.configuration.DvsFilterConfig) str#
class samna.speck2f.configuration.DvsLayerConfig#

Bases: pybind11_object

Configuration options for event pre-process layer. The event pre-processing layer receives as input the events coming from the internal DVS, or from an external source through the Input Serial Interface

property cut#

Select the bottom right point of region of interest (default [127, 127]). It needs to be used with origin.

Type:

Instance of Vec2

property destinations#

Destinations

Type:

list of 2 DvsLayerDestination

from_json(self: samna.speck2f.configuration.DvsLayerConfig, arg0: str) None#
property merge#

merge the two polarities from the DVS (On/Off) (default False).

If True, Merge all events marking them with Polarity = 1. If False, Pass all events and maintain the polarity information.

Type:

bool

property mirror#

Enable mirroring or not of the X or Y dimension (default (False, False)).

Mirroring is reversing image on X or Y dimension.

Type:

object(x bool, y bool)

property mirror_diagonal#

Enables mirroring of the input events along the diagonal. (default False)

when set to True, it swaps X with Y.

Type:

bool

property monitor_enable#

Enables the DVS Pre-Processing Spike Monitor Bus (default False).

When enabled, output messages of the dvs pre-processing block are forwarded on the monitor bus to the output serial interface data1 input.

This is typically openned when you want speck2f to output dvs events.

Type:

bool

property off_channel#

Whether pass events with OFF polarity. (default True).

If True, pass events with OFF polarity. If False, block events with OFF polarity

Type:

bool

property on_channel#

Whether pass events with ON polarity. (default True).

If True, pass events with ON polarity. If code:False, block events with ON polarity

Type:

bool

property origin#

Select the top left point of region of interest (default [0, 0]). It needs to be used with cut.

Type:

Instance of Vec2

property pass_sensor_events#

Pass/Drop Internal DVS Events (default False). This will be automatically set by setting raw_monitor_enable and monitor_enable.

If disabled, the internal sensor events are dropped, i.e., not forwarded to the DVS pre-processing block.

This is typically used when sensor data is provided by an external source (Ext DVS Mode).

Type:

bool

property pooling#

Pooling is collecting DVS events in an area, available values are {1, 2, 4}, you can set pooling value on X/Y dimension separately (default (1, 1)).

For example, if you set config.dvs_layer.pooling.x = 2 and config.dvs_layer.pooling.y = 2, the DVS events of a 2x2 pixel area are summed together.

Type:

Instance of Vec2

property raw_monitor_enable#

Enables the DVS Monitor Bus (default False).

When enabled, input messages to the DVS pre-processing block are forwarded on the monitor bus to the output serial interface data1 input.

These messages are the raw messages coming from the internal DVS or an external sensor (Ext DVS Mode) before pre-processing.

Type:

bool

to_json(self: samna.speck2f.configuration.DvsLayerConfig) str#
class samna.speck2f.configuration.DvsLayerDestination#

Bases: pybind11_object

Configuration options for dvs layer destination. It can have 2 destinations.

property enable#

if this destination is enabled (default False).)

Type:

bool

from_json(self: samna.speck2f.configuration.DvsLayerDestination, arg0: str) None#
property layer#

destination layer that is going to receive output data (default 0).

Type:

int

to_json(self: samna.speck2f.configuration.DvsLayerDestination) str#
class samna.speck2f.configuration.FactoryConfig#

Bases: pybind11_object

Contains the factory configurations for Speck 2f. Most configurations here are tuned for best performance. The configurations that user could modify are given with doc strings.

from_json(self: samna.speck2f.configuration.FactoryConfig, arg0: str) None#
property internal_slow_clk_divider#

set the power of internal slow clock divider. Default 17. Must be one of 14, 15, 16 and 17.

The internally generated clock exploits the random continuous generation of internal DVS events (even though the generation frequency can fluctuate) by dividing the number of generated events by a constant (2^14 to 2^17). In a typical application, the slow clock toggles at a speed of around 10Hz to 10kHz.

Type:

int

property monitor_dual_channel#

enable the dual channel output feature. This could improve the output bandwidth if you have extremely high output throughput, otherwise it may decrease the performance. Default False.

Type:

bool

to_json(self: samna.speck2f.configuration.FactoryConfig) str#
class samna.speck2f.configuration.IOShape#

Bases: pybind11_object

Describes the input or output shape of a CNN layer.

property feature_count#

Number of features in the input or output (default 1).

Type:

int

from_json(self: samna.speck2f.configuration.IOShape, arg0: str) None#
property size#

Size of each feature (default (1, 1)).

Type:

Instance of Vec2

to_json(self: samna.speck2f.configuration.IOShape) str#
class samna.speck2f.configuration.ReadoutConfig#

Bases: pybind11_object

The main use of the post-processing block is to calculate the moving average over a time window for a maximum of 15 neurons, provide the maximum average of the 15 neurons and compare the value of the calculated moving averages against a specified threshold.

property enable#

enable the readout block, a slow clk (frequency depends on the algorithm model) must be provided to SLOW_CLK pin (default False).

Type:

bool

from_json(self: samna.speck2f.configuration.ReadoutConfig, arg0: str) None#
property internal_slow_clk#

forward internally generated slow clk to the readout block to replace the need of external slow clk (default False). The enable must be set to True first.

Type:

bool

property low_pass_filter32_not16#

Selects readout moving average length (default False).

Value

Configuration

False

time window = 16* MOVING_AVERAGE_CLK period

True

time window = 32* MOVING_AVERAGE_CLK period

Type:

bool

property low_pass_filter_disable#

Disables readout low pass filtering (default False).

Value

Configuration

False

time window = selected by low_pass_filter32_not16

True

time window = 1 MOVING_AVERAGE_CLK period

This overrides low_pass_filter32_not16 when set to True.

Type:

bool

property monitor_enable#

Allow monitoring of readout events (default False).

You will receive ReadoutValue from the model if enabled.

Please note that if you turn this on, you can’t get any events from CNN layers or the DVS sensor anymore.

Type:

bool

property output_mode_sel#

Select the readout output mode (default 0).

There are 4 different modes where the output data are multiplexed. In the following table the different data output modes are described:

output_mode_sel

data_out[20]

data_out[19:16]

data_out[15:0]

0b00

data valid

neuron index of max average

power down (clock gating)

0b01

data valid

neuron index of max average

threshold compare output

0b10

data valid

neuron index of max average

average output of the selected neuron

0b11

max spiking neuron above threshold

neuron index of max average

average output of max spiking neuron

If output_mode_sel equals to 0b00 then the clk_gated signal and the data_out[15:0] are equal to 0.

If output_mode_sel equals to 0b01 then the data_out[15:0] consists of the data of the threshold comparison, the index of the maximum moving average neuron and the data valid signal. The threshold comparison data is the 16 bit value of the comparison of each neurons’ moving average with the threshold.

If output_mode_sel equals to 0b10 then the data_out[15:0] consists of the moving average of the selected neuron, the index of the maximum moving average neuron and the data valid signal. The data valid signal is asserted after all the computations have finished in order to ensure correct sampling of the data.

If :output_mode_sel equals to 0b11 then the data_out[15:0] consists of the maximum average of the 15 neurons, the index of the maximum moving average neuron and the comparison output between the maximum moving average and the threshold.

Type:

int

property output_neuron_num#

select one of the 15 readout neurons (default 0).

The internal signal output_mode_sel enable the selection of one of the 15 output neurons. The neuron selection is used when signals output_mode_sel == 0b10.

Selected neuron number = average_sel.

Type:

int

property override_threshold_max#

Override Output Layer Threshold compare (default False).

Sends interrupt at each slow clock cycle.

Type:

bool

property readout_configuration_sel#

Addressing modes of the incoming spikes (default 0).

There are 4 different addressing modes that could be selected. The valid configurations are the following:

Value

Configuration

0b00

2x*2y*4f

0b10

4x*4y*1f

0b01

2x*4y*2f

0b11

1x*1y*16f

Where x, y and f represent, respectively, the X, Y and Feature dimensions of the events arriving at the Readout Layer.

Type:

int

property readout_pin_monitor_enable#

enable/disable the monitor of the readout pins (default False).

If enabled, the ReadoutPinValue will be outputted.

Type:

bool

property threshold#

Readout neurons threshold value (default 0).

The moving average of the output neurons is compared to the threshold value to produce an output if the received number of spikes is greater than the threshold.

Type:

int

to_json(self: samna.speck2f.configuration.ReadoutConfig) str#
class samna.speck2f.configuration.SpeckConfiguration#

Bases: pybind11_object

Contains configuration options and network parameters for a Speck 2f device. Applied to a device via apply_configuration() on the device model.

The configuration is divided into settings for the 9 CNN layers, the DVS event pre-processing layer and the readout layer. The factory configuration and debug configuration sub structs are pre-populated with default values and are only used for debug scenarios.

property cnn_layers#

List of 5 CnnLayerConfig.

property debug_config#

Instace of DebugConfig

property dvs_filter#

Instance of DvsFilterConfig

property dvs_layer#

Instance of DvsLayerConfig

property factory_config#

Instance of FactoryConfig.

from_json(self: samna.speck2f.configuration.SpeckConfiguration, arg0: str) None#
property readout#

Instance of ReadoutConfig.

to_json(self: samna.speck2f.configuration.SpeckConfiguration) str#