未验证 提交 7042d597 编写于 作者: Q Qi Li 提交者: GitHub

[NPU] fix yolov3 error on NPU(#5581) (#5592)

* [NPU] fix yolov3 error on NPU, test=develop

* fix xpu, test=develop
上级 3e5135a5
......@@ -58,6 +58,7 @@ def main():
"""
Main evaluate function
"""
env = os.environ
cfg = load_config(FLAGS.config)
merge_config(FLAGS.opt)
check_config(cfg)
......@@ -84,13 +85,22 @@ def main():
multi_scale_test = getattr(cfg, 'MultiScaleTEST', None)
if cfg.use_gpu and 'FLAGS_selected_gpus' in env:
device_id = int(env['FLAGS_selected_gpus'])
elif cfg.use_npu and 'FLAGS_selected_npus' in env:
device_id = int(env['FLAGS_selected_npus'])
elif use_xpu and 'FLAGS_selected_xpus' in env:
device_id = int(env['FLAGS_selected_xpus'])
else:
device_id = 0
# define executor
if cfg.use_gpu:
place = fluid.CUDAPlace(0)
place = fluid.CUDAPlace(device_id)
elif cfg.use_npu:
place = fluid.NPUPlace(0)
place = fluid.NPUPlace(device_id)
elif use_xpu:
place = fluid.XPUPlace(0)
place = fluid.XPUPlace(device_id)
else:
place = fluid.CPUPlace()
exe = fluid.Executor(place)
......
......@@ -103,6 +103,7 @@ def get_test_images(infer_dir, infer_img):
def main():
env = os.environ
cfg = load_config(FLAGS.config)
merge_config(FLAGS.opt)
......@@ -127,12 +128,22 @@ def main():
test_images = get_test_images(FLAGS.infer_dir, FLAGS.infer_img)
dataset.set_images(test_images)
if cfg.use_gpu and 'FLAGS_selected_gpus' in env:
device_id = int(env['FLAGS_selected_gpus'])
elif cfg.use_npu and 'FLAGS_selected_npus' in env:
device_id = int(env['FLAGS_selected_npus'])
elif cfg.use_xpu and 'FLAGS_selected_xpus' in env:
device_id = int(env['FLAGS_selected_xpus'])
else:
device_id = 0
# define executor
if cfg.use_gpu:
place = fluid.CUDAPlace(0)
place = fluid.CUDAPlace(device_id)
elif cfg.use_npu:
place = fluid.NPUPlace(0)
place = fluid.NPUPlace(device_id)
elif cfg.use_xpu:
place = fluid.XPUPlace(0)
place = fluid.XPUPlace(device_id)
else:
place = fluid.CPUPlace()
exe = fluid.Executor(place)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册