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
4c4ba6cb
Unverified
Commit
4c4ba6cb
authored
Mar 24, 2023
by
liuhw
Committed by
GitHub
Mar 24, 2023
Browse files
[Fix] Force bbox_overlaps calculation with FP32 for ascend device (#2697)
* modify bbox_overlaps op adapter * update
parent
5f1d5588
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
11 deletions
+21
-11
mmcv/ops/csrc/pytorch/npu/bbox_overlaps_npu.cpp
mmcv/ops/csrc/pytorch/npu/bbox_overlaps_npu.cpp
+21
-11
No files found.
mmcv/ops/csrc/pytorch/npu/bbox_overlaps_npu.cpp
View file @
4c4ba6cb
...
@@ -12,23 +12,33 @@ void bbox_overlaps_npu(const Tensor bboxes1, const Tensor bboxes2, Tensor ious,
...
@@ -12,23 +12,33 @@ void bbox_overlaps_npu(const Tensor bboxes1, const Tensor bboxes2, Tensor ious,
if
(
mode
==
1
)
{
if
(
mode
==
1
)
{
modeStr
=
"iof"
;
modeStr
=
"iof"
;
}
}
float
offset_
=
1
;
at
::
Tensor
bboxesFP32
=
bboxes2
;
if
(
offset
==
0
)
{
at
::
Tensor
gtboxesFP32
=
bboxes1
;
offset_
=
0.01
;
if
(
bboxes2
.
scalar_type
()
!=
at
::
ScalarType
::
Float
)
{
bboxesFP32
=
NPUNativeFunctions
::
npu_dtype_cast
(
bboxes2
,
at
::
kFloat
);
gtboxesFP32
=
NPUNativeFunctions
::
npu_dtype_cast
(
bboxes1
,
at
::
kFloat
);
}
}
at
::
Tensor
bboxes
=
at
::
ones_like
(
bboxes2
);
c10
::
SmallVector
<
int64_t
,
SIZE
>
iousSize
=
{
gtboxesFP32
.
size
(
0
),
at
::
Tensor
gtboxes
=
at
::
ones_like
(
bboxes1
);
bboxesFP32
.
size
(
0
)};
bboxes
=
aligned
?
bboxes2
.
transpose
(
0
,
1
)
:
bboxes2
;
if
(
aligned
)
{
gtboxes
=
aligned
?
bboxes1
.
transpose
(
0
,
1
)
:
bboxes1
;
iousSize
=
{
gtboxesFP32
.
size
(
0
),
1
};
}
at
::
Tensor
iousFP32
=
OpPreparation
::
ApplyTensor
(
bboxesFP32
,
iousSize
);
bboxesFP32
=
aligned
?
bboxesFP32
.
transpose
(
0
,
1
)
:
bboxesFP32
;
gtboxesFP32
=
aligned
?
gtboxesFP32
.
transpose
(
0
,
1
)
:
gtboxesFP32
;
OpCommand
cmd
;
OpCommand
cmd
;
cmd
.
Name
(
"Iou"
)
cmd
.
Name
(
"Iou"
)
.
Input
(
bboxes
)
.
Input
(
bboxes
FP32
)
.
Input
(
gtboxes
)
.
Input
(
gtboxes
FP32
)
.
Output
(
ious
)
.
Output
(
ious
FP32
)
.
Attr
(
"mode"
,
modeStr
)
.
Attr
(
"mode"
,
modeStr
)
.
Attr
(
"eps"
,
offset
_
)
.
Attr
(
"eps"
,
(
float
)
offset
)
.
Attr
(
"aligned"
,
aligned
)
.
Attr
(
"aligned"
,
aligned
)
.
Run
();
.
Run
();
if
(
bboxes2
.
scalar_type
()
!=
at
::
ScalarType
::
Float
)
{
iousFP32
=
NPUNativeFunctions
::
npu_dtype_cast
(
iousFP32
,
at
::
kHalf
);
}
ious
.
copy_
(
iousFP32
);
}
}
REGISTER_NPU_IMPL
(
bbox_overlaps_impl
,
bbox_overlaps_npu
);
REGISTER_NPU_IMPL
(
bbox_overlaps_impl
,
bbox_overlaps_npu
);
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