Skip to content

QuantConv2d

Bases: QuantBase

Int8-quantized 2-D convolution with optional BatchNorm and ReLU.

When bn=True a :class:torch.nn.BatchNorm2d is applied after the convolution during training; for schema export BN is folded into the weight and bias.

Parameters:

Name Type Description Default
in_channels int

Number of input channels.

required
out_channels int

Number of output channels.

required
kernel_size int | tuple[int, int]

Kernel size.

required
stride int | tuple[int, int]

Convolution stride.

1
padding int | tuple[int, int] | tuple[int, int, int, int]

Zero-padding. int or 2-tuple (pad_h, pad_w) or 4-tuple (L, R, T, B).

0
bias bool

Whether to include an additive bias.

True
device str

Torch device for the underlying parameters.

'cpu'
act_func str | None

Either "relu" or None.

None
ema_constant float

EMA smoothing factor for observers.

0.01
bn bool

If True, append a BatchNorm2d layer and fold it into weights for schema export.

False