Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
b71af29f
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b71af29f
编写于
2月 26, 2019
作者:
M
minqiyang
提交者:
ceci3
3月 04, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove var op deps in imperative mode
test=develop
上级
690be0bb
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
29 addition
and
12 deletion
+29
-12
paddle/fluid/framework/block_desc.cc
paddle/fluid/framework/block_desc.cc
+1
-0
paddle/fluid/imperative/layer.cc
paddle/fluid/imperative/layer.cc
+3
-2
python/paddle/fluid/framework.py
python/paddle/fluid/framework.py
+3
-1
python/paddle/fluid/imperative/tracer.py
python/paddle/fluid/imperative/tracer.py
+5
-1
python/paddle/fluid/initializer.py
python/paddle/fluid/initializer.py
+17
-8
未找到文件。
paddle/fluid/framework/block_desc.cc
浏览文件 @
b71af29f
...
@@ -159,6 +159,7 @@ void BlockDesc::RemoveOpInternal(const OpDesc *op_desc) {
...
@@ -159,6 +159,7 @@ void BlockDesc::RemoveOpInternal(const OpDesc *op_desc) {
for
(
auto
it
=
ops_
.
begin
();
it
!=
ops_
.
end
();
++
it
)
{
for
(
auto
it
=
ops_
.
begin
();
it
!=
ops_
.
end
();
++
it
)
{
if
(
it
->
get
()
==
op_desc
)
{
if
(
it
->
get
()
==
op_desc
)
{
ops_
.
erase
(
it
);
ops_
.
erase
(
it
);
break
;
}
}
}
}
}
}
...
...
paddle/fluid/imperative/layer.cc
浏览文件 @
b71af29f
...
@@ -158,8 +158,9 @@ class Autograd {
...
@@ -158,8 +158,9 @@ class Autograd {
for
(
auto
it
:
candidate
->
pre_ops_
)
{
for
(
auto
it
:
candidate
->
pre_ops_
)
{
for
(
OpBase
*
pre_op
:
it
.
second
)
{
for
(
OpBase
*
pre_op
:
it
.
second
)
{
if
(
!
pre_op
)
continue
;
if
(
!
pre_op
)
continue
;
VLOG
(
5
)
<<
"op dep "
<<
candidate
->
op_desc_
->
Type
()
<<
" <---- "
VLOG
(
5
)
<<
"op dep "
<<
candidate
->
op_desc_
->
Type
()
<<
" "
<<
it
.
first
<<
" <---- "
<<
pre_op
->
op_desc_
->
Type
();
<<
candidate
->
trace_id_
<<
" <---- "
<<
it
.
first
<<
" <---- "
<<
pre_op
->
op_desc_
->
Type
()
<<
" "
<<
pre_op
->
trace_id_
;
if
(
visited
.
find
(
pre_op
)
==
visited
.
end
())
{
if
(
visited
.
find
(
pre_op
)
==
visited
.
end
())
{
visited
.
insert
(
pre_op
);
visited
.
insert
(
pre_op
);
queue
.
push_back
(
pre_op
);
queue
.
push_back
(
pre_op
);
...
...
python/paddle/fluid/framework.py
浏览文件 @
b71af29f
...
@@ -723,7 +723,9 @@ class Operator(object):
...
@@ -723,7 +723,9 @@ class Operator(object):
out_arg_names
=
[]
out_arg_names
=
[]
for
arg
in
out_args
:
for
arg
in
out_args
:
out_arg_names
.
append
(
cpt
.
to_text
(
arg
.
name
))
out_arg_names
.
append
(
cpt
.
to_text
(
arg
.
name
))
arg
.
op
=
self
# TODO(minqiyang): could we remove variable's op in static mode?
if
not
_in_imperative_mode
():
arg
.
op
=
self
self
.
desc
.
set_output
(
out_proto
.
name
,
out_arg_names
)
self
.
desc
.
set_output
(
out_proto
.
name
,
out_arg_names
)
if
op_attrs
is
not
None
:
if
op_attrs
is
not
None
:
...
...
python/paddle/fluid/imperative/tracer.py
浏览文件 @
b71af29f
...
@@ -24,6 +24,10 @@ __all__ = ['Tracer']
...
@@ -24,6 +24,10 @@ __all__ = ['Tracer']
def
release_op
(
op
):
def
release_op
(
op
):
import
gc
assert
len
(
gc
.
get_referrers
(
framework
.
_imperative_tracer
().
_ops
[
op
.
_trace_id
]))
==
1
del
framework
.
_imperative_tracer
().
_ops
[
op
.
_trace_id
]
del
framework
.
_imperative_tracer
().
_ops
[
op
.
_trace_id
]
...
@@ -41,7 +45,6 @@ class Tracer(core.Tracer):
...
@@ -41,7 +45,6 @@ class Tracer(core.Tracer):
def
trace_op
(
self
,
op
,
stop_gradient
=
False
):
def
trace_op
(
self
,
op
,
stop_gradient
=
False
):
# record op's trace id
# record op's trace id
op
.
iop
.
_trace_id
=
self
.
_trace_id
op
.
iop
.
_trace_id
=
self
.
_trace_id
self
.
_trace_id
+=
1
# trace op and save it
# trace op and save it
backward_refs
=
self
.
trace
(
op
.
iop
,
op
.
inputs
,
op
.
outputs
,
op
.
block
.
desc
,
backward_refs
=
self
.
trace
(
op
.
iop
,
op
.
inputs
,
op
.
outputs
,
op
.
block
.
desc
,
...
@@ -49,6 +52,7 @@ class Tracer(core.Tracer):
...
@@ -49,6 +52,7 @@ class Tracer(core.Tracer):
stop_gradient
)
stop_gradient
)
if
not
stop_gradient
:
if
not
stop_gradient
:
self
.
_trace_id
+=
1
self
.
_ops
[
op
.
iop
.
_trace_id
]
=
op
self
.
_ops
[
op
.
iop
.
_trace_id
]
=
op
# register backward hooks and variables if needed
# register backward hooks and variables if needed
...
...
python/paddle/fluid/initializer.py
浏览文件 @
b71af29f
...
@@ -19,6 +19,7 @@ import numpy as np
...
@@ -19,6 +19,7 @@ import numpy as np
from
.wrapped_decorator
import
signature_safe_contextmanager
from
.wrapped_decorator
import
signature_safe_contextmanager
from
.core
import
VarDesc
from
.core
import
VarDesc
from
.
import
unique_name
from
.
import
unique_name
from
.imperative
import
base
__all__
=
[
__all__
=
[
'Constant'
,
'Uniform'
,
'Normal'
,
'TruncatedNormal'
,
'Xavier'
,
'Bilinear'
,
'Constant'
,
'Uniform'
,
'Normal'
,
'TruncatedNormal'
,
'Xavier'
,
'Bilinear'
,
...
@@ -165,7 +166,8 @@ class ConstantInitializer(Initializer):
...
@@ -165,7 +166,8 @@ class ConstantInitializer(Initializer):
'force_cpu'
:
self
.
_force_cpu
or
force_init_on_cpu
()
'force_cpu'
:
self
.
_force_cpu
or
force_init_on_cpu
()
},
},
stop_gradient
=
True
)
stop_gradient
=
True
)
var
.
op
=
op
if
not
base
.
enabled
():
var
.
op
=
op
return
op
return
op
...
@@ -244,7 +246,8 @@ class UniformInitializer(Initializer):
...
@@ -244,7 +246,8 @@ class UniformInitializer(Initializer):
attrs
=
{
"in_dtype"
:
out_var
.
dtype
,
attrs
=
{
"in_dtype"
:
out_var
.
dtype
,
"out_dtype"
:
var
.
dtype
})
"out_dtype"
:
var
.
dtype
})
var
.
op
=
op
if
not
base
.
enabled
():
var
.
op
=
op
return
op
return
op
...
@@ -322,7 +325,8 @@ class NormalInitializer(Initializer):
...
@@ -322,7 +325,8 @@ class NormalInitializer(Initializer):
outputs
=
{
"Out"
:
var
},
outputs
=
{
"Out"
:
var
},
attrs
=
{
"in_dtype"
:
out_var
.
dtype
,
attrs
=
{
"in_dtype"
:
out_var
.
dtype
,
"out_dtype"
:
var
.
dtype
})
"out_dtype"
:
var
.
dtype
})
var
.
op
=
op
if
not
base
.
enabled
():
var
.
op
=
op
return
op
return
op
...
@@ -400,7 +404,8 @@ class TruncatedNormalInitializer(Initializer):
...
@@ -400,7 +404,8 @@ class TruncatedNormalInitializer(Initializer):
outputs
=
{
"Out"
:
var
},
outputs
=
{
"Out"
:
var
},
attrs
=
{
"in_dtype"
:
out_var
.
dtype
,
attrs
=
{
"in_dtype"
:
out_var
.
dtype
,
"out_dtype"
:
var
.
dtype
})
"out_dtype"
:
var
.
dtype
})
var
.
op
=
op
if
not
base
.
enabled
():
var
.
op
=
op
return
op
return
op
...
@@ -505,7 +510,8 @@ class XavierInitializer(Initializer):
...
@@ -505,7 +510,8 @@ class XavierInitializer(Initializer):
"seed"
:
self
.
_seed
"seed"
:
self
.
_seed
},
},
stop_gradient
=
True
)
stop_gradient
=
True
)
var
.
op
=
op
if
not
base
.
enabled
():
var
.
op
=
op
return
op
return
op
...
@@ -605,7 +611,8 @@ class MSRAInitializer(Initializer):
...
@@ -605,7 +611,8 @@ class MSRAInitializer(Initializer):
"seed"
:
self
.
_seed
"seed"
:
self
.
_seed
},
},
stop_gradient
=
True
)
stop_gradient
=
True
)
var
.
op
=
op
if
not
base
.
enabled
():
var
.
op
=
op
return
op
return
op
...
@@ -703,7 +710,8 @@ class BilinearInitializer(Initializer):
...
@@ -703,7 +710,8 @@ class BilinearInitializer(Initializer):
'shape'
:
list
(
shape
),
'shape'
:
list
(
shape
),
value_name
:
values
value_name
:
values
})
})
var
.
op
=
op
if
not
base
.
enabled
():
var
.
op
=
op
return
op
return
op
...
@@ -761,7 +769,8 @@ class NumpyArrayInitializer(Initializer):
...
@@ -761,7 +769,8 @@ class NumpyArrayInitializer(Initializer):
value_name
:
values
value_name
:
values
},
},
stop_gradient
=
True
)
stop_gradient
=
True
)
var
.
op
=
op
if
not
base
.
enabled
():
var
.
op
=
op
return
op
return
op
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录