Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
d08791d1
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
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
limitations under the License. */
#include "paddle/fluid/operators/chunk_eval_op.h"
#include <string>
#include <vector>
namespace
paddle
{
namespace
operators
{
...
...
paddle/fluid/operators/chunk_eval_op.h
浏览文件 @
d08791d1
...
...
@@ -14,6 +14,9 @@ limitations under the License. */
#pragma once
#include <set>
#include <string>
#include <vector>
#include "paddle/fluid/framework/eigen.h"
#include "paddle/fluid/framework/op_registry.h"
...
...
@@ -36,11 +39,11 @@ class ChunkEvalKernel : public framework::OpKernel<T> {
};
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
tag_inside
,
int
tag_end
,
int
tag_single
)
const
{
segments
.
clear
();
segments
.
reserve
(
length
);
segments
->
clear
();
segments
->
reserve
(
length
);
int
chunk_start
=
0
;
bool
in_chunk
=
false
;
int
tag
=
-
1
;
...
...
@@ -58,7 +61,7 @@ class ChunkEvalKernel : public framework::OpKernel<T> {
i
-
1
,
// end
prev_type
,
};
segments
.
push_back
(
segment
);
segments
->
push_back
(
segment
);
in_chunk
=
false
;
}
if
(
ChunkBegin
(
prev_tag
,
prev_type
,
tag
,
type
,
other_chunk_type
,
...
...
@@ -73,7 +76,7 @@ class ChunkEvalKernel : public framework::OpKernel<T> {
length
-
1
,
// end
type
,
};
segments
.
push_back
(
segment
);
segments
->
push_back
(
segment
);
}
}
...
...
@@ -177,8 +180,8 @@ class ChunkEvalKernel : public framework::OpKernel<T> {
for
(
int
i
=
0
;
i
<
num_sequences
;
++
i
)
{
int
seq_length
=
lod
[
0
][
i
+
1
]
-
lod
[
0
][
i
];
EvalOneSeq
(
inference_data
+
lod
[
0
][
i
],
label_data
+
lod
[
0
][
i
],
seq_length
,
output_segments
,
label_segments
,
*
num_infer_chunks_data
,
*
num_label_chunks_data
,
*
num_correct_chunks_data
,
&
output_segments
,
&
label_segments
,
num_infer_chunks_data
,
num_label_chunks_data
,
num_correct_chunks_data
,
num_chunk_types
,
num_tag_types
,
other_chunk_type
,
tag_begin
,
tag_inside
,
tag_end
,
tag_single
,
excluded_chunk_types
);
}
...
...
@@ -197,10 +200,10 @@ class ChunkEvalKernel : public framework::OpKernel<T> {
}
void
EvalOneSeq
(
const
int64_t
*
output
,
const
int64_t
*
label
,
int
length
,
std
::
vector
<
Segment
>
&
output_segments
,
std
::
vector
<
Segment
>
&
label_segments
,
int64_t
&
num_output_segments
,
int64_t
&
num_label_segments
,
int64_t
&
num_correct
,
int
num_chunk_types
,
int
num_tag_types
,
std
::
vector
<
Segment
>
*
output_segments
,
std
::
vector
<
Segment
>
*
label_segments
,
int64_t
*
num_output_segments
,
int64_t
*
num_label_segments
,
int64_t
*
num_correct
,
int
num_chunk_types
,
int
num_tag_types
,
int
other_chunk_type
,
int
tag_begin
,
int
tag_inside
,
int
tag_end
,
int
tag_single
,
const
std
::
set
<
int
>&
excluded_chunk_types
)
const
{
...
...
@@ -209,25 +212,29 @@ class ChunkEvalKernel : public framework::OpKernel<T> {
GetSegments
(
label
,
length
,
label_segments
,
num_chunk_types
,
num_tag_types
,
other_chunk_type
,
tag_begin
,
tag_inside
,
tag_end
,
tag_single
);
size_t
i
=
0
,
j
=
0
;
while
(
i
<
output_segments
.
size
()
&&
j
<
label_segments
.
size
())
{
if
(
output_segments
[
i
]
==
label_segments
[
j
]
&&
excluded_chunk_types
.
count
(
output_segments
[
i
]
.
type
)
!=
1
)
{
++
num_correct
;
while
(
i
<
output_segments
->
size
()
&&
j
<
label_segments
->
size
())
{
if
(
output_segments
->
at
(
i
)
==
label_segments
->
at
(
j
)
&&
excluded_chunk_types
.
count
(
output_segments
->
at
(
i
)
.
type
)
!=
1
)
{
++
(
*
num_correct
)
;
}
if
(
output_segments
[
i
].
end
<
label_segments
[
j
]
.
end
)
{
if
(
output_segments
->
at
(
i
).
end
<
label_segments
->
at
(
j
)
.
end
)
{
++
i
;
}
else
if
(
output_segments
[
i
].
end
>
label_segments
[
j
]
.
end
)
{
}
else
if
(
output_segments
->
at
(
i
).
end
>
label_segments
->
at
(
j
)
.
end
)
{
++
j
;
}
else
{
++
i
;
++
j
;
}
}
for
(
auto
&
segment
:
label_segments
)
{
if
(
excluded_chunk_types
.
count
(
segment
.
type
)
!=
1
)
++
num_label_segments
;
for
(
auto
&
segment
:
(
*
label_segments
))
{
if
(
excluded_chunk_types
.
count
(
segment
.
type
)
!=
1
)
{
++
(
*
num_label_segments
);
}
}
for
(
auto
&
segment
:
output_segments
)
{
if
(
excluded_chunk_types
.
count
(
segment
.
type
)
!=
1
)
++
num_output_segments
;
for
(
auto
&
segment
:
(
*
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录