Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
a52ab135
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看板
未验证
提交
a52ab135
编写于
10月 11, 2022
作者:
T
Tony Cao
提交者:
GitHub
10月 11, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
代码退场,清除了与python2相关的一些条件分支 (#46696)
上级
2b5d325f
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
30 addition
and
92 deletion
+30
-92
python/paddle/fluid/layers/rnn.py
python/paddle/fluid/layers/rnn.py
+5
-21
python/paddle/fluid/param_attr.py
python/paddle/fluid/param_attr.py
+1
-4
python/paddle/fluid/tests/unittests/test_fs_interface.py
python/paddle/fluid/tests/unittests/test_fs_interface.py
+1
-4
python/paddle/fluid/tests/unittests/test_imperative_data_loader_exit_func.py
.../tests/unittests/test_imperative_data_loader_exit_func.py
+1
-4
python/paddle/fluid/tests/unittests/test_imperative_data_loader_process.py
...id/tests/unittests/test_imperative_data_loader_process.py
+1
-4
python/paddle/nn/layer/rnn.py
python/paddle/nn/layer/rnn.py
+2
-9
python/paddle/tests/test_callback_visualdl.py
python/paddle/tests/test_callback_visualdl.py
+0
-4
python/setup.py.in
python/setup.py.in
+2
-6
tools/prune_for_jetson.py
tools/prune_for_jetson.py
+11
-24
tools/remove_grad_op_and_kernel.py
tools/remove_grad_op_and_kernel.py
+6
-12
未找到文件。
python/paddle/fluid/layers/rnn.py
浏览文件 @
a52ab135
...
...
@@ -126,43 +126,27 @@ class RNNCell(object):
Variable: tensor variable[s] packed in the same structure provided \
by shape, representing the initialized states.
"""
if
sys
.
version_info
<
(
3
,
):
integer_types
=
(
int
,
long
,
)
else
:
integer_types
=
(
int
,
)
check_variable_and_dtype
(
batch_ref
,
'batch_ref'
,
[
'float32'
,
'float64'
,
'int32'
,
'int64'
],
'RNNCell'
)
check_type
(
shape
,
'shape'
,
(
list
,
tuple
,
type
(
None
),
integer_types
),
'RNNCell'
)
check_type
(
shape
,
'shape'
,
(
list
,
tuple
,
type
(
None
),
int
),
'RNNCell'
)
if
isinstance
(
shape
,
(
list
,
tuple
)):
shapes
=
map_structure
(
lambda
x
:
x
,
shape
)
if
isinstance
(
shape
,
list
):
for
i
,
_shape
in
enumerate
(
shapes
):
check_type
(
_shape
,
'shapes['
+
str
(
i
)
+
']'
,
integer_types
,
'RNNCell'
)
check_type
(
_shape
,
'shapes['
+
str
(
i
)
+
']'
,
int
,
'RNNCell'
)
else
:
check_type
(
shapes
,
'shapes'
,
int
eger_types
,
'RNNCell'
)
check_type
(
shapes
,
'shapes'
,
int
,
'RNNCell'
)
check_dtype
(
dtype
,
'dtype'
,
[
'float32'
,
'float64'
],
'RNNCell'
)
# TODO: use inputs and batch_size
batch_ref
=
flatten
(
batch_ref
)[
0
]
def
_is_shape_sequence
(
seq
):
if
sys
.
version_info
<
(
3
,
):
integer_types
=
(
int
,
long
,
)
else
:
integer_types
=
(
int
,
)
"""For shape, list/tuple of integer is the finest-grained objection"""
if
(
isinstance
(
seq
,
list
)
or
isinstance
(
seq
,
tuple
)):
if
reduce
(
lambda
flag
,
x
:
isinstance
(
x
,
int
eger_types
)
and
flag
,
seq
,
True
):
if
reduce
(
lambda
flag
,
x
:
isinstance
(
x
,
int
)
and
flag
,
seq
,
True
):
return
False
# TODO: Add check for the illegal
if
isinstance
(
seq
,
dict
):
...
...
python/paddle/fluid/param_attr.py
浏览文件 @
a52ab135
...
...
@@ -84,10 +84,7 @@ class ParamAttr(object):
do_model_average
=
True
,
need_clip
=
True
):
if
sys
.
version_info
.
major
==
2
:
check_type
(
name
,
"name"
,
(
str
,
type
(
None
),
unicode
),
"ParamAttr"
)
else
:
check_type
(
name
,
"name"
,
(
str
,
type
(
None
)),
"ParamAttr"
)
check_type
(
name
,
"name"
,
(
str
,
type
(
None
)),
"ParamAttr"
)
check_type
(
learning_rate
,
"learning_rate"
,
(
float
,
int
),
"ParamAttr"
)
check_type
(
trainable
,
"trainable"
,
(
bool
),
"ParamAttr"
)
check_type
(
do_model_average
,
"do_model_average"
,
(
bool
),
"ParamAttr"
)
...
...
python/paddle/fluid/tests/unittests/test_fs_interface.py
浏览文件 @
a52ab135
...
...
@@ -26,10 +26,7 @@ from paddle.distributed.fleet.utils.fs import LocalFS, FS, HDFSClient, FSTimeOut
class
FSTest
(
unittest
.
TestCase
):
def
_test_method
(
self
,
func
):
if
sys
.
version_info
[
0
]
<=
2
:
args
=
inspect
.
getargspec
(
func
).
args
else
:
args
=
inspect
.
getfullargspec
(
func
).
args
args
=
inspect
.
getfullargspec
(
func
).
args
a
=
None
try
:
...
...
python/paddle/fluid/tests/unittests/test_imperative_data_loader_exit_func.py
浏览文件 @
a52ab135
...
...
@@ -21,10 +21,7 @@ import time
import
paddle.compat
as
cpt
from
paddle.fluid.framework
import
_test_eager_guard
if
sys
.
version_info
[
0
]
==
2
:
import
Queue
as
queue
else
:
import
queue
import
queue
from
paddle.fluid.reader
import
multiprocess_queue_set
,
_cleanup
,
CleanupFuncRegistrar
...
...
python/paddle/fluid/tests/unittests/test_imperative_data_loader_process.py
浏览文件 @
a52ab135
...
...
@@ -21,10 +21,7 @@ from paddle.fluid import core
from
paddle.fluid.reader
import
_reader_process_loop
from
paddle.fluid.framework
import
_test_eager_guard
if
sys
.
version_info
[
0
]
==
2
:
import
Queue
as
queue
else
:
import
queue
import
queue
def
get_random_images_and_labels
(
image_shape
,
label_shape
):
...
...
python/paddle/nn/layer/rnn.py
浏览文件 @
a52ab135
...
...
@@ -188,17 +188,10 @@ class RNNCellBase(Layer):
batch_ref
=
flatten
(
batch_ref
)[
0
]
def
_is_shape_sequence
(
seq
):
if
sys
.
version_info
<
(
3
,
):
integer_types
=
(
int
,
long
,
)
else
:
integer_types
=
(
int
,
)
"""For shape, list/tuple of integer is the finest-grained objection"""
if
(
isinstance
(
seq
,
list
)
or
isinstance
(
seq
,
tuple
)):
if
reduce
(
lambda
flag
,
x
:
isinstance
(
x
,
int
eger_types
)
and
flag
,
seq
,
True
):
if
reduce
(
lambda
flag
,
x
:
isinstance
(
x
,
int
)
and
flag
,
seq
,
True
):
return
False
# TODO: Add check for the illegal
if
isinstance
(
seq
,
dict
):
...
...
python/paddle/tests/test_callback_visualdl.py
浏览文件 @
a52ab135
...
...
@@ -47,10 +47,6 @@ class TestCallbacks(unittest.TestCase):
shutil
.
rmtree
(
self
.
save_dir
)
def
func_visualdl_callback
(
self
):
# visualdl not support python2
if
sys
.
version_info
<
(
3
,
):
return
inputs
=
[
InputSpec
([
-
1
,
1
,
28
,
28
],
'float32'
,
'image'
)]
labels
=
[
InputSpec
([
None
,
1
],
'int64'
,
'label'
)]
...
...
python/setup.py.in
浏览文件 @
a52ab135
...
...
@@ -735,12 +735,8 @@ else:
yield
# Log for PYPI
if sys.version_info > (3,0):
with open("@PADDLE_BINARY_DIR@/python/paddle/README.rst", "r", encoding='UTF-8') as f:
long_description = f.read()
else:
with open("@PADDLE_BINARY_DIR@/python/paddle/README.rst", "r")as f:
long_description = unicode(f.read(), 'UTF-8')
with open("@PADDLE_BINARY_DIR@/python/paddle/README.rst", "r", encoding='UTF-8') as f:
long_description = f.read()
# strip *.so to reduce package size
if '${WITH_STRIP}' == 'ON':
...
...
tools/prune_for_jetson.py
浏览文件 @
a52ab135
...
...
@@ -54,18 +54,11 @@ def find_kernel(content, pattern):
def
prune_phi_kernels
():
tool_dir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
if
sys
.
version_info
[
0
]
==
3
:
all_op
=
glob
.
glob
(
os
.
path
.
join
(
tool_dir
,
'../paddle/phi/kernels/**/*.cc'
),
recursive
=
True
)
all_op
+=
glob
.
glob
(
os
.
path
.
join
(
tool_dir
,
'../paddle/phi/kernels/**/*.cu'
),
recursive
=
True
)
elif
sys
.
version_info
[
0
]
==
2
:
all_op
=
find_type_files
(
os
.
path
.
join
(
tool_dir
,
'../paddle/phi/kernels/'
),
'.cc'
)
all_op
=
find_type_files
(
os
.
path
.
join
(
tool_dir
,
'../paddle/phi/kernels/'
),
'.cu'
,
all_op
)
all_op
=
glob
.
glob
(
os
.
path
.
join
(
tool_dir
,
'../paddle/phi/kernels/**/*.cc'
),
recursive
=
True
)
all_op
+=
glob
.
glob
(
os
.
path
.
join
(
tool_dir
,
'../paddle/phi/kernels/**/*.cu'
),
recursive
=
True
)
register_op_count
=
0
for
op_file
in
all_op
:
...
...
@@ -139,18 +132,12 @@ def append_fluid_kernels():
#2. add op and kernel register
op_white_list
.
append
(
"tensorrt_engine"
)
tool_dir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
if
sys
.
version_info
[
0
]
==
3
:
all_op
=
glob
.
glob
(
os
.
path
.
join
(
tool_dir
,
'../paddle/fluid/operators/**/*.cc'
),
recursive
=
True
)
all_op
+=
glob
.
glob
(
os
.
path
.
join
(
tool_dir
,
'../paddle/fluid/operators/**/*.cu'
),
recursive
=
True
)
elif
sys
.
version_info
[
0
]
==
2
:
all_op
=
find_type_files
(
os
.
path
.
join
(
tool_dir
,
'../paddle/fluid/operators/'
),
'.cc'
)
all_op
=
find_type_files
(
os
.
path
.
join
(
tool_dir
,
'../paddle/fluid/operators/'
),
'.cu'
,
all_op
)
all_op
=
glob
.
glob
(
os
.
path
.
join
(
tool_dir
,
'../paddle/fluid/operators/**/*.cc'
),
recursive
=
True
)
all_op
+=
glob
.
glob
(
os
.
path
.
join
(
tool_dir
,
'../paddle/fluid/operators/**/*.cu'
),
recursive
=
True
)
for
op_file
in
all_op
:
with
io
.
open
(
op_file
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
...
...
tools/remove_grad_op_and_kernel.py
浏览文件 @
a52ab135
...
...
@@ -67,18 +67,12 @@ if __name__ == '__main__':
tool_dir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
if
sys
.
version_info
[
0
]
==
3
:
all_op
=
glob
.
glob
(
os
.
path
.
join
(
tool_dir
,
'../paddle/fluid/operators/**/*.cc'
),
recursive
=
True
)
all_op
+=
glob
.
glob
(
os
.
path
.
join
(
tool_dir
,
'../paddle/fluid/operators/**/*.cu'
),
recursive
=
True
)
elif
sys
.
version_info
[
0
]
==
2
:
all_op
=
find_type_files
(
os
.
path
.
join
(
tool_dir
,
'../paddle/fluid/operators/'
),
'.cc'
)
all_op
=
find_type_files
(
os
.
path
.
join
(
tool_dir
,
'../paddle/fluid/operators/'
),
'.cu'
,
all_op
)
all_op
=
glob
.
glob
(
os
.
path
.
join
(
tool_dir
,
'../paddle/fluid/operators/**/*.cc'
),
recursive
=
True
)
all_op
+=
glob
.
glob
(
os
.
path
.
join
(
tool_dir
,
'../paddle/fluid/operators/**/*.cu'
),
recursive
=
True
)
spec_ops
=
[
'activation_op.cc'
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录