Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
6f06b322
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看板
提交
6f06b322
编写于
4月 20, 2018
作者:
K
ktlichkid
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added GetExpectedKernelType and Debug message
上级
df70d5f1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
40 addition
and
9 deletion
+40
-9
paddle/fluid/operators/beam_search_op.cc
paddle/fluid/operators/beam_search_op.cc
+13
-0
paddle/fluid/operators/beam_search_op.h
paddle/fluid/operators/beam_search_op.h
+27
-9
未找到文件。
paddle/fluid/operators/beam_search_op.cc
浏览文件 @
6f06b322
...
...
@@ -21,6 +21,8 @@ limitations under the License. */
#include "paddle/fluid/framework/lod_tensor.h"
#include "paddle/fluid/framework/op_registry.h"
#include <iostream>
namespace
paddle
{
namespace
operators
{
...
...
@@ -252,6 +254,17 @@ class BeamSearchOp : public framework::OperatorWithKernel {
PADDLE_ENFORCE
(
ctx
->
HasOutput
(
arg
),
"BeamSearch need output argument '%s'"
,
arg
);
}
std
::
cout
<<
"Done Infer Shape
\n
"
;
}
framework
::
OpKernelType
GetExpectedKernelType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
std
::
cout
<<
"Get Expected type 1
\n
"
;
framework
::
OpKernelType
kt
=
OperatorWithKernel
::
GetExpectedKernelType
(
ctx
);
std
::
cout
<<
"Get Expected type 2
\n
"
;
kt
.
place_
=
ctx
.
Input
<
framework
::
LoDTensor
>
(
"pre_ids"
)
->
place
();
std
::
cout
<<
"Get Expected type 3
\n
"
;
return
kt
;
}
/*
private:
...
...
paddle/fluid/operators/beam_search_op.h
浏览文件 @
6f06b322
...
...
@@ -23,6 +23,8 @@ limitations under the License. */
#include "paddle/fluid/framework/lod_tensor.h"
#include "paddle/fluid/framework/operator.h"
#include <iostream>
namespace
paddle
{
namespace
operators
{
...
...
@@ -196,31 +198,47 @@ template <typename DeviceContext, typename T>
class
BeamSearchOpKernel
:
public
framework
::
OpKernel
<
T
>
{
public:
void
Compute
(
const
framework
::
ExecutionContext
&
context
)
const
override
{
std
::
cout
<<
"Compute 1
\n
"
;
auto
ids_var
=
context
.
Input
<
framework
::
LoDTensor
>
(
"ids"
);
std
::
cout
<<
"Compute 2
\n
"
;
auto
scores_var
=
context
.
Input
<
framework
::
LoDTensor
>
(
"scores"
);
std
::
cout
<<
"Compute 3
\n
"
;
auto
pre_ids_var
=
context
.
Input
<
framework
::
LoDTensor
>
(
"pre_ids"
);
std
::
cout
<<
"Compute 4
\n
"
;
PADDLE_ENFORCE_NOT_NULL
(
ids_var
);
std
::
cout
<<
"Compute 5
\n
"
;
PADDLE_ENFORCE_NOT_NULL
(
scores_var
);
std
::
cout
<<
"Compute 6
\n
"
;
PADDLE_ENFORCE_NOT_NULL
(
pre_ids_var
);
//auto& ids = ids_var->Get<framework::LoDTensor>();
//auto& scores = scores_var->Get<framework::LoDTensor>();
//auto& pre_ids = pre_ids_var->Get<framework::LoDTensor>();
std
::
cout
<<
"Compute 7
\n
"
;
//
auto& ids = ids_var->Get<framework::LoDTensor>();
//
auto& scores = scores_var->Get<framework::LoDTensor>();
//
auto& pre_ids = pre_ids_var->Get<framework::LoDTensor>();
size_t
level
=
context
.
Attr
<
int
>
(
"level"
);
std
::
cout
<<
"Compute 8
\n
"
;
size_t
beam_size
=
context
.
Attr
<
int
>
(
"beam_size"
);
std
::
cout
<<
"Compute 9
\n
"
;
int
end_id
=
context
.
Attr
<
int
>
(
"end_id"
);
std
::
cout
<<
"Compute 10
\n
"
;
BeamSearch
alg
(
*
ids_var
,
*
scores_var
,
level
,
beam_size
,
end_id
);
auto
selected_ids_var
=
context
.
Output
<
framework
::
LoDTensor
>
(
"selected_ids"
);
auto
selected_scores_var
=
context
.
Output
<
framework
::
LoDTensor
>
(
"selected_scores"
);
std
::
cout
<<
"Compute 11
\n
"
;
auto
selected_ids_var
=
context
.
Output
<
framework
::
LoDTensor
>
(
"selected_ids"
);
std
::
cout
<<
"Compute 12
\n
"
;
auto
selected_scores_var
=
context
.
Output
<
framework
::
LoDTensor
>
(
"selected_scores"
);
std
::
cout
<<
"Compute 13
\n
"
;
PADDLE_ENFORCE_NOT_NULL
(
selected_ids_var
);
std
::
cout
<<
"Compute 14
\n
"
;
PADDLE_ENFORCE_NOT_NULL
(
selected_scores_var
);
//auto& selected_ids_tensor =
std
::
cout
<<
"Compute 15
\n
"
;
// auto& selected_ids_tensor =
// *selected_ids_var->GetMutable<framework::LoDTensor>();
//auto& selected_scores_tensor =
//
auto& selected_scores_tensor =
// *selected_scores_var->GetMutable<framework::LoDTensor>();
alg
(
*
pre_ids_var
,
selected_ids_var
,
selected_scores_var
);
std
::
cout
<<
"Compute 16
\n
"
;
}
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录