tf.raw_ops.UniformRequantize
Stay organized with collections
Save and categorize content based on your preferences.
Given quantized tensor input
, requantize it with new quantization parameters.
tf.raw_ops.UniformRequantize(
input,
input_scales,
input_zero_points,
output_scales,
output_zero_points,
Tout,
input_quantization_min_val,
input_quantization_max_val,
output_quantization_min_val,
output_quantization_max_val,
input_quantization_axis=-1,
output_quantization_axis=-1,
name=None
)
Given quantized tensor input
, which was quantized using {input_scales, input_zero_points, input_quantization_axis, input_quantization_min_val, input_quantization_max_val},
requantize it to a tensor, which is quantized using {output_scales, output_zero_points, output_quantization_axis, output_quantization_min_val, output_quantization_max_val}.
The requantization is done by using the formula:
output_quantized_data = clip(
(input_quantized_data - input_zero_point) * (input_scale / output_scale) + output_zero_point,
output_quantization_min_val,
output_quantization_max_val)
Per-tensor and per-axis quantization supported cases are followings:
- per-tensor -> per-tensor
- per-tensor -> per-axis
- per-axis -> per-axis where input_quantization_axis equals output_quantization_axis.
i.e. At least one among input_quantization_axis and output_quantization_axis must be -1, or two must be equal.
Args |
input
|
A Tensor . Must be one of the following types: qint8 , qint32 .
Must be a Tensor of Tin.
|
input_scales
|
A Tensor of type float32 .
The float value(s) used as scale(s) when quantizing original data that input represents.
Must be a scalar Tensor if quantization_axis is -1 (per-tensor quantization), otherwise 1D Tensor of size (input.dim_size(quantization_axis),) (per-axis quantization).
|
input_zero_points
|
A Tensor of type int32 .
The int32 value(s) used as zero_point(s) when quantizing original data that input represents.
Same shape condition as scales.
|
output_scales
|
A Tensor of type float32 .
The float value(s) to use as new scale(s) to quantize original data that input represents.
Must be a scalar Tensor if quantization_axis is -1 (per-tensor quantization), otherwise 1D Tensor of size (input.dim_size(quantization_axis),) (per-axis quantization).
|
output_zero_points
|
A Tensor of type int32 .
The int32 value(s) to use as new zero_point(s) to quantize original data that input represents.
Same shape condition as scales.
|
Tout
|
A tf.DType from: tf.qint8, tf.qint32 .
The type of output Tensor. A tf.DType from: tf.qint8, tf.qint32
|
input_quantization_min_val
|
An int .
The quantization min value that was used when quantizing original data that input represents.
The purpose of this attribute is typically (but not limited to) to indicate narrow range, where this is set to:
(Tin lowest) + 1 if narrow range, and (Tin lowest) otherwise.
For example, if Tin is qint8, this is set to -127 if narrow range quantized or -128 if not.
|
input_quantization_max_val
|
An int .
The quantization max value that was used when quantizing original data that input represents.
The purpose of this attribute is typically (but not limited to) indicate narrow range, where this is set to:
(Tout max) for both narrow range and not narrow range.
For example, if Tin is qint8, this is set to 127.
|
output_quantization_min_val
|
An int .
The new quantization min value to quantize original data that input represents.
|
output_quantization_max_val
|
An int .
The new quantization max value to quantize original data that input represents.
|
input_quantization_axis
|
An optional int . Defaults to -1 .
The quantization axis that was used when quantizing original data that input represents.
Indicates the dimension index of the tensor where per-axis quantization is applied for the slices along that dimension.
If set to -1 (default), this indicates per-tensor quantization. Otherwise, it must be set within range [0, input.dims()).
|
output_quantization_axis
|
An optional int . Defaults to -1 .
The new quantization axis to use to quantize original data that input represents.
|
name
|
A name for the operation (optional).
|
Returns |
A Tensor of type Tout .
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2023-10-06 UTC.
[null,null,["Last updated 2023-10-06 UTC."],[],[],null,["# tf.raw_ops.UniformRequantize\n\n\u003cbr /\u003e\n\nGiven quantized tensor `input`, requantize it with new quantization parameters.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.raw_ops.UniformRequantize`](https://www.tensorflow.org/api_docs/python/tf/raw_ops/UniformRequantize)\n\n\u003cbr /\u003e\n\n tf.raw_ops.UniformRequantize(\n input,\n input_scales,\n input_zero_points,\n output_scales,\n output_zero_points,\n Tout,\n input_quantization_min_val,\n input_quantization_max_val,\n output_quantization_min_val,\n output_quantization_max_val,\n input_quantization_axis=-1,\n output_quantization_axis=-1,\n name=None\n )\n\nGiven quantized tensor `input`, which was quantized using {input_scales, input_zero_points, input_quantization_axis, input_quantization_min_val, input_quantization_max_val},\nrequantize it to a tensor, which is quantized using {output_scales, output_zero_points, output_quantization_axis, output_quantization_min_val, output_quantization_max_val}.\nThe requantization is done by using the formula:\noutput_quantized_data = clip(\n(input_quantized_data - input_zero_point) \\* (input_scale / output_scale) + output_zero_point,\noutput_quantization_min_val,\noutput_quantization_max_val)\n\nPer-tensor and per-axis quantization supported cases are followings:\n\n- per-tensor -\\\u003e per-tensor\n- per-tensor -\\\u003e per-axis\n- per-axis -\\\u003e per-axis where input_quantization_axis equals output_quantization_axis. i.e. At least one among input_quantization_axis and output_quantization_axis must be -1, or two must be equal.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `input` | A `Tensor`. Must be one of the following types: `qint8`, `qint32`. Must be a Tensor of Tin. |\n| `input_scales` | A `Tensor` of type `float32`. The float value(s) used as scale(s) when quantizing original data that `input` represents. Must be a scalar Tensor if quantization_axis is -1 (per-tensor quantization), otherwise 1D Tensor of size (input.dim_size(quantization_axis),) (per-axis quantization). |\n| `input_zero_points` | A `Tensor` of type `int32`. The int32 value(s) used as zero_point(s) when quantizing original data that `input` represents. Same shape condition as scales. |\n| `output_scales` | A `Tensor` of type `float32`. The float value(s) to use as new scale(s) to quantize original data that `input` represents. Must be a scalar Tensor if quantization_axis is -1 (per-tensor quantization), otherwise 1D Tensor of size (input.dim_size(quantization_axis),) (per-axis quantization). |\n| `output_zero_points` | A `Tensor` of type `int32`. The int32 value(s) to use as new zero_point(s) to quantize original data that `input` represents. Same shape condition as scales. |\n| `Tout` | A [`tf.DType`](../../tf/dtypes/DType) from: `tf.qint8, tf.qint32`. The type of output Tensor. A tf.DType from: tf.qint8, tf.qint32 |\n| `input_quantization_min_val` | An `int`. The quantization min value that was used when quantizing original data that `input` represents. The purpose of this attribute is typically (but not limited to) to indicate narrow range, where this is set to: `(Tin lowest) + 1` if narrow range, and `(Tin lowest)` otherwise. For example, if Tin is qint8, this is set to -127 if narrow range quantized or -128 if not. |\n| `input_quantization_max_val` | An `int`. The quantization max value that was used when quantizing original data that `input` represents. The purpose of this attribute is typically (but not limited to) indicate narrow range, where this is set to: `(Tout max)` for both narrow range and not narrow range. For example, if Tin is qint8, this is set to 127. |\n| `output_quantization_min_val` | An `int`. The new quantization min value to quantize original data that `input` represents. |\n| `output_quantization_max_val` | An `int`. The new quantization max value to quantize original data that `input` represents. |\n| `input_quantization_axis` | An optional `int`. Defaults to `-1`. The quantization axis that was used when quantizing original data that `input` represents. Indicates the dimension index of the tensor where per-axis quantization is applied for the slices along that dimension. If set to -1 (default), this indicates per-tensor quantization. Otherwise, it must be set within range \\[0, input.dims()). |\n| `output_quantization_axis` | An optional `int`. Defaults to `-1`. The new quantization axis to use to quantize original data that `input` represents. |\n| `name` | A name for the operation (optional). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A `Tensor` of type `Tout`. ||\n\n\u003cbr /\u003e"]]