YouTip LogoYouTip

Pytorch Torch Quantize_Per_Channel

```html PyTorch torch.quantize_per_channel Function | Tutorial

Tutorial -- Learning not only technology, but also dreams!

PyTorch Tutorial

PyTorch Data Transforms

PyTorch torch.nn Reference

PyTorch torch.quantize_per_channel Function


Pytorch torch Reference Pytorch torch Reference

torch.quantize_per_channel is a PyTorch function used to create a quantized tensor with per-channel quantization.

Function Definition

torch.quantize_per_channel(input, scales, zero_points, axis, dtype)

Usage Example

import torch

# Create input tensor (2D)
input = torch.tensor([[-1.0,0.0],[1.0,2.0]])

# Per-channel quantization
# scales: scaling factors for each channel
# zero_points: zero points for each channel
# axis: dimension along which to quantize
scales = torch.tensor([0.1,0.2])
zero_points = torch.tensor([10,10])
axis = 0

x = torch.quantize_per_channel(input, scales, zero_points, axis, dtype=torch.quint8)

print("Quantized tensor:")
print(x)
print("Dequantized original values:")
print(x.dequantize())

Pytorch torch Reference Pytorch torch Reference

PyTorch Data Transforms

PyTorch torch.nn Reference

ByteDance Coding Plan supports major large models like Doubao, GLM, DeepSeek, Kimi, MiniMax, with official direct supply for stable and reliable service. Configuration Guide Β₯9.9/month Sign Up Now

iFlytek Star Coding Plan includes free model invocation quotas for DeepSeek, GLM, Kimi, MiniMax, a one-stop experience and deployment platform. Configuration Guide Β₯3.9/month Sign Up Now

Share Notes

```
← Pytorch Torch Quantized_Batch_Pytorch Torch Qr β†’