Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
bae5930b
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看板
未验证
提交
bae5930b
编写于
3月 24, 2020
作者:
Z
Zeng Jinle
提交者:
GitHub
3月 25, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix graph attr copy issues, test=develop (#23191)
上级
092a62e2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
35 addition
and
0 deletion
+35
-0
paddle/fluid/framework/details/multi_devices_helper.cc
paddle/fluid/framework/details/multi_devices_helper.cc
+8
-0
paddle/fluid/framework/details/multi_devices_helper.h
paddle/fluid/framework/details/multi_devices_helper.h
+9
-0
paddle/fluid/framework/ir/graph_test.cc
paddle/fluid/framework/ir/graph_test.cc
+18
-0
未找到文件。
paddle/fluid/framework/details/multi_devices_helper.cc
浏览文件 @
bae5930b
...
@@ -171,6 +171,10 @@ std::vector<std::unique_ptr<ir::Graph>> TrySeparateToMultipleSingleDeviceGraphs(
...
@@ -171,6 +171,10 @@ std::vector<std::unique_ptr<ir::Graph>> TrySeparateToMultipleSingleDeviceGraphs(
"issue at https://github.com/PaddlePaddle/Paddle/issues/new. And "
"issue at https://github.com/PaddlePaddle/Paddle/issues/new. And "
"we will resolve it with high priority."
));
"we will resolve it with high priority."
));
if
(
place_num
==
1
)
{
return
{};
}
std
::
vector
<
std
::
unique_ptr
<
ir
::
Graph
>>
graphs
(
place_num
);
std
::
vector
<
std
::
unique_ptr
<
ir
::
Graph
>>
graphs
(
place_num
);
for
(
auto
&
g
:
graphs
)
{
for
(
auto
&
g
:
graphs
)
{
g
.
reset
(
new
ir
::
Graph
(
ProgramDesc
()));
g
.
reset
(
new
ir
::
Graph
(
ProgramDesc
()));
...
@@ -208,6 +212,10 @@ std::vector<std::unique_ptr<ir::Graph>> TrySeparateToMultipleSingleDeviceGraphs(
...
@@ -208,6 +212,10 @@ std::vector<std::unique_ptr<ir::Graph>> TrySeparateToMultipleSingleDeviceGraphs(
graph
->
Erase
(
kGraphVars
);
graph
->
Erase
(
kGraphVars
);
graph
->
Erase
(
kGraphDepVars
);
graph
->
Erase
(
kGraphDepVars
);
for
(
auto
&
g
:
graphs
)
{
CopyGraphAttrIfExists
<
ProgramDescs
>
(
*
graph
,
g
.
get
(),
kProgramDescs
);
CopyGraphAttrIfExists
<
FusedVars
>
(
*
graph
,
g
.
get
(),
kFusedVars
);
}
return
graphs
;
return
graphs
;
}
}
...
...
paddle/fluid/framework/details/multi_devices_helper.h
浏览文件 @
bae5930b
...
@@ -108,6 +108,15 @@ bool HasDropLastReadOp(const ir::Graph &graph);
...
@@ -108,6 +108,15 @@ bool HasDropLastReadOp(const ir::Graph &graph);
bool
HasKeepLastReadOp
(
const
ir
::
Graph
&
graph
);
bool
HasKeepLastReadOp
(
const
ir
::
Graph
&
graph
);
template
<
typename
T
>
void
CopyGraphAttrIfExists
(
const
ir
::
Graph
&
src
,
ir
::
Graph
*
dst
,
const
std
::
string
&
name
)
{
if
(
src
.
Has
(
name
))
{
auto
&
attr
=
src
.
Get
<
T
>
(
name
);
dst
->
Set
(
name
,
new
T
(
attr
));
}
}
}
// namespace details
}
// namespace details
}
// namespace framework
}
// namespace framework
}
// namespace paddle
}
// namespace paddle
paddle/fluid/framework/ir/graph_test.cc
浏览文件 @
bae5930b
...
@@ -14,6 +14,7 @@ limitations under the License. */
...
@@ -14,6 +14,7 @@ limitations under the License. */
#include "paddle/fluid/framework/ir/graph.h"
#include "paddle/fluid/framework/ir/graph.h"
#include "gtest/gtest.h"
#include "gtest/gtest.h"
#include "paddle/fluid/framework/details/multi_devices_helper.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/framework/program_desc.h"
#include "paddle/fluid/framework/program_desc.h"
...
@@ -252,5 +253,22 @@ TEST(GraphTest, TestException) {
...
@@ -252,5 +253,22 @@ TEST(GraphTest, TestException) {
}
}
ASSERT_TRUE
(
not_met_exception
);
ASSERT_TRUE
(
not_met_exception
);
}
}
TEST
(
GraphTest
,
TestAttrCopy
)
{
ProgramDesc
prog
;
ir
::
Graph
src_g
(
prog
);
ir
::
Graph
dst_g
(
prog
);
const
std
::
string
kIntValue
=
"int_value"
;
const
std
::
string
kFloatValue
=
"float_value"
;
const
int
INT_VALUE
=
3
;
src_g
.
Set
<
int
>
(
kIntValue
,
new
int
(
INT_VALUE
));
details
::
CopyGraphAttrIfExists
<
int
>
(
src_g
,
&
dst_g
,
kIntValue
);
details
::
CopyGraphAttrIfExists
<
float
>
(
src_g
,
&
dst_g
,
kFloatValue
);
ASSERT_TRUE
(
dst_g
.
Has
(
kIntValue
));
ASSERT_EQ
(
dst_g
.
Get
<
int
>
(
kIntValue
),
INT_VALUE
);
ASSERT_FALSE
(
dst_g
.
Has
(
kFloatValue
));
}
}
// namespace framework
}
// namespace framework
}
// namespace paddle
}
// namespace paddle
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录