/usr/local/lib64/python3.6/site-packages/torch/ao/quantization/__pycache__
NameSizeModeActions
fake_quantize.cpython-36.pyc139970644editdlrm
fuser_method_mappings.cpython-36.pyc45210644editdlrm
fuse_modules.cpython-36.pyc50120644editdlrm
observer.cpython-36.pyc392270644editdlrm
qconfig.cpython-36.pyc85840644editdlrm
quantization_mappings.cpython-36.pyc68670644editdlrm
quantize.cpython-36.pyc189010644editdlrm
quantize_jit.cpython-36.pyc86310644editdlrm
quant_type.cpython-36.pyc6340644editdlrm
stubs.cpython-36.pyc27160644editdlrm
utils.cpython-36.pyc66890644editdlrm
_correct_bias.cpython-36.pyc44490644editdlrm
_equalize.cpython-36.pyc57040644editdlrm
_learnable_fake_quantize.cpython-36.pyc64550644editdlrm
__init__.cpython-36.pyc2530644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/torch/ao/quantization/__pycache__/observer.cpython-36.pyc (39227B)
3 Eg9@sUddlZddlZddlmZmZddlmZddlmZddl m Z m Z m Z m Z mZmZddlZddljZddlmZmZGdddeZd d Zd d Zeed efiZe GdddeejZGdddeZGdddeZGdddeZ GdddeZ!Gddde!Z"GdddeZ#GdddeZ$GdddeZ%Gd d!d!eZ&d"d#Z'd$d%Z(d&d'Z)d(d)Z*d*d+Z+ej,d,d-Z-e$Z.e%Z/ej,ej0ej1d.Z2e#j,d,d-Z3e!j,ej0ej4d.Z5e$j,ej6ej7d/Z8e!j,ej7ej9dd0Z:dS)1N)ABCMetaabstractmethod) OrderedDict)partial)AnyListTupleOptionalDictUnion)check_min_max_validcalculate_qmin_qmaxc@s4eZdZddZddZddZddZd d Zd S) _PartialWrappercCs||_i|_dS)N)p callable_args)selfrrJ/usr/local/lib64/python3.6/site-packages/torch/ao/quantization/observer.py__init__sz_PartialWrapper.__init__cOs8x*|jD] }||kr|||j|i}qW|j||S)N)rr)rargskeywordsZarg_namerrr__call__s z_PartialWrapper.__call__cCs|jj|jjS)N)r__repr__r)rrrrrsz_PartialWrapper.__repr__cKs t|f|S)N) _with_args)rkwargsrrr with_argssz_PartialWrapper.with_argscKst|jd}|j||_|S)N)r)rrr)rrresultrrrwith_callable_args s  z"_PartialWrapper.with_callable_argsN)__name__ __module__ __qualname__rrrrrrrrrr s rcKstt|f|}|S)a Wrapper that allows creation of class factories. This can be useful when there is a need to create classes with the same constructor arguments, but different instances. Can be used in conjunction with _callable_args Example:: >>> Foo.with_args = classmethod(_with_args) >>> foo_builder = Foo.with_args(a=3, b=4).with_args(answer=42) >>> foo_instance1 = foo_builder() >>> foo_instance2 = foo_builder() >>> id(foo_instance1) == id(foo_instance2) False )rr) cls_or_selfrrrrrr&srcKstt|}|jf|S)a Wrapper that allows creation of class factories args that need to be called at construction time. This can be useful when there is a need to create classes with the same constructor arguments, but different instances and those arguments should only be calculated at construction time. Can be used in conjunction with _with_args Example:: >>> Foo.with_callable_args = classmethod(_with_callable_args) >>> Foo.with_args = classmethod(_with_args) >>> foo_builder = Foo.with_callable_args(cur_time=get_time_func).with_args(name="dan") >>> foo_instance1 = foo_builder() >>> wait 50 >>> foo_instance2 = foo_builder() >>> id(foo_instance1.creation_time) == id(foo_instance2.creation_time) False )rrr)r!rr"rrr_with_callable_args9s r#ABCcsHeZdZdZfddZeddZeddZee Z ee Z Z S) ObserverBaseaBase observer Module. Any observer implementation should derive from this class. Concrete observers should follow the same API. In forward, they will update the statistics of the observed Tensor. And they should provide a `calculate_qparams` function that computes the quantization parameters given the collected statistics. Args: dtype: Quantized data type cstt|j||_dS)N)superr%rdtype)rr') __class__rrr`szObserverBase.__init__cCsdS)Nr)rxrrrforwarddszObserverBase.forwardcKsdS)Nr)rrrrrcalculate_qparamshszObserverBase.calculate_qparams)rrr __doc__rrr*r+ classmethodrrr#r __classcell__rr)r(rr%Ss     r%cseZdZUdZdZejejej ddddfddfdd Z fdd Z ej j eedd d d Zej j ejejeejejfd ddZej j ddZZS) _ObserverBaseaInternal common base for all qint/quint8 observers. This base is for commonly used parameters used internally. Users should use `~torch.quantization.observer.ObserverBase` as a base class for custom observers. Args: dtype: Quantized data type. qscheme: Quantization scheme to be used. reduce_range: Reduces the range of the quantized data type by 1 bit. This is sometimes required to avoid instruction overflow. quant_min: Minimum quantization value. If unspecified, it will follow the 8-bit setup. quant_max: Maximum quantization value. If unspecified, it will follow the 8-bit setup. .. warning:: :attr:`dtype` can only take ``torch.qint8`` or ``torch.quint8``. .. warning:: :attr:`qscheme` can only take one of the following options: - ``torch.per_tensor_affine`` - ``torch.per_tensor_symmetric`` - ``torch.per_channel_affine`` - ``torch.per_channel_symmetric`` FN)returncstjj|}tt|j|d||_|r2tjd||_ |j dtj tj tj jgf||jtjtjtjtjtjfkstd|jtjtjtjfkstd|dk o|dk |_|jr|j||t|||j|j|j \|_|_dS)N)r'zPlease use quant_min and quant_max to specify the range for observers. reduce_range will be deprecated in a future release of PyTorch.epszDefault Observer only works for per_tensor_affine, per_tensor_symmetric, per_channel_affine, per_channel_symmetric and per_channel_float_qparams quantization schemezDDefault Observer only works for qint8, quint8 and quint4x2 data type)torchnnfactory_kwargsr&r/rqschemewarningswarn reduce_rangeregister_buffertensorfinfofloat32r2per_tensor_affineper_tensor_symmetricper_channel_affineper_channel_symmetric per_channel_affine_float_qparamsAssertionErrorr'qint8quint8Zquint4x2has_customized_qrange_validate_qmin_qmaxr quant_min quant_max)rr'r6r9rHrIr5)r(rrrs2    z_ObserverBase.__init__c s^|jdd}|dks|dkr>tjtjtjjg} | ||d<tt|j|||||||dS)Nversionr2) getr3r;r<r=r2r&r%_load_from_state_dict) r state_dictprefixlocal_metadatastrict missing_keysunexpected_keys error_msgsrJr2)r(rrrMs   z#_ObserverBase._load_from_state_dict)rHrIr1cCs4|dko|kns td||ks0tddS)aValidates that the user-specified quantization range is properly initialized and within the given bound supported by the observer dtype. To accommodate lower-bit quantization with respect to the existing torch.qint8 and torch.quint8 datatypes, the user can choose to use dynamic quantization range by passing in a tuple of initial qmin and qmax values. One use case is these customized qmin and qmax values are used to calculate static estimates of the scale and zero point for aggressive lower-bit fake quantization. These estimates are compared against parameters learned through backpropagation. The related literatures for scale and zero point via backpropagation are as follows: Learned Step Size Quantization: https://openreview.net/pdf?id=rkgO66VKDS Trained Quantization Thresholds: https://arxiv.org/pdf/1903.08066.pdf rz1Used-specified quantization range must include 0.zKqmin must be strictly less than qmax for user-specified quantization range.N)rC)rrHrIrrrrGs z!_ObserverBase._validate_qmin_qmax)min_valmax_valr1c Cs4t||s2tjdg|jjdtjdg|jjdfS|j|j}}tj|tj|}tj |tj|}|j}tj |j tj |d}tj |j tj|d} |jtjks|jtjkr"tj | |}|t||d}tj ||j}|jtjkr|jr| j| j ||d} n| j| j d} n|jtjkrl||t||}tj||jk|tj|}d||} nJ||t||}tj ||j}|tj||jtj} tj| ||} t|j dkrtjt|g|j|d}t| j dkr,tjt| g| j|d} |jtjkr,tjt| g| j|d} || fS) aCalculates the quantization parameters, given min and max value tensors. Works for both per tensor and per channel cases Args: min_val: Minimum values per channel max_val: Maximum values per channel Returns: scales: Scales tensor of shape (#channels,) zero_points: Zero points tensor of shape (#channels,) g?)devicer)r'rWrK)!r r3r;rWtyperHrIminZ zeros_likemaxonessizer=zerosZint64r6r?rAfloatr2r'rErFZnew_fullrBwhereZ ones_likeroundtointclamplenshape) rrUrVrHrIZ min_val_negZ max_val_posrWZscaleZ zero_pointrrr_calculate_qparamssF ( z _ObserverBase._calculate_qparamscCs tddS)Nz2Cannot reset min/max values in the given observer.)NotImplementedError)rrrrreset_min_max_valsDsz _ObserverBase.reset_min_max_vals)rrr r,_versionr3Tensorr2rEr>rrMjitexportrerGrrirkr.rr)r(rr/ps" ! Er/cs~eZdZUdZejejejej ddddfddfdd Z ddZ ej j d d Zej j d d Zej j d dZZS)MinMaxObservera Observer module for computing the quantization parameters based on the running min and max values. This observer uses the tensor min/max statistics to compute the quantization parameters. The module records the running minimum and maximum of incoming tensors, and uses this statistic to compute the quantization parameters. Args: dtype: Quantized data type qscheme: Quantization scheme to be used reduce_range: Reduces the range of the quantized data type by 1 bit quant_min: Minimum quantization value. If unspecified, it will follow the 8-bit setup. quant_max: Maximum quantization value. If unspecified, it will follow the 8-bit setup. Given running min/max as :math:`x_\text{min}` and :math:`x_\text{max}`, scale :math:`s` and zero point :math:`z` are computed as: The running minimum/maximum :math:`x_\text{min/max}` is computed as: .. math:: \begin{array}{ll} x_\text{min} &= \begin{cases} \min(X) & \text{if~}x_\text{min} = \text{None} \\ \min\left(x_\text{min}, \min(X)\right) & \text{otherwise} \end{cases}\\ x_\text{max} &= \begin{cases} \max(X) & \text{if~}x_\text{max} = \text{None} \\ \max\left(x_\text{max}, \max(X)\right) & \text{otherwise} \end{cases}\\ \end{array} where :math:`X` is the observed tensor. The scale :math:`s` and zero point :math:`z` are then computed as: .. math:: \begin{aligned} \text{if Symmetric:}&\\ &s = 2 \max(|x_\text{min}|, x_\text{max}) / \left( Q_\text{max} - Q_\text{min} \right) \\ &z = \begin{cases} 0 & \text{if dtype is qint8} \\ 128 & \text{otherwise} \end{cases}\\ \text{Otherwise:}&\\ &s = \left( x_\text{max} - x_\text{min} \right ) / \left( Q_\text{max} - Q_\text{min} \right ) \\ &z = Q_\text{min} - \text{round}(x_\text{min} / s) \end{aligned} where :math:`Q_\text{min}` and :math:`Q_\text{max}` are the minimum and maximum of the quantized data type. .. warning:: Only works with ``torch.per_tensor_symmetric`` quantization scheme .. warning:: :attr:`dtype` can only take ``torch.qint8`` or ``torch.quint8``. .. note:: If the running minimum equals to the running maximum, the scale and zero_point are set to 1.0 and 0. FN)r1cstt|j||||||dtjj|}|jdtjtdf||jdtjtdf||j tj kr|j r|j tj krtddS)N)r'r6r9rHrIr5rUinfrVz-infz`Cannot reduce range for symmetric quantization for quint8)r&rprr3r4r5r:r;rar6r?r9r'rErj)rr'r6r9rHrIr5)r(rrrs    zMinMaxObserver.__init__cCsl|jdkr|S|j}|j|jj}tj|\}}tj||j}tj||j }|jj ||j j ||S)z1Records the running minimum and maximum of ``x``.r) numeldetachrdrUr'r3_aminmaxr\r]rVcopy_)rx_origr) min_val_cur max_val_currUrVrrrr*s   zMinMaxObserver.forwardcCs|j|j|jS)z'Calculates the quantization parameters.)rirUrV)rrrrr+sz MinMaxObserver.calculate_qparamscCsdj|j|jS)Nzmin_val={}, max_val={})formatrUrV)rrrr extra_reprszMinMaxObserver.extra_reprcCs$tjtd|_tjtd|_dS)zResets the min/max values.rqz-infN)r3r;rarUrV)rrrrrksz!MinMaxObserver.reset_min_max_vals)rrr r,r3rmrUrVrEr>rr*rnror+rzrkr.rr)r(rrpIs > rpcs@eZdZdZdejejdddfddfdd Zdd ZZ S) MovingAverageMinMaxObservera;Observer module for computing the quantization parameters based on the moving average of the min and max values. This observer computes the quantization parameters based on the moving averages of minimums and maximums of the incoming tensors. The module records the average minimum and maximum of incoming tensors, and uses this statistic to compute the quantization parameters. Args: averaging_constant: Averaging constant for min/max. dtype: Quantized data type qscheme: Quantization scheme to be used reduce_range: Reduces the range of the quantized data type by 1 bit quant_min: Minimum quantization value. If unspecified, it will follow the 8-bit setup. quant_max: Maximum quantization value. If unspecified, it will follow the 8-bit setup. The moving average min/max is computed as follows .. math:: \begin{array}{ll} x_\text{min} = \begin{cases} \min(X) & \text{if~}x_\text{min} = \text{None} \\ (1 - c) x_\text{min} + c \min(X) & \text{otherwise} \end{cases}\\ x_\text{max} = \begin{cases} \max(X) & \text{if~}x_\text{max} = \text{None} \\ (1 - c) x_\text{max} + c \max(X) & \text{otherwise} \end{cases}\\ \end{array} where :math:`x_\text{min/max}` is the running average min/max, :math:`X` is is the incoming tensor, and :math:`c` is the ``averaging_constant``. The scale and zero point are then computed as in :class:`~torch.quantization.observer.MinMaxObserver`. .. note:: Only works with ``torch.per_tensor_affine`` quantization scheme. .. note:: If the running minimum equals to the running maximum, the scale and zero_point are set to 1.0 and 0. g{Gz?FN)r1c s,||_tt|jf|||||d|dS)N)r'r6r9rHrI)averaging_constantr&r{r)rr|r'r6r9rHrIr)r(rrrs  z$MovingAverageMinMaxObserver.__init__cCs|jdkr|S|j}|j|jj}|j}|j}|tdkrZ|tdkrZtj|\}}n2tj|\}}||j ||}||j ||}|jj ||jj ||S)Nrrqz-inf) rrrsrdrUr'rVrar3rtr|ru)rrvr)rUrVrwrxrrrr* s   z#MovingAverageMinMaxObserver.forward) rrr r,r3rEr>rr*r.rr)r(rr{s* r{cseZdZUdZejejdejej ddddfddfdd Z dd Z d d Z ej jd d ZddZeeeejfeeejffeeeejfeeeeeeedfdd ZeeeejfeeejffeeeejfeeeeeeedddZej jddZZS)PerChannelMinMaxObserveraObserver module for computing the quantization parameters based on the running per channel min and max values. This observer uses the tensor min/max statistics to compute the per channel quantization parameters. The module records the running minimum and maximum of incoming tensors, and uses this statistic to compute the quantization parameters. Args: ch_axis: Channel axis dtype: Quantized data type qscheme: Quantization scheme to be used reduce_range: Reduces the range of the quantized data type by 1 bit quant_min: Minimum quantization value. If unspecified, it will follow the 8-bit setup. quant_max: Maximum quantization value. If unspecified, it will follow the 8-bit setup. The quantization parameters are computed the same way as in :class:`~torch.quantization.observer.MinMaxObserver`, with the difference that the running min/max values are stored per channel. Scales and zero points are thus computed per channel as well. .. note:: If the running minimum equals to the running maximum, the scales and zero_points are set to 1.0 and 0. rFN)r1cstt|j||||||dtjj|}||_|jdtjgf||jdtjgf||j tj kr|j r|j tj krtddS)N)r'r6r9rHrIr5rUrVz9Cannot reduce range for symmetric quantization for quint8)r&r}rr3r4r5ch_axisr:r;r6rAr9r'rErj)rr~r'r6r9rHrIr5)r(rrr:s    z!PerChannelMinMaxObserver.__init__cCs |j|S)N)_forward)rrvrrrr*Ysz PerChannelMinMaxObserver.forwardc Cs|jdkr|S|j}|j}|j}|j}ddtt|D}d||j<|j|d<|j|}|j |jj }t j |dd}|jdks|jdkrt j |d\}}n(t j |d\}} t j||}t j| |}|jj|j|jj|j|jj||jj||S)NrcSsg|]}|qSrr).0irrr dsz5PerChannelMinMaxObserver._forward..rK) start_dim)rrrsrUrVr_rangergr~permuterdr'r3flattenrtr\r]resize_rhru) rrvr)rUrVx_dim new_axis_listyrwrxrrrr\s,        z!PerChannelMinMaxObserver._forwardcCs|j|j|jS)N)rirUrV)rrrrr+xsz*PerChannelMinMaxObserver.calculate_qparamscCsdj|j|jS)Nzmin_val={}, max_val={})ryrUrV)rrrrrz|sz#PerChannelMinMaxObserver.extra_repr)rNrOrPrQrRrSrTcs&|jdd}|dks|dkr.ddg} d} d} nddg} d} d} x| D]} || } | |kr|| }| | krx|jj|jn(| | kr|jj|jntjdj| tj j r| | kr|jj |q| | kr|jj |qtjdj| qD|rD|j | qDWtj j s"t t|j|||d|||dS) NrJr0Zmin_valsZmax_valsrUrVz4Observer load_from_state_dict got unexpected name {}F)rLrUrrhrVr7r8ryr3rnZ is_scriptingruappendr&r}rM)rrNrOrPrQrRrSrTrJ local_stateZexpected_min_nameZexpected_max_namenamekeyval)r(rrrMsD     z.PerChannelMinMaxObserver._load_from_state_dictcCs|j|||||||dS)N)rM)rrNrOrPrQrRrSrTrrr_load_from_state_dict_scripts z5PerChannelMinMaxObserver._load_from_state_dict_scriptcCstjg|_tjg|_dS)zResets the min/max values.N)r3r;rUrV)rrrrrks z+PerChannelMinMaxObserver.reset_min_max_vals)rrr r,r3rmrUrVrEr@rr*rrnror+rzr r strboolrrMrrkr.rr)r(rr}s<  2  r}csBeZdZdZddejejdddfddfdd Zd d ZZ S) %MovingAveragePerChannelMinMaxObserveraObserver module for computing the quantization parameters based on the running per channel min and max values. This observer uses the tensor min/max statistics to compute the per channel quantization parameters. The module records the running minimum and maximum of incoming tensors, and uses this statistic to compute the quantization parameters. Args: averaging_constant: Averaging constant for min/max. ch_axis: Channel axis dtype: Quantized data type qscheme: Quantization scheme to be used reduce_range: Reduces the range of the quantized data type by 1 bit quant_min: Minimum quantization value. If unspecified, it will follow the 8-bit setup. quant_max: Maximum quantization value. If unspecified, it will follow the 8-bit setup. The quantization parameters are computed the same way as in :class:`~torch.quantization.observer.MovingAverageMinMaxObserver`, with the difference that the running min/max values are stored per channel. Scales and zero points are thus computed per channel as well. .. note:: If the running minimum equals to the running maximum, the scales and zero_points are set to 1.0 and 0. g{Gz?rFN)r1c s.tt|jf||||||d|||_dS)N)r~r'r6r9rHrI)r&rrr|) rr|r~r'r6r9rHrIr)r(rrrs z.MovingAveragePerChannelMinMaxObserver.__init__c Cs|jdkr|S|j}|j|jj}|j}|j}|j}ddtt|D}d||j <|j |d<|j |}t j |dd}|jdks|jdkrt j |d\}}n4t j |d\}} ||j||}||j| |}|jj|j|jj|j|jj||jj||S)NrcSsg|]}|qSrr)rrrrrr szAMovingAveragePerChannelMinMaxObserver.forward..rK)r)rrrsrdrUr'rVr_rrgr~rr3rrtr|rrhru) rrvr)rUrVrrrrwrxrrrr*s,      z-MovingAveragePerChannelMinMaxObserver.forward) rrr r,r3rEr@rr*r.rr)r(rrs rcseZdZUdZejejejddej ej ddfe e ej ddfdd Z ejejejejd d d Ze e d d dZeejejfdddZejeje eejeje e fdddZejeje e e e ejdddZejejdddZejjddZfddZfdd ZZS)!HistogramObserveraX The module records the running histogram of tensor values along with min/max values. ``calculate_qparams`` will calculate scale and zero_point. Args: bins: Number of bins to use for the histogram upsample_rate: Factor by which the histograms are upsampled, this is used to interpolate histograms with varying ranges across observations dtype: Quantized data type qscheme: Quantization scheme to be used reduce_range: Reduces the range of the quantized data type by 1 bit The scale and zero point are computed as follows: 1. Create the histogram of the incoming inputs. The histogram is computed continuously, and the ranges per bin change with every new tensor observed. 2. Search the distribution in the histogram for optimal min/max values. The search for the min/max values ensures the minimization of the quantization error with respect to the floating point model. 3. Compute the scale and zero point the same way as in the :class:`~torch.quantization.MinMaxObserver` irYFN)bins upsample_rater'r1cstt|j||||dtjj|}||_|jdtj|jf||jdtj t df||jdtj t df|dtj |j j |_||_dS)N)r'r6r9r5 histogramrUrqrVz-infrX)r&rrr3r4r5rr:r`r;raZiinfor'bits dst_nbinsr)rrrr'r6r9r5)r(rrr;s  zHistogramObserver.__init__) delta_begin delta_enddensityr1cCs$||||||d}||S)a Compute the norm of the values uniformaly distributed between delta_begin and delta_end. Currently only L2 norm is supported. norm = density * (integral_{begin, end} x^2) = density * (end^3 - begin^3) / 3 r0r)rrrrnormrrr _get_normSs zHistogramObserver._get_norm)next_start_bin next_end_bincCsz|jj|jj|j}|||d|j}|dkrgg?rKrq) rr_rrCrVrUr3rrcumsumrar)rrtotalZcSumZstepsizealphabetaZ start_binZend_binZnorm_minZ next_alphaZ next_betalr"rrrnew_minnew_maxrrr_non_linear_param_searchsJ      z*HistogramObserver._non_linear_param_search) combined_min combined_maxrr1cCs|j|j|j|}ttj|||j|j}||j|||}||}|}ttj|j||j}||||fS)N)rVrUrrer3ceilrrc)rrrrZhist_bin_widthdownsample_ratee start_idxrrr_adjust_min_maxs   z!HistogramObserver._adjust_min_max) orig_histnew_histrrrNbinsr1c Cs|j|}tj|||jd}||||||<tj|dtjd|dd|} tj||jd} | dd| d|<| | |} || jtj}|S)N)rWr)r'rKrZ)Zrepeat_interleaver3r`rWrdoublerdra) rrrrrrrZupsampled_histogramZhistogram_with_output_rangeZintegral_histogramZshifted_integral_histogramZinterpolated_histogramrrr_combine_histogramss  z%HistogramObserver._combine_histograms)rvr1cCs|jdkr|S|j}|j}|j}|j|jk}|tdkoJ|tdk}|sT|rtj|\}}|jj|j |jj ||jj|j |jj ||jdkr|jdkst dtj ||j t|t||jdntj|\}}tj||} tj||} |j| | |j\} } } } | jdkr4| jdksrer'rrrrrrrr*rnror+rrMr.rr)r(rrs8   2@ ; rcsHeZdZdZejddfddfdd ZddZejj d d Z Z S) PlaceholderObservera Observer that doesn't do anything and just passes its configuration to the quantized module's ``.from_float()``. Can be used for quantization to float16 which doesn't require determining ranges. Args: dtype: Quantized data type custom_op_name: (temporary) specify this observer for an operator that doesn't require any observation (Can be used in Graph Mode Passes for special case ops). N)r1cs,tt|j|d||_||_|r(||_dS)N)r')r&rrr' custom_op compute_dtype)rr'custom_op_namer)r(rrrs zPlaceholderObserver.__init__cCs|S)Nr)rr)rrrr*szPlaceholderObserver.forwardcCs tddS)Nz>calculate_qparams should not be called for PlaceholderObserver) Exception)rrrrr+sz%PlaceholderObserver.calculate_qparams) rrr r,r3r=rr*rnror+r.rr)r(rrs    rcsZeZdZdZdeeejiZfddZ ddZ ej j ddZ ej j d d ZZS) RecordingObservera The module is mainly for debug and records the tensor values during runtime. Args: dtype: Quantized data type qscheme: Quantization scheme to be used reduce_range: Reduces the range of the quantized data type by 1 bit tensor_valc stt|jf|g|_dS)N)r&rrr)rr)r(rrrszRecordingObserver.__init__cCs|jj|j|S)N)rrclone)rr)rrrr*szRecordingObserver.forwardcCs tddS)NzsZ    ZR6Lu$