Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
bdd1404e
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
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看板
提交
bdd1404e
编写于
9月 22, 2017
作者:
D
dangqingqing
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' of
https://github.com/PaddlePaddle/Paddle
into lod_share
上级
4f9d82a9
7d33447d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
38 addition
and
9 deletion
+38
-9
cmake/util.cmake
cmake/util.cmake
+1
-1
paddle/framework/attribute.cc
paddle/framework/attribute.cc
+23
-7
paddle/framework/attribute.h
paddle/framework/attribute.h
+3
-1
paddle/framework/framework.proto
paddle/framework/framework.proto
+11
-0
未找到文件。
cmake/util.cmake
浏览文件 @
bdd1404e
...
...
@@ -25,7 +25,7 @@ function(target_circle_link_libraries TARGET_NAME)
endif
()
endforeach
()
if
(
"
${
CMAKE_CXX_COMPILER_ID
}
"
STREQUAL
"Clang"
OR
"
${
CMAKE_CXX_COMPILER_ID
}
"
STREQUAL
"AppleClang"
)
if
(
IOS AND
NOT IOS_ENABLE_BITCODE
)
if
(
NOT IOS_ENABLE_BITCODE
)
list
(
APPEND LIBS
"-undefined dynamic_lookup"
)
endif
()
endif
()
...
...
paddle/framework/attribute.cc
浏览文件 @
bdd1404e
...
...
@@ -19,6 +19,15 @@ limitations under the License. */
namespace
paddle
{
namespace
framework
{
static
ProgramDesc
*
g_program_desc
=
nullptr
;
ProgramDesc
&
GetProgramDesc
()
{
if
(
g_program_desc
==
nullptr
)
{
g_program_desc
=
new
ProgramDesc
();
}
return
*
g_program_desc
;
}
template
<
>
AttrType
AttrTypeID
<
int
>
()
{
return
INT
;
...
...
@@ -47,40 +56,44 @@ template <>
AttrType
AttrTypeID
<
std
::
vector
<
std
::
pair
<
int
,
int
>>>
()
{
return
INT_PAIRS
;
}
template
<
>
AttrType
AttrTypeID
<
BlockDesc
>
()
{
return
BLOCK
;
}
Attribute
GetAttrValue
(
const
OpDesc
::
Attr
&
attr_desc
)
{
switch
(
attr_desc
.
type
())
{
case
paddle
::
framework
::
AttrType
::
INT
:
{
case
framework
::
AttrType
::
INT
:
{
return
attr_desc
.
i
();
}
case
paddle
::
framework
::
AttrType
::
FLOAT
:
{
case
framework
::
AttrType
::
FLOAT
:
{
return
attr_desc
.
f
();
}
case
paddle
::
framework
::
AttrType
::
STRING
:
{
case
framework
::
AttrType
::
STRING
:
{
return
attr_desc
.
s
();
}
case
paddle
::
framework
::
AttrType
::
INTS
:
{
case
framework
::
AttrType
::
INTS
:
{
std
::
vector
<
int
>
val
(
attr_desc
.
ints_size
());
for
(
int
i
=
0
;
i
<
attr_desc
.
ints_size
();
++
i
)
{
val
[
i
]
=
attr_desc
.
ints
(
i
);
}
return
val
;
}
case
paddle
::
framework
::
AttrType
::
FLOATS
:
{
case
framework
::
AttrType
::
FLOATS
:
{
std
::
vector
<
float
>
val
(
attr_desc
.
floats_size
());
for
(
int
i
=
0
;
i
<
attr_desc
.
floats_size
();
++
i
)
{
val
[
i
]
=
attr_desc
.
floats
(
i
);
}
return
val
;
}
case
paddle
::
framework
::
AttrType
::
STRINGS
:
{
case
framework
::
AttrType
::
STRINGS
:
{
std
::
vector
<
std
::
string
>
val
(
attr_desc
.
strings_size
());
for
(
int
i
=
0
;
i
<
attr_desc
.
strings_size
();
++
i
)
{
val
[
i
]
=
attr_desc
.
strings
(
i
);
}
return
val
;
}
case
paddle
::
framework
::
AttrType
::
INT_PAIRS
:
{
case
framework
::
AttrType
::
INT_PAIRS
:
{
std
::
vector
<
std
::
pair
<
int
,
int
>>
val
(
attr_desc
.
int_pairs_size
());
for
(
int
i
=
0
;
i
<
attr_desc
.
int_pairs_size
();
++
i
)
{
val
[
i
].
first
=
attr_desc
.
int_pairs
(
i
).
first
();
...
...
@@ -88,6 +101,9 @@ Attribute GetAttrValue(const OpDesc::Attr& attr_desc) {
}
return
val
;
}
case
framework
::
AttrType
::
BLOCK
:
{
return
GetProgramDesc
().
mutable_blocks
(
attr_desc
.
block_idx
());
}
}
PADDLE_ENFORCE
(
false
,
"Unknown OpDesc::AttrDesc::type !"
);
return
boost
::
blank
();
...
...
paddle/framework/attribute.h
浏览文件 @
bdd1404e
...
...
@@ -29,11 +29,13 @@ namespace framework {
typedef
boost
::
variant
<
boost
::
blank
,
int
,
float
,
std
::
string
,
std
::
vector
<
int
>
,
std
::
vector
<
float
>
,
std
::
vector
<
std
::
string
>
,
std
::
vector
<
std
::
pair
<
int
,
int
>>>
std
::
vector
<
std
::
pair
<
int
,
int
>>
,
BlockDesc
*
>
Attribute
;
typedef
std
::
unordered_map
<
std
::
string
,
Attribute
>
AttributeMap
;
ProgramDesc
&
GetProgramDesc
();
template
<
typename
T
>
AttrType
AttrTypeID
();
...
...
paddle/framework/framework.proto
浏览文件 @
bdd1404e
...
...
@@ -23,6 +23,7 @@ enum AttrType {
FLOATS
=
4
;
STRINGS
=
5
;
INT_PAIRS
=
6
;
BLOCK
=
7
;
}
message
IntPair
{
...
...
@@ -44,6 +45,7 @@ message OpDesc {
repeated
float
floats
=
7
;
repeated
string
strings
=
8
;
repeated
IntPair
int_pairs
=
9
;
optional
int32
block_idx
=
10
;
};
message
Var
{
...
...
@@ -108,3 +110,12 @@ message VarDesc {
required
string
name
=
1
;
optional
LoDTensorDesc
lod_tensor
=
2
;
}
message
BlockDesc
{
required
int32
idx
=
1
;
required
int32
parent_idx
=
2
;
repeated
VarDesc
vars
=
3
;
repeated
OpDesc
ops
=
4
;
}
message
ProgramDesc
{
repeated
BlockDesc
blocks
=
1
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录