Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
b4ebb3c8
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b4ebb3c8
编写于
8月 05, 2017
作者:
Y
Yu Yang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Change attr_type_pb2 to attribute_pb2
Make ci pass
上级
b8ff8275
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
34 addition
and
36 deletion
+34
-36
python/paddle/v2/framework/create_op_creation_methods.py
python/paddle/v2/framework/create_op_creation_methods.py
+15
-15
python/paddle/v2/framework/tests/test_op_creation_methods.py
python/paddle/v2/framework/tests/test_op_creation_methods.py
+17
-17
python/paddle/v2/framework/tests/test_protobuf.py
python/paddle/v2/framework/tests/test_protobuf.py
+2
-4
未找到文件。
python/paddle/v2/framework/create_op_creation_methods.py
浏览文件 @
b4ebb3c8
import
paddle.v2.framework.core
as
core
import
paddle.v2.framework.proto.op_proto_pb2
as
op_proto_pb2
import
paddle.v2.framework.proto.op_desc_pb2
as
op_desc_pb2
import
paddle.v2.framework.proto.attr
_type_pb2
as
attr_typ
e_pb2
import
paddle.v2.framework.proto.attr
ibute_pb2
as
attribut
e_pb2
import
cStringIO
...
...
@@ -57,7 +57,7 @@ class OpDescCreationMethod(object):
op_desc
.
attrs
.
extend
([
out_format
])
if
len
(
tmp_index
)
!=
0
:
tmp_index_attr
=
op_desc
.
attrs
.
add
()
tmp_index_attr
.
type
=
attr
_typ
e_pb2
.
INTS
tmp_index_attr
.
type
=
attr
ibut
e_pb2
.
INTS
tmp_index_attr
.
name
=
"temporary_index"
tmp_index_attr
.
ints
.
extend
(
tmp_index
)
...
...
@@ -73,17 +73,17 @@ class OpDescCreationMethod(object):
new_attr
=
op_desc
.
attrs
.
add
()
new_attr
.
name
=
attr
.
name
new_attr
.
type
=
attr
.
type
if
attr
.
type
==
attr
_typ
e_pb2
.
INT
:
if
attr
.
type
==
attr
ibut
e_pb2
.
INT
:
new_attr
.
i
=
user_defined_attr
elif
attr
.
type
==
attr
_typ
e_pb2
.
FLOAT
:
elif
attr
.
type
==
attr
ibut
e_pb2
.
FLOAT
:
new_attr
.
f
=
user_defined_attr
elif
attr
.
type
==
attr
_typ
e_pb2
.
STRING
:
elif
attr
.
type
==
attr
ibut
e_pb2
.
STRING
:
new_attr
.
s
=
user_defined_attr
elif
attr
.
type
==
attr
_typ
e_pb2
.
INTS
:
elif
attr
.
type
==
attr
ibut
e_pb2
.
INTS
:
new_attr
.
ints
.
extend
(
user_defined_attr
)
elif
attr
.
type
==
attr
_typ
e_pb2
.
FLOATS
:
elif
attr
.
type
==
attr
ibut
e_pb2
.
FLOATS
:
new_attr
.
floats
.
extend
(
user_defined_attr
)
elif
attr
.
type
==
attr
_typ
e_pb2
.
STRINGS
:
elif
attr
.
type
==
attr
ibut
e_pb2
.
STRINGS
:
new_attr
.
strings
.
extend
(
user_defined_attr
)
else
:
raise
NotImplementedError
(
"Not support attribute type "
+
...
...
@@ -109,7 +109,7 @@ class OpDescCreationMethod(object):
retv
=
[]
if
multiple
:
var_format
=
op_desc_pb2
.
AttrDesc
()
var_format
.
type
=
attr
_typ
e_pb2
.
INTS
var_format
.
type
=
attr
ibut
e_pb2
.
INTS
var_format
.
name
=
"%s_format"
%
in_out
var_format
.
ints
.
append
(
0
)
...
...
@@ -185,17 +185,17 @@ def get_docstring_from_op_proto(op_proto):
for
attr
in
op_proto
.
attrs
:
attr_type
=
None
if
attr
.
type
==
attr
_typ
e_pb2
.
INT
:
if
attr
.
type
==
attr
ibut
e_pb2
.
INT
:
attr_type
=
"int"
elif
attr
.
type
==
attr
_typ
e_pb2
.
FLOAT
:
elif
attr
.
type
==
attr
ibut
e_pb2
.
FLOAT
:
attr_type
=
"float"
elif
attr
.
type
==
attr
_typ
e_pb2
.
STRING
:
elif
attr
.
type
==
attr
ibut
e_pb2
.
STRING
:
attr_type
=
"basestr"
elif
attr
.
type
==
attr
_typ
e_pb2
.
INTS
:
elif
attr
.
type
==
attr
ibut
e_pb2
.
INTS
:
attr_type
=
"list of int"
elif
attr
.
type
==
attr
_typ
e_pb2
.
FLOATS
:
elif
attr
.
type
==
attr
ibut
e_pb2
.
FLOATS
:
attr_type
=
"list of float"
elif
attr
.
type
==
attr
_typ
e_pb2
.
STRINGS
:
elif
attr
.
type
==
attr
ibut
e_pb2
.
STRINGS
:
attr_type
=
"list of basestr"
if
attr_type
is
None
:
...
...
python/paddle/v2/framework/tests/test_op_creation_methods.py
浏览文件 @
b4ebb3c8
...
...
@@ -3,7 +3,7 @@ import paddle.v2.framework.create_op_creation_methods as creation
import
paddle.v2.framework.core
as
core
import
paddle.v2.framework.proto.op_proto_pb2
as
op_proto_pb2
import
paddle.v2.framework.proto.op_desc_pb2
as
op_desc_pb2
import
paddle.v2.framework.proto.attr
_type_pb2
as
attr_typ
e_pb2
import
paddle.v2.framework.proto.attr
ibute_pb2
as
attribut
e_pb2
class
TestGetAllProtos
(
unittest
.
TestCase
):
...
...
@@ -76,7 +76,7 @@ class TestOpDescCreationMethod(unittest.TestCase):
expected1
.
type
=
'fc'
attr
=
expected1
.
attrs
.
add
()
attr
.
name
=
'input_format'
attr
.
type
=
attr
_typ
e_pb2
.
INTS
attr
.
type
=
attr
ibut
e_pb2
.
INTS
attr
.
ints
.
extend
([
0
,
1
,
2
,
3
])
self
.
assertEqual
(
expected1
,
generated1
)
...
...
@@ -88,7 +88,7 @@ class TestOpDescCreationMethod(unittest.TestCase):
expected2
.
type
=
'fc'
attr
=
expected2
.
attrs
.
add
()
attr
.
name
=
'input_format'
attr
.
type
=
attr
_typ
e_pb2
.
INTS
attr
.
type
=
attr
ibut
e_pb2
.
INTS
attr
.
ints
.
extend
([
0
,
3
,
6
,
7
])
self
.
assertEqual
(
expected2
,
generated2
)
...
...
@@ -105,12 +105,12 @@ class TestOpDescCreationMethod(unittest.TestCase):
attr
.
comment
=
""
attr
.
type
=
type
__add_attr__
(
"int_attr"
,
attr
_typ
e_pb2
.
INT
)
__add_attr__
(
"float_attr"
,
attr
_typ
e_pb2
.
FLOAT
)
__add_attr__
(
"string_attr"
,
attr
_typ
e_pb2
.
STRING
)
__add_attr__
(
"ints_attr"
,
attr
_typ
e_pb2
.
INTS
)
__add_attr__
(
"floats_attr"
,
attr
_typ
e_pb2
.
FLOATS
)
__add_attr__
(
"strings_attr"
,
attr
_typ
e_pb2
.
STRINGS
)
__add_attr__
(
"int_attr"
,
attr
ibut
e_pb2
.
INT
)
__add_attr__
(
"float_attr"
,
attr
ibut
e_pb2
.
FLOAT
)
__add_attr__
(
"string_attr"
,
attr
ibut
e_pb2
.
STRING
)
__add_attr__
(
"ints_attr"
,
attr
ibut
e_pb2
.
INTS
)
__add_attr__
(
"floats_attr"
,
attr
ibut
e_pb2
.
FLOATS
)
__add_attr__
(
"strings_attr"
,
attr
ibut
e_pb2
.
STRINGS
)
op
.
comment
=
""
self
.
assertTrue
(
op
.
IsInitialized
())
...
...
@@ -131,32 +131,32 @@ class TestOpDescCreationMethod(unittest.TestCase):
expected
.
inputs
.
extend
([
'a'
])
attr
=
expected
.
attrs
.
add
()
attr
.
name
=
"int_attr"
attr
.
type
=
attr
_typ
e_pb2
.
INT
attr
.
type
=
attr
ibut
e_pb2
.
INT
attr
.
i
=
10
attr
=
expected
.
attrs
.
add
()
attr
.
name
=
"float_attr"
attr
.
type
=
attr
_typ
e_pb2
.
FLOAT
attr
.
type
=
attr
ibut
e_pb2
.
FLOAT
attr
.
f
=
3.2
attr
=
expected
.
attrs
.
add
()
attr
.
name
=
"string_attr"
attr
.
type
=
attr
_typ
e_pb2
.
STRING
attr
.
type
=
attr
ibut
e_pb2
.
STRING
attr
.
s
=
"test_str"
attr
=
expected
.
attrs
.
add
()
attr
.
name
=
"ints_attr"
attr
.
type
=
attr
_typ
e_pb2
.
INTS
attr
.
type
=
attr
ibut
e_pb2
.
INTS
attr
.
ints
.
extend
([
0
,
1
,
2
,
3
,
4
])
attr
=
expected
.
attrs
.
add
()
attr
.
name
=
'floats_attr'
attr
.
type
=
attr
_typ
e_pb2
.
FLOATS
attr
.
type
=
attr
ibut
e_pb2
.
FLOATS
attr
.
floats
.
extend
([
0.2
,
3.2
,
4.5
])
attr
=
expected
.
attrs
.
add
()
attr
.
name
=
'strings_attr'
attr
.
type
=
attr
_typ
e_pb2
.
STRINGS
attr
.
type
=
attr
ibut
e_pb2
.
STRINGS
attr
.
strings
.
extend
([
'a'
,
'b'
,
'c'
])
self
.
assertEqual
(
expected
,
generated
)
...
...
@@ -185,7 +185,7 @@ class TestOpDescCreationMethod(unittest.TestCase):
desc
.
type
=
"test"
attr
=
desc
.
attrs
.
add
()
attr
.
name
=
"temporary_index"
attr
.
type
=
attr
_typ
e_pb2
.
INTS
attr
.
type
=
attr
ibut
e_pb2
.
INTS
attr
.
ints
.
append
(
2
)
self
.
assertEqual
(
generated
,
desc
)
...
...
@@ -219,7 +219,7 @@ This op is used for unit test, not a real op.
test_str
=
op
.
attrs
.
add
()
test_str
.
name
=
"str_attr"
test_str
.
type
=
attr
_typ
e_pb2
.
STRING
test_str
.
type
=
attr
ibut
e_pb2
.
STRING
test_str
.
comment
=
"A string attribute for test op"
actual
=
creation
.
get_docstring_from_op_proto
(
op
)
...
...
python/paddle/v2/framework/tests/test_protobuf.py
浏览文件 @
b4ebb3c8
import
paddle.v2.framework.proto.op_proto_pb2
import
paddle.v2.framework.proto.attr
_type_pb2
import
paddle.v2.framework.proto.op_proto_pb2
as
op_proto_lib
import
paddle.v2.framework.proto.attr
ibute_pb2
as
attr_type_lib
import
unittest
class
TestFrameworkProto
(
unittest
.
TestCase
):
def
test_all
(
self
):
op_proto_lib
=
paddle
.
v2
.
framework
.
proto
.
op_proto_pb2
attr_type_lib
=
paddle
.
v2
.
framework
.
proto
.
attr_type_pb2
op_proto
=
op_proto_lib
.
OpProto
()
ipt0
=
op_proto
.
inputs
.
add
()
ipt0
.
name
=
"a"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录