Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
979fb35e
P
Paddle
项目概览
Crayon鑫
/
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看板
未验证
提交
979fb35e
编写于
4月 08, 2020
作者:
Z
Zeng Jinle
提交者:
GitHub
4月 09, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update print signatures(#23619)
上级
5f22478a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
61 addition
and
4 deletion
+61
-4
paddle/scripts/paddle_build.sh
paddle/scripts/paddle_build.sh
+1
-1
tools/print_signatures.py
tools/print_signatures.py
+60
-3
未找到文件。
paddle/scripts/paddle_build.sh
浏览文件 @
979fb35e
...
...
@@ -508,7 +508,7 @@ function generate_api_spec() {
source
.
${
spec_kind
}
_env/bin/activate
pip
install
${
PADDLE_ROOT
}
/build/python/dist/
*
whl
spec_path
=
${
PADDLE_ROOT
}
/paddle/fluid/API_
${
spec_kind
}
.spec
python
${
PADDLE_ROOT
}
/tools/print_signatures.py paddle
.fluid
>
$spec_path
python
${
PADDLE_ROOT
}
/tools/print_signatures.py paddle
>
$spec_path
# used to log op_register data_type
op_type_path
=
${
PADDLE_ROOT
}
/paddle/fluid/OP_TYPE_
${
spec_kind
}
.spec
...
...
tools/print_signatures.py
浏览文件 @
979fb35e
...
...
@@ -25,9 +25,13 @@ import collections
import
sys
import
pydoc
import
hashlib
import
six
import
functools
member_dict
=
collections
.
OrderedDict
()
visited_modules
=
set
()
# APIs that should not be printed into API.spec
omitted_list
=
[
"paddle.fluid.LoDTensor.set"
,
# Do not know why it should be omitted
...
...
@@ -42,23 +46,45 @@ def md5(doc):
return
hash
.
hexdigest
()
def
get_functools_partial_spec
(
func
):
func_str
=
func
.
func
.
__name__
args
=
func
.
args
keywords
=
func
.
keywords
return
'{}(args={}, keywords={})'
.
format
(
func_str
,
args
,
keywords
)
def
format_spec_doc
(
spec
,
doc
=
None
):
args
=
spec
.
args
varargs
=
spec
.
varargs
keywords
=
spec
.
keywords
defaults
=
list
(
spec
.
defaults
)
for
idx
,
item
in
enumerate
(
defaults
):
if
not
isinstance
(
item
,
functools
.
partial
):
continue
defaults
[
idx
]
=
get_functools_partial_spec
(
item
)
return
'ArgSpec(args={}, varargs={}, keywords={}, defaults={})'
.
format
(
args
,
varargs
,
keywords
,
tuple
(
defaults
))
def
queue_dict
(
member
,
cur_name
):
if
cur_name
in
omitted_list
:
return
doc
=
(
'document'
,
md5
(
member
.
__doc__
)
)
doc
_md5
=
md5
(
member
.
__doc__
)
if
inspect
.
isclass
(
member
):
args
=
member
.
__module__
+
"."
+
member
.
__name__
else
:
try
:
args
=
inspect
.
getargspec
(
member
)
args
=
format_spec_doc
(
inspect
.
getargspec
(
member
)
)
except
TypeError
:
# special for PyBind method
args
=
" "
.
join
([
line
.
strip
()
for
line
in
pydoc
.
render_doc
(
member
).
split
(
'
\n
'
)
if
"->"
in
line
])
member_dict
[
cur_name
]
=
(
args
,
doc
)
member_dict
[
cur_name
]
=
"({}, ('document', '{}'))"
.
format
(
args
,
doc_md5
)
def
visit_member
(
parent_name
,
member
):
...
...
@@ -78,7 +104,31 @@ def visit_member(parent_name, member):
format
(
str
(
type
(
member
))))
def
is_primitive
(
instance
):
int_types
=
(
int
,
long
)
if
six
.
PY2
else
(
int
,
)
pritimitive_types
=
int_types
+
(
float
,
str
)
if
isinstance
(
instance
,
pritimitive_types
):
return
True
elif
isinstance
(
instance
,
(
list
,
tuple
,
set
)):
for
obj
in
instance
:
if
not
is_primitive
(
obj
):
return
False
return
True
else
:
return
False
def
visit_all_module
(
mod
):
mod_name
=
mod
.
__name__
if
mod_name
!=
'paddle'
and
not
mod_name
.
startswith
(
'paddle.'
):
return
if
mod
in
visited_modules
:
return
visited_modules
.
add
(
mod
)
for
member_name
in
(
name
for
name
in
(
mod
.
__all__
if
hasattr
(
mod
,
"__all__"
)
else
dir
(
mod
))
...
...
@@ -86,6 +136,13 @@ def visit_all_module(mod):
instance
=
getattr
(
mod
,
member_name
,
None
)
if
instance
is
None
:
continue
if
is_primitive
(
instance
):
continue
if
not
hasattr
(
instance
,
"__name__"
):
continue
if
inspect
.
ismodule
(
instance
):
visit_all_module
(
instance
)
else
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录