latest (dev)
Copy
Latest development documentation · Updated 2026-10-15
tensorplay.functional.fake_quantize_per_channel_affine
- tensorplay.functional.fake_quantize_per_channel_affine(input, scale, zero_point, axis, quant_min, quant_max) Tensor[source]
Returns a new tensor with the data in
inputfake quantized per channel usingscale,zero_point,quant_minandquant_max, across the channel specified byaxis.- Parameters:
input (Tensor) – the input value(s), in
tensorplay.float32scale (Tensor) – quantization scale, per channel in
tensorplay.float32zero_point (Tensor) – quantization zero_point, per channel in
tensorplay.int32ortensorplay.halfortensorplay.float32axis (int32) – channel axis
quant_min (int64) – lower bound of the quantized domain
quant_max (int64) – upper bound of the quantized domain
- Returns:
A newly fake_quantized per channel
tensorplay.float32tensor- Return type:
Example:
>>> x = tensorplay.randn(2, 2, 2) >>> x tensor([[[-0.2525, -0.0466], [ 0.3491, -0.2168]], [[-0.5906, 1.6258], [ 0.6444, -0.0542]]]) >>> scales = (tensorplay.randn(2) + 1) * 0.05 >>> scales tensor([0.0475, 0.0486]) >>> zero_points = tensorplay.zeros(2).to(tensorplay.int32) >>> zero_points tensor([0, 0]) >>> tensorplay.fake_quantize_per_channel_affine(x, scales, zero_points, 1, 0, 255) tensor([[[0.0000, 0.0000], [0.3405, 0.0000]], [[0.0000, 1.6134], [0.6323, 0.0000]]])
Help improve this page
Found an error, an unclear step, or a missing example?
Was this page helpful?

