tensorflow / model-optimization

A toolkit to optimize ML models for deployment for Keras and TensorFlow, including quantization and pruning.
https://www.tensorflow.org/model_optimization
Apache License 2.0
1.49k stars 319 forks source link

Extract _clone_model_with_weights from quantize_apply #1076

Open tbekolay opened 1 year ago

tbekolay commented 1 year ago

This aids downstream repos that implement fixes for various cloning issues by making this function able to be monkey-patched.

For context, I am part of @hunse's team that is affected by #994. We are successfully using the workaround that he posted in his final comment. However, in order to implement that workaround we have to copy/paste the entirety of quantize_apply in our project to monkey-patch it. While it works, it's a brittle solution as we will have to update our copied quantize_apply when it changes in this repo.

While we are happy to make a pull request with our full fix, it will add to your maintenance burden, so we thought that we would instead start off with this very minimal change that will not increase your maintenance burden, but still allow us to do a minor surgical monkey patch that requires no copy/pasting in our project. If you would like us to instead or in addition contribute that fix, please let me know (but since #994 has not received the "contributions welcome" tag, I assume it is not of interest at the moment).