Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
a05d25cf
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a05d25cf
编写于
1月 23, 2018
作者:
W
wanghaox
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update code and doc, change input x to LoDTensor
上级
d4587959
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
38 addition
and
12 deletion
+38
-12
paddle/operators/iou_similarity_op.cc
paddle/operators/iou_similarity_op.cc
+21
-9
paddle/operators/iou_similarity_op.cu
paddle/operators/iou_similarity_op.cu
+0
-1
paddle/operators/iou_similarity_op.h
paddle/operators/iou_similarity_op.h
+4
-2
python/paddle/v2/fluid/tests/test_iou_similarity_op.py
python/paddle/v2/fluid/tests/test_iou_similarity_op.py
+13
-0
未找到文件。
paddle/operators/iou_similarity_op.cc
浏览文件 @
a05d25cf
...
...
@@ -44,11 +44,14 @@ class IOUSimilarityOpMaker : public framework::OpProtoAndCheckerMaker {
IOUSimilarityOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"(Tensor, default Tensor<float>) "
"Box list X holds N boxes, each box is "
"represented as [xmin, ymin, xmax, ymax], the shape of X is [N, "
"4]. [xmin, ymin] is the lower left coordinate of the box, and "
"[xmax, ymax] is the right upper coordinate of the box."
);
"(LoDTensor, default LoDTensor<float>) "
"Box list X is a 2-D LoDTensor with shape [N, 4] holds N boxes, "
"each box is represented as [xmin, ymin, xmax, ymax], "
"the shape of X is [N, 4]. [xmin, ymin] is the lower left "
"coordinate of the box, and [xmax, ymax] is the right upper "
"coordinate of the box.This tensor can contain LoD information "
"to represent a batch of inputs. One instance of this batch can "
"contain different numbers of entities."
);
AddInput
(
"Y"
,
"(Tensor, default Tensor<float>) "
"Box list Y holds M boxes, each box is "
...
...
@@ -56,14 +59,23 @@ class IOUSimilarityOpMaker : public framework::OpProtoAndCheckerMaker {
"4]. [xmin, ymin] is the lower left coordinate of the box, and "
"[xmax, ymax] is the right upper coordinate of the box."
);
AddOutput
(
"Out"
,
"(Tensor) The output of
iou_similarity op, a tensor with shape [N, M] "
AddOutput
(
"Out"
,
"(LoDTensor or Tensor, the lod is same as input X) The output of "
"
iou_similarity op, a tensor with shape [N, M] "
"representing pairwise iou scores."
);
AddComment
(
R"DOC(
IOU Similarity Operator.
Computes intersection-over-union (IOU) between two box lists.
Box list 'X' should be a LoDTensor and 'Y' is a common Tensor,
boxes in 'Y' are shared by all input images.
Given two box A and B, the calculation of IOU is as follows:
$$
IOU(A, B) =
\frac{area(A\cap B)}{area(A)+area(B)-area(A\cap B)}
$$
)DOC"
);
}
};
...
...
paddle/operators/iou_similarity_op.cu
浏览文件 @
a05d25cf
...
...
@@ -12,7 +12,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#define EIGEN_USE_GPU
#include "paddle/operators/iou_similarity_op.h"
namespace
ops
=
paddle
::
operators
;
...
...
paddle/operators/iou_similarity_op.h
浏览文件 @
a05d25cf
...
...
@@ -71,9 +71,9 @@ template <typename DeviceContext, typename T>
class
IOUSimilarityKernel
:
public
framework
::
OpKernel
<
T
>
{
public:
void
Compute
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
const
framework
::
Tensor
*
in_x
=
ctx
.
Input
<
framework
::
Tensor
>
(
"X"
);
const
framework
::
LoDTensor
*
in_x
=
ctx
.
Input
<
framework
::
LoD
Tensor
>
(
"X"
);
const
framework
::
Tensor
*
in_y
=
ctx
.
Input
<
framework
::
Tensor
>
(
"Y"
);
framework
::
Tensor
*
out
=
ctx
.
Output
<
framework
::
Tensor
>
(
"Out"
);
framework
::
LoDTensor
*
out
=
ctx
.
Output
<
framework
::
LoD
Tensor
>
(
"Out"
);
int
x_n
=
in_x
->
dims
()[
0
];
int
y_n
=
in_y
->
dims
()[
0
];
...
...
@@ -83,6 +83,8 @@ class IOUSimilarityKernel : public framework::OpKernel<T> {
platform
::
ForRange
<
DeviceContext
>
for_range
(
static_cast
<
const
DeviceContext
&>
(
ctx
.
device_context
()),
x_n
);
for_range
(
functor
);
out
->
set_lod
(
in_x
->
lod
());
}
};
// namespace operators
...
...
python/paddle/v2/fluid/tests/test_iou_similarity_op.py
浏览文件 @
a05d25cf
...
...
@@ -38,5 +38,18 @@ class TestIOUSimilarityOp(OpTest):
self
.
outputs
=
{
'Out'
:
self
.
output
}
class
TestIOUSimilarityOpWithLoD
(
TestIOUSimilarityOp
):
def
test_check_output
(
self
):
self
.
check_output
()
def
setUp
(
self
):
super
(
TestIOUSimilarityOpWithLoD
,
self
).
setUp
()
self
.
boxes1_lod
=
[[
0
,
1
,
2
]]
self
.
output_lod
=
[[
0
,
1
,
2
]]
self
.
inputs
=
{
'X'
:
(
self
.
boxes1
,
self
.
boxes1_lod
),
'Y'
:
self
.
boxes2
}
self
.
outputs
=
{
'Out'
:
(
self
.
output
,
self
.
output_lod
)}
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录