tf.raw_ops.UniformQuantize
Stay organized with collections
Save and categorize content based on your preferences.
Perform quantization on Tensor input
.
tf.raw_ops.UniformQuantize(
input,
scales,
zero_points,
Tout,
quantization_min_val,
quantization_max_val,
quantization_axis=-1,
name=None
)
Given input
, scales
and zero_points
, performs quantization using the formula:
quantized_data = floor(input_data * (1.0f / scale) + 0.5f) + zero_point
Args |
input
|
A Tensor . Must be one of the following types: float32 .
Must be a Tensor of Tin.
|
scales
|
A Tensor of type float32 .
The float value(s) to use as scale(s) to quantize input .
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).
|
zero_points
|
A Tensor of type int32 .
The int32 value(s) to use as zero_point(s) to quantize input .
Same shape condition as scales.
|
Tout
|
A tf.DType from: tf.qint8, tf.qint32 .
The type of output Tensor. A tf.DType from: tf.float32
|
quantization_min_val
|
An int .
The quantization min value to quantize input .
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.
|
quantization_max_val
|
An int .
The quantization max value to quantize input .
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.
|
quantization_axis
|
An optional int . Defaults to -1 .
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()).
|
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 2024-04-26 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-04-26 UTC."],[],[],null,["# tf.raw_ops.UniformQuantize\n\n\u003cbr /\u003e\n\nPerform quantization on Tensor `input`.\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.UniformQuantize`](https://www.tensorflow.org/api_docs/python/tf/raw_ops/UniformQuantize)\n\n\u003cbr /\u003e\n\n tf.raw_ops.UniformQuantize(\n input,\n scales,\n zero_points,\n Tout,\n quantization_min_val,\n quantization_max_val,\n quantization_axis=-1,\n name=None\n )\n\nGiven `input`, `scales` and `zero_points`, performs quantization using the formula:\nquantized_data = floor(input_data \\* (1.0f / scale) + 0.5f) + zero_point\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: `float32`. Must be a Tensor of Tin. |\n| `scales` | A `Tensor` of type `float32`. The float value(s) to use as scale(s) to quantize `input`. 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| `zero_points` | A `Tensor` of type `int32`. The int32 value(s) to use as zero_point(s) to quantize `input`. 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.float32 |\n| `quantization_min_val` | An `int`. The quantization min value to quantize `input`. 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| `quantization_max_val` | An `int`. The quantization max value to quantize `input`. 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| `quantization_axis` | An optional `int`. Defaults to `-1`. 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| `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"]]