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

Add MAC metric #51

Closed
vlomonaco opened this issue May 15, 2020 · 10 comments · Fixed by #138
Closed

Add MAC metric #51

vlomonaco opened this issue May 15, 2020 · 10 comments · Fixed by #138
Assignees
Labels
Feature - Low Priority New feature or request, low priority

Comments

@vlomonaco
Copy link
Member

It would be nice to have also a MAC metric. It's difficult to compute it in native pytorch for every possible layer, but it would be a nice, hardware independed metric.

Any idea on how to do this easily in PyTorch?

@vlomonaco vlomonaco added Feature - Low Priority New feature or request, low priority question labels May 15, 2020
@AntonioCarta
Copy link
Collaborator

A simple implementation can ignore the cost of activation functions and only compute the cost of feedforward and convolutional layers. Then you have to manage all the cases for convolutional layers.

The biggest problem is that for convolutional layers you need to know the input size, and therefore the layer's order.

@vlomonaco
Copy link
Member Author

@AntonioCarta Maybe we can create a script that given a pytorch model:

  1. Convert every conv layer into a custom conv layer which also counts MAC for it (on-the-fly during the forward pass) and saves them in a common attribute of the model object (let's say a dict).
  2. Run the model on the first mini-batch of the chosen benchmark and return MAC statistics

What do you think?

@AntonioCarta
Copy link
Collaborator

Yes, that may be a solution. It should also be possible with forward hooks without subclassing.
I can try to implement it.

@akshitac8
Copy link
Collaborator

@AntonioCarta Is this issue solved?

@AntonioCarta
Copy link
Collaborator

Not yet. If you want you can work on this @akshitac8.

@AntonioCarta
Copy link
Collaborator

@akshitac8 are you working on this? It's not clear to me since I see that I am still assigned to the issue. Please give me a confirmation and assign the issue to yourself if you are taking it.
Otherwise I will work on this.

@akshitac8
Copy link
Collaborator

I am sorry for not giving you a clear sign on it. I had a medical emergency but now I have started working on this bust not clear just MAC metric is needed or both this issue and #60 are related?
if you can clear me on this and then you can assign me the issue :)

@vlomonaco vlomonaco changed the title Add MAC metric (?) Add MAC metric Jun 19, 2020
@vlomonaco
Copy link
Member Author

@AntonioCarta any news on this? Should we disassign this issue?

@AntonioCarta
Copy link
Collaborator

Sorry, I forgot this issue was still assigned to me. I can do it (with the limitations discussed above), give me about a week of time to complete it.

@vlomonaco
Copy link
Member Author

This may be interesting to look into when we want to upgrade the profiler: https://github.com/zhijian-liu/torchprofile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature - Low Priority New feature or request, low priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants