/usr/local/lib64/python3.6/site-packages/torch/nn/quantized/modules/__pycache__
NameSizeModeActions
activation.cpython-36.pyc61900644editdlrm
batchnorm.cpython-36.pyc29440644editdlrm
conv.cpython-36.pyc301510644editdlrm
embedding_ops.cpython-36.pyc96790644editdlrm
functional_modules.cpython-36.pyc87570644editdlrm
linear.cpython-36.pyc90710644editdlrm
normalization.cpython-36.pyc74910644editdlrm
utils.cpython-36.pyc19550644editdlrm
__init__.cpython-36.pyc46270644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/torch/nn/quantized/modules/__pycache__/conv.cpython-36.pyc (30151B)
3 EgA@sLdZddlmZmZmZddlZddljZddljj Z ddl jj Z ddljj jZddlmZddlmZddlmZmZmZddlmZddlmZd d hZeeeed d d ZGdddej Z!Gddde!Z"Gddde!Z#Gddde!Z$edej%j&j!dZ'Gddde!Z(Gddde(Z)Gddde(Z*Gddde(Z+dS) zQuantized convolution modules.)OptionalListTypeVarN)ops) _size_1_t)_single_pair_triple)_quantize_weight)fuse_conv_bn_weightszerosreflect)paddingreturncCsJg}t|}x8t|D],}x&tdD]}|j|||dq$WqW|S)N)lenrangeappend)r _reversed_padding_repeated_twiceNidx_rK/usr/local/lib64/python3.6/site-packages/torch/nn/quantized/modules/conv.py_reverse_repeat_paddings rcseZdZd#ddZd$ddfd d Zd d Zd dZddZddZfddZ e j j ddZ fddZe j j ddZddZddZed%dd Zed!d"ZZS)&_ConvNdrrTr Nc CstdS)N)NotImplementedError) self in_channels out_channels kernel_sizestriderdilationgroupsbias padding_modedevicedtyperrr__init__!sz_ConvNd.__init__)rcs4| | d}tt|j|| dkr,td|| dkr@td||_||_||_||_||_||_ ||_ ||_ | |_ | t krtdj| | |_|j r|||j g}n|||j g}tj|t|fddtjddd |jD}| rtj|fd tjid d |jDnd}|j||d |_d|_dS) N)r'r(rz'in_channels must be divisible by groupsz(out_channels must be divisible by groupsz;'padding_mode' {} is not supported by quantized convolutionr)scale zero_pointr(cSsi|]\}}|dkr||qS)r(r).0kvrrr Isz!_ConvNd._init..r(cSsi|]\}}|dkr||qS)r(r)r,r-r.rrrr/Lsg?)superrr) ValueErrorrr r!r"rr# transposedoutput_paddingr$_SUPPORTED_PADDINGformatr&torchZ_empty_affine_quantizedlistqint8itemsr floatset_weight_biasr*r+)rrr r!r"rr#r2r3r$r%r&r'r(factory_kwargsZ weight_shapeqweight bias_float) __class__rr_init's:     0 z _ConvNd._initcCstdS)N)r)rr=r>rrrr;Rsz_ConvNd.set_weight_biascCstdS)N)r)rrrrr%Usz _ConvNd.biascCstdS)N)r)rrrr _weight_biasXsz_ConvNd._weight_biascCsd}|jd t|jkr |d7}|jd t|jkr<|d7}|jd t|jkrX|d7}|jdkrj|d7}|jdkr~|d7}|jf|jS) Nzq{in_channels}, {out_channels}, kernel_size={kernel_size}, stride={stride}, scale={scale}, zero_point={zero_point}rz, padding={padding}rz, dilation={dilation}z!, output_padding={output_padding}z, groups={groups}z , bias=False)r)r)r)rrr#r3r$r%r5__dict__)rsrrr extra_repr[s  z_ConvNd.extra_reprcsdtt|j||||j\}}|||d<|||d<tj|j||d<tj|j||d<dS)Nweightr%r*r+)r0r_save_to_state_dictrAr6Ztensorr*r+)r destinationprefixZ keep_varswb)r?rrrFvs    z_ConvNd._save_to_state_dictcCsH|j\}}|j|j|j|j|j|j|j|j|j |j |||j |j |j fS)N)rArr r!r"rr#r2r3r$r&r*r+training)rrIrJrrr __getstate__~s  z_ConvNd.__getstate__cs|j||d||d|j|d|j|dt||d|_|j|dt||d|_|j|dtt|j|||d|||dS)NrEr%r*r+F) r;popr:r*intr+r0r_load_from_state_dict)rZ state_dictrHZlocal_metadatastrictZ missing_keysZunexpected_keysZ error_msgs)r?rrrOs  z_ConvNd._load_from_state_dictcCs|d|_|d|_|d|_|d|_|d|_|d|_|d|_|d|_|d |_|d |_ |j |d |d |d |_ |d|_ |d|_ dS)Nrrr )rr r!r"rr#r2r3r$r&r;r*r+rK)rstaterrr __setstate__s            z_ConvNd.__setstate__cCs6t|jt|}tjjj||j}|j||S)N)type__new__r6nnModuler)rLr^)rmemoZ new_instancer]rrr __deepcopy__s  z_ConvNd.__deepcopy__cCs |jiS)N)rd)rrrr__copy__sz_ConvNd.__copy__c Cs|dkr|jj}||j|j\}}|jtjks>> m = nn.quantized.Conv1d(16, 33, 3, stride=2) >>> input = torch.randn(20, 16, 100) >>> # quantize input to quint8 >>> q_input = torch.quantize_per_tensor(input, scale=1.0, zero_point=0, dtype=torch.quint8) >>> output = m(q_input) rrTr N) rr r!r"rr#r$r%r&c sh| | d} t|}t|}t|tr(|nt|}t|}tt|j||||||dtd||| f | dS)N)r'r(Fr)r isinstancervr0rr@) rrr r!r"rr#r$r%r&r'r(r<)r?rrr)s   zConv1d.__init__cCsdS)NZQuantizedConv1dr)rrrr _get_name)szConv1d._get_name)rIrJrcCsV|jdkr.tjjj|||j|j|j|j|_ n$tjjj|||jt d|j|j|_ dS)Nr r) r&r6r quantizedZconv1d_prepackr"rr#r$_packed_paramsr)rrIrJrrrr;,s  zConv1d.set_weight_biascCstjjj|j\}}||fS)N)r6rrZ conv1d_unpackr)rrIrJrrrrA5szConv1d._weight_biascCs |jdS)Nr)rA)rrrrrE9sz Conv1d.weightcCs |jdS)Nr)rA)rrrrr%<sz Conv1d.biascCs\t|jdkrtd|jdkrDt|jdd}tj|||jd}tj j ||j |j |j S)NrQz Input shape must be `(N, C, L)`!r r)mode)rshaper1r&rrFpadrrZconv1drr*r+)rinputrrrrforward?s  zConv1d.forwardcCs tj||S)zCreates a quantized module from a float module or qparams_dict. Args: mod (Module): a float module, either produced by torch.quantization utilities or provided by the user )rrx)rirjrrrrxKszConv1d.from_float)rrrrTr NN)ruryrz__doc__rarrtnniqatZConvBn1drsnniZ ConvReLU1drwrNrboolrvr)rr6Tensorrr;rArEr%rr|rxr~rr)r?rrs&$   rcseZdZdZejZejZ e j Z dfdd Z d d Zejeejdd d d ZddZddZddZddZeddZZS)Conv2daZApplies a 2D convolution over a quantized input signal composed of several quantized input planes. For details on input arguments, parameters, and implementation see :class:`~torch.nn.Conv2d`. .. note:: Only `zeros` is supported for the :attr:`padding_mode` argument. .. note:: Only `torch.quint8` is supported for the input data type. Attributes: weight (Tensor): packed tensor derived from the learnable weight parameter. scale (Tensor): scalar for the output scale zero_point (Tensor): scalar for the output zero point See :class:`~torch.nn.Conv2d` for other attributes. Examples:: >>> # With square kernels and equal stride >>> m = nn.quantized.Conv2d(16, 33, 3, stride=2) >>> # non-square kernels and unequal stride and with padding >>> m = nn.quantized.Conv2d(16, 33, (3, 5), stride=(2, 1), padding=(4, 2)) >>> # non-square kernels and unequal stride and with padding and dilation >>> m = nn.quantized.Conv2d(16, 33, (3, 5), stride=(2, 1), padding=(4, 2), dilation=(3, 1)) >>> input = torch.randn(20, 16, 50, 100) >>> # quantize input to quint8 >>> q_input = torch.quantize_per_tensor(input, scale=1.0, zero_point=0, dtype=torch.quint8) >>> output = m(q_input) rrTr Nc sZ| | d} t|}t|}t|}t|}tt|j||||||dtd||| f | dS)N)r'r(Fr)rr0rr@) rrr r!r"rr#r$r%r&r'r(r<)r?rrr)~s   zConv2d.__init__cCsdS)NZQuantizedConv2dr)rrrrrszConv2d._get_name)rIrJrcCsV|jdkr.tjjj|||j|j|j|j|_ n$tjjj|||jt d|j|j|_ dS)Nr r) r&r6rrZconv2d_prepackr"rr#r$rr)rrIrJrrrr;s  zConv2d.set_weight_biascCs |jjS)N)runpack)rrrrrAszConv2d._weight_biascCs |jdS)Nr)rA)rrrrrEsz Conv2d.weightcCs |jdS)Nr)rA)rrrrr%sz Conv2d.biascCsTt|jdkrtd|jdkr>> # With square kernels and equal stride >>> m = nn.quantized.Conv3d(16, 33, 3, stride=2) >>> # non-square kernels and unequal stride and with padding >>> m = nn.quantized.Conv3d(16, 33, (3, 5, 5), stride=(1, 2, 2), padding=(1, 2, 2)) >>> # non-square kernels and unequal stride and with padding and dilation >>> m = nn.quantized.Conv3d(16, 33, (3, 5, 5), stride=(1, 2, 2), padding=(1, 2, 2), dilation=(1, 2, 2)) >>> input = torch.randn(20, 16, 56, 56, 56) >>> # quantize input to quint8 >>> q_input = torch.quantize_per_tensor(input, scale=1.0, zero_point=0, dtype=torch.quint8) >>> output = m(q_input) rrTr Nc sj| dkstd| | d} t|}t|}t|}t|}tt|j||||||dtd||| f | dS)Nr z*Conv3d does not support reflection padding)r'r(Fr)rhr r0rr@) rrr r!r"rr#r$r%r&r'r(r<)r?rrr)s   zConv3d.__init__cCsdS)NZQuantizedConv3dr)rrrrrszConv3d._get_name)rIrJrcCsV|jdkr.tjjj|||j|j|j|j|_ n$tjjj|||jt d|j|j|_ dS)Nr r) r&r6rrZconv3d_prepackr"rr#r$rr )rrIrJrrrr;s  zConv3d.set_weight_biascCs |jjS)N)rr)rrrrrAszConv3d._weight_biascCs |jdS)Nr)rA)rrrrrEsz Conv3d.weightcCs |jdS)Nr)rA)rrrrr%sz Conv3d.biascCsTt|jdkrtd|jdkrtd|jj}||j|jj\}}|j t j ksttdt |jj |}||j|j|j|j|j|j|j|jdk |j|j }|j||jt ||_t||_|S)zCreates a quantized module from a float module or qparams_dict. Args: mod (Module): a float module, either produced by torch.quantization utilities or provided by the user z nnq.z.from_float only works for rfz-Input float module must have qconfig defined.z*Weight observer must have a dtype of qint8N)rurtr_rhrrrfrErkrgr(r6r8r r:rr r!r"rr3r$r%r#r&r;r*rNr+)rirjmsgrlrmrnr=rorrrrx3s$       z_ConvTransposeNd.from_float)NN) ruryrzrrtr)rrNrr|rxr~rr)r?rrs $rc sjeZdZdZejZdfdd Zd d Ze j e e j dd d d Z ddZ ddZddZddZZS)ConvTranspose1daApplies a 1D transposed convolution operator over an input image composed of several input planes. For details on input arguments, parameters, and implementation see :class:`~torch.nn.ConvTranspose1d`. .. note:: Currently only the QNNPACK engine is implemented. Please, set the `torch.backends.quantized.engine = 'qnnpack'` For special notes, please, see :class:`~torch.nn.quantized.Conv1d` Attributes: weight (Tensor): packed tensor derived from the learnable weight parameter. scale (Tensor): scalar for the output scale zero_point (Tensor): scalar for the output zero point See :class:`~torch.nn.ConvTranspose2d` for other attributes. Examples:: >>> torch.backends.quantized.engine = 'qnnpack' >>> # With square kernels and equal stride >>> m = nnq.ConvTranspose1d(16, 33, 3, stride=2) >>> # non-square kernels and unequal stride and with padding >>> m = nnq.ConvTranspose1d(16, 33, (3, 5), stride=(2, 1), padding=(4, 2)) >>> input = torch.randn(20, 16, 50) >>> q_input = torch.quantize_per_tensor(input, scale=1.0, zero_point=0, dtype=torch.quint8) >>> output = m(q_input) >>> # exact output size can be also specified as an argument >>> input = torch.randn(1, 16, 12) >>> q_input = torch.quantize_per_tensor(input, scale=1.0, zero_point=0, dtype=torch.quint8) >>> downsample = nnq.Conv1d(16, 16, 3, stride=2, padding=1) >>> upsample = nnq.ConvTranspose1d(16, 16, 3, stride=2, padding=1) >>> h = downsample(q_input) >>> h.size() torch.Size([1, 16, 6]) >>> output = upsample(h, output_size=input.size()) >>> output.size() torch.Size([1, 16, 12]) rrTr Nc  s^| | d} t|}t|}t|}t| } t|}tt|j|||||| d|||| f | dS)N)r'r(T)rr0rr))rrr r!r"rr3r$r%r#r&r'r(r<)r?rrr)|s   zConvTranspose1d.__init__cCsdS)NZQuantizedConvTranpose1dr)rrrrrszConvTranspose1d._get_name)rIrJrcCs*tjjj|||j|j|j|j|j|_ dS)N) r6rrZconv_transpose1d_prepackr"rr3r#r$r)rrIrJrrrr;szConvTranspose1d.set_weight_biascCstjjj|j\}}||fS)N)r6rrZconv_transpose1d_unpackr)rrIrJrrrrAszConvTranspose1d._weight_biascCs|j\}}|S)N)rA)rrIrrrrrEs zConvTranspose1d.weightcCs|j\}}|S)N)rA)rrrJrrrr%s zConvTranspose1d.biascCs0t|jdkrtdtjjj||j|j|j S)NrQz Input shape must be `(N, C, L)`!) rrr1r6rrZconv_transpose1drr*r+)rrrrrrszConvTranspose1d.forward) rrrrTrr NN)ruryrzrrarrtr)rr6rrr;rArEr%rr~rr)r?rrQs' rc sjeZdZdZejZdfdd Zd d Ze j e e j dd d d Z ddZ ddZddZddZZS)ConvTranspose2daApplies a 2D transposed convolution operator over an input image composed of several input planes. For details on input arguments, parameters, and implementation see :class:`~torch.nn.ConvTranspose2d`. For special notes, please, see :class:`~torch.nn.quantized.Conv2d` Attributes: weight (Tensor): packed tensor derived from the learnable weight parameter. scale (Tensor): scalar for the output scale zero_point (Tensor): scalar for the output zero point See :class:`~torch.nn.ConvTranspose2d` for other attributes. Examples:: >>> # QNNPACK or FBGEMM as backend >>> torch.backends.quantized.engine = 'qnnpack' >>> # With square kernels and equal stride >>> m = nnq.ConvTranspose2d(16, 33, 3, stride=2) >>> # non-square kernels and unequal stride and with padding >>> m = nnq.ConvTranspose2d(16, 33, (3, 5), stride=(2, 1), padding=(4, 2)) >>> input = torch.randn(20, 16, 50, 100) >>> q_input = torch.quantize_per_tensor(input, scale=1.0, zero_point=0, dtype=torch.quint8) >>> output = m(q_input) >>> # exact output size can be also specified as an argument >>> input = torch.randn(1, 16, 12, 12) >>> q_input = torch.quantize_per_tensor(input, scale=1.0, zero_point=0, dtype=torch.quint8) >>> downsample = nnq.Conv2d(16, 16, 3, stride=2, padding=1) >>> upsample = nnq.ConvTranspose2d(16, 16, 3, stride=2, padding=1) >>> h = downsample(q_input) >>> h.size() torch.Size([1, 16, 6, 6]) >>> output = upsample(h, output_size=input.size()) >>> output.size() torch.Size([1, 16, 12, 12]) rrTr Nc  s^| | d} t|}t|}t|}t| } t|}tt|j|||||| d|||| f | dS)N)r'r(T)rr0rr))rrr r!r"rr3r$r%r#r&r'r(r<)r?rrr)s   zConvTranspose2d.__init__cCsdS)NZQuantizedConvTranpose2dr)rrrrrszConvTranspose2d._get_name)rIrJrcCs*tjjj|||j|j|j|j|j|_ dS)N) r6rrZconv_transpose2d_prepackr"rr3r#r$r)rrIrJrrrr;szConvTranspose2d.set_weight_biascCstjjj|j\}}||fS)N)r6rrZ conv2d_unpackr)rrIrJrrrrAszConvTranspose2d._weight_biascCs|j\}}|S)N)rA)rrIrrrrrEs zConvTranspose2d.weightcCs|j\}}|S)N)rA)rrrJrrrr%s zConvTranspose2d.biascCs.t|jdkrtdtjj||j|j|jS)NrRz#Input shape must be `(N, C, H, W)`!) rrr1rrZconv_transpose2drr*r+)rrrrrrszConvTranspose2d.forward) rrrrTrr NN)ruryrzrrarrtr)rr6rrr;rArEr%rr~rr)r?rrs% rc sjeZdZdZejZdfdd Zd d Ze j e e j dd d d Z ddZ ddZddZddZZS)ConvTranspose3da8Applies a 3D transposed convolution operator over an input image composed of several input planes. For details on input arguments, parameters, and implementation see :class:`~torch.nn.ConvTranspose3d`. .. note:: Currently only the FBGEMM engine is implemented. Please, set the `torch.backends.quantized.engine = 'fbgemm'` For special notes, please, see :class:`~torch.nn.quantized.Conv3d` Attributes: weight (Tensor): packed tensor derived from the learnable weight parameter. scale (Tensor): scalar for the output scale zero_point (Tensor): scalar for the output zero point See :class:`~torch.nn.ConvTranspose3d` for other attributes. Examples:: >>> torch.backends.quantized.engine = 'fbgemm' >>> # With cubic kernels and equal stride >>> m = nnq.ConvTranspose3d(16, 33, 3, stride=2) >>> # non-cubic kernels and unequal stride and with padding >>> m = nnq.ConvTranspose3d(16, 33, (3, 3, 5), stride=(2, 1, 1), padding=(4, 2, 2)) >>> input = torch.randn(20, 16, 50, 100, 100) >>> q_input = torch.quantize_per_tensor(input, scale=1.0, zero_point=0, dtype=torch.quint8) >>> output = m(q_input) >>> # exact output size can be also specified as an argument >>> input = torch.randn(1, 16, 12, 12, 12) >>> q_input = torch.quantize_per_tensor(input, scale=1.0, zero_point=0, dtype=torch.quint8) >>> downsample = nnq.Conv3d(16, 16, 3, stride=2, padding=1) >>> upsample = nnq.ConvTranspose3d(16, 16, 3, stride=2, padding=1) >>> h = downsample(q_input) >>> h.size() torch.Size([1, 16, 6, 6, 6]) >>> output = upsample(h, output_size=input.size()) >>> output.size() torch.Size([1, 16, 12, 12, 12]) rrTr Nc  s^| | d} t|}t|}t|}t| } t|}tt|j|||||| d|||| f | dS)N)r'r(T)rr0rr))rrr r!r"rr3r$r%r#r&r'r(r<)r?rrr)%s   zConvTranspose3d.__init__cCsdS)NZQuantizedConvTranpose3dr)rrrrr3szConvTranspose3d._get_name)rIrJrcCs*tjjj|||j|j|j|j|j|_ dS)N) r6rrZconv_transpose3d_prepackr"rr3r#r$r)rrIrJrrrr;6szConvTranspose3d.set_weight_biascCstjjj|j\}}||fS)N)r6rrZ conv3d_unpackr)rrIrJrrrrA;szConvTranspose3d._weight_biascCs|j\}}|S)N)rA)rrIrrrrrE?s zConvTranspose3d.weightcCs|j\}}|S)N)rA)rrrJrrrr%Cs zConvTranspose3d.biascCs.t|jdkrtdtjj||j|j|jS)NrSz&Input shape must be `(N, C, T, H, W)`!) rrr1rrZconv_transpose3drr*r+)rrrrrrGszConvTranspose3d.forward) rrrrTrr NN)ruryrzrrarrtr)rr6rrr;rArEr%rr~rr)r?rrs' r),rtypingrrrr6Ztorch.nnraZtorch.nn.functionalZ functionalrZtorch.nn.intrinsicZ intrinsicrZtorch.nn.intrinsic.qatZqatrZ torch._opsrZtorch.nn.common_typesrZtorch.nn.modules.utilsrrr Z torch.nn.quantized.modules.utilsr Ztorch.nn.utilsr r4rNrrbrrrrmodulesconvrrrrrrrrrs0       Mjab6VS