# tensorplay.functional.quantize_per_channel Source: https://www.tensorplay.cn/docs/generated/tensorplay.functional.quantize_per_channel.html ```python tensorplay.functional.quantize_per_channel(input, scales, zero_points, axis, dtype) → Tensor ``` Converts a float tensor to a per-channel quantized tensor with given scales and zero points. Parameters: - input ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)) – float tensor to quantize - scales ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)) – float 1D tensor of scales to use, size should match input.size(axis) - zero_points ([int](https://docs.python.org/3/builtins/functions.html#int)) – integer 1D tensor of offset to use, size should match input.size(axis) - axis ([int](https://docs.python.org/3/builtins/functions.html#int)) – dimension on which apply per-channel quantization - 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, tensorplay.qint32 Returns: A newly quantized tensor Return type: [Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor) Example: ``` >>> x = tensorplay.tensor([[-1.0, 0.0], [1.0, 2.0]]) >>> tensorplay.quantize_per_channel(x, tensorplay.tensor([0.1, 0.01]), tensorplay.tensor([10, 0]), 0, tensorplay.quint8) tensor([[-1., 0.], [ 1., 2.]], size=(2, 2), dtype=tensorplay.quint8, quantization_scheme=tensorplay.per_channel_affine, scale=tensor([0.1000, 0.0100], dtype=tensorplay.float64), zero_point=tensor([10, 0]), axis=0) >>> tensorplay.quantize_per_channel(x, tensorplay.tensor([0.1, 0.01]), tensorplay.tensor([10, 0]), 0, tensorplay.quint8).int_repr() tensor([[ 0, 10], [100, 200]], dtype=tensorplay.uint8) ```