/usr/local/lib64/python3.6/site-packages/torch/ao/quantization/__pycache__
Edit: /usr/local/lib64/python3.6/site-packages/torch/ao/quantization/__pycache__/quantize.cpython-36.pyc (18901B)
3
Eg^ @ sJ d dl Z d dlZd dlZd dlZd dljZd dljjZd dl m
Z
d dlmZm
Z
mZmZmZmZmZ d dlmZmZ d dlmZmZmZmZ dd Zd/d d
Zd0ddZd
d Zdd Zd1ddZ dd Z!dd Z"d2ddZ#dd Z$dd Z%d3ddZ&dej'ddfd d!Z(d4d"d#Z)d5d$d%Z*d6d'd(Z+d7d)d*Z,d+d, Z-d8d-d.Z.dS )9 N)_FusedModule))get_default_dynamic_quant_module_mappings(get_default_static_quant_module_mappingsget_default_qat_module_mappings$get_default_qconfig_propagation_listno_observer_set_has_special_act_post_process_get_special_act_post_process)DeQuantStubQuantWrapper)add_module_to_qconfig_obs_ctrdefault_dynamic_qconfigfloat16_dynamic_qconfig!float_qparams_weight_only_qconfigc C s t | tjjpt | tjjS )N)
isinstancetorchquantizationZObserverBaseZFakeQuantizeBase)module r J/usr/local/lib64/python3.6/site-packages/torch/ao/quantization/quantize.pyis_activation_post_process s r c
C s |dkrt }|jt| |}|j||}t| d|}tjjj|| t|| }|| _x8| j D ],\}}|rx|d | n|} t
||||| q`W dS )ay This is a helper function for `propagate_qconfig_`
Args:
module: input module
qconfig_dict: dictionary that maps from name of submodule to quantization
configuration
allow_list: list of quantizable modules
qconfig_parent: quantization config of parent module, we will fallback to
this config when there is no specified config for current
module
prefix: corresponding prefix of the current module, used as key in
qconfig_dict
Return:
None, module is modified inplace with qconfig attached
Nqconfig.)r gettypegetattrr r r Zassert_valid_qconfigr named_children_propagate_qconfig_helper)
r qconfig_dict
allow_listZqconfig_parentprefixZmodule_qconfigZqconfig_with_device_checknamechild
module_prefixr r r r s
r c C s |dkri }t | || dS )a Propagate qconfig through the module hierarchy and assign `qconfig`
attribute on each leaf module
Args:
module: input module
qconfig_dict: dictionary that maps from name or type of submodule to
quantization configuration, qconfig applies to all submodules of a
given module unless qconfig for the submodules are specified (when
the submodule already has qconfig attribute)
Return:
None, module is modified inplace with qconfig attached
N)r )r r r r r r propagate_qconfig_D s r% c C s
| j |S )z3Forward hook that calls observer on the output
)activation_post_process)selfinputoutputr r r _observer_forward_hookV s r* c C s t | dstd| jtS )Nr&