Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
49c31feb
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看板
提交
49c31feb
编写于
8月 27, 2018
作者:
T
tensor-tang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix typo and op test
上级
02909335
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
10 addition
and
11 deletion
+10
-11
paddle/fluid/operators/fusion_seqexpand_concat_fc_op.cc
paddle/fluid/operators/fusion_seqexpand_concat_fc_op.cc
+6
-7
python/paddle/fluid/tests/unittests/test_fusion_seqexpand_concat_fc_op.py
...uid/tests/unittests/test_fusion_seqexpand_concat_fc_op.py
+4
-4
未找到文件。
paddle/fluid/operators/fusion_seqexpand_concat_fc_op.cc
浏览文件 @
49c31feb
...
@@ -63,7 +63,7 @@ void FusionSeqExpandConcatFCOp::InferShape(
...
@@ -63,7 +63,7 @@ void FusionSeqExpandConcatFCOp::InferShape(
framework
::
OpKernelType
FusionSeqExpandConcatFCOp
::
GetExpectedKernelType
(
framework
::
OpKernelType
FusionSeqExpandConcatFCOp
::
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
.
MultiInput
<
LoDTensor
>
(
"X"
)[
0
]
->
type
()),
ctx
.
device_context
());
ctx
.
device_context
());
}
}
...
@@ -113,7 +113,7 @@ class FusionSeqExpandConcatFCOpKernel : public framework::OpKernel<T> {
...
@@ -113,7 +113,7 @@ class FusionSeqExpandConcatFCOpKernel : public framework::OpKernel<T> {
auto
*
w
=
ctx
.
Input
<
Tensor
>
(
"FCWeight"
);
auto
*
w
=
ctx
.
Input
<
Tensor
>
(
"FCWeight"
);
auto
*
b
=
ctx
.
Input
<
Tensor
>
(
"FCBias"
);
auto
*
b
=
ctx
.
Input
<
Tensor
>
(
"FCBias"
);
auto
*
out
=
ctx
.
Output
<
LoDTensor
>
(
"Out"
);
auto
*
out
=
ctx
.
Output
<
LoDTensor
>
(
"Out"
);
auto
*
fc_out
=
ctx
.
Output
<
Tensor
>
(
"FCO
UT
"
);
auto
*
fc_out
=
ctx
.
Output
<
Tensor
>
(
"FCO
ut
"
);
auto
*
ref_in
=
ins
[
0
];
auto
*
ref_in
=
ins
[
0
];
auto
ref_lod
=
ref_in
->
lod
();
auto
ref_lod
=
ref_in
->
lod
();
...
@@ -164,7 +164,7 @@ class FusionSeqExpandConcatFCOpKernel : public framework::OpKernel<T> {
...
@@ -164,7 +164,7 @@ class FusionSeqExpandConcatFCOpKernel : public framework::OpKernel<T> {
math
::
FCCompute
<
DeviceContext
,
T
>
(
blas
,
total_T
,
D
,
M0
,
ref_in_data
,
w_data
,
math
::
FCCompute
<
DeviceContext
,
T
>
(
blas
,
total_T
,
D
,
M0
,
ref_in_data
,
w_data
,
out_data
,
b
?
b
->
data
<
T
>
()
:
NULL
);
out_data
,
b
?
b
->
data
<
T
>
()
:
NULL
);
w_data
=
w_data
+
M0
*
D
;
w_data
=
w_data
+
M0
*
D
;
// first
one use
write on
// first write on
blas
.
MatMul
(
N
,
D
,
M1
,
in1_data
,
w_data
,
fc_out_data
);
blas
.
MatMul
(
N
,
D
,
M1
,
in1_data
,
w_data
,
fc_out_data
);
w_data
=
w_data
+
M1
*
D
;
w_data
=
w_data
+
M1
*
D
;
for
(
size_t
i
=
2
;
i
<
ins
.
size
();
++
i
)
{
for
(
size_t
i
=
2
;
i
<
ins
.
size
();
++
i
)
{
...
@@ -175,16 +175,15 @@ class FusionSeqExpandConcatFCOpKernel : public framework::OpKernel<T> {
...
@@ -175,16 +175,15 @@ class FusionSeqExpandConcatFCOpKernel : public framework::OpKernel<T> {
K
,
w_data
,
D
,
static_cast
<
T
>
(
1
),
fc_out_data
,
D
);
K
,
w_data
,
D
,
static_cast
<
T
>
(
1
),
fc_out_data
,
D
);
w_data
=
w_data
+
K
*
D
;
w_data
=
w_data
+
K
*
D
;
}
}
T
*
cur_out_data
=
out_data
;
for
(
int
i
=
0
;
i
<
N
;
++
i
)
{
for
(
int
i
=
0
;
i
<
N
;
++
i
)
{
int
seq_len
=
ref_lod
[
0
][
i
+
1
]
-
ref_lod
[
0
][
i
];
int
seq_len
=
ref_lod
[
0
][
i
+
1
]
-
ref_lod
[
0
][
i
];
T
*
src
=
fc_out_data
+
i
*
D
;
T
*
src
=
fc_out_data
+
i
*
D
;
for
(
int
step
=
0
;
step
<
seq_len
;
++
step
)
{
for
(
int
step
=
0
;
step
<
seq_len
;
++
step
)
{
blas
.
VADD
(
D
,
out_data
,
src
,
out_data
);
blas
.
VADD
(
D
,
cur_out_data
,
src
,
cur_
out_data
);
out_data
=
out_data
+
D
;
cur_out_data
=
cur_
out_data
+
D
;
}
}
}
}
fc_act
(
total_T
*
D
,
out_data
,
out_data
);
fc_act
(
total_T
*
D
,
out_data
,
out_data
);
}
}
};
};
...
...
python/paddle/fluid/tests/unittests/test_fusion_seqexpand_concat_fc_op.py
浏览文件 @
49c31feb
...
@@ -80,16 +80,16 @@ class TestFusionSeqExpandConcatFCOp(OpTest):
...
@@ -80,16 +80,16 @@ class TestFusionSeqExpandConcatFCOp(OpTest):
out
=
fusion_seqexpand_concat_fc
(
xs
,
self
.
lod
,
w
,
b
,
out
=
fusion_seqexpand_concat_fc
(
xs
,
self
.
lod
,
w
,
b
,
ACTIVATION
[
self
.
fc_act
])
ACTIVATION
[
self
.
fc_act
])
self
.
inputs
=
{
'X'
:
[(
x0
,
self
.
lod
)],
'FCWeight'
:
w
}
self
.
inputs
=
{
'X'
:
[(
'x0'
,
(
x0
,
self
.
lod
)
)],
'FCWeight'
:
w
}
normal_lod
=
[
i
for
i
in
range
(
bs
+
1
)
]
normal_lod
=
[
[
1
]
*
bs
]
for
i
in
range
(
num_inputs
-
1
):
for
i
in
range
(
num_inputs
-
1
):
self
.
inputs
[
'X'
].
append
((
xs
[
i
+
1
],
normal_lod
))
self
.
inputs
[
'X'
].
append
((
'x%d'
%
(
i
+
1
),
(
xs
[
i
+
1
],
normal_lod
)
))
if
self
.
with_bias
:
if
self
.
with_bias
:
self
.
inputs
[
'FCBias'
]
=
b
self
.
inputs
[
'FCBias'
]
=
b
self
.
outputs
=
{
'Out'
:
(
out
,
self
.
lod
)}
self
.
outputs
=
{
'Out'
:
(
out
,
self
.
lod
)}
self
.
attrs
=
{
'fc_activation'
:
self
.
fc_act
,
}
self
.
attrs
=
{
'fc_activation'
:
self
.
fc_act
}
def
test_check_output
(
self
):
def
test_check_output
(
self
):
self
.
check_output
()
self
.
check_output
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录