open-mmlab / mmcv

OpenMMLab Computer Vision Foundation
https://mmcv.readthedocs.io/en/latest/
Apache License 2.0
5.91k stars 1.65k forks source link

can not find _BatchNorm in mmengine #3054

Open lsj1111 opened 8 months ago

lsj1111 commented 8 months ago

Prerequisite

Environment

mmcv 2.0.1

Reproduces the problem - code sample

from mmcv.utils import (IS_NPU_AVAILABLE, _BatchNorm, )

Reproduces the problem - command or script

In the mmcv1.x , the method of _BatchNorm is in the mmcv.utils,but now in the mmcv 2.x ,it does not exist,and i can't find it in the mmengine

Reproduces the problem - error message

ImportError: cannot import name '_BatchNorm' from 'mmcv.utils' (D:\Tool\Anaconda\Anaconda\envs\openmmlab\lib\site-packages\mmcv\utils__init__.py)

Additional information

In the mmcv1.x , the method of _BatchNorm is in the mmcv.utils,but now in the mmcv 2.x ,it does not exist,and i can't find it in the mmengine

inbook58 commented 5 months ago

I found it in parrots_wrapper.py

Husan2 commented 4 months ago

try this: from torch.nn.modules.batchnorm import _BatchNorm