Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
9ac785be
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9ac785be
编写于
6月 07, 2018
作者:
C
chengduoZH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
check graph's validation
上级
50104f18
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
73 addition
and
2 deletion
+73
-2
paddle/fluid/framework/details/multi_devices_graph_builder.cc
...le/fluid/framework/details/multi_devices_graph_builder.cc
+0
-1
paddle/fluid/framework/details/ssa_graph_builder.cc
paddle/fluid/framework/details/ssa_graph_builder.cc
+69
-1
paddle/fluid/framework/details/ssa_graph_builder.h
paddle/fluid/framework/details/ssa_graph_builder.h
+3
-0
paddle/fluid/framework/details/threaded_ssa_graph_executor.cc
...le/fluid/framework/details/threaded_ssa_graph_executor.cc
+1
-0
未找到文件。
paddle/fluid/framework/details/multi_devices_graph_builder.cc
浏览文件 @
9ac785be
...
...
@@ -272,7 +272,6 @@ std::unique_ptr<SSAGraph> MultiDevSSAGraphBuilder::Build(
* Only variables should be the leaves of graph.
*/
AddOutputToLeafOps
(
&
result
);
return
std
::
unique_ptr
<
SSAGraph
>
(
graph
);
}
...
...
paddle/fluid/framework/details/ssa_graph_builder.cc
浏览文件 @
9ac785be
...
...
@@ -11,8 +11,8 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "paddle/fluid/framework/details/ssa_graph_builder.h"
#include <utility>
namespace
paddle
{
namespace
framework
{
...
...
@@ -83,6 +83,74 @@ void SSAGraphBuilder::AddOutputToLeafOps(SSAGraph *graph) {
op
->
AddOutput
(
dummy_leaf
);
}
}
std
::
unique_ptr
<
SSAGraph
>
SSAGraphBuilder
::
BuildAndCheck
(
const
ProgramDesc
&
program
)
final
{
std
::
unique_ptr
<
SSAGraph
>
graph
=
Build
(
program
);
PADDLE_ENFORCE
(
IsValidGraph
(
graph
.
get
()));
return
std
::
move
(
graph
);
}
bool
SSAGraphBuilder
::
IsValidGraph
(
const
SSAGraph
*
graph
)
const
{
std
::
unordered_map
<
OpHandleBase
*
,
size_t
>
pending_ops
;
std
::
unordered_set
<
VarHandleBase
*>
pending_vars
;
std
::
unordered_set
<
VarHandleBase
*>
ready_vars
;
std
::
unordered_set
<
OpHandleBase
*>
ready_ops
;
auto
insert_pending_var
=
[
&
](
VarHandleBase
*
var
)
{
pending_vars
.
insert
(
var
);
if
(
var
->
generated_op_
==
nullptr
)
{
ready_vars
.
emplace
(
var
);
}
};
for
(
auto
&
var_map
:
graph
->
vars_
)
{
for
(
auto
&
name_pair
:
var_map
)
{
for
(
auto
&
version_pair
:
name_pair
.
second
)
{
insert_pending_var
(
version_pair
.
get
());
}
}
}
for
(
auto
&
var
:
graph
->
dep_vars_
)
{
insert_pending_var
(
var
.
get
());
}
for
(
auto
&
op
:
graph
->
ops_
)
{
if
(
op
->
Inputs
().
empty
())
{
ready_ops
.
insert
(
op
.
get
());
}
else
{
pending_ops
.
insert
({
op
.
get
(),
op
.
get
()
->
NoDupInputSize
()});
}
}
auto
run_all_ops
=
[
&
](
std
::
unordered_set
<
OpHandleBase
*>
&
set
)
{
for
(
auto
*
op
:
set
)
{
for
(
auto
out
:
op
->
Outputs
())
{
ready_vars
.
emplace
(
out
);
}
}
set
.
clear
();
};
while
(
!
pending_vars
.
empty
())
{
run_all_ops
(
ready_ops
);
if
(
ready_vars
.
empty
())
{
return
false
;
}
for
(
auto
ready_var
:
ready_vars
.)
{
pending_vars
.
erase
(
ready_var
);
for
(
auto
*
op
:
ready_var
->
pending_ops_
)
{
auto
&
deps
=
--
pending_ops
[
op
];
if
(
deps
==
0
)
{
ready_ops
.
insert
(
op
);
}
}
}
ready_vars
.
clear
();
}
return
true
;
}
}
// namespace details
}
// namespace framework
}
// namespace paddle
paddle/fluid/framework/details/ssa_graph_builder.h
浏览文件 @
9ac785be
...
...
@@ -31,6 +31,8 @@ class SSAGraphBuilder {
virtual
~
SSAGraphBuilder
()
{}
virtual
std
::
unique_ptr
<
SSAGraph
>
Build
(
const
ProgramDesc
&
program
)
const
=
0
;
std
::
unique_ptr
<
SSAGraph
>
BuildAndCheck
(
const
ProgramDesc
&
program
)
final
;
DISABLE_COPY_AND_ASSIGN
(
SSAGraphBuilder
);
protected:
...
...
@@ -48,6 +50,7 @@ class SSAGraphBuilder {
const
platform
::
Place
&
place
,
size_t
place_offset
);
bool
IsValidGraph
(
const
SSAGraph
*
graph
)
const
;
// Add an output variable (each_var_name, place, place_offset) to op_handle,
// which belongs to graph
static
void
CreateOpOutput
(
SSAGraph
*
graph
,
OpHandleBase
*
op_handle
,
...
...
paddle/fluid/framework/details/threaded_ssa_graph_executor.cc
浏览文件 @
9ac785be
...
...
@@ -185,6 +185,7 @@ void ThreadedSSAGraphExecutor::InsertPendingVar(
ready_vars
->
Push
(
var
);
}
}
void
ThreadedSSAGraphExecutor
::
RunOp
(
BlockingQueue
<
VarHandleBase
*>
*
ready_var_q
,
details
::
OpHandleBase
*
op
)
{
auto
op_run
=
[
ready_var_q
,
op
,
this
]
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录