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.

Parameters
  • model – Spiking model.

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

Example

>>> counter = SNNSynOpCounter(my_spiking_model)
>>> output = my_spiking_model(input)  # forward pass
>>> synops_table = counter.get_synops()
get_synops() dict[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 dictionary 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

dict

Example

>>> synops_map = counter.get_synops()
>>> SynOps_dataframe = pandas.DataFrame.from_dict(synops_map, "index")
>>> SynOps_dataframe.set_index("Layer", inplace=True)
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]#

Sums up total number of synaptic operations across the network.

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.

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.

Example

>>> counter = SynOpCounter(MyTorchModel.modules(), sum_activations=True)
>>> output = MyTorchModule(input)  # forward pass
>>> synop_count = counter()