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

Discussion on the role of some classes #4

Open
saman-aghazadeh opened this issue Nov 15, 2021 · 4 comments
Open

Discussion on the role of some classes #4

saman-aghazadeh opened this issue Nov 15, 2021 · 4 comments

Comments

@saman-aghazadeh
Copy link

Hi,

I'm trying to understand the structure of the core pruning classes. I wanted to start this thread, and see if you can provide some explanation on the roles of the below classes, and how they generally interact with the main net class:

  • Allocator
  • Pruner
  • Sparsifier
  • Tracker

Any other extra information is also much appreciated.

@lucaslie
Copy link
Owner

lucaslie commented Dec 2, 2021

Hi,

thanks for reaching out. here is an overview and please feel free to ask me any follow-up questions if you want to go into details about any of those:

The BaseCompressedNet takes care of the overall compression and provides the high-level API for compressing a network.

The network compression itself is split up into multiple parts:

  1. Allocator: The allocator takes a overall desired prune ratio for the network and allocates a per-layer prune ratio. So in the simplest case the allocator could just be a constant per-layer prune ratio, for example.

  2. Pruner: The pruner takes as input the per-layer prune ratio and determines how many weights should be pruned from each filter or neuron in the layer. So it's almost like a allocator within a layer.

  3. Sparsifier: this class actually implements the sparsification. So as input it takes the per-neuron/filter sparsity determined by the pruner and sparsifies the weight tensor.

  4. Tracker: is a convenient wrapper for pytorch's forward/backward hook functionality to track layer statistics that might be required during pruning.

@saman-aghazadeh
Copy link
Author

Hi,

Thanks for the explanation. I was going through the code with the info you provided above and it helped me get a better understanding of how things works.

I just need a bit more explanation on how base classes for allocator and pruner work. I have hard time to understand the base logic behind these two classes, just by reading the code. Any help will be appreciated.

@saman-aghazadeh
Copy link
Author

Also another question. I'm interested to play around with the structured sparsification of the model. Does the code remove the sparsed filters from the model? I would like to be able to get real performance boost on the hardware, after performing the sparsification.

Thanks,

@lucaslie
Copy link
Owner

This is currently not supported and/or I don't have plans to support it. If you are interested in inference time speed-ups, then I would recommend writing some type of post-processing tool that takes the network graph as input and outputs the slimmed model.

Alternatively, you can also hardcode the slimmed version for a particular architecture.

If you want to implement something like this, I would be happy to take PRs as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants