Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
02909335
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看板
提交
02909335
编写于
8月 27, 2018
作者:
T
tensor-tang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename fusion seq_concat_fc to fusion seqexpand_concat_fc
上级
0f0d4823
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
28 addition
and
22 deletion
+28
-22
paddle/fluid/operators/fusion_seqexpand_concat_fc_op.cc
paddle/fluid/operators/fusion_seqexpand_concat_fc_op.cc
+23
-18
paddle/fluid/operators/fusion_seqexpand_concat_fc_op.h
paddle/fluid/operators/fusion_seqexpand_concat_fc_op.h
+4
-3
python/paddle/fluid/tests/unittests/test_fusion_seqexpand_concat_fc_op.py
...uid/tests/unittests/test_fusion_seqexpand_concat_fc_op.py
+1
-1
未找到文件。
paddle/fluid/operators/fusion_seq_concat_fc_op.cc
→
paddle/fluid/operators/fusion_seq
expand
_concat_fc_op.cc
浏览文件 @
02909335
...
@@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
@@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include "paddle/fluid/operators/fusion_seq_concat_fc_op.h"
#include "paddle/fluid/operators/fusion_seq
expand
_concat_fc_op.h"
#include <string>
#include <string>
#include "paddle/fluid/operators/math/blas.h"
#include "paddle/fluid/operators/math/blas.h"
#include "paddle/fluid/operators/math/cpu_vec.h"
#include "paddle/fluid/operators/math/cpu_vec.h"
...
@@ -22,15 +22,20 @@ limitations under the License. */
...
@@ -22,15 +22,20 @@ limitations under the License. */
namespace
paddle
{
namespace
paddle
{
namespace
operators
{
namespace
operators
{
void
FusionSeqConcatFCOp
::
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
{
void
FusionSeqExpandConcatFCOp
::
InferShape
(
PADDLE_ENFORCE_GT
(
ctx
->
Inputs
(
"X"
).
size
(),
1UL
,
framework
::
InferShapeContext
*
ctx
)
const
{
"Inputs(X) of FusionSeqConcatFCOp should larger than 1."
);
PADDLE_ENFORCE_GT
(
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"FCWeight"
),
ctx
->
Inputs
(
"X"
).
size
(),
1UL
,
"Input(FCWeight) of FusionSeqConcatFC should not be null."
);
"Inputs(X) of FusionSeqExpandConcatFCOp should larger than 1."
);
PADDLE_ENFORCE
(
ctx
->
HasOutput
(
"Out"
),
PADDLE_ENFORCE
(
"Output(Out) of FusionSeqConcatFC should not be null."
);
ctx
->
HasInput
(
"FCWeight"
),
PADDLE_ENFORCE
(
ctx
->
HasOutput
(
"FCOut"
),
"Input(FCWeight) of FusionSeqExpandConcatFCOp should not be null."
);
"Output(FCOut) of FusionSeqConcatFC should not be null."
);
PADDLE_ENFORCE
(
ctx
->
HasOutput
(
"Out"
),
"Output(Out) of FusionSeqExpandConcatFCOp should not be null."
);
PADDLE_ENFORCE
(
ctx
->
HasOutput
(
"FCOut"
),
"Output(FCOut) of FusionSeqExpandConcatFCOp should not be null."
);
auto
ins_dims
=
ctx
->
GetInputsDim
(
"X"
);
auto
ins_dims
=
ctx
->
GetInputsDim
(
"X"
);
auto
w_dims
=
ctx
->
GetInputDim
(
"FCWeight"
);
// (M0+M1+M2+..) x D
auto
w_dims
=
ctx
->
GetInputDim
(
"FCWeight"
);
// (M0+M1+M2+..) x D
...
@@ -55,14 +60,14 @@ void FusionSeqConcatFCOp::InferShape(framework::InferShapeContext* ctx) const {
...
@@ -55,14 +60,14 @@ void FusionSeqConcatFCOp::InferShape(framework::InferShapeContext* ctx) const {
ctx
->
ShareLoD
(
"X"
,
"Out"
,
0
);
ctx
->
ShareLoD
(
"X"
,
"Out"
,
0
);
}
}
framework
::
OpKernelType
FusionSeqConcatFCOp
::
GetExpectedKernelType
(
framework
::
OpKernelType
FusionSeq
Expand
ConcatFCOp
::
GetExpectedKernelType
(
const
framework
::
ExecutionContext
&
ctx
)
const
{
const
framework
::
ExecutionContext
&
ctx
)
const
{
return
framework
::
OpKernelType
(
return
framework
::
OpKernelType
(
framework
::
ToDataType
(
ctx
.
Input
<
framework
::
LoDTensor
>
(
"X"
)
->
type
()),
framework
::
ToDataType
(
ctx
.
Input
<
framework
::
LoDTensor
>
(
"X"
)
->
type
()),
ctx
.
device_context
());
ctx
.
device_context
());
}
}
void
FusionSeqConcatFCOpMaker
::
Make
()
{
void
FusionSeq
Expand
ConcatFCOpMaker
::
Make
()
{
AddInput
(
"X"
,
AddInput
(
"X"
,
"(LoDTensor) input LodDTensors, the first one must be have ref lod "
"(LoDTensor) input LodDTensors, the first one must be have ref lod "
"for sequence expand, and the rest input should have same lod."
)
"for sequence expand, and the rest input should have same lod."
)
...
@@ -100,7 +105,7 @@ The concat axis should be 1.
...
@@ -100,7 +105,7 @@ The concat axis should be 1.
}
}
template
<
typename
T
>
template
<
typename
T
>
class
FusionSeq
ConcatFC
Kernel
:
public
framework
::
OpKernel
<
T
>
{
class
FusionSeq
ExpandConcatFCOp
Kernel
:
public
framework
::
OpKernel
<
T
>
{
public:
public:
void
Compute
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
void
Compute
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
using
DeviceContext
=
paddle
::
platform
::
CPUDeviceContext
;
using
DeviceContext
=
paddle
::
platform
::
CPUDeviceContext
;
...
@@ -188,10 +193,10 @@ class FusionSeqConcatFCKernel : public framework::OpKernel<T> {
...
@@ -188,10 +193,10 @@ class FusionSeqConcatFCKernel : public framework::OpKernel<T> {
}
// namespace paddle
}
// namespace paddle
namespace
ops
=
paddle
::
operators
;
namespace
ops
=
paddle
::
operators
;
REGISTER_OPERATOR
(
fusion_seq
_concat_fc
,
ops
::
FusionSeq
ConcatFCOp
,
REGISTER_OPERATOR
(
fusion_seq
expand_concat_fc
,
ops
::
FusionSeqExpand
ConcatFCOp
,
ops
::
FusionSeqConcatFCOpMaker
,
ops
::
FusionSeq
Expand
ConcatFCOpMaker
,
paddle
::
framework
::
DefaultGradOpDescMaker
<
true
>
);
paddle
::
framework
::
DefaultGradOpDescMaker
<
true
>
);
REGISTER_OP_CPU_KERNEL
(
fusion_seq_concat_fc
,
REGISTER_OP_CPU_KERNEL
(
fusion_seq
expand
_concat_fc
,
ops
::
FusionSeq
ConcatFC
Kernel
<
float
>
,
ops
::
FusionSeq
ExpandConcatFCOp
Kernel
<
float
>
,
ops
::
FusionSeq
ConcatFC
Kernel
<
double
>
);
ops
::
FusionSeq
ExpandConcatFCOp
Kernel
<
double
>
);
paddle/fluid/operators/fusion_seq_concat_fc_op.h
→
paddle/fluid/operators/fusion_seq
expand
_concat_fc_op.h
浏览文件 @
02909335
/* Copyright (c) 201
6
PaddlePaddle Authors. All Rights Reserved.
/* Copyright (c) 201
8
PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
you may not use this file except in compliance with the License.
...
@@ -21,7 +21,7 @@ namespace operators {
...
@@ -21,7 +21,7 @@ namespace operators {
using
LoDTensor
=
framework
::
LoDTensor
;
using
LoDTensor
=
framework
::
LoDTensor
;
using
Tensor
=
framework
::
Tensor
;
using
Tensor
=
framework
::
Tensor
;
class
FusionSeqConcatFCOp
:
public
framework
::
OperatorWithKernel
{
class
FusionSeq
Expand
ConcatFCOp
:
public
framework
::
OperatorWithKernel
{
public:
public:
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
...
@@ -32,7 +32,8 @@ class FusionSeqConcatFCOp : public framework::OperatorWithKernel {
...
@@ -32,7 +32,8 @@ class FusionSeqConcatFCOp : public framework::OperatorWithKernel {
const
framework
::
ExecutionContext
&
ctx
)
const
override
;
const
framework
::
ExecutionContext
&
ctx
)
const
override
;
};
};
class
FusionSeqConcatFCOpMaker
:
public
framework
::
OpProtoAndCheckerMaker
{
class
FusionSeqExpandConcatFCOpMaker
:
public
framework
::
OpProtoAndCheckerMaker
{
public:
public:
void
Make
()
override
;
void
Make
()
override
;
};
};
...
...
python/paddle/fluid/tests/unittests/test_fusion_seq_concat_fc_op.py
→
python/paddle/fluid/tests/unittests/test_fusion_seq
expand
_concat_fc_op.py
浏览文件 @
02909335
...
@@ -51,7 +51,7 @@ class TestFusionSeqExpandConcatFCOp(OpTest):
...
@@ -51,7 +51,7 @@ class TestFusionSeqExpandConcatFCOp(OpTest):
pass
pass
def
setUp
(
self
):
def
setUp
(
self
):
self
.
op_type
=
'fusion_seq_concat_fc'
self
.
op_type
=
'fusion_seq
expand
_concat_fc'
self
.
lod
=
[[
3
,
5
,
8
,
2
]]
self
.
lod
=
[[
3
,
5
,
8
,
2
]]
self
.
inputs_M
=
[
15
,
10
,
10
]
self
.
inputs_M
=
[
15
,
10
,
10
]
self
.
D
=
20
self
.
D
=
20
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录