# tensorplay.functional.quantize_per_tensor_dynamic Source: https://www.tensorplay.cn/docs/generated/tensorplay.functional.quantize_per_tensor_dynamic.html ```python tensorplay.functional.quantize_per_tensor_dynamic(input, dtype, reduce_range) → Tensor ``` Converts a float tensor to a quantized tensor with scale and zero_point calculated dynamically based on the input. Parameters: - input ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)) – float tensor or list of tensors to quantize - dtype ([tensorplay.dtype](/docs/generated/tensorplay.DType.html#tensorplay.DType)) – the desired data type of returned tensor. Has to be one of the quantized dtypes: tensorplay.quint8, tensorplay.qint8 - reduce_range ([bool](https://docs.python.org/3/builtins/functions.html#bool)) – a flag to indicate whether to reduce the range of quantized - bit (data by 1) - hardwares (it's required to avoid instruction overflow for some) Returns: A newly (dynamically) quantized tensor Return type: [Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor) Example: ``` >>> t = tensorplay.quantize_per_tensor_dynamic(tensorplay.tensor([-1.0, 0.0, 1.0, 2.0]), tensorplay.quint8, False) >>> print(t) tensor([-1., 0., 1., 2.], size=(4,), dtype=tensorplay.quint8, quantization_scheme=tensorplay.per_tensor_affine, scale=0.011764705882352941, zero_point=85) >>> t.int_repr() tensor([ 0, 85, 170, 255], dtype=tensorplay.uint8) ```