Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Compression for Tensorflow #2755

Merged
merged 12 commits into from
Aug 12, 2020
Merged

Compression for Tensorflow #2755

merged 12 commits into from
Aug 12, 2020

Conversation

liuzhe-lz
Copy link
Contributor

No description provided.

@scarlett2018 scarlett2018 mentioned this pull request Jul 31, 2020
66 tasks
@liuzhe-lz liuzhe-lz marked this pull request as ready for review August 5, 2020 02:40
Common base class for all compressors.

This class is designed for other base classes.
Algorithms should inherit ``Pruner`` or Quantizer instead.
Copy link
Contributor

Choose a reason for hiding this comment

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

Quantizer -> Quantizer

if ret is None or ret.get('exclude'):
return None
return ret
The compressed model can only execute in eager mode.
Copy link
Contributor

Choose a reason for hiding this comment

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

is this statement still true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we apply masks by modifying weight variables, which can only be done in eager mode.

Copy link
Contributor

Choose a reason for hiding this comment

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

so the performance will be affected if we apply masks on the model? how much performance degradation it would induce?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know...

Copy link
Contributor

Choose a reason for hiding this comment

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

better to check the performance degradation using simple test


If you want to prune the model during training, use callback API instead.
Copy link
Contributor

Choose a reason for hiding this comment

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

which one is callback API?

Copy link
Contributor

Choose a reason for hiding this comment

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

PrunerCallback right?

The key is weight ``Variable``'s name. The value is a mask ``Tensor`` of weight's shape and dtype.
If a weight's key does not appear in the return value, that weight will not be pruned.
Returning ``None`` means the mask is not changed since last time.
Weight names are globally unique, e.g. `model/conv_1/kernel:0`.
Copy link
Contributor

Choose a reason for hiding this comment

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

very clear!

@QuanluZhang
Copy link
Contributor

looks good. please add test for it and fix pipeline error

}]
pruner = FPGMPruner(model, config_list)
pruner.compress()
```
Copy link
Contributor

Choose a reason for hiding this comment

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

i think we should keep Chinese doc unchanged, and let @JunweiSUN to update Chinese doc using crowdin

@liuzhe-lz liuzhe-lz merged commit 5623dbf into microsoft:master Aug 12, 2020
@tu1258
Copy link

tu1258 commented Aug 12, 2020

Would you mind telling me why FPGM Pruner is removed? Is former version not work or you guys are work on a new version now? I may have to use filter pruning for CNN while there is almost no tensorflow related toolkit for it. Is there a stable version here?(no need to be latest) Much thanks!

@QuanluZhang
Copy link
Contributor

Would you mind telling me why FPGM Pruner is removed? Is former version not work or you guys are work on a new version now? I may have to use filter pruning for CNN while there is almost no tensorflow related toolkit for it. Is there a stable version here?(no need to be latest) Much thanks!

@tu1258 As model compression framework on NNI has been refactored, we will re-implement the algorithms on the new framework for tensorflow. also, highly recommend external contributors to contribute the compression algorithms.

LovPe pushed a commit to LovPe/nni that referenced this pull request Aug 17, 2020
@liuzhe-lz liuzhe-lz deleted the tf-compress branch September 17, 2020 23:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants