Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
nni
Commits
fde9e1a0
Unverified
Commit
fde9e1a0
authored
Nov 01, 2021
by
J-shang
Committed by
GitHub
Nov 01, 2021
Browse files
update speed up doc (#4281)
parent
e779d7f3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
19 deletions
+26
-19
docs/en_US/Compression/ModelSpeedup.rst
docs/en_US/Compression/ModelSpeedup.rst
+9
-1
nni/compression/pytorch/speedup/compressor.py
nni/compression/pytorch/speedup/compressor.py
+17
-18
No files found.
docs/en_US/Compression/ModelSpeedup.rst
View file @
fde9e1a0
...
@@ -197,4 +197,12 @@ We measure the latencies and accuracies of the pruned model under different spar
...
@@ -197,4 +197,12 @@ We measure the latencies and accuracies of the pruned model under different spar
The latency is measured on one V100 GPU and the input tensor is ``torch.randn(128, 3, 32, 32)``.
The latency is measured on one V100 GPU and the input tensor is ``torch.randn(128, 3, 32, 32)``.
.. image:: ../../img/SA_latency_accuracy.png
.. image:: ../../img/SA_latency_accuracy.png
\ No newline at end of file
User configuration for ModelSpeedup
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
**PyTorch**
.. autoclass:: nni.compression.pytorch.ModelSpeedup
nni/compression/pytorch/speedup/compressor.py
View file @
fde9e1a0
...
@@ -23,28 +23,27 @@ _logger.setLevel(logging.INFO)
...
@@ -23,28 +23,27 @@ _logger.setLevel(logging.INFO)
class
ModelSpeedup
:
class
ModelSpeedup
:
"""
"""
This class is to speedup the model with provided weight mask.
This class is to speedup the model with provided weight mask.
Parameters
----------
model : pytorch model
The model user wants to speed up
dummy_input : pytorch tensor, tuple of tensor, list of tensor
Note: The first dimension of the dummy_input should be the batchsize.
The dummy input for ```jit.trace```, users should put it on the right
device.
masks_file : str/dict
The path of user provided mask file, or the mask object
map_location : str
the device on which masks are placed, same to map_location in ```torch.load```
batch_dim : int
the index of batch dimension in the dummy_input
confidence: the confidence coefficient of the sparsity inference. This value is
actually used as the batchsize of the dummy_input.
"""
"""
def
__init__
(
self
,
model
,
dummy_input
,
masks_file
,
map_location
=
None
,
def
__init__
(
self
,
model
,
dummy_input
,
masks_file
,
map_location
=
None
,
batch_dim
=
0
,
confidence
=
8
):
batch_dim
=
0
,
confidence
=
8
):
"""
Parameters
----------
model : pytorch model
The model user wants to speed up
dummy_input : pytorch tensor, tuple of tensor, list of tensor
Note: The first dimension of the dummy_input should be the batchsize.
The dummy input for ```jit.trace```, users should put it on the right
device.
masks_file : str/dict
The path of user provided mask file, or the mask object
map_location : str
the device on which masks are placed, same to map_location in ```torch.load```
batch_dim : int
the index of batch dimension in the dummy_input
confidence: the confidence coefficient of the sparsity inference. This value is
actually used as the batchsize of the dummy_input.
"""
assert
confidence
>
1
assert
confidence
>
1
# The auto inference will change the values of the parameters in the model
# The auto inference will change the values of the parameters in the model
# so we need make a copy before the mask inference
# so we need make a copy before the mask inference
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment