pytorch/torch/csrc/jit/python
Supriya Rao 55019d357e [quant][graphmode] Add observers for dynamic quant (#35121)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/35121

For dynamic quantization we insert observers at the input to mimic the quatization of activations that happens in the operator
Observer for weight is inserted similar to static quant

Test Plan:
python test/test_quantize_script.py

Sample output for single layer FC

.graph(%self : __torch__.___torch_mangle_4.M,
      %x.2 : Tensor):
  %_observer_1 : __torch__.torch.quantization.observer.MinMaxObserver = prim::GetAttr[name="_observer_1"](%self)
  %x.1 : Tensor = prim::CallMethod[name="forward"](%_observer_1, %x.2)
  %2 : __torch__.torch.nn.modules.linear.___torch_mangle_5.Linear = prim::GetAttr[name="fc"](%self)
  %3 : Tensor = prim::CallMethod[name="forward"](%2, %x.1) # test/test_quantize_script.py:19:23
  return (%3)

graph(%self : __torch__.torch.nn.modules.linear.___torch_mangle_5.Linear,
      %input.1 : Tensor):
 %2 : Function = prim::Constant[name="linear"]()
 %3 : Tensor = prim::GetAttr[name="weight"](%self)
 %_observer_0 : __torch__.torch.quantization.observer.MinMaxObserver = prim::GetAttr[name="_observer_0"](%self)
 %7 : Tensor = prim::CallMethod[name="forward"](%_observer_0, %3)
 %4 : Tensor = prim::GetAttr[name="bias"](%self)
 %5 : Tensor = prim::CallFunction(%2, %input.1, %7, %4) # /home/supriyar/miniconda3/envs/pytorch_py3/lib/python3.7/site-packages/torch/nn/modules/linear.py:87:15
 return (%5)

Imported from OSS

Differential Revision: D20599144

fbshipit-source-id: 9a8fa0e8655b9908826b981dce8a11d86efce5df
2020-03-24 10:54:16 -07:00
..
init.cpp [quant][graphmode] Add observers for dynamic quant (#35121) 2020-03-24 10:54:16 -07:00
init.h
module_python.h [jit] kill script namespace (#34515) 2020-03-11 23:32:48 -07:00
pybind_utils.h [JIT] add id function (#34975) 2020-03-23 17:10:13 -07:00
pybind.h
python_arg_flatten.cpp
python_arg_flatten.h
python_custom_class.cpp [reapply][JIT] Namespaces for TorchBind (#35254) 2020-03-24 00:39:48 -07:00
python_custom_class.h
python_interpreter.cpp Delete OperatorOptions, absorb AliasAnalysisKind into FunctionSchema. (#34588) 2020-03-11 20:59:46 -07:00
python_ir.cpp [CUDA_FUSER] Fork CUDA fuser (#33527) 2020-03-04 20:25:08 -08:00
python_ir.h
python_ivalue.h
python_sugared_value.cpp [jit] kill script namespace (#34515) 2020-03-11 23:32:48 -07:00
python_sugared_value.h [jit] kill script namespace (#34515) 2020-03-11 23:32:48 -07:00
python_tracer.cpp [jit] kill script namespace (#34515) 2020-03-11 23:32:48 -07:00
python_tracer.h [jit] kill script namespace (#34515) 2020-03-11 23:32:48 -07:00
python_tree_views.cpp [jit] kill script namespace (#34515) 2020-03-11 23:32:48 -07:00
python_tree_views.h [jit] kill script namespace (#34515) 2020-03-11 23:32:48 -07:00
script_init.cpp [jit] Include call stack in OSError message (#34669) 2020-03-18 15:10:23 -07:00
script_init.h [jit] kill script namespace (#34515) 2020-03-11 23:32:48 -07:00
update_graph_executor_opt.cpp
update_graph_executor_opt.h