-
- Downloads
More robust handling of data-parallel/serial graphs (#27)
Remove the complicated logic trying to handle data-parallel models as serially-processed models, and vice versa. *Function distiller.utils.make_non_parallel_copy() does the heavy lifting of replacing all instances of nn.DataParallel in a model with instances of DoNothingModuleWrapper. The DoNothingModuleWrapper wrapper does nothing but forward to the wrapped module. This is a trick we use to transform a data-parallel model to a serial-processed model. *SummaryGraph uses a copy of the model after the model is processed by distiller.make_non_parallel_copy() which renders the model non-data-parallel. *The same goes for model_performance_summary() *Model inputs are explicitly placed on the Cuda device, since now all models are Executed on the CPU. Previously, if a model was not created using nn.DataParallel, then the model was not explicitly placed on the Cuda device. *The logic in distiller.CompressionScheduler that attempted to load a model parallel model and process it serially, or load a serial model and process it data-parallel, was removed. This removes a lot of fuzziness and makes the code more robust: we do not needlessly try to be heroes. * model summaries - remove pytorch 0.4 warning * create_model: remove redundant .cuda() call * Tests: support both parallel and serial tests
Showing
- apputils/model_summaries.py 3 additions, 1 deletionapputils/model_summaries.py
- distiller/model_summaries.py 6 additions, 7 deletionsdistiller/model_summaries.py
- distiller/scheduler.py 2 additions, 14 deletionsdistiller/scheduler.py
- distiller/thinning.py 1 addition, 1 deletiondistiller/thinning.py
- distiller/utils.py 45 additions, 1 deletiondistiller/utils.py
- examples/classifier_compression/compress_classifier.py 1 addition, 3 deletionsexamples/classifier_compression/compress_classifier.py
- models/__init__.py 2 additions, 2 deletionsmodels/__init__.py
- tests/common.py 2 additions, 2 deletionstests/common.py
- tests/test_pruning.py 97 additions, 59 deletionstests/test_pruning.py
Loading
Please register or sign in to comment