/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__/utils.cpython-36.pyc (6689B)
3 Eg @sdZddlZddlZddlZddlmZmZddlmZm Z ddZ ddZ d d Z e e e d d d ZddZddZddZddZddZddZddZddZddZd d!Zejejed"d#d$Zeeeejeeeefd%d&d'ZdS)(z? Utils shared by different modes of quantization (eager/graph) N) QuantTypequant_type_to_str)TupleAnycCs|j}|j||S)N)copyupdate)Z default_dictZadditional_dictdr G/usr/local/lib64/python3.6/site-packages/torch/ao/quantization/utils.pyget_combined_dict s r cCs|tjkp|tjkS)N)torchper_tensor_affineZper_tensor_symmetric)qschemer r r is_per_tensors rcCs|tjtjtjgkS)N)r per_channel_affineZ per_channel_affine_float_qparamsper_channel_symmetric)rr r r is_per_channelsr)objfqnreturncCstjt|jd|S)zO Given an obj and a fqn such as "foo.bar.baz", returns gm.foo.bar.baz. .) functoolsreducegetattrsplit)rrr r r getattr_from_fqnsrcCst|dr|jnd}|j}||d}|s,|St|r|dk s t|j}|j}t|dr,|jnd}|j|j|fS)zk returns the qconfig tuple for qconfig: (activation_dtype, weight_dtype, activation_compute_dtype) N compute_dtype)r%r)r+rr4r)r'r)r+r4r r r get_qconfig_dtypesos  r5cCs|dk s t|j}|j}tjtjg}|j|krb|j|krBtjSt |dr\|j |kr\tj Stj S|jtj kr|jtjkrtj S|jtj krtjStdj|j|jdS)Nr4zKUnrecognized dtype combination in get_quant_type: activation({}),weight({}))r%r)r+r r-r.rrZSTATICrr4ZDYNAMICZ WEIGHT_ONLYr/float Exceptionr&)r'r)r+Z static_dtypesr r r r"ys"       r")min_valmax_valrcCs|jdks|jdkr&tjd dS|jdks>|jdkr~|tdkrd|tdkrdtjd dS||kstdj||ntj||kstdj||dS) z Checks if the given minimum and maximum values are valid, meaning that they exist and the min value is less than the max value. rz4must run observer before calling calculate_qparams. zReturning default values.Finfz-infz!min {} should be less than max {}TzMmust run observer before calling calculate_qparams. Returning default values.zMmust run observer before calling calculate_qparams. Returning default values.) ZnumelwarningswarnZdimr6r%r&r all)r8r9r r r check_min_max_valids"  r>) quant_min quant_maxhas_customized_qranger reduce_rangerc Cs|rd \}}||}}|dk r0|dk r0||}}||d} d| koNdkns\td|tjkr| d| dd}}nd| d}}|r|d|d}}nP|tjkr|rd\}}nd\}}n.|tjkr|rd\}}nd\}}nd\}}||fS)ztCalculates actual qmin and qmax based on the quantization range, observer datatype and if range is reduced. rNzRquantization range should be positive and not exceed the maximum bit range (=256).@?)rrC)rLrH)rMrJ)rrJ)rrC)rrK)r%r r.r-) r?r@rArrBZinitial_quant_minZinitial_quant_maxZcustom_quant_minZcustom_quant_maxZ qrange_lenr r r calculate_qmin_qmaxs0         rN)__doc__r;rr Z torch.ao.quantization.quant_typerrtypingrrr rrstrrr!r(r*r,r0r1r2r3r5r"ZTensorboolr>intrrNr r r r s,