Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
MMCV
Commits
5a61e534
Unverified
Commit
5a61e534
authored
Feb 06, 2023
by
liuhw
Committed by
GitHub
Feb 06, 2023
Browse files
[Feature] Add Ascend support for bbox_overlaps (#2580)
* Add support for Ascend devices with bbox_overlaps * ... * ...
parent
615d2817
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
5 deletions
+44
-5
docs/en/understand_mmcv/ops.md
docs/en/understand_mmcv/ops.md
+1
-1
docs/zh_cn/understand_mmcv/ops.md
docs/zh_cn/understand_mmcv/ops.md
+1
-1
mmcv/ops/csrc/pytorch/npu/bbox_overlaps_npu.cpp
mmcv/ops/csrc/pytorch/npu/bbox_overlaps_npu.cpp
+30
-0
tests/test_ops/test_bbox.py
tests/test_ops/test_bbox.py
+12
-3
No files found.
docs/en/understand_mmcv/ops.md
View file @
5a61e534
...
@@ -7,7 +7,7 @@ We implement common ops used in detection, segmentation, etc.
...
@@ -7,7 +7,7 @@ We implement common ops used in detection, segmentation, etc.
| ActiveRotatedFilter | √ | √ | | | |
| ActiveRotatedFilter | √ | √ | | | |
| AssignScoreWithK | | √ | | | |
| AssignScoreWithK | | √ | | | |
| BallQuery | | √ | √ | | |
| BallQuery | | √ | √ | | |
| BBoxOverlaps | | √ | √ | √ |
|
| BBoxOverlaps | | √ | √ | √ |
√
|
| BorderAlign | | √ | | | |
| BorderAlign | | √ | | | |
| BoxIouRotated | √ | √ | | | |
| BoxIouRotated | √ | √ | | | |
| BoxIouQuadri | √ | √ | | | |
| BoxIouQuadri | √ | √ | | | |
...
...
docs/zh_cn/understand_mmcv/ops.md
View file @
5a61e534
...
@@ -7,7 +7,7 @@ MMCV 提供了检测、分割等任务中常用的算子
...
@@ -7,7 +7,7 @@ MMCV 提供了检测、分割等任务中常用的算子
| ActiveRotatedFilter | √ | √ | | | |
| ActiveRotatedFilter | √ | √ | | | |
| AssignScoreWithK | | √ | | | |
| AssignScoreWithK | | √ | | | |
| BallQuery | | √ | √ | | |
| BallQuery | | √ | √ | | |
| BBoxOverlaps | | √ | √ | √ |
|
| BBoxOverlaps | | √ | √ | √ |
√
|
| BorderAlign | | √ | | | |
| BorderAlign | | √ | | | |
| BoxIouRotated | √ | √ | | | |
| BoxIouRotated | √ | √ | | | |
| BoxIouQuadri | √ | √ | | | |
| BoxIouQuadri | √ | √ | | | |
...
...
mmcv/ops/csrc/pytorch/npu/bbox_overlaps_npu.cpp
0 → 100644
View file @
5a61e534
#include "pytorch_npu_helper.hpp"
using
namespace
NPU_NAME_SPACE
;
using
namespace
std
;
void
bbox_overlaps_impl
(
const
Tensor
bboxes1
,
const
Tensor
bboxes2
,
Tensor
ious
,
const
int
mode
,
const
bool
aligned
,
const
int
offset
);
void
bbox_overlaps_npu
(
const
Tensor
bboxes1
,
const
Tensor
bboxes2
,
Tensor
ious
,
const
int
mode
,
const
bool
aligned
,
const
int
offset
)
{
string
modeStr
=
"iou"
;
if
(
mode
==
1
)
{
modeStr
=
"iof"
;
}
at
::
Tensor
bboxes
=
at
::
ones_like
(
bboxes2
);
at
::
Tensor
gtboxes
=
at
::
ones_like
(
bboxes1
);
bboxes
=
aligned
?
bboxes2
.
transpose
(
0
,
1
)
:
bboxes2
;
gtboxes
=
aligned
?
bboxes1
.
transpose
(
0
,
1
)
:
bboxes1
;
OpCommand
cmd
;
cmd
.
Name
(
"Iou"
)
.
Input
(
bboxes
)
.
Input
(
gtboxes
)
.
Output
(
ious
)
.
Attr
(
"mode"
,
modeStr
)
.
Attr
(
"eps"
,
(
float
)
offset
)
.
Attr
(
"aligned"
,
aligned
)
.
Run
();
}
REGISTER_NPU_IMPL
(
bbox_overlaps_impl
,
bbox_overlaps_npu
);
tests/test_ops/test_bbox.py
View file @
5a61e534
...
@@ -3,7 +3,8 @@ import numpy as np
...
@@ -3,7 +3,8 @@ import numpy as np
import
pytest
import
pytest
import
torch
import
torch
from
mmcv.utils
import
IS_CUDA_AVAILABLE
,
IS_MLU_AVAILABLE
,
IS_MPS_AVAILABLE
from
mmcv.utils
import
(
IS_CUDA_AVAILABLE
,
IS_MLU_AVAILABLE
,
IS_MPS_AVAILABLE
,
IS_NPU_AVAILABLE
)
class
TestBBox
:
class
TestBBox
:
...
@@ -55,7 +56,11 @@ class TestBBox:
...
@@ -55,7 +56,11 @@ class TestBBox:
pytest
.
param
(
pytest
.
param
(
'mps'
,
'mps'
,
marks
=
pytest
.
mark
.
skipif
(
marks
=
pytest
.
mark
.
skipif
(
not
IS_MPS_AVAILABLE
,
reason
=
'requires MPS support'
))
not
IS_MPS_AVAILABLE
,
reason
=
'requires MPS support'
)),
pytest
.
param
(
'npu'
,
marks
=
pytest
.
mark
.
skipif
(
not
IS_NPU_AVAILABLE
,
reason
=
'requires NPU support'
))
])
])
def
test_bbox_overlaps_float
(
self
,
device
):
def
test_bbox_overlaps_float
(
self
,
device
):
self
.
_test_bbox_overlaps
(
device
,
dtype
=
torch
.
float
)
self
.
_test_bbox_overlaps
(
device
,
dtype
=
torch
.
float
)
...
@@ -68,7 +73,11 @@ class TestBBox:
...
@@ -68,7 +73,11 @@ class TestBBox:
pytest
.
param
(
pytest
.
param
(
'mlu'
,
'mlu'
,
marks
=
pytest
.
mark
.
skipif
(
marks
=
pytest
.
mark
.
skipif
(
not
IS_MLU_AVAILABLE
,
reason
=
'requires MLU support'
))
not
IS_MLU_AVAILABLE
,
reason
=
'requires MLU support'
)),
pytest
.
param
(
'npu'
,
marks
=
pytest
.
mark
.
skipif
(
not
IS_NPU_AVAILABLE
,
reason
=
'requires NPU support'
))
])
])
def
test_bbox_overlaps_half
(
self
,
device
):
def
test_bbox_overlaps_half
(
self
,
device
):
self
.
_test_bbox_overlaps
(
device
,
dtype
=
torch
.
half
)
self
.
_test_bbox_overlaps
(
device
,
dtype
=
torch
.
half
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment