THU-MIG / RepViT

RepViT: Revisiting Mobile CNN From ViT Perspective [CVPR 2024] and RepViT-SAM: Towards Real-Time Segmenting Anything
https://arxiv.org/abs/2307.09283
Apache License 2.0
681 stars 55 forks source link

why do we need replace_batchnorm ? #32

Closed TranThanh96 closed 4 months ago

TranThanh96 commented 6 months ago

why do you need replace_batchnorm when eval?

Isalia20 commented 6 months ago

Not the author of the repo but I assume it's done to achieve maximum performance on IoT devices. Batch norm is fused with convolution operation and is done with just convolution(by fusing the conv weights with batchnorm stats+affine transforms). It first fuses batch norm with convolution and then replaces batch norm layer with identity layer(multiply by 1 basically) to speed up the computation

jameslahm commented 4 months ago

As @Isalia20 explains. Thanks!