Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft of Power Profiling #170 #232

Merged
merged 15 commits into from
Aug 15, 2023

Conversation

mlewandowski0
Copy link

related to issue #170

Hi,
I have implemented an initial version of power profiling. It was based on the torchinfo (the display style is the same as torchinfo, however, it reports the number of synapses, neurons, spiking and all events with some power estimations, simillarly to KerasSpiking ). Currently, I implemented :

  • 'estimate_energy' function which takes a nn.Module, some extra information like input tensor on which we want to run the network or input shape and information about the Device, and similarly to KerasSpiking, it produces some estimation about the energy required for inference [snntorch/energy_estimation/estimate_energy.py ]
  • A basic model of the device contained in DeviceProfile (similar to Keras Spiking, currently considers only energy per neuron event, energy per synapse event and is the device neuromorphic) and a way to register new devices (DeviceProfileRegistry) [snntorch/energy_estimation/device_profile.py and snntorch/energy_estimation/device_profile_registry.py]
  • only support for Linear layers, Convolutional layers, Activation functions and any nested layers containing these (calculating synapse/neuron counts and events for them). I added a simple way to register new types of layers: for a given layer type (identified by class name), I can add some function that will count the number of synapses/neurons (given the layer information and input/output tensors), another function which will count the number of total and spiking events(given the layer information and input/output tensors), and optional function which will override default way of calculating energy, and return a custom energy term [snntorch/energy_estimation/layer_parameter_event_calculator.py]

To see how in current shape it is used, and what it looks like please see the tests/test_energy_estimation.py file.

Please let me know if you think this implementation is good enough and what I can improve to make it part of the repository.
Best Regards

Copy link
Collaborator

@ahenkes1 ahenkes1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mlewandowski0 ,

thank you very much for your extensive contribution! Everything looks fine to me.

Just as a comment: for testing everything, we could first put it to a new branch before merging it with the master branch. What do you think, @jeshraghian ?

@ahenkes1 ahenkes1 self-assigned this Aug 14, 2023
@ahenkes1 ahenkes1 added the enhancement New feature or request label Aug 14, 2023
@ahenkes1 ahenkes1 linked an issue Aug 14, 2023 that may be closed by this pull request
@ahenkes1 ahenkes1 changed the base branch from master to Power-Profiling August 14, 2023 09:40
@ahenkes1
Copy link
Collaborator

@mlewandowski0 , some tests are failing:

py37: commands[1]> pytest --basetemp=/home/runner/work/snntorch/snntorch/.tox/py37/tmp
ImportError while loading conftest '/home/runner/work/snntorch/snntorch/tests/conftest.py'.
tests/conftest.py:43: in
class EnergyEfficiencyNetTest1(nn.Module):
tests/conftest.py:44: in EnergyEfficiencyNetTest1
def init(self, beta: float, num_timesteps: int | None = None):
E TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'

Could you check again? Be sure that all tests are passing.
Contributing

@ahenkes1 ahenkes1 marked this pull request as draft August 15, 2023 11:43
@ahenkes1 ahenkes1 marked this pull request as ready for review August 15, 2023 12:11
@ahenkes1 ahenkes1 merged commit 150eeb0 into jeshraghian:Power-Profiling Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add power profiling capabilities
3 participants