/usr/local/lib64/python3.6/site-packages/torch/nn/quantized/__pycache__
Edit: /usr/local/lib64/python3.6/site-packages/torch/nn/quantized/__pycache__/functional.cpython-36.pyc (26537B)
3
EgLo @ s d Z ddlmZmZ ddlZddlZddlmZ ddlmZm Z ddl
mZ ddlm
Z
dDd
dZdEdd
Zee
e edddZee
e edddZdddddddejfddZdddddddejfddZdddddddejfddZdFddZdGeeee ee ee edd d!ZdHd"d#ZdId$d%ZdJeeeeed&d'd(ZdKeeeee ee d*d+d,ZdMeeeeed-d.d/Zeeeed0d1d2Z eeeed3d4d5Z!dNeeeeed&d6d7Z"eed8d9d:Z#eeeed;d
d?Z%dPd@dAZ&dQdBdCZ'dS )Rz" Functional interface (quantized). )ListOptionalN)Tensor)_pair_triple)_pair_from_first)BroadcastingList2FTc C s( | j stdtjjj| ||||||S )a
Applies 2D average-pooling operation in :math:`kH \times kW` regions by step size
:math:`sH \times sW` steps. The number of output features is equal to the number of
input planes.
.. note:: The input quantization parameters propagate to the output.
See :class:`~torch.nn.quantized.AvgPool2d` for details and output shape.
Args:
input: quantized input tensor :math:`(\text{minibatch} , \text{in\_channels} , iH , iW)`
kernel_size: size of the pooling region. Can be a single number or a
tuple `(kH, kW)`
stride: stride of the pooling operation. Can be a single number or a
tuple `(sH, sW)`. Default: :attr:`kernel_size`
padding: implicit zero paddings on both sides of the input. Can be a
single number or a tuple `(padH, padW)`. Default: 0
ceil_mode: when True, will use `ceil` instead of `floor` in the formula
to compute the output shape. Default: ``False``
count_include_pad: when True, will include the zero-padding in the
averaging calculation. Default: ``True``
divisor_override: if specified, it will be used as divisor, otherwise
size of the pooling region will be used. Default: None
z2Input to 'quantized.avg_pool2d' must be quantized!)is_quantized
ValueErrortorchnn
functional
avg_pool2d)inputkernel_sizestridepadding ceil_modecount_include_paddivisor_override r I/usr/local/lib64/python3.6/site-packages/torch/nn/quantized/functional.pyr s
r c C s( | j stdtjjj| ||||||S )a
Applies 3D average-pooling operation in :math:`kD \ times kH \times kW` regions by step size
:math:`sD \times sH \times sW` steps. The number of output features is equal to the number of
input planes.
.. note:: The input quantization parameters propagate to the output.
Args:
input: quantized input tensor :math:`(\text{minibatch} , \text{in\_channels} , iH , iW)`
kernel_size: size of the pooling region. Can be a single number or a
tuple `(kD, kH, kW)`
stride: stride of the pooling operation. Can be a single number or a
tuple `(sD, sH, sW)`. Default: :attr:`kernel_size`
padding: implicit zero paddings on both sides of the input. Can be a
single number or a tuple `(padD, padH, padW)`. Default: 0
ceil_mode: when True, will use `ceil` instead of `floor` in the formula
to compute the output shape. Default: ``False``
count_include_pad: when True, will include the zero-padding in the
averaging calculation. Default: ``True``
divisor_override: if specified, it will be used as divisor, otherwise
size of the pooling region will be used. Default: None
z2Input to 'quantized.avg_pool3d' must be quantized!)r r
r r r
avg_pool3d)r r r r r r r r r r r . s
r )r output_sizereturnc C s | j stdtjjj| |S )a
Applies a 2D adaptive average pooling over a quantized input signal composed
of several quantized input planes.
.. note:: The input quantization parameters propagate to the output.
See :class:`~torch.nn.quantized.AdaptiveAvgPool2d` for details and output shape.
Args:
output_size: the target output size (single integer or
double-integer tuple)
zFInput to 'quantized.functional.adaptive_avg_pool2d' must be quantized!)r r
r r r
adaptive_avg_pool2d)r r r r r r L s
r c C s | j stdtjjj| |S )a
Applies a 3D adaptive average pooling over a quantized input signal composed
of several quantized input planes.
.. note:: The input quantization parameters propagate to the output.
See :class:`~torch.nn.quantized.AdaptiveAvgPool3d` for details and output shape.
Args:
output_size: the target output size (single integer or
double-integer tuple)
zFInput to 'quantized.functional.adaptive_avg_pool3d' must be quantized!)r r
r r r
adaptive_avg_pool3d)r r r r r r ] s
r zeros ?c C s |dkrt d| jtjkr$t d|jtjkr8t d| jdkrJtdt|}t|}t|}tjj j
||||||}tjj j| ||| S )a
Applies a 1D convolution over a quantized 1D input composed of several input
planes.
See :class:`~torch.nn.quantized.Conv1d` for details and output shape.
Args:
input: quantized input tensor of shape :math:`(\text{minibatch} , \text{in\_channels} , iW)`
weight: quantized filters of shape :math:`(\text{out\_channels} , \frac{\text{in\_channels}}{\text{groups}} , iW)`
bias: **non-quantized** bias tensor of shape :math:`(\text{out\_channels})`. The tensor type must be `torch.float`.
stride: the stride of the convolving kernel. Can be a single number or a
tuple `(sW,)`. Default: 1
padding: implicit paddings on both sides of the input. Can be a
single number or a tuple `(padW,)`. Default: 0
dilation: the spacing between kernel elements. Can be a single number or
a tuple `(dW,)`. Default: 1
groups: split input into groups, :math:`\text{in\_channels}` should be divisible by the
number of groups. Default: 1
padding_mode: the padding mode to use. Only "zeros" is supported for quantized convolution at the moment. Default: "zeros"
scale: quantization scale for the output. Default: 1.0
zero_point: quantization zero_point for the output. Default: 0
dtype: quantization data type to use. Default: ``torch.quint8``
Examples::
>>> from torch.nn.quantized import functional as qF
>>> filters = torch.randn(33, 16, 3, dtype=torch.float)
>>> inputs = torch.randn(20, 16, 50, dtype=torch.float)
>>> bias = torch.randn(33, dtype=torch.float)
>>>
>>> scale, zero_point = 1.0, 0
>>> dtype_inputs = torch.quint8
>>> dtype_filters = torch.qint8
>>>
>>> q_filters = torch.quantize_per_tensor(filters, scale, zero_point, dtype_filters)
>>> q_inputs = torch.quantize_per_tensor(inputs, scale, zero_point, dtype_inputs)
>>> qF.conv1d(q_inputs, q_filters, bias, padding=1, scale=scale, zero_point=zero_point)
r zOnly zero-padding is supported!z5Only torch.quint8 is supported for activation tensor!z0Only torch.qint8 is supported for weight tensor! z Input shape must be `(N, C, L)`!)NotImplementedErrordtyper quint8qint8ndimr
r ops quantizedZconv1d_prepackconv1d)r weightbiasr r dilationgroupspadding_modescale
zero_pointr"
packed_paramsr r r r( o s +
r( c C s |dkrt d| jtjkr$t d|jtjkr8t d| jdkrJtdt|}t|}t|}tjj j
||||||}tjj j| ||| S )a
Applies a 2D convolution over a quantized 2D input composed of several input
planes.
See :class:`~torch.nn.quantized.Conv2d` for details and output shape.
Args:
input: quantized input tensor of shape :math:`(\text{minibatch} , \text{in\_channels} , iH , iW)`
weight: quantized filters of shape :math:`(\text{out\_channels} , \frac{\text{in\_channels}}{\text{groups}} , kH , kW)`
bias: **non-quantized** bias tensor of shape :math:`(\text{out\_channels})`. The tensor type must be `torch.float`.
stride: the stride of the convolving kernel. Can be a single number or a
tuple `(sH, sW)`. Default: 1
padding: implicit paddings on both sides of the input. Can be a
single number or a tuple `(padH, padW)`. Default: 0
dilation: the spacing between kernel elements. Can be a single number or
a tuple `(dH, dW)`. Default: 1
groups: split input into groups, :math:`\text{in\_channels}` should be divisible by the
number of groups. Default: 1
padding_mode: the padding mode to use. Only "zeros" is supported for quantized convolution at the moment. Default: "zeros"
scale: quantization scale for the output. Default: 1.0
zero_point: quantization zero_point for the output. Default: 0
dtype: quantization data type to use. Default: ``torch.quint8``
Examples::
>>> from torch.nn.quantized import functional as qF
>>> filters = torch.randn(8, 4, 3, 3, dtype=torch.float)
>>> inputs = torch.randn(1, 4, 5, 5, dtype=torch.float)
>>> bias = torch.randn(8, dtype=torch.float)
>>>
>>> scale, zero_point = 1.0, 0
>>> dtype_inputs = torch.quint8
>>> dtype_filters = torch.qint8
>>>
>>> q_filters = torch.quantize_per_tensor(filters, scale, zero_point, dtype_filters)
>>> q_inputs = torch.quantize_per_tensor(inputs, scale, zero_point, dtype_inputs)
>>> qF.conv2d(q_inputs, q_filters, bias, padding=1, scale=scale, zero_point=zero_point)
r zOnly zero-padding is supported!z5Only torch.quint8 is supported for activation tensor!z0Only torch.qint8 is supported for weight tensor! z#Input shape must be `(N, C, H, W)`!)r! r" r r# r$ r% r
r r&