Skip to content

Commit

Permalink
Update on "[reland][quant][eagermode] Move custom_module registration…
Browse files Browse the repository at this point in the history
… to prepare/convert_custom_config_dict (#46293)"

Summary:

Test Plan: Imported from OSS

Reviewed By: raghuramank100

Differential Revision: [D24322747](https://our.internmc.facebook.com/intern/diff/D24322747)

[ghstack-poisoned]
  • Loading branch information
jerryzh168 committed Oct 16, 2020
1 parent 50a32d5 commit 0b23e2c
Showing 1 changed file with 5 additions and 23 deletions.
28 changes: 5 additions & 23 deletions torch/quantization/quantize.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,8 @@ def prepare(model, inplace=False, allow_list=None,
`observer_non_leaf_module_list`: list of non-leaf modules we want to add observer
`prepare_custom_config_dict`: customization configuration dictionary for prepare function
.. note::
Example of prepare_custom_config_dict:
import torch
class CustomModule(torch.nn.Module):
pass
class ObservedCustomModule(torch.nn.Module):
pass
.. code-block:: python
# Example of prepare_custom_config_dict:
prepare_custom_config_dict = {
# user will manually define the corresponding observed
# module class which has a from_float class method that converts
Expand All @@ -208,8 +201,6 @@ class ObservedCustomModule(torch.nn.Module):
CustomModule: ObservedCustomModule
}
}
# get around the no code/output warning
print(prepare_custom_config_dict)
"""
torch._C._log_api_usage_once("quantization_api.quantize.prepare")
Expand All @@ -223,7 +214,7 @@ class ObservedCustomModule(torch.nn.Module):
qconfig_propagation_list = allow_list
if qconfig_propagation_list is None:
qconfig_propagation_list = get_qconfig_propagation_list()
propagate_qconfig_(model, qconfig_dict=None)
propagate_qconfig_(model, qconfig_dict=None)

# sanity check common API misusage
if not any(hasattr(m, 'qconfig') and m.qconfig for m in model.modules()):
Expand Down Expand Up @@ -419,15 +410,8 @@ def convert(
is mutated
`convert_custom_config_dict`: custom configuration dictionary for convert function
.. note::
Example of convert_custom_config_dict:
import torch
class ObservedCustomModule(torch.nn.Module):
pass
class QuantizedCustomModule(torch.nn.Module):
pass
.. code-block:: python
# Example of convert_custom_config_dict:
convert_custom_config_dict = {
# user will manually define the corresponding quantized
# module class which has a from_observed class method that converts
Expand All @@ -437,8 +421,6 @@ class QuantizedCustomModule(torch.nn.Module):
}
}
Returns: A module with all the children quantized
"""
torch._C._log_api_usage_once("quantization_api.quantize.convert")
if not inplace:
Expand Down

0 comments on commit 0b23e2c

Please sign in to comment.