Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
1b9c8d5f
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
1b9c8d5f
编写于
3月 07, 2019
作者:
Z
Zhen Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add clone function for IrGraph. test=develop
上级
08e75731
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
28 addition
and
2 deletion
+28
-2
paddle/fluid/framework/ir/graph.cc
paddle/fluid/framework/ir/graph.cc
+3
-0
paddle/fluid/framework/ir/graph.h
paddle/fluid/framework/ir/graph.h
+2
-0
paddle/fluid/pybind/ir.cc
paddle/fluid/pybind/ir.cc
+2
-0
python/paddle/fluid/contrib/slim/tests/test_graph.py
python/paddle/fluid/contrib/slim/tests/test_graph.py
+11
-2
python/paddle/fluid/framework.py
python/paddle/fluid/framework.py
+10
-0
未找到文件。
paddle/fluid/framework/ir/graph.cc
浏览文件 @
1b9c8d5f
...
...
@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License. */
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include "paddle/fluid/framework/ir/graph.h"
...
...
@@ -29,6 +30,8 @@ Graph::Graph(const ProgramDesc &program) : program_(program) {
ResolveHazard
(
var_nodes
);
}
Graph
::
Graph
(
const
Graph
&
o
)
:
Graph
(
o
.
program_
)
{}
std
::
map
<
std
::
string
,
std
::
vector
<
ir
::
Node
*>>
Graph
::
InitFromProgram
(
const
ProgramDesc
&
program
)
{
VLOG
(
3
)
<<
"block in program:"
<<
program_
.
Size
();
...
...
paddle/fluid/framework/ir/graph.h
浏览文件 @
1b9c8d5f
...
...
@@ -17,6 +17,7 @@ limitations under the License. */
#include <map>
#include <memory>
#include <string>
#include <unordered_set>
#include <vector>
#include "paddle/fluid/framework/ir/node.h"
...
...
@@ -71,6 +72,7 @@ namespace ir {
class
Graph
{
public:
explicit
Graph
(
const
ProgramDesc
&
program
);
Graph
(
const
Graph
&
o
);
virtual
~
Graph
()
{
for
(
auto
&
attr
:
attrs_
)
{
...
...
paddle/fluid/pybind/ir.cc
浏览文件 @
1b9c8d5f
...
...
@@ -54,6 +54,8 @@ void BindGraph(py::module *m) {
"The graph is a Directed Acyclic Single Static Assignment Graph, see "
"`paddle::ir::Graph` for details."
)
.
def
(
py
::
init
<
const
ProgramDesc
&>
())
.
def
(
"__init__"
,
[](
Graph
&
self
,
const
Graph
&
other
)
{
new
(
&
self
)
Graph
(
other
);
})
.
def
(
"has"
,
&
Graph
::
Has
)
.
def
(
"get_int"
,
&
Graph
::
Get
<
int
>
)
.
def
(
"get_float"
,
&
Graph
::
Get
<
float
>
)
...
...
python/paddle/fluid/contrib/slim/tests/test_graph.py
浏览文件 @
1b9c8d5f
...
...
@@ -52,7 +52,7 @@ def residual_block(num):
class
TestGraph
(
unittest
.
TestCase
):
def
test_graph_functions
(
self
):
def
test_graph_functions
(
self
,
for_ci
=
True
):
main
=
fluid
.
Program
()
startup
=
fluid
.
Program
()
with
fluid
.
program_guard
(
main
,
startup
):
...
...
@@ -60,11 +60,20 @@ class TestGraph(unittest.TestCase):
opt
=
fluid
.
optimizer
.
Adam
(
learning_rate
=
0.001
)
opt
.
minimize
(
loss
)
graph
=
IrGraph
(
core
.
Graph
(
main
.
desc
),
for_test
=
False
)
backup_graph
=
graph
.
clone
()
self
.
assertEqual
(
len
(
graph
.
all_nodes
()),
len
(
backup_graph
.
all_nodes
()))
marked_nodes
=
set
()
for
op
in
graph
.
all_op_nodes
():
if
op
.
name
().
find
(
'conv2d'
)
>
-
1
:
marked_nodes
.
add
(
op
)
graph
.
draw
(
'.'
,
'residual'
,
marked_nodes
)
if
not
for_ci
:
graph
.
draw
(
'.'
,
'residual'
,
marked_nodes
)
backup_marked_nodes
=
set
()
for
op
in
backup_graph
.
all_op_nodes
():
if
op
.
name
().
find
(
'conv2d'
)
>
-
1
:
backup_marked_nodes
.
add
(
op
)
backup_graph
.
draw
(
'.'
,
'backup'
,
backup_marked_nodes
)
self
.
assertFalse
(
graph
.
has_circle
())
self
.
assertEqual
(
graph
.
graph_num
(),
1
)
nodes
=
graph
.
topology_sort
()
...
...
python/paddle/fluid/framework.py
浏览文件 @
1b9c8d5f
...
...
@@ -2002,6 +2002,16 @@ class IrGraph(object):
self
.
graph
=
graph
self
.
_for_test
=
for_test
def
clone
(
self
):
"""
Create a new and duplicated IrGraph.
Returns:
IrGraph: A new and duplicated graph.
"""
g
=
core
.
Graph
(
self
.
graph
)
return
IrGraph
(
g
,
self
.
_for_test
)
def
is_test
(
self
):
"""
If the graph is used for testing, the function returns true. Otherwise, returns false.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录