Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
4f43d51f
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
4f43d51f
编写于
10月 20, 2020
作者:
D
Double_V
提交者:
GitHub
10月 20, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add rois_num params for roi_align_xpu op, test=kunlun (#28094)
上级
c4e18dc0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
58 addition
and
8 deletion
+58
-8
paddle/fluid/operators/roi_align_op_xpu.cc
paddle/fluid/operators/roi_align_op_xpu.cc
+34
-8
python/paddle/fluid/tests/unittests/xpu/test_roi_align_op_xpu.py
...paddle/fluid/tests/unittests/xpu/test_roi_align_op_xpu.py
+24
-0
未找到文件。
paddle/fluid/operators/roi_align_op_xpu.cc
浏览文件 @
4f43d51f
...
...
@@ -39,14 +39,40 @@ class XPUROIAlignOpKernel : public framework::OpKernel<T> {
int
width
=
in_dims
[
3
];
int
rois_num
=
rois
->
dims
()[
0
];
const
T
*
input_data
=
in
->
data
<
T
>
();
auto
rois_lod
=
rois
->
lod
().
back
();
int
rois_batch_size
=
rois_lod
.
size
()
-
1
;
PADDLE_ENFORCE_EQ
(
rois_batch_size
,
batch_size
,
platform
::
errors
::
InvalidArgument
(
"The rois_batch_size and imgs batch_size of roi_align_xpu OP must "
"be the same. But received rois_batch_size %d , batch_size %d"
,
rois_batch_size
,
batch_size
));
framework
::
Tensor
_roi_batch_list
;
_roi_batch_list
.
Resize
({
rois_num
});
int
*
rois_lod
=
_roi_batch_list
.
mutable_data
<
int
>
(
ctx
.
GetPlace
());
int
rois_batch_size
=
1
;
if
(
ctx
.
HasInput
(
"RoisNum"
))
{
auto
*
rois_num_t
=
ctx
.
Input
<
framework
::
Tensor
>
(
"RoisNum"
);
rois_batch_size
=
rois_num_t
->
numel
();
PADDLE_ENFORCE_EQ
(
rois_batch_size
,
batch_size
,
platform
::
errors
::
InvalidArgument
(
"The batch size of rois and the batch size of images "
" must be the same. But received the batch size of rois is %d, "
"and the batch size of images is %d"
,
rois_batch_size
,
batch_size
));
auto
*
rois_num_data
=
rois_num_t
->
data
<
int
>
();
rois_lod
[
0
]
=
0
;
for
(
int
n
=
0
;
n
<
rois_batch_size
;
++
n
)
{
rois_lod
[
n
+
1
]
=
rois_lod
[
n
]
+
rois_num_data
[
n
];
}
}
else
{
auto
_rois_lod
=
rois
->
lod
().
back
();
rois_batch_size
=
_rois_lod
.
size
()
-
1
;
for
(
int
n
=
0
;
n
<
_rois_lod
.
size
();
++
n
)
{
rois_lod
[
n
]
=
_rois_lod
[
n
];
}
PADDLE_ENFORCE_EQ
(
rois_batch_size
,
batch_size
,
platform
::
errors
::
InvalidArgument
(
"The rois_batch_size and imgs batch_size of roi_align_xpu OP "
"must "
"be the same. But received rois_batch_size %d , batch_size %d"
,
rois_batch_size
,
batch_size
));
}
int
rois_num_with_lod
=
rois_lod
[
rois_batch_size
];
PADDLE_ENFORCE_EQ
(
rois_num
,
rois_num_with_lod
,
...
...
python/paddle/fluid/tests/unittests/xpu/test_roi_align_op_xpu.py
浏览文件 @
4f43d51f
...
...
@@ -179,5 +179,29 @@ class TestROIAlignOp(OpTest):
self
.
check_output_with_place
(
place
)
class
TestROIAlignInLodOp
(
TestROIAlignOp
):
def
set_data
(
self
):
self
.
init_test_case
()
self
.
make_rois
()
self
.
calc_roi_align
()
seq_len
=
self
.
rois_lod
[
0
]
self
.
inputs
=
{
'X'
:
self
.
x
,
'ROIs'
:
(
self
.
rois
[:,
1
:
5
],
self
.
rois_lod
),
'RoisNum'
:
np
.
asarray
(
seq_len
).
astype
(
'int32'
)
}
self
.
attrs
=
{
'spatial_scale'
:
self
.
spatial_scale
,
'pooled_height'
:
self
.
pooled_height
,
'pooled_width'
:
self
.
pooled_width
,
'sampling_ratio'
:
self
.
sampling_ratio
}
self
.
outputs
=
{
'Out'
:
self
.
out_data
}
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录