Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Support engine with NPU backend. #2262

Merged
merged 23 commits into from
Sep 30, 2022
Merged

[Feature] Support engine with NPU backend. #2262

merged 23 commits into from
Sep 30, 2022

Conversation

wangjiangben-hw
Copy link
Collaborator

Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily get feedback. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.

Motivation

Added ascending device support in mmcv.

Modification

  • The main modification points are as follows:
    1. In mmcv/device/, We've added our NPU devices. Since the NPU does not support the DataParallel mode, DP and DDP have been customized, the Scatter related methods have been rewritten, and the use case of MLU has been referenced, thanks.
    2. In mmcv/runner/dist_utils.py, We have added NPU-related distributed initialization methods.
    3. In mmcv/runner/hooks/optimizer.py, We've added the amp method on npu.
    4. In mmcv/utils/, We've added NPU devices.

BC-breaking (Optional)

None

Use cases (Optional)

  • test case
    • tests/test_device/test_device_utils.py
    • tests/test_device/test_functions.py
    • tests/test_device/test_npu/test_npu_parallel.py

Checklist

Before PR:

  • I have read and followed the workflow indicated in the CONTRIBUTING.md to create this PR.
  • Pre-commit or linting tools indicated in CONTRIBUTING.md are used to fix the potential lint issues.
  • Bug fixes are covered by unit tests, the case that causes the bug should be added in the unit tests.
  • New functionalities are covered by complete unit tests. If not, please add more unit test to ensure the correctness.
  • The documentation has been modified accordingly, including docstring or example tutorials.

After PR:

  • If the modification has potential influence on downstream or other related projects, this PR should be tested with some of those projects, like MMDet or MMCls.
  • CLA has been signed and all committers have signed the CLA in this PR.

wangjiangben-hw and others added 2 commits September 14, 2022 12:02
[Feature] Support engine with NPU backend.
@CLAassistant
Copy link

CLAassistant commented Sep 15, 2022

CLA assistant check
All committers have signed the CLA.

setup.py Outdated Show resolved Hide resolved
* fix autocast bugs on npu
* using scatter_kwargs in mmcv.device.scatter_gather
mmcv/ops/focal_loss.py Outdated Show resolved Hide resolved
@@ -280,7 +280,7 @@ def get_extensions():
if is_rocm_pytorch or torch.cuda.is_available() or os.getenv(
'FORCE_CUDA', '0') == '1':
if is_rocm_pytorch:
define_macros += [('HIP_DIFF', None)]
define_macros += [('MMCV_WITH_HIP', None)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we remove HIP_DIFF?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@grimoire
Copy link
Member

Please update tests/test_ops/test_focal_loss.py.

* add npu test case
@wangjiangben-hw
Copy link
Collaborator Author

Please update tests/test_ops/test_focal_loss.py.

done..

mmcv/ops/focal_loss.py Outdated Show resolved Hide resolved
Copy link
Member

@grimoire grimoire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Co-authored-by: Zaida Zhou <58739961+zhouzaida@users.noreply.github.com>
@zhouzaida zhouzaida merged commit a5db5f6 into master Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NPU Ascend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants