Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
2d1a6f8d
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
2d1a6f8d
编写于
4月 17, 2018
作者:
A
Abhinav Arora
提交者:
GitHub
4月 17, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix cpplint issues in Detection_map_op (#9969)
* Fix conv_op.h * Fix conv_mkldnn_op * Fix cpplint issues in detection_map_op
上级
d08791d1
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
67 addition
and
55 deletion
+67
-55
paddle/fluid/operators/conv_mkldnn_op.cc
paddle/fluid/operators/conv_mkldnn_op.cc
+16
-13
paddle/fluid/operators/conv_op.h
paddle/fluid/operators/conv_op.h
+5
-3
paddle/fluid/operators/detection_map_op.cc
paddle/fluid/operators/detection_map_op.cc
+1
-0
paddle/fluid/operators/detection_map_op.h
paddle/fluid/operators/detection_map_op.h
+44
-39
paddle/fluid/operators/edit_distance_op.cu
paddle/fluid/operators/edit_distance_op.cu
+1
-0
未找到文件。
paddle/fluid/operators/conv_mkldnn_op.cc
浏览文件 @
2d1a6f8d
...
...
@@ -72,10 +72,10 @@ class ConvMKLDNNOpKernel : public paddle::framework::OpKernel<T> {
auto
dst_md
=
platform
::
MKLDNNMemDesc
(
dst_tz
,
mkldnn
::
memory
::
data_type
::
f32
,
mkldnn
::
memory
::
format
::
nchw
);
auto
src_memory
=
mkldnn
::
memory
({
src_md
,
mkldnn_engine
},
(
void
*
)
input_data
);
auto
weights_memory
=
mkldnn
::
memory
({
weights_md
,
mkldnn_engine
},
(
void
*
)
filter_data
);
auto
src_memory
=
mkldnn
::
memory
({
src_md
,
mkldnn_engine
},
reinterpret_cast
<
void
*>
(
input_data
)
);
auto
weights_memory
=
mkldnn
::
memory
({
weights_md
,
mkldnn_engine
},
reinterpret_cast
<
void
*>
(
filter_data
)
);
auto
dst_memory
=
mkldnn
::
memory
({
dst_md
,
mkldnn_engine
},
output_data
);
std
::
shared_ptr
<
mkldnn
::
convolution_forward
::
primitive_desc
>
conv_pd
=
...
...
@@ -180,8 +180,9 @@ class ConvMKLDNNGradOpKernel : public paddle::framework::OpKernel<T> {
dst_tz
,
mkldnn
::
memory
::
data_type
::
f32
,
mkldnn
::
memory
::
format
::
nchw
);
// create memory
auto
diff_dst_memory
=
mkldnn
::
memory
({
diff_weights_md
,
mkldnn_engine
},
(
void
*
)
output_grad_data
);
auto
diff_dst_memory
=
mkldnn
::
memory
({
diff_weights_md
,
mkldnn_engine
},
reinterpret_cast
<
void
*>
(
output_grad_data
));
// Retrieve conv_pd from device context
auto
conv_pd
=
std
::
static_pointer_cast
<
mkldnn
::
convolution_forward
::
primitive_desc
>
(
...
...
@@ -198,10 +199,11 @@ class ConvMKLDNNGradOpKernel : public paddle::framework::OpKernel<T> {
mkldnn_engine
);
// create memory
auto
diff_weights_memory
=
mkldnn
::
memory
(
{
diff_weights_md
,
mkldnn_engine
},
(
void
*
)
filter_grad_data
);
auto
src_memory
=
mkldnn
::
memory
({
src_md
,
mkldnn_engine
},
(
void
*
)
input_data
);
auto
diff_weights_memory
=
mkldnn
::
memory
({
diff_weights_md
,
mkldnn_engine
},
reinterpret_cast
<
void
*>
(
filter_grad_data
));
auto
src_memory
=
mkldnn
::
memory
({
src_md
,
mkldnn_engine
},
reinterpret_cast
<
void
*>
(
input_data
));
// create backward conv primitive for weights
auto
conv_bwd_weights_prim
=
mkldnn
::
convolution_backward_weights
(
...
...
@@ -221,9 +223,10 @@ class ConvMKLDNNGradOpKernel : public paddle::framework::OpKernel<T> {
// create memory
auto
diff_src_memory
=
mkldnn
::
memory
({
diff_src_md
,
mkldnn_engine
},
(
void
*
)
input_grad_data
);
auto
weights_memory
=
mkldnn
::
memory
({
weights_md
,
mkldnn_engine
},
(
void
*
)
filter_data
);
mkldnn
::
memory
({
diff_src_md
,
mkldnn_engine
},
reinterpret_cast
<
void
*>
(
input_grad_data
));
auto
weights_memory
=
mkldnn
::
memory
(
{
weights_md
,
mkldnn_engine
},
reinterpret_cast
<
void
*>
(
filter_data
));
// create backward conv primitive for data
auto
conv_bwd_data_prim
=
mkldnn
::
convolution_backward_data
(
...
...
paddle/fluid/operators/conv_op.h
浏览文件 @
2d1a6f8d
...
...
@@ -14,6 +14,7 @@ limitations under the License. */
#pragma once
#include <vector>
#include "paddle/fluid/framework/eigen.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/math/depthwise_conv.h"
...
...
@@ -41,9 +42,10 @@ inline int ConvOutputSize(int input_size, int filter_size, int dilation,
return
output_size
;
}
inline
bool
IsExpand
(
std
::
vector
<
int64_t
>&
filter_dim
,
std
::
vector
<
int
>&
strides
,
std
::
vector
<
int
>&
paddings
,
std
::
vector
<
int
>&
dilations
)
{
inline
bool
IsExpand
(
const
std
::
vector
<
int64_t
>&
filter_dim
,
const
std
::
vector
<
int
>&
strides
,
const
std
::
vector
<
int
>&
paddings
,
const
std
::
vector
<
int
>&
dilations
)
{
bool
filter_1
=
true
,
strides_1
=
true
,
padding_0
=
true
,
dilation_1
=
true
;
for
(
size_t
j
=
0
;
j
<
strides
.
size
();
++
j
)
{
filter_1
=
filter_1
&&
(
static_cast
<
int
>
(
filter_dim
[
j
+
2
])
==
1
);
...
...
paddle/fluid/operators/detection_map_op.cc
浏览文件 @
2d1a6f8d
...
...
@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License. */
#include "paddle/fluid/operators/detection_map_op.h"
#include <string>
namespace
paddle
{
namespace
operators
{
...
...
paddle/fluid/operators/detection_map_op.h
浏览文件 @
2d1a6f8d
...
...
@@ -13,6 +13,11 @@ See the License for the specific language governing permissions and
limitations under the License. */
#pragma once
#include <algorithm>
#include <map>
#include <string>
#include <utility>
#include <vector>
#include "paddle/fluid/framework/eigen.h"
#include "paddle/fluid/framework/op_registry.h"
...
...
@@ -82,7 +87,7 @@ class DetectionMAPOpKernel : public framework::OpKernel<T> {
std
::
vector
<
std
::
map
<
int
,
std
::
vector
<
Box
>>>
gt_boxes
;
std
::
vector
<
std
::
map
<
int
,
std
::
vector
<
std
::
pair
<
T
,
Box
>>>>
detect_boxes
;
GetBoxes
(
*
in_label
,
*
in_detect
,
gt_boxes
,
detect_boxes
);
GetBoxes
(
*
in_label
,
*
in_detect
,
&
gt_boxes
,
detect_boxes
);
std
::
map
<
int
,
int
>
label_pos_count
;
std
::
map
<
int
,
std
::
vector
<
std
::
pair
<
T
,
int
>>>
true_pos
;
...
...
@@ -95,20 +100,20 @@ class DetectionMAPOpKernel : public framework::OpKernel<T> {
}
if
(
in_pos_count
!=
nullptr
&&
state
)
{
GetInputPos
(
*
in_pos_count
,
*
in_true_pos
,
*
in_false_pos
,
label_pos_count
,
true_pos
,
false_pos
,
class_num
);
GetInputPos
(
*
in_pos_count
,
*
in_true_pos
,
*
in_false_pos
,
&
label_pos_count
,
&
true_pos
,
&
false_pos
,
class_num
);
}
CalcTrueAndFalsePositive
(
gt_boxes
,
detect_boxes
,
evaluate_difficult
,
overlap_threshold
,
label_pos_count
,
true_pos
,
false_pos
);
overlap_threshold
,
&
label_pos_count
,
&
true_pos
,
&
false_pos
);
int
background_label
=
ctx
.
Attr
<
int
>
(
"background_label"
);
T
map
=
CalcMAP
(
ap_type
,
label_pos_count
,
true_pos
,
false_pos
,
background_label
);
GetOutputPos
(
ctx
,
label_pos_count
,
true_pos
,
false_pos
,
*
out_pos_count
,
*
out_true_pos
,
*
out_false_pos
,
class_num
);
GetOutputPos
(
ctx
,
label_pos_count
,
true_pos
,
false_pos
,
out_pos_count
,
out_true_pos
,
out_false_pos
,
class_num
);
T
*
map_data
=
out_map
->
mutable_data
<
T
>
(
ctx
.
GetPlace
());
map_data
[
0
]
=
map
;
...
...
@@ -155,7 +160,7 @@ class DetectionMAPOpKernel : public framework::OpKernel<T> {
void
GetBoxes
(
const
framework
::
LoDTensor
&
input_label
,
const
framework
::
LoDTensor
&
input_detect
,
std
::
vector
<
std
::
map
<
int
,
std
::
vector
<
Box
>>>
&
gt_boxes
,
std
::
vector
<
std
::
map
<
int
,
std
::
vector
<
Box
>>>
*
gt_boxes
,
std
::
vector
<
std
::
map
<
int
,
std
::
vector
<
std
::
pair
<
T
,
Box
>>>>&
detect_boxes
)
const
{
auto
labels
=
framework
::
EigenTensor
<
T
,
2
>::
From
(
input_label
);
...
...
@@ -179,7 +184,7 @@ class DetectionMAPOpKernel : public framework::OpKernel<T> {
box
.
is_difficult
=
true
;
boxes
[
label
].
push_back
(
box
);
}
gt_boxes
.
push_back
(
boxes
);
gt_boxes
->
push_back
(
boxes
);
}
auto
detect_index
=
detect_lod
[
0
];
...
...
@@ -200,9 +205,9 @@ class DetectionMAPOpKernel : public framework::OpKernel<T> {
const
std
::
map
<
int
,
int
>&
label_pos_count
,
const
std
::
map
<
int
,
std
::
vector
<
std
::
pair
<
T
,
int
>>>&
true_pos
,
const
std
::
map
<
int
,
std
::
vector
<
std
::
pair
<
T
,
int
>>>&
false_pos
,
framework
::
Tensor
&
output_pos_count
,
framework
::
LoDTensor
&
output_true_pos
,
framework
::
LoDTensor
&
output_false_pos
,
const
int
class_num
)
const
{
framework
::
Tensor
*
output_pos_count
,
framework
::
LoDTensor
*
output_true_pos
,
framework
::
LoDTensor
*
output_false_pos
,
const
int
class_num
)
const
{
int
true_pos_count
=
0
;
int
false_pos_count
=
0
;
for
(
auto
it
=
true_pos
.
begin
();
it
!=
true_pos
.
end
();
++
it
)
{
...
...
@@ -214,12 +219,12 @@ class DetectionMAPOpKernel : public framework::OpKernel<T> {
false_pos_count
+=
fp
.
size
();
}
int
*
pos_count_data
=
output_pos_count
.
mutable_data
<
int
>
(
int
*
pos_count_data
=
output_pos_count
->
mutable_data
<
int
>
(
framework
::
make_ddim
({
class_num
,
1
}),
ctx
.
GetPlace
());
T
*
true_pos_data
=
output_true_pos
.
mutable_data
<
T
>
(
T
*
true_pos_data
=
output_true_pos
->
mutable_data
<
T
>
(
framework
::
make_ddim
({
true_pos_count
,
2
}),
ctx
.
GetPlace
());
T
*
false_pos_data
=
output_false_pos
.
mutable_data
<
T
>
(
T
*
false_pos_data
=
output_false_pos
->
mutable_data
<
T
>
(
framework
::
make_ddim
({
false_pos_count
,
2
}),
ctx
.
GetPlace
());
true_pos_count
=
0
;
false_pos_count
=
0
;
...
...
@@ -261,21 +266,21 @@ class DetectionMAPOpKernel : public framework::OpKernel<T> {
framework
::
LoD
false_pos_lod
;
false_pos_lod
.
emplace_back
(
false_pos_starts
);
output_true_pos
.
set_lod
(
true_pos_lod
);
output_false_pos
.
set_lod
(
false_pos_lod
);
output_true_pos
->
set_lod
(
true_pos_lod
);
output_false_pos
->
set_lod
(
false_pos_lod
);
return
;
}
void
GetInputPos
(
const
framework
::
Tensor
&
input_pos_count
,
const
framework
::
LoDTensor
&
input_true_pos
,
const
framework
::
LoDTensor
&
input_false_pos
,
std
::
map
<
int
,
int
>
&
label_pos_count
,
std
::
map
<
int
,
std
::
vector
<
std
::
pair
<
T
,
int
>>>
&
true_pos
,
std
::
map
<
int
,
std
::
vector
<
std
::
pair
<
T
,
int
>>>
&
false_pos
,
std
::
map
<
int
,
int
>
*
label_pos_count
,
std
::
map
<
int
,
std
::
vector
<
std
::
pair
<
T
,
int
>>>
*
true_pos
,
std
::
map
<
int
,
std
::
vector
<
std
::
pair
<
T
,
int
>>>
*
false_pos
,
const
int
class_num
)
const
{
const
int
*
pos_count_data
=
input_pos_count
.
data
<
int
>
();
for
(
int
i
=
0
;
i
<
class_num
;
++
i
)
{
label_pos_count
[
i
]
=
pos_count_data
[
i
];
(
*
label_pos_count
)
[
i
]
=
pos_count_data
[
i
];
}
auto
SetData
=
[](
const
framework
::
LoDTensor
&
pos_tensor
,
...
...
@@ -291,8 +296,8 @@ class DetectionMAPOpKernel : public framework::OpKernel<T> {
}
};
SetData
(
input_true_pos
,
true_pos
);
SetData
(
input_false_pos
,
false_pos
);
SetData
(
input_true_pos
,
*
true_pos
);
SetData
(
input_false_pos
,
*
false_pos
);
return
;
}
...
...
@@ -301,9 +306,9 @@ class DetectionMAPOpKernel : public framework::OpKernel<T> {
const
std
::
vector
<
std
::
map
<
int
,
std
::
vector
<
std
::
pair
<
T
,
Box
>>>>&
detect_boxes
,
bool
evaluate_difficult
,
float
overlap_threshold
,
std
::
map
<
int
,
int
>
&
label_pos_count
,
std
::
map
<
int
,
std
::
vector
<
std
::
pair
<
T
,
int
>>>
&
true_pos
,
std
::
map
<
int
,
std
::
vector
<
std
::
pair
<
T
,
int
>>>
&
false_pos
)
const
{
std
::
map
<
int
,
int
>
*
label_pos_count
,
std
::
map
<
int
,
std
::
vector
<
std
::
pair
<
T
,
int
>>>
*
true_pos
,
std
::
map
<
int
,
std
::
vector
<
std
::
pair
<
T
,
int
>>>
*
false_pos
)
const
{
int
batch_size
=
gt_boxes
.
size
();
for
(
int
n
=
0
;
n
<
batch_size
;
++
n
)
{
auto
image_gt_boxes
=
gt_boxes
[
n
];
...
...
@@ -320,10 +325,10 @@ class DetectionMAPOpKernel : public framework::OpKernel<T> {
continue
;
}
int
label
=
it
->
first
;
if
(
label_pos_count
.
find
(
label
)
==
label_pos_count
.
end
())
{
label_pos_count
[
label
]
=
count
;
if
(
label_pos_count
->
find
(
label
)
==
label_pos_count
->
end
())
{
(
*
label_pos_count
)
[
label
]
=
count
;
}
else
{
label_pos_count
[
label
]
+=
count
;
(
*
label_pos_count
)
[
label
]
+=
count
;
}
}
}
...
...
@@ -338,8 +343,8 @@ class DetectionMAPOpKernel : public framework::OpKernel<T> {
int
label
=
it
->
first
;
for
(
size_t
i
=
0
;
i
<
pred_boxes
.
size
();
++
i
)
{
auto
score
=
pred_boxes
[
i
].
first
;
true_pos
[
label
].
push_back
(
std
::
make_pair
(
score
,
0
));
false_pos
[
label
].
push_back
(
std
::
make_pair
(
score
,
1
));
(
*
true_pos
)
[
label
].
push_back
(
std
::
make_pair
(
score
,
0
));
(
*
false_pos
)
[
label
].
push_back
(
std
::
make_pair
(
score
,
1
));
}
}
continue
;
...
...
@@ -351,8 +356,8 @@ class DetectionMAPOpKernel : public framework::OpKernel<T> {
if
(
image_gt_boxes
.
find
(
label
)
==
image_gt_boxes
.
end
())
{
for
(
size_t
i
=
0
;
i
<
pred_boxes
.
size
();
++
i
)
{
auto
score
=
pred_boxes
[
i
].
first
;
true_pos
[
label
].
push_back
(
std
::
make_pair
(
score
,
0
));
false_pos
[
label
].
push_back
(
std
::
make_pair
(
score
,
1
));
(
*
true_pos
)
[
label
].
push_back
(
std
::
make_pair
(
score
,
0
));
(
*
false_pos
)
[
label
].
push_back
(
std
::
make_pair
(
score
,
1
));
}
continue
;
}
...
...
@@ -381,17 +386,17 @@ class DetectionMAPOpKernel : public framework::OpKernel<T> {
(
!
evaluate_difficult
&&
!
matched_bboxes
[
max_idx
].
is_difficult
);
if
(
match_evaluate_difficult
)
{
if
(
!
visited
[
max_idx
])
{
true_pos
[
label
].
push_back
(
std
::
make_pair
(
score
,
1
));
false_pos
[
label
].
push_back
(
std
::
make_pair
(
score
,
0
));
(
*
true_pos
)
[
label
].
push_back
(
std
::
make_pair
(
score
,
1
));
(
*
false_pos
)
[
label
].
push_back
(
std
::
make_pair
(
score
,
0
));
visited
[
max_idx
]
=
true
;
}
else
{
true_pos
[
label
].
push_back
(
std
::
make_pair
(
score
,
0
));
false_pos
[
label
].
push_back
(
std
::
make_pair
(
score
,
1
));
(
*
true_pos
)
[
label
].
push_back
(
std
::
make_pair
(
score
,
0
));
(
*
false_pos
)
[
label
].
push_back
(
std
::
make_pair
(
score
,
1
));
}
}
}
else
{
true_pos
[
label
].
push_back
(
std
::
make_pair
(
score
,
0
));
false_pos
[
label
].
push_back
(
std
::
make_pair
(
score
,
1
));
(
*
true_pos
)
[
label
].
push_back
(
std
::
make_pair
(
score
,
0
));
(
*
false_pos
)
[
label
].
push_back
(
std
::
make_pair
(
score
,
1
));
}
}
}
...
...
paddle/fluid/operators/edit_distance_op.cu
浏览文件 @
2d1a6f8d
...
...
@@ -14,6 +14,7 @@ limitations under the License. */
#include <algorithm>
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/edit_distance_op.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/cuda_helper.h"
#include "paddle/fluid/platform/gpu_info.h"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录