Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
urhero
Paddle
提交
dafd449c
P
Paddle
项目概览
urhero
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
0
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dafd449c
编写于
12月 14, 2017
作者:
F
fengjiayi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Unify `step_block` and `block` to `sub_block`
上级
7ab48aec
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
11 addition
and
11 deletion
+11
-11
paddle/framework/backward.cc
paddle/framework/backward.cc
+2
-2
paddle/operators/conditional_block_op.cc
paddle/operators/conditional_block_op.cc
+4
-4
paddle/operators/recurrent_op.cc
paddle/operators/recurrent_op.cc
+1
-1
paddle/operators/while_op.cc
paddle/operators/while_op.cc
+1
-1
python/paddle/v2/fluid/layers.py
python/paddle/v2/fluid/layers.py
+3
-3
未找到文件。
paddle/framework/backward.cc
浏览文件 @
dafd449c
...
...
@@ -430,14 +430,14 @@ std::vector<std::unique_ptr<OpDescBind>> MakeBlockBackward(
std
::
vector
<
std
::
unique_ptr
<
OpDescBind
>>
op_grads
;
if
((
*
it
)
->
Type
()
==
"recurrent"
||
(
*
it
)
->
Type
()
==
"while"
)
{
int
step_block_idx
=
(
*
it
)
->
GetBlockAttr
(
"s
tep
_block"
);
int
step_block_idx
=
(
*
it
)
->
GetBlockAttr
(
"s
ub
_block"
);
BlockDescBind
*
backward_block
=
CreateStepBlock
(
program_desc
,
no_grad_vars
,
grad_to_var
,
step_block_idx
);
op_grads
=
MakeOpGrad
(
*
it
,
no_grad_vars
,
grad_to_var
,
{
backward_block
});
}
else
if
((
*
it
)
->
Type
()
==
"conditional_block"
)
{
BlockDescBind
*
backward_block
=
CreateStepBlock
(
program_desc
,
no_grad_vars
,
grad_to_var
,
(
*
it
)
->
GetBlockAttr
(
"block"
));
(
*
it
)
->
GetBlockAttr
(
"
sub_
block"
));
op_grads
=
MakeOpGrad
(
*
it
,
no_grad_vars
,
grad_to_var
,
{
backward_block
});
}
else
{
op_grads
=
MakeOpGrad
(
*
it
,
no_grad_vars
,
grad_to_var
);
...
...
paddle/operators/conditional_block_op.cc
浏览文件 @
dafd449c
...
...
@@ -65,7 +65,7 @@ class ConditionalBlockOp : public ConditionalOp {
scopes
->
front
()
=
&
scope
.
NewScope
();
auto
&
cur_scope
=
*
scopes
->
front
();
auto
*
block
=
Attr
<
framework
::
BlockDescBind
*>
(
"block"
);
auto
*
block
=
Attr
<
framework
::
BlockDescBind
*>
(
"
sub_
block"
);
framework
::
Executor
exec
(
dev_ctx
);
exec
.
Run
(
*
block
->
Program
(),
&
cur_scope
,
block
->
ID
(),
false
);
}
...
...
@@ -88,7 +88,7 @@ class ConditionalBlockOpProtoMaker : public framework::OpProtoAndCheckerMaker {
"unify the conditional block, rnn and while op, the type of "
"scope is std::vector<Scope*>"
);
AddAttr
<
framework
::
BlockDescBind
*>
(
"block"
,
"The step block of conditional block operator"
);
"
sub_
block"
,
"The step block of conditional block operator"
);
AddComment
(
R"DOC(Conditional block operator
Run the sub-block if X is not empty. Params is the other inputs and Out is the
...
...
@@ -117,7 +117,7 @@ class ConditionalBlockGradOp : public ConditionalOp {
auto
&
scopes
=
scope_var
->
Get
<
std
::
vector
<
framework
::
Scope
*>>
();
framework
::
Scope
&
cur_scope
=
*
scopes
[
0
];
auto
*
block
=
Attr
<
framework
::
BlockDescBind
*>
(
"block"
);
auto
*
block
=
Attr
<
framework
::
BlockDescBind
*>
(
"
sub_
block"
);
framework
::
Executor
exec
(
dev_ctx
);
exec
.
Run
(
*
block
->
Program
(),
&
cur_scope
,
block
->
ID
(),
false
);
...
...
@@ -181,7 +181,7 @@ class ConditionalBlockGradMaker : public framework::SingleGradOpDescMaker {
grad_op
->
SetInput
(
"Scope"
,
Output
(
"Scope"
));
grad_op
->
SetOutput
(
framework
::
GradVarName
(
"X"
),
InputGrad
(
"X"
));
grad_op
->
SetOutput
(
framework
::
GradVarName
(
"Params"
),
InputGrad
(
"Params"
));
grad_op
->
SetBlockAttr
(
"block"
,
*
this
->
grad_block_
[
0
]);
grad_op
->
SetBlockAttr
(
"
sub_
block"
,
*
this
->
grad_block_
[
0
]);
return
std
::
unique_ptr
<
framework
::
OpDescBind
>
(
grad_op
);
}
};
...
...
paddle/operators/recurrent_op.cc
浏览文件 @
dafd449c
...
...
@@ -25,7 +25,7 @@ constexpr char kOutputs[] = "outputs";
constexpr
char
kStepScopes
[]
=
"step_scopes"
;
constexpr
char
kExStates
[]
=
"ex_states"
;
constexpr
char
kStates
[]
=
"states"
;
constexpr
char
kStepBlock
[]
=
"s
tep
_block"
;
constexpr
char
kStepBlock
[]
=
"s
ub
_block"
;
constexpr
char
kReverse
[]
=
"reverse"
;
constexpr
char
kIsTrain
[]
=
"is_train"
;
#define GRAD_SUFFIX "@GRAD"
...
...
paddle/operators/while_op.cc
浏览文件 @
dafd449c
...
...
@@ -25,7 +25,7 @@ namespace operators {
using
StepScopeVar
=
std
::
vector
<
framework
::
Scope
*>
;
using
LoDTensor
=
framework
::
LoDTensor
;
constexpr
char
kStepBlock
[]
=
"s
tep
_block"
;
constexpr
char
kStepBlock
[]
=
"s
ub
_block"
;
constexpr
char
kCondition
[]
=
"Condition"
;
constexpr
char
kStepScopes
[]
=
"StepScopes"
;
constexpr
char
kParameters
[]
=
"X"
;
...
...
python/paddle/v2/fluid/layers.py
浏览文件 @
dafd449c
...
...
@@ -1130,7 +1130,7 @@ class StaticRNN(object):
attrs
=
{
'ex_states'
:
pre_memories
,
'states'
:
memories
,
's
tep
_block'
:
rnn_block
's
ub
_block'
:
rnn_block
})
...
...
@@ -1207,7 +1207,7 @@ class While(object):
},
outputs
=
{
'Out'
:
out_vars
,
'StepScopes'
:
[
step_scope
]},
attrs
=
{
's
tep
_block'
:
while_block
})
attrs
=
{
's
ub
_block'
:
while_block
})
def
lstm
(
x
,
...
...
@@ -1671,7 +1671,7 @@ class ConditionalBlock(object):
},
outputs
=
{
'Out'
:
out_list
,
'Scope'
:
[
step_scope
]},
attrs
=
{
'block'
:
inside_block
})
attrs
=
{
'
sub_
block'
:
inside_block
})
class
IfElseBlockGuard
(
object
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录