Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
dc68e7c4
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看板
提交
dc68e7c4
编写于
2月 05, 2018
作者:
K
Kexin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix constructor bug
上级
6f0e630c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
21 addition
and
14 deletion
+21
-14
paddle/framework/op_desc.cc
paddle/framework/op_desc.cc
+3
-6
paddle/framework/program_desc.cc
paddle/framework/program_desc.cc
+18
-8
未找到文件。
paddle/framework/op_desc.cc
浏览文件 @
dc68e7c4
...
...
@@ -133,13 +133,10 @@ OpDesc::OpDesc(const proto::OpDesc &desc, ProgramDesc *prog, BlockDesc *block)
size_t
blk_idx
=
attr
.
block_idx
();
if
(
blk_idx
<
prog
->
Size
())
{
attrs_
[
attr_name
]
=
prog
->
MutableBlock
(
blk_idx
);
}
else
{
std
::
cout
<<
"Setting blockdesc attribute for id "
<<
blk_idx
std
::
cout
<<
"In OpDesc: set up attr block idx "
<<
blk_idx
<<
std
::
endl
;
attrs_
[
attr_name
]
=
reinterpret_cast
<
BlockDesc
*>
(
blk_idx
);
std
::
cout
<<
"Testing reinterpret_cast result is "
<<
reinterpret_cast
<
size_t
>
(
boost
::
get
<
BlockDesc
*>
(
attrs_
[
attr_name
]))
}
else
{
std
::
cout
<<
"In OpDesc: We don't have this block idx "
<<
blk_idx
<<
std
::
endl
;
}
}
...
...
paddle/framework/program_desc.cc
浏览文件 @
dc68e7c4
...
...
@@ -48,6 +48,18 @@ ProgramDesc::ProgramDesc(const ProgramDesc &o) {
auto
*
block
=
desc_
.
mutable_blocks
(
i
);
blocks_
.
emplace_back
(
new
BlockDesc
(
*
o
.
blocks_
[
i
],
block
,
this
));
}
for
(
auto
&
block
:
blocks_
)
{
for
(
auto
*
op
:
block
->
AllOps
())
{
for
(
const
auto
&
attr
:
op
->
Proto
()
->
attrs
())
{
if
(
attr
.
type
()
==
proto
::
AttrType
::
BLOCK
)
{
size_t
blk_idx
=
attr
.
block_idx
();
op
->
SetBlockAttr
(
attr
.
name
(),
*
this
->
MutableBlock
(
blk_idx
));
std
::
cout
<<
"In ProgramDesc 1: set block attr idx "
<<
blk_idx
<<
std
::
endl
;
}
}
}
}
}
ProgramDesc
::
ProgramDesc
(
const
proto
::
ProgramDesc
&
desc
)
{
...
...
@@ -60,14 +72,12 @@ ProgramDesc::ProgramDesc(const proto::ProgramDesc &desc) {
}
for
(
auto
&
block
:
blocks_
)
{
for
(
auto
*
op
:
block
->
AllOps
())
{
for
(
auto
&
name
:
op
->
AttrNames
())
{
if
(
op
->
GetAttrType
(
name
)
==
proto
::
AttrType
::
BLOCK
)
{
auto
attr
=
op
->
GetAttr
(
name
);
size_t
blk_idx
=
reinterpret_cast
<
size_t
>
(
boost
::
get
<
BlockDesc
*>
(
attr
));
op
->
SetBlockAttr
(
name
,
*
this
->
MutableBlock
(
blk_idx
));
std
::
cout
<<
"Update attr name "
<<
name
<<
" for block idx "
<<
blk_idx
<<
std
::
endl
;
for
(
const
auto
&
attr
:
op
->
Proto
()
->
attrs
())
{
if
(
attr
.
type
()
==
proto
::
AttrType
::
BLOCK
)
{
size_t
blk_idx
=
attr
.
block_idx
();
op
->
SetBlockAttr
(
attr
.
name
(),
*
this
->
MutableBlock
(
blk_idx
));
std
::
cout
<<
"In ProgramDesc 2: set block attr idx "
<<
blk_idx
<<
std
::
endl
;
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录