Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
6bb8206d
P
Paddle
项目概览
机器未来
/
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看板
未验证
提交
6bb8206d
编写于
4月 09, 2020
作者:
W
wangguanzhong
提交者:
GitHub
4月 09, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enhance the error message of box_clip, test=develop (#23638)
上级
8987946f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
31 addition
and
12 deletion
+31
-12
paddle/fluid/operators/detection/box_clip_op.cc
paddle/fluid/operators/detection/box_clip_op.cc
+23
-9
paddle/fluid/operators/detection/box_clip_op.cu
paddle/fluid/operators/detection/box_clip_op.cu
+0
-2
paddle/fluid/operators/detection/box_clip_op.h
paddle/fluid/operators/detection/box_clip_op.h
+3
-1
python/paddle/fluid/layers/detection.py
python/paddle/fluid/layers/detection.py
+5
-0
未找到文件。
paddle/fluid/operators/detection/box_clip_op.cc
浏览文件 @
6bb8206d
...
...
@@ -21,22 +21,36 @@ class BoxClipOp : public framework::OperatorWithKernel {
protected:
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"Input"
),
"Input(Input) of BoxClipOp should not be null."
);
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"ImInfo"
),
"Input(ImInfo) of BoxClipOp should not be null."
);
PADDLE_ENFORCE_EQ
(
ctx
->
HasInput
(
"Input"
),
true
,
platform
::
errors
::
NotFound
(
"Input(Input) of BoxClipOp "
"is not found."
));
PADDLE_ENFORCE_EQ
(
ctx
->
HasInput
(
"ImInfo"
),
true
,
platform
::
errors
::
NotFound
(
"Input(ImInfo) of BoxClipOp "
"is not found."
));
auto
input_box_dims
=
ctx
->
GetInputDim
(
"Input"
);
auto
im_info_dims
=
ctx
->
GetInputDim
(
"ImInfo"
);
if
(
ctx
->
IsRuntime
())
{
auto
input_box_size
=
input_box_dims
.
size
();
PADDLE_ENFORCE_EQ
(
input_box_dims
[
input_box_size
-
1
],
4
,
"The last dimension of Input must be 4"
);
PADDLE_ENFORCE_EQ
(
input_box_dims
[
input_box_size
-
1
],
4
,
platform
::
errors
::
InvalidArgument
(
"The last dimension "
"of Input must be 4. But received last dimension = %d"
,
input_box_dims
[
input_box_size
-
1
]));
PADDLE_ENFORCE_EQ
(
im_info_dims
.
size
(),
2
,
"The rank of Input(Input) in BoxClipOp must be 2"
);
PADDLE_ENFORCE_EQ
(
im_info_dims
[
1
],
3
,
"The last dimension of ImInfo must be 3"
);
platform
::
errors
::
InvalidArgument
(
"The rank of "
"Input(Input) in BoxClipOp must be 2. But received "
"rank = %d"
,
im_info_dims
.
size
()));
PADDLE_ENFORCE_EQ
(
im_info_dims
[
1
],
3
,
platform
::
errors
::
InvalidArgument
(
"The last dimension "
"of ImInfo must be 3. But received last dimension = %d"
,
im_info_dims
[
1
]));
}
ctx
->
ShareDim
(
"Input"
,
/*->*/
"Output"
);
ctx
->
ShareLoD
(
"Input"
,
/*->*/
"Output"
);
...
...
paddle/fluid/operators/detection/box_clip_op.cu
浏览文件 @
6bb8206d
...
...
@@ -46,8 +46,6 @@ template <typename DeviceContext, typename T>
class
GPUBoxClipKernel
:
public
framework
::
OpKernel
<
T
>
{
public:
void
Compute
(
const
framework
::
ExecutionContext
&
context
)
const
override
{
PADDLE_ENFORCE
(
platform
::
is_gpu_place
(
context
.
GetPlace
()),
"This kernel only runs on GPU device."
);
auto
*
input
=
context
.
Input
<
LoDTensor
>
(
"Input"
);
auto
*
im_info
=
context
.
Input
<
Tensor
>
(
"ImInfo"
);
auto
*
output
=
context
.
Output
<
LoDTensor
>
(
"Output"
);
...
...
paddle/fluid/operators/detection/box_clip_op.h
浏览文件 @
6bb8206d
...
...
@@ -33,7 +33,9 @@ class BoxClipKernel : public framework::OpKernel<T> {
output_box
->
mutable_data
<
T
>
(
context
.
GetPlace
());
if
(
input_box
->
lod
().
size
())
{
PADDLE_ENFORCE_EQ
(
input_box
->
lod
().
size
(),
1UL
,
"Only support 1 level of LoD."
);
platform
::
errors
::
InvalidArgument
(
"Input(Input) of "
"BoxClip only supports 1 level of LoD."
));
}
auto
box_lod
=
input_box
->
lod
().
back
();
int64_t
n
=
static_cast
<
int64_t
>
(
box_lod
.
size
()
-
1
);
...
...
python/paddle/fluid/layers/detection.py
浏览文件 @
6bb8206d
...
...
@@ -30,6 +30,7 @@ import math
import
six
import
numpy
from
functools
import
reduce
from
..data_feeder
import
convert_dtype
,
check_variable_and_dtype
,
check_type
,
check_dtype
__all__
=
[
'prior_box'
,
...
...
@@ -2866,6 +2867,10 @@ def box_clip(input, im_info, name=None):
input=boxes, im_info=im_info)
"""
check_variable_and_dtype
(
input
,
'input'
,
[
'float32'
,
'float64'
],
'box_clip'
)
check_variable_and_dtype
(
im_info
,
'im_info'
,
[
'float32'
,
'float64'
],
'box_clip'
)
helper
=
LayerHelper
(
"box_clip"
,
**
locals
())
output
=
helper
.
create_variable_for_type_inference
(
dtype
=
input
.
dtype
)
inputs
=
{
"Input"
:
input
,
"ImInfo"
:
im_info
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录