/usr/local/lib64/python3.6/site-packages/torch/ao/quantization/__pycache__
Edit: /usr/local/lib64/python3.6/site-packages/torch/ao/quantization/__pycache__/stubs.cpython-36.pyc (2716B)
3
Eg? ã @ sF d dl mZ G dd„ dejƒZG dd„ dejƒZG dd„ dejƒZdS ) é )Únnc s* e Zd ZdZd‡ fdd„ Zdd„ Z‡ ZS )Ú QuantStuba Quantize stub module, before calibration, this is same as an observer,
it will be swapped as `nnq.Quantize` in `convert`.
Args:
qconfig: quantization configuration for the tensor,
if qconfig is not provided, we will get qconfig from parent modules
Nc s t t| ƒjƒ |r|| _d S )N)Úsuperr Ú__init__Úqconfig)Úselfr )Ú __class__© úG/usr/local/lib64/python3.6/site-packages/torch/ao/quantization/stubs.pyr s zQuantStub.__init__c C s |S )Nr )r Úxr r r
Úforward s zQuantStub.forward)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r r Ú
__classcell__r r )r r
r s r c s( e Zd ZdZ‡ fdd„Zdd„ Z‡ ZS )ÚDeQuantStubz…Dequantize stub module, before calibration, this is same as identity,
this will be swapped as `nnq.DeQuantize` in `convert`.
c s t t| ƒjƒ d S )N)r r r )r )r r r
r s zDeQuantStub.__init__c C s |S )Nr )r r r r r
r s zDeQuantStub.forward)r
r r r r r r r r )r r
r s r c s8 e Zd ZU dZeeej
‡ fdd„Zdd„ Z‡ Z
S )ÚQuantWrapperaç A wrapper class that wraps the input module, adds QuantStub and
DeQuantStub and surround the call to module with call to quant and dequant
modules.
This is used by the `quantization` utility functions to add the quant and
dequant modules, before `convert` function `QuantStub` will just be observer,
it observes the input tensor, after `convert`, `QuantStub`
will be swapped to `nnq.Quantize` which does actual quantization. Similarly
for `DeQuantStub`.
c s\ t t| ƒjƒ t|dƒr|jnd }| jdt|ƒƒ | jdtƒ ƒ | jd|ƒ | j|j ƒ d S )Nr ÚquantÚdequantÚmodule)
r r r Úhasattrr Z
add_moduler r ZtrainZtraining)r r r )r r r
r / s zQuantWrapper.__init__c C s | j |ƒ}| j|ƒ}| j|ƒS )N)r r r )r ÚXr r r
r 7 s
zQuantWrapper.forward)r
r r r r r r r r ÚModuler r r r r r )r r
r s
r N)Ztorchr r r r r r r r r
Ú
s