#include <array_ops.h>
Quantizes then dequantizes a tensor.
This op simulates the precision loss from the quantized forward pass by:
There are different ways to quantize. This version uses only scaling, so 0.0 maps to 0.
From the specified 'num_bits' in the quantized output type, it determines minimum and maximum representable quantized values.
e.g.
If range_given == False, the initial input_min, input_max will be determined automatically as the minimum and maximum values in the input tensor, otherwise the specified values of input_min, input_max are used.
Note: If the input_min, input_max are specified, they do not need to equal the actual minimum and maximum values in the tensor. e.g. in some cases it may be beneficial to specify these values such that the low probability extremes of the input distribution are clipped.
This op determines the maximum scale_factor that would map the initial [input_min, input_max] range to a range that lies within the representable quantized range.
It determines the scale from one of input_min and input_max, then updates the other one to maximize the representable range.
e.g.
After determining the scale_factor and updating the input range, it applies the following to each value in the 'input' tensor.
output = round(clamp(value, input_min, input_max) * scale_factor) / scale_factor.
The above round function rounds the value based on the given round_mode.
Arguments:
range_given == True
, this specifies the minimum input value that needs to be represented, otherwise it is determined from the min value of the input
tensor.range_given == True
, this specifies the maximum input value that needs to be represented, otherwise it is determined from the max value of the input
tensor.Optional attributes (see Attrs
):
signed_output
)input
tensor.Returns:
Output
: The output tensor. Constructors and Destructors | |
---|---|
QuantizeAndDequantizeV2(const ::tensorflow::Scope & scope, ::tensorflow::Input input, ::tensorflow::Input input_min, ::tensorflow::Input input_max) | |
QuantizeAndDequantizeV2(const ::tensorflow::Scope & scope, ::tensorflow::Input input, ::tensorflow::Input input_min, ::tensorflow::Input input_max, const QuantizeAndDequantizeV2::Attrs & attrs) |
Public attributes | |
---|---|
operation | |
output |
Public functions | |
---|---|
node() const | ::tensorflow::Node * |
operator::tensorflow::Input() const | |
operator::tensorflow::Output() const |
Public static functions | |
---|---|
Axis(int64 x) | |
NarrowRange(bool x) | |
NumBits(int64 x) | |
RangeGiven(bool x) | |
RoundMode(StringPiece x) | |
SignedInput(bool x) |
Structs | |
---|---|
tensorflow::ops::QuantizeAndDequantizeV2::Attrs | Optional attribute setters for QuantizeAndDequantizeV2. |
Operation operation
::tensorflow::Output output
QuantizeAndDequantizeV2( const ::tensorflow::Scope & scope, ::tensorflow::Input input, ::tensorflow::Input input_min, ::tensorflow::Input input_max )
QuantizeAndDequantizeV2( const ::tensorflow::Scope & scope, ::tensorflow::Input input, ::tensorflow::Input input_min, ::tensorflow::Input input_max, const QuantizeAndDequantizeV2::Attrs & attrs )
::tensorflow::Node * node() const
operator::tensorflow::Input() const
operator::tensorflow::Output() const
Attrs Axis( int64 x )
Attrs NarrowRange( bool x )
Attrs NumBits( int64 x )
Attrs RangeGiven( bool x )
Attrs RoundMode( StringPiece x )
Attrs SignedInput( bool x )
© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.4/api_docs/cc/class/tensorflow/ops/quantize-and-dequantize-v2