prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  `benchmark.py`.  ModuleNotFoundError: No module named 'tools.fuse_conv_bn'.
  Recently the `tools/fuse_conv_bn.py`  was removed in #3529 . But the `benchmark.py`  is still trying to use the old script. 
  
  [https://github.com/open-mmlab/mmdetection/blob/master/tools/benchmark.py#L8](https://github.com/open-mmlab/mmdetection/blob/master/tools/benchmark.py#L8)
  
  I think this might be causing the error.
  
  **Reproduction**
  1. What command or script did you run?
  ```
  tools/benchmark.py
  ```
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `tools/benchmark.py`
  Content:
  ```
  1 import argparse
  2 import time
  3 
  4 import torch
  5 from mmcv import Config
  6 from mmcv.parallel import MMDataParallel
  7 from mmcv.runner import load_checkpoint
  8 from tools.fuse_conv_bn import fuse_module
  9 
  10 from mmdet.core import wrap_fp16_model
  11 from mmdet.datasets import build_dataloader, build_dataset
  12 from mmdet.models import build_detector
  13 
  14 
  15 def parse_args():
  16     parser = argparse.ArgumentParser(description='MMDet benchmark a model')
  17     parser.add_argument('config', help='test config file path')
  18     parser.add_argument('checkpoint', help='checkpoint file')
  19     parser.add_argument(
  20         '--log-interval', default=50, help='interval of logging')
  21     parser.add_argument(
  22         '--fuse-conv-bn',
  23         action='store_true',
  24         help='Whether to fuse conv and bn, this will slightly increase'
  25         'the inference speed')
  26     args = parser.parse_args()
  27     return args
  28 
  29 
  30 def main():
  31     args = parse_args()
  32 
  33     cfg = Config.fromfile(args.config)
  34     # set cudnn_benchmark
  35     if cfg.get('cudnn_benchmark', False):
  36         torch.backends.cudnn.benchmark = True
  37     cfg.model.pretrained = None
  38     cfg.data.test.test_mode = True
  39 
  40     # build the dataloader
  41     # TODO: support multiple images per gpu (only minor changes are needed)
  42     dataset = build_dataset(cfg.data.test)
  43     data_loader = build_dataloader(
  44         dataset,
  45         samples_per_gpu=1,
  46         workers_per_gpu=cfg.data.workers_per_gpu,
  47         dist=False,
  48         shuffle=False)
  49 
  50     # build the model and load checkpoint
  51     model = build_detector(cfg.model, train_cfg=None, test_cfg=cfg.test_cfg)
  52     fp16_cfg = cfg.get('fp16', None)
  53     if fp16_cfg is not None:
  54         wrap_fp16_model(model)
  55     load_checkpoint(model, args.checkpoint, map_location='cpu')
  56     if args.fuse_conv_bn:
  57         model = fuse_module(model)
  58 
  59     model = MMDataParallel(model, device_ids=[0])
  60 
  61     model.eval()
  62 
  63     # the first several iterations may be very slow so skip them
  64     num_warmup = 5
  65     pure_inf_time = 0
  66 
  67     # benchmark with 2000 image and take the average
  68     for i, data in enumerate(data_loader):
  69 
  70         torch.cuda.synchronize()
  71         start_time = time.perf_counter()
  72 
  73         with torch.no_grad():
  74             model(return_loss=False, rescale=True, **data)
  75 
  76         torch.cuda.synchronize()
  77         elapsed = time.perf_counter() - start_time
  78 
  79         if i >= num_warmup:
  80             pure_inf_time += elapsed
  81             if (i + 1) % args.log_interval == 0:
  82                 fps = (i + 1 - num_warmup) / pure_inf_time
  83                 print(f'Done image [{i + 1:<3}/ 2000], fps: {fps:.1f} img / s')
  84 
  85         if (i + 1) == 2000:
  86             pure_inf_time += elapsed
  87             fps = (i + 1 - num_warmup) / pure_inf_time
  88             print(f'Overall fps: {fps:.1f} img / s')
  89             break
  90 
  91 
  92 if __name__ == '__main__':
  93     main()
  94
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/tools/benchmark.py b/tools/benchmark.py
  --- a/tools/benchmark.py
  +++ b/tools/benchmark.py
  @@ -3,9 +3,9 @@
   
   import torch
   from mmcv import Config
  +from mmcv.cnn import fuse_conv_bn
   from mmcv.parallel import MMDataParallel
   from mmcv.runner import load_checkpoint
  -from tools.fuse_conv_bn import fuse_module
   
   from mmdet.core import wrap_fp16_model
   from mmdet.datasets import build_dataloader, build_dataset
  @@ -54,7 +54,7 @@
           wrap_fp16_model(model)
       load_checkpoint(model, args.checkpoint, map_location='cpu')
       if args.fuse_conv_bn:
  -        model = fuse_module(model)
  +        model = fuse_conv_bn(model)
   
       model = MMDataParallel(model, device_ids=[0])
  
verification_info: {"golden_diff": "diff --git a/tools/benchmark.py b/tools/benchmark.py\n--- a/tools/benchmark.py\n+++ b/tools/benchmark.py\n@@ -3,9 +3,9 @@\n \n import torch\n from mmcv import Config\n+from mmcv.cnn import fuse_conv_bn\n from mmcv.parallel import MMDataParallel\n from mmcv.runner import load_checkpoint\n-from tools.fuse_conv_bn import fuse_module\n \n from mmdet.core import wrap_fp16_model\n from mmdet.datasets import build_dataloader, build_dataset\n@@ -54,7 +54,7 @@\n         wrap_fp16_model(model)\n     load_checkpoint(model, args.checkpoint, map_location='cpu')\n     if args.fuse_conv_bn:\n-        model = fuse_module(model)\n+        model = fuse_conv_bn(model)\n \n     model = MMDataParallel(model, device_ids=[0])\n", "issue": "`benchmark.py`.  ModuleNotFoundError: No module named 'tools.fuse_conv_bn'.\nRecently the `tools/fuse_conv_bn.py`  was removed in #3529 . But the `benchmark.py`  is still trying to use the old script. \r\n\r\n[https://github.com/open-mmlab/mmdetection/blob/master/tools/benchmark.py#L8](https://github.com/open-mmlab/mmdetection/blob/master/tools/benchmark.py#L8)\r\n\r\nI think this might be causing the error.\r\n\r\n**Reproduction**\r\n1. What command or script did you run?\r\n```\r\ntools/benchmark.py\r\n```\n", "before_files": [{"content": "import argparse\nimport time\n\nimport torch\nfrom mmcv import Config\nfrom mmcv.parallel import MMDataParallel\nfrom mmcv.runner import load_checkpoint\nfrom tools.fuse_conv_bn import fuse_module\n\nfrom mmdet.core import wrap_fp16_model\nfrom mmdet.datasets import build_dataloader, build_dataset\nfrom mmdet.models import build_detector\n\n\ndef parse_args():\n    parser = argparse.ArgumentParser(description='MMDet benchmark a model')\n    parser.add_argument('config', help='test config file path')\n    parser.add_argument('checkpoint', help='checkpoint file')\n    parser.add_argument(\n        '--log-interval', default=50, help='interval of logging')\n    parser.add_argument(\n        '--fuse-conv-bn',\n        action='store_true',\n        help='Whether to fuse conv and bn, this will slightly increase'\n        'the inference speed')\n    args = parser.parse_args()\n    return args\n\n\ndef main():\n    args = parse_args()\n\n    cfg = Config.fromfile(args.config)\n    # set cudnn_benchmark\n    if cfg.get('cudnn_benchmark', False):\n        torch.backends.cudnn.benchmark = True\n    cfg.model.pretrained = None\n    cfg.data.test.test_mode = True\n\n    # build the dataloader\n    # TODO: support multiple images per gpu (only minor changes are needed)\n    dataset = build_dataset(cfg.data.test)\n    data_loader = build_dataloader(\n        dataset,\n        samples_per_gpu=1,\n        workers_per_gpu=cfg.data.workers_per_gpu,\n        dist=False,\n        shuffle=False)\n\n    # build the model and load checkpoint\n    model = build_detector(cfg.model, train_cfg=None, test_cfg=cfg.test_cfg)\n    fp16_cfg = cfg.get('fp16', None)\n    if fp16_cfg is not None:\n        wrap_fp16_model(model)\n    load_checkpoint(model, args.checkpoint, map_location='cpu')\n    if args.fuse_conv_bn:\n        model = fuse_module(model)\n\n    model = MMDataParallel(model, device_ids=[0])\n\n    model.eval()\n\n    # the first several iterations may be very slow so skip them\n    num_warmup = 5\n    pure_inf_time = 0\n\n    # benchmark with 2000 image and take the average\n    for i, data in enumerate(data_loader):\n\n        torch.cuda.synchronize()\n        start_time = time.perf_counter()\n\n        with torch.no_grad():\n            model(return_loss=False, rescale=True, **data)\n\n        torch.cuda.synchronize()\n        elapsed = time.perf_counter() - start_time\n\n        if i >= num_warmup:\n            pure_inf_time += elapsed\n            if (i + 1) % args.log_interval == 0:\n                fps = (i + 1 - num_warmup) / pure_inf_time\n                print(f'Done image [{i + 1:<3}/ 2000], fps: {fps:.1f} img / s')\n\n        if (i + 1) == 2000:\n            pure_inf_time += elapsed\n            fps = (i + 1 - num_warmup) / pure_inf_time\n            print(f'Overall fps: {fps:.1f} img / s')\n            break\n\n\nif __name__ == '__main__':\n    main()\n", "path": "tools/benchmark.py"}], "after_files": [{"content": "import argparse\nimport time\n\nimport torch\nfrom mmcv import Config\nfrom mmcv.cnn import fuse_conv_bn\nfrom mmcv.parallel import MMDataParallel\nfrom mmcv.runner import load_checkpoint\n\nfrom mmdet.core import wrap_fp16_model\nfrom mmdet.datasets import build_dataloader, build_dataset\nfrom mmdet.models import build_detector\n\n\ndef parse_args():\n    parser = argparse.ArgumentParser(description='MMDet benchmark a model')\n    parser.add_argument('config', help='test config file path')\n    parser.add_argument('checkpoint', help='checkpoint file')\n    parser.add_argument(\n        '--log-interval', default=50, help='interval of logging')\n    parser.add_argument(\n        '--fuse-conv-bn',\n        action='store_true',\n        help='Whether to fuse conv and bn, this will slightly increase'\n        'the inference speed')\n    args = parser.parse_args()\n    return args\n\n\ndef main():\n    args = parse_args()\n\n    cfg = Config.fromfile(args.config)\n    # set cudnn_benchmark\n    if cfg.get('cudnn_benchmark', False):\n        torch.backends.cudnn.benchmark = True\n    cfg.model.pretrained = None\n    cfg.data.test.test_mode = True\n\n    # build the dataloader\n    # TODO: support multiple images per gpu (only minor changes are needed)\n    dataset = build_dataset(cfg.data.test)\n    data_loader = build_dataloader(\n        dataset,\n        samples_per_gpu=1,\n        workers_per_gpu=cfg.data.workers_per_gpu,\n        dist=False,\n        shuffle=False)\n\n    # build the model and load checkpoint\n    model = build_detector(cfg.model, train_cfg=None, test_cfg=cfg.test_cfg)\n    fp16_cfg = cfg.get('fp16', None)\n    if fp16_cfg is not None:\n        wrap_fp16_model(model)\n    load_checkpoint(model, args.checkpoint, map_location='cpu')\n    if args.fuse_conv_bn:\n        model = fuse_conv_bn(model)\n\n    model = MMDataParallel(model, device_ids=[0])\n\n    model.eval()\n\n    # the first several iterations may be very slow so skip them\n    num_warmup = 5\n    pure_inf_time = 0\n\n    # benchmark with 2000 image and take the average\n    for i, data in enumerate(data_loader):\n\n        torch.cuda.synchronize()\n        start_time = time.perf_counter()\n\n        with torch.no_grad():\n            model(return_loss=False, rescale=True, **data)\n\n        torch.cuda.synchronize()\n        elapsed = time.perf_counter() - start_time\n\n        if i >= num_warmup:\n            pure_inf_time += elapsed\n            if (i + 1) % args.log_interval == 0:\n                fps = (i + 1 - num_warmup) / pure_inf_time\n                print(f'Done image [{i + 1:<3}/ 2000], fps: {fps:.1f} img / s')\n\n        if (i + 1) == 2000:\n            pure_inf_time += elapsed\n            fps = (i + 1 - num_warmup) / pure_inf_time\n            print(f'Overall fps: {fps:.1f} img / s')\n            break\n\n\nif __name__ == '__main__':\n    main()\n", "path": "tools/benchmark.py"}]}