SynOpCounter#

SNNSynOpCounter#

class sinabs.synopcounter.SNNSynOpCounter(model, dt=1.0)[source]#

Counter for the synaptic operations emitted by all SpikingLayers in a spiking model. Note that this is automatically instantiated by from_torch and by Network if they are passed synops=True.

Usage:

counter = SNNSynOpCounter(my_spiking_model)

output = my_spiking_model(input) # forward pass

synops_table = counter.get_synops()

Parameters
  • model – Spiking model.

  • dt – the number of milliseconds corresponding to a time step in the simulation (default 1.0).

get_synops() pandas.core.frame.DataFrame[source]#

Method to compute a table of synaptic operations for the latest forward pass.

NOTE: this may not be accurate in presence of average pooling.

Returns

A Pandas DataFrame containing layer IDs and respectively, for the latest forward pass performed, their:

number of input spikes, fanout, synaptic operations, number of timesteps, total duration of simulation, number of synaptic operations per second.

Return type

SynOps_dataframe

get_total_power_use(j_per_synop=1e-11)[source]#

Method to quickly get the total power use of the network, estimated over the latest forward pass.

Parameters

j_per_synop – Energy use per synaptic operation, in joules. Default 1e-11 J.

Returns: estimated power in mW.

get_total_synops(per_second=False) float[source]#

Faster method for computing total synaptic operations without using Pandas.

NOTE: this may not be accurate in presence of average pooling.

Parameters

per_second (bool, default False) – if True, gives synops per second instead of total synops in the last forward pass.

Returns

the total synops in the network, based on the last forward pass.

Return type

synops

SynOpCounter#

class sinabs.synopcounter.SynOpCounter(modules, sum_activations=True)[source]#

Counter for the synaptic operations emitted by all Neuromorphic ReLUs in an analog CNN model.

Usage:

counter = SynOpCounter(MyTorchModel.modules(), sum_activations=True)

output = MyTorchModule(input) # forward pass

synop_count = counter()

Parameters
  • modules – list of modules, e.g. MyTorchModel.modules()

  • sum_activations – If True (default), returns a single number of synops, otherwise a list of layer synops.