Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
18afb77e
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
18afb77e
编写于
2月 18, 2019
作者:
D
dzhwinter
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
polish code for reading. test=develop
上级
684b5723
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
32 addition
and
1 deletion
+32
-1
paddle/fluid/framework/details/memory_optimize_pass.cc
paddle/fluid/framework/details/memory_optimize_pass.cc
+27
-1
paddle/fluid/framework/details/memory_optimize_pass.h
paddle/fluid/framework/details/memory_optimize_pass.h
+1
-0
python/paddle/fluid/tests/unittests/test_fuse_elewise_add_act_pass.py
...e/fluid/tests/unittests/test_fuse_elewise_add_act_pass.py
+4
-0
未找到文件。
paddle/fluid/framework/details/memory_optimize_pass.cc
浏览文件 @
18afb77e
...
@@ -128,7 +128,7 @@ std::unique_ptr<ir::Graph> MemoryOptimizePass::ApplyImpl(
...
@@ -128,7 +128,7 @@ std::unique_ptr<ir::Graph> MemoryOptimizePass::ApplyImpl(
}
}
}
}
}
}
graph
->
ResolveHazard
(
var_nodes_
);
//
graph->ResolveHazard(var_nodes_);
return
graph
;
return
graph
;
}
}
...
@@ -324,6 +324,32 @@ void MemoryOptimizePass::RenameVarInGraphNode(const std::string& var,
...
@@ -324,6 +324,32 @@ void MemoryOptimizePass::RenameVarInGraphNode(const std::string& var,
}
}
}
}
void
MemoryOptimizePass
::
ClearControlDepVars
(
ir
::
Graph
*
graph
)
const
{
for
(
auto
&
op
:
graph
->
Nodes
())
{
if
(
!
op
->
IsOp
())
continue
;
{
auto
&
nodes
=
op
->
inputs
;
nodes
.
erase
(
std
::
remove_if
(
nodes
.
begin
(),
nodes
.
end
(),
[
&
](
ir
::
Node
*
var
)
{
return
var
->
IsCtrlVar
();
}),
nodes
.
end
());
}
{
auto
&
nodes
=
op
->
outputs
;
nodes
.
erase
(
std
::
remove_if
(
nodes
.
begin
(),
nodes
.
end
(),
[
&
](
ir
::
Node
*
var
)
{
return
var
->
IsCtrlVar
();
}),
nodes
.
end
());
}
}
for
(
auto
&
node
:
graph
->
Nodes
())
{
if
(
node
->
IsCtrlVar
())
{
graph
->
RemoveNode
(
node
);
}
}
}
}
// namespace details
}
// namespace details
}
// namespace framework
}
// namespace framework
}
// namespace paddle
}
// namespace paddle
...
...
paddle/fluid/framework/details/memory_optimize_pass.h
浏览文件 @
18afb77e
...
@@ -48,6 +48,7 @@ class MemoryOptimizePass : public ir::Pass {
...
@@ -48,6 +48,7 @@ class MemoryOptimizePass : public ir::Pass {
void
RenameVarInGraphNode
(
const
std
::
string
&
var
,
void
RenameVarInGraphNode
(
const
std
::
string
&
var
,
const
std
::
string
&
cache_var
,
size_t
idx
,
const
std
::
string
&
cache_var
,
size_t
idx
,
ir
::
Graph
*
graph
)
const
;
ir
::
Graph
*
graph
)
const
;
void
ClearControlDepVars
(
ir
::
Graph
*
graph
)
const
;
void
SubGraphOptimize
(
OpDesc
*
op_desc
)
const
;
void
SubGraphOptimize
(
OpDesc
*
op_desc
)
const
;
// 1. scan op with subblock and collect the output/input vars.
// 1. scan op with subblock and collect the output/input vars.
...
...
python/paddle/fluid/tests/unittests/test_fuse_elewise_add_act_pass.py
浏览文件 @
18afb77e
...
@@ -121,6 +121,8 @@ class TestMNIST(TestParallelExecutorBase):
...
@@ -121,6 +121,8 @@ class TestMNIST(TestParallelExecutorBase):
regularization
=
fluid
.
regularizer
.
L2Decay
(
1e-6
))
regularization
=
fluid
.
regularizer
.
L2Decay
(
1e-6
))
return
optimizer
return
optimizer
# NOTE(dzh):
# need to make it compatible with elewise fuse act
not_fuse_op_first_loss
,
not_fuse_op_last_loss
=
self
.
check_network_convergence
(
not_fuse_op_first_loss
,
not_fuse_op_last_loss
=
self
.
check_network_convergence
(
model
,
model
,
feed_dict
=
{
"image"
:
img
,
feed_dict
=
{
"image"
:
img
,
...
@@ -128,6 +130,7 @@ class TestMNIST(TestParallelExecutorBase):
...
@@ -128,6 +130,7 @@ class TestMNIST(TestParallelExecutorBase):
use_cuda
=
use_cuda
,
use_cuda
=
use_cuda
,
fuse_elewise_add_act_ops
=
False
,
fuse_elewise_add_act_ops
=
False
,
memory_opt
=
False
,
memory_opt
=
False
,
use_ir_memory_optimize
=
False
,
optimizer
=
_optimizer
)
optimizer
=
_optimizer
)
fuse_op_first_loss
,
fuse_op_last_loss
=
self
.
check_network_convergence
(
fuse_op_first_loss
,
fuse_op_last_loss
=
self
.
check_network_convergence
(
model
,
model
,
...
@@ -136,6 +139,7 @@ class TestMNIST(TestParallelExecutorBase):
...
@@ -136,6 +139,7 @@ class TestMNIST(TestParallelExecutorBase):
use_cuda
=
use_cuda
,
use_cuda
=
use_cuda
,
fuse_elewise_add_act_ops
=
True
,
fuse_elewise_add_act_ops
=
True
,
memory_opt
=
False
,
memory_opt
=
False
,
use_ir_memory_optimize
=
False
,
optimizer
=
_optimizer
)
optimizer
=
_optimizer
)
for
loss
in
zip
(
not_fuse_op_first_loss
,
fuse_op_first_loss
):
for
loss
in
zip
(
not_fuse_op_first_loss
,
fuse_op_first_loss
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录