# tensorflow::ops::Dequantize Class Reference

# tensorflow::
ops::
Dequantize

`
#include <array_ops.h>
`


[Dequantize](https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/dequantize#classtensorflow_1_1ops_1_1_dequantize)
the 'input' tensor into a float or bfloat16
[Tensor](https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor)
.

## Summary


\[min_range, max_range\] are scalar floats that specify the range for the output. The 'mode' attribute controls exactly which calculations are used to convert the float values to their quantized equivalents.


In 'MIN_COMBINED' mode, each value of the tensor will undergo the following:


```
if T == qint8: in[i] += (range(T) + 1)/ 2.0
out[i] = min_range + (in[i]* (max_range - min_range) / range(T))
```
here `
range(T) = numeric_limits

::max() - numeric_limits

::min()


`

<br />


* MIN_COMBINED Mode Example *


If the input comes from a
[QuantizedRelu6](https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/quantized-relu6#classtensorflow_1_1ops_1_1_quantized_relu6)
, the output type is quint8 (range of 0-255) but the possible range of
[QuantizedRelu6](https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/quantized-relu6#classtensorflow_1_1ops_1_1_quantized_relu6)
is 0-6. The min_range and max_range values are therefore 0.0 and 6.0.
[Dequantize](https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/dequantize#classtensorflow_1_1ops_1_1_dequantize)
on quint8 will take each value, cast to float, and multiply by 6 / 255. Note that if quantizedtype is qint8, the operation will additionally add each value by 128 prior to casting.


If the mode is 'MIN_FIRST', then this approach is used:


```
num_discrete_values = 1 << (# of bits in T)
range_adjust = num_discrete_values / (num_discrete_values - 1)
range = (range_max - range_min) * range_adjust
range_scale = range / num_discrete_values
const double offset_input = static_cast(input) - lowest_quantized;
result = range_min + ((input - numeric_limits::min()) * range_scale)
```

<br />


If the mode is
`
SCALED
`
, dequantization is performed by multiplying each input value by a scaling_factor. (Thus an input of 0 always maps to 0.0).


The scaling_factor is determined from
`
min_range
`
,
`
max_range
`
, and
`
narrow_range
`
in a way that is compatible with
`
QuantizeAndDequantize{V2|V3}
`
and
`
https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/quantize-v2#classtensorflow_1_1ops_1_1_quantize_v2
`
, using the following algorithm:


```

```

<br />


```
  const int min_expected_T = std::numeric_limits::min() +
    (narrow_range ? 1 : 0);
  const int max_expected_T = std::numeric_limits::max();
  const float max_expected_T = std::numeric_limits::max();
```

<br />


```
  const float scale_factor =
    (std::numeric_limits::min() == 0) ? (max_range / max_expected_T)
                                         : std::max(min_range / min_expected_T,
                                                    max_range / max_expected_T);
```

<br />


Args:

- scope: A [Scope](https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object
- min_range: The minimum scalar value possibly produced for the input.
- max_range: The maximum scalar value possibly produced for the input.

<br />


Optional attributes (see
`
https://www.tensorflow.org/versions/r2.6/api_docs/cc/struct/tensorflow/ops/dequantize/attrs#structtensorflow_1_1ops_1_1_dequantize_1_1_attrs
`
):

- dtype: Type of the output tensor. Currently [Dequantize](https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/dequantize#classtensorflow_1_1ops_1_1_dequantize) supports float and bfloat16. If 'dtype' is 'bfloat16', it only supports 'MIN_COMBINED' mode.

<br />


Returns:

- `
  https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output
  ` : The output tensor.

<br />

| ### Constructors and Destructors ||
|---|---|
| ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/dequantize#classtensorflow_1_1ops_1_1_dequantize_1ace6411557abc00c6e59649720be7d579 (const :: https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope & scope, :: https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input input, :: https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input min_range, :: https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input max_range) ` ||
| ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/dequantize#classtensorflow_1_1ops_1_1_dequantize_1afb71f46f9e4fc4922578ecd9116ad9b1 (const :: https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope & scope, :: https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input input, :: https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input min_range, :: https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input max_range, const https://www.tensorflow.org/versions/r2.6/api_docs/cc/struct/tensorflow/ops/dequantize/attrs#structtensorflow_1_1ops_1_1_dequantize_1_1_attrs & attrs) ` ||

| ### Public attributes ||
|---|---|
| ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/dequantize#classtensorflow_1_1ops_1_1_dequantize_1a917ce29fbec6ef49406db9a374bde9aa ` | ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation ` |
| ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/dequantize#classtensorflow_1_1ops_1_1_dequantize_1a5c4618ae3d058bcd8547217612f8f41e ` | ` :: https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output ` |

| ### Public functions ||
|---|---|
| ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/dequantize#classtensorflow_1_1ops_1_1_dequantize_1a4bdeb613e4b88880638a67528cbd01f0 () const ` | ` ::tensorflow::Node * ` |
| ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/dequantize#classtensorflow_1_1ops_1_1_dequantize_1ab1b62ee39a382d6e124eb62156c05525 () const ` | ` ` |
| ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/dequantize#classtensorflow_1_1ops_1_1_dequantize_1ae01ee2df9b62f7729848ca15ed70e8fc () const ` | ` ` |

| ### Public static functions ||
|---|---|
| ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/dequantize#classtensorflow_1_1ops_1_1_dequantize_1ac0b7d9ea267e2c8719f63ff4434b5250 (int64 x) ` | ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/struct/tensorflow/ops/dequantize/attrs#structtensorflow_1_1ops_1_1_dequantize_1_1_attrs ` |
| ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/dequantize#classtensorflow_1_1ops_1_1_dequantize_1aeb2c0e323cdc6f85554c6e03de751730 (DataType x) ` | ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/struct/tensorflow/ops/dequantize/attrs#structtensorflow_1_1ops_1_1_dequantize_1_1_attrs ` |
| ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/dequantize#classtensorflow_1_1ops_1_1_dequantize_1ac9873b34c5c0eb36296e0fe726644fc9 (StringPiece x) ` | ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/struct/tensorflow/ops/dequantize/attrs#structtensorflow_1_1ops_1_1_dequantize_1_1_attrs ` |
| ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/dequantize#classtensorflow_1_1ops_1_1_dequantize_1a4409107547aae6b42715813687850b35 (bool x) ` | ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/struct/tensorflow/ops/dequantize/attrs#structtensorflow_1_1ops_1_1_dequantize_1_1_attrs ` |

| ### Structs ||
|---|---|
| [tensorflow:: ops:: Dequantize:: Attrs](https://www.tensorflow.org/versions/r2.6/api_docs/cc/struct/tensorflow/ops/dequantize/attrs) | Optional attribute setters for [Dequantize](https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/dequantize#classtensorflow_1_1ops_1_1_dequantize) . |

## Public attributes

### operation

```
Operation operation
```

### output

```
::tensorflow::Output output
```

## Public functions

### Dequantize

```
 Dequantize(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input input,
  ::tensorflow::Input min_range,
  ::tensorflow::Input max_range
)
```

### Dequantize

```
 Dequantize(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input input,
  ::tensorflow::Input min_range,
  ::tensorflow::Input max_range,
  const Dequantize::Attrs & attrs
)
```

### node

```
::tensorflow::Node * node() const 
```

### operator::tensorflow::Input

```
 operator::tensorflow::Input() const 
```

### operator::tensorflow::Output

```
 operator::tensorflow::Output() const 
```

## Public static functions

### Axis

```
Attrs Axis(
  int64 x
)
```

### Dtype

```
Attrs Dtype(
  DataType x
)
```

### Mode

```
Attrs Mode(
  StringPiece x
)
```

### NarrowRange

```
Attrs NarrowRange(
  bool x
)
```