Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
d08791d1
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
未验证
提交
d08791d1
编写于
4月 17, 2018
作者:
A
Abhinav Arora
提交者:
GitHub
4月 17, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix CPPLint issues with Chunk_eval_op (#9964)
上级
8352f938
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
30 addition
and
21 deletion
+30
-21
paddle/fluid/operators/chunk_eval_op.cc
paddle/fluid/operators/chunk_eval_op.cc
+2
-0
paddle/fluid/operators/chunk_eval_op.h
paddle/fluid/operators/chunk_eval_op.h
+28
-21
未找到文件。
paddle/fluid/operators/chunk_eval_op.cc
浏览文件 @
d08791d1
...
@@ -13,6 +13,8 @@ See the License for the specific language governing permissions and
...
@@ -13,6 +13,8 @@ See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include "paddle/fluid/operators/chunk_eval_op.h"
#include "paddle/fluid/operators/chunk_eval_op.h"
#include <string>
#include <vector>
namespace
paddle
{
namespace
paddle
{
namespace
operators
{
namespace
operators
{
...
...
paddle/fluid/operators/chunk_eval_op.h
浏览文件 @
d08791d1
...
@@ -14,6 +14,9 @@ limitations under the License. */
...
@@ -14,6 +14,9 @@ limitations under the License. */
#pragma once
#pragma once
#include <set>
#include <set>
#include <string>
#include <vector>
#include "paddle/fluid/framework/eigen.h"
#include "paddle/fluid/framework/eigen.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/op_registry.h"
...
@@ -36,11 +39,11 @@ class ChunkEvalKernel : public framework::OpKernel<T> {
...
@@ -36,11 +39,11 @@ class ChunkEvalKernel : public framework::OpKernel<T> {
};
};
void
GetSegments
(
const
int64_t
*
label
,
int
length
,
void
GetSegments
(
const
int64_t
*
label
,
int
length
,
std
::
vector
<
Segment
>
&
segments
,
int
num_chunk_types
,
std
::
vector
<
Segment
>
*
segments
,
int
num_chunk_types
,
int
num_tag_types
,
int
other_chunk_type
,
int
tag_begin
,
int
num_tag_types
,
int
other_chunk_type
,
int
tag_begin
,
int
tag_inside
,
int
tag_end
,
int
tag_single
)
const
{
int
tag_inside
,
int
tag_end
,
int
tag_single
)
const
{
segments
.
clear
();
segments
->
clear
();
segments
.
reserve
(
length
);
segments
->
reserve
(
length
);
int
chunk_start
=
0
;
int
chunk_start
=
0
;
bool
in_chunk
=
false
;
bool
in_chunk
=
false
;
int
tag
=
-
1
;
int
tag
=
-
1
;
...
@@ -58,7 +61,7 @@ class ChunkEvalKernel : public framework::OpKernel<T> {
...
@@ -58,7 +61,7 @@ class ChunkEvalKernel : public framework::OpKernel<T> {
i
-
1
,
// end
i
-
1
,
// end
prev_type
,
prev_type
,
};
};
segments
.
push_back
(
segment
);
segments
->
push_back
(
segment
);
in_chunk
=
false
;
in_chunk
=
false
;
}
}
if
(
ChunkBegin
(
prev_tag
,
prev_type
,
tag
,
type
,
other_chunk_type
,
if
(
ChunkBegin
(
prev_tag
,
prev_type
,
tag
,
type
,
other_chunk_type
,
...
@@ -73,7 +76,7 @@ class ChunkEvalKernel : public framework::OpKernel<T> {
...
@@ -73,7 +76,7 @@ class ChunkEvalKernel : public framework::OpKernel<T> {
length
-
1
,
// end
length
-
1
,
// end
type
,
type
,
};
};
segments
.
push_back
(
segment
);
segments
->
push_back
(
segment
);
}
}
}
}
...
@@ -177,8 +180,8 @@ class ChunkEvalKernel : public framework::OpKernel<T> {
...
@@ -177,8 +180,8 @@ class ChunkEvalKernel : public framework::OpKernel<T> {
for
(
int
i
=
0
;
i
<
num_sequences
;
++
i
)
{
for
(
int
i
=
0
;
i
<
num_sequences
;
++
i
)
{
int
seq_length
=
lod
[
0
][
i
+
1
]
-
lod
[
0
][
i
];
int
seq_length
=
lod
[
0
][
i
+
1
]
-
lod
[
0
][
i
];
EvalOneSeq
(
inference_data
+
lod
[
0
][
i
],
label_data
+
lod
[
0
][
i
],
seq_length
,
EvalOneSeq
(
inference_data
+
lod
[
0
][
i
],
label_data
+
lod
[
0
][
i
],
seq_length
,
output_segments
,
label_segments
,
*
num_infer_chunks_data
,
&
output_segments
,
&
label_segments
,
num_infer_chunks_data
,
*
num_label_chunks_data
,
*
num_correct_chunks_data
,
num_label_chunks_data
,
num_correct_chunks_data
,
num_chunk_types
,
num_tag_types
,
other_chunk_type
,
tag_begin
,
num_chunk_types
,
num_tag_types
,
other_chunk_type
,
tag_begin
,
tag_inside
,
tag_end
,
tag_single
,
excluded_chunk_types
);
tag_inside
,
tag_end
,
tag_single
,
excluded_chunk_types
);
}
}
...
@@ -197,10 +200,10 @@ class ChunkEvalKernel : public framework::OpKernel<T> {
...
@@ -197,10 +200,10 @@ class ChunkEvalKernel : public framework::OpKernel<T> {
}
}
void
EvalOneSeq
(
const
int64_t
*
output
,
const
int64_t
*
label
,
int
length
,
void
EvalOneSeq
(
const
int64_t
*
output
,
const
int64_t
*
label
,
int
length
,
std
::
vector
<
Segment
>
&
output_segments
,
std
::
vector
<
Segment
>
*
output_segments
,
std
::
vector
<
Segment
>
&
label_segments
,
std
::
vector
<
Segment
>
*
label_segments
,
int64_t
&
num_output_segments
,
int64_t
&
num_label_segments
,
int64_t
*
num_output_segments
,
int64_t
*
num_label_segments
,
int64_t
&
num_correct
,
int
num_chunk_types
,
int
num_tag_types
,
int64_t
*
num_correct
,
int
num_chunk_types
,
int
num_tag_types
,
int
other_chunk_type
,
int
tag_begin
,
int
tag_inside
,
int
other_chunk_type
,
int
tag_begin
,
int
tag_inside
,
int
tag_end
,
int
tag_single
,
int
tag_end
,
int
tag_single
,
const
std
::
set
<
int
>&
excluded_chunk_types
)
const
{
const
std
::
set
<
int
>&
excluded_chunk_types
)
const
{
...
@@ -209,25 +212,29 @@ class ChunkEvalKernel : public framework::OpKernel<T> {
...
@@ -209,25 +212,29 @@ class ChunkEvalKernel : public framework::OpKernel<T> {
GetSegments
(
label
,
length
,
label_segments
,
num_chunk_types
,
num_tag_types
,
GetSegments
(
label
,
length
,
label_segments
,
num_chunk_types
,
num_tag_types
,
other_chunk_type
,
tag_begin
,
tag_inside
,
tag_end
,
tag_single
);
other_chunk_type
,
tag_begin
,
tag_inside
,
tag_end
,
tag_single
);
size_t
i
=
0
,
j
=
0
;
size_t
i
=
0
,
j
=
0
;
while
(
i
<
output_segments
.
size
()
&&
j
<
label_segments
.
size
())
{
while
(
i
<
output_segments
->
size
()
&&
j
<
label_segments
->
size
())
{
if
(
output_segments
[
i
]
==
label_segments
[
j
]
&&
if
(
output_segments
->
at
(
i
)
==
label_segments
->
at
(
j
)
&&
excluded_chunk_types
.
count
(
output_segments
[
i
]
.
type
)
!=
1
)
{
excluded_chunk_types
.
count
(
output_segments
->
at
(
i
)
.
type
)
!=
1
)
{
++
num_correct
;
++
(
*
num_correct
)
;
}
}
if
(
output_segments
[
i
].
end
<
label_segments
[
j
]
.
end
)
{
if
(
output_segments
->
at
(
i
).
end
<
label_segments
->
at
(
j
)
.
end
)
{
++
i
;
++
i
;
}
else
if
(
output_segments
[
i
].
end
>
label_segments
[
j
]
.
end
)
{
}
else
if
(
output_segments
->
at
(
i
).
end
>
label_segments
->
at
(
j
)
.
end
)
{
++
j
;
++
j
;
}
else
{
}
else
{
++
i
;
++
i
;
++
j
;
++
j
;
}
}
}
}
for
(
auto
&
segment
:
label_segments
)
{
for
(
auto
&
segment
:
(
*
label_segments
))
{
if
(
excluded_chunk_types
.
count
(
segment
.
type
)
!=
1
)
++
num_label_segments
;
if
(
excluded_chunk_types
.
count
(
segment
.
type
)
!=
1
)
{
++
(
*
num_label_segments
);
}
}
}
for
(
auto
&
segment
:
output_segments
)
{
for
(
auto
&
segment
:
(
*
output_segments
))
{
if
(
excluded_chunk_types
.
count
(
segment
.
type
)
!=
1
)
++
num_output_segments
;
if
(
excluded_chunk_types
.
count
(
segment
.
type
)
!=
1
)
{
++
(
*
num_output_segments
);
}
}
}
}
}
};
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录