Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
edb61a52
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看板
未验证
提交
edb61a52
编写于
4月 28, 2022
作者:
P
pangyoki
提交者:
GitHub
4月 28, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix collections.Sequence in python3.10 (#42242)
* fix collections.Sequence in python3.10 * fix format
上级
5134f110
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
31 addition
and
8 deletion
+31
-8
python/paddle/fluid/backward.py
python/paddle/fluid/backward.py
+5
-1
python/paddle/fluid/dygraph/dygraph_to_static/origin_info.py
python/paddle/fluid/dygraph/dygraph_to_static/origin_info.py
+5
-1
python/paddle/fluid/layers/rnn.py
python/paddle/fluid/layers/rnn.py
+5
-1
python/paddle/fluid/layers/utils.py
python/paddle/fluid/layers/utils.py
+6
-3
python/paddle/fluid/tests/unittests/gradient_checker.py
python/paddle/fluid/tests/unittests/gradient_checker.py
+5
-1
python/paddle/nn/layer/rnn.py
python/paddle/nn/layer/rnn.py
+5
-1
未找到文件。
python/paddle/fluid/backward.py
浏览文件 @
edb61a52
...
...
@@ -28,6 +28,10 @@ from . import log_helper
import
paddle.fluid
from
.data_feeder
import
check_type
import
warnings
try
:
from
collections.abc
import
Sequence
except
:
from
collections
import
Sequence
__all__
=
[
'append_backward'
,
'gradients'
,
...
...
@@ -1722,7 +1726,7 @@ def append_backward(loss,
def
_as_list
(
x
):
if
x
is
None
:
return
[]
return
list
(
x
)
if
isinstance
(
x
,
collections
.
Sequence
)
else
[
x
]
return
list
(
x
)
if
isinstance
(
x
,
Sequence
)
else
[
x
]
def
_is_ancestor_block
(
ancestor_block
,
block
):
...
...
python/paddle/fluid/dygraph/dygraph_to_static/origin_info.py
浏览文件 @
edb61a52
...
...
@@ -21,6 +21,10 @@ from paddle.utils import gast
from
paddle.fluid
import
core
from
paddle.fluid.dygraph.dygraph_to_static.utils
import
unwrap
from
paddle.fluid.framework
import
Program
try
:
from
collections.abc
import
Sequence
except
:
from
collections
import
Sequence
# NOTE(liym27): Please use `getattr(ast_node, ORIGI_INFO)` instead of . operation to get the original information of ast node.
ORIGI_INFO
=
"Original information of source code for ast node."
...
...
@@ -214,7 +218,7 @@ def ast_walk(transformed_node, static_node):
def
_as_list
(
x
):
if
x
is
None
:
return
[]
return
list
(
x
)
if
isinstance
(
x
,
collections
.
Sequence
)
else
[
x
]
return
list
(
x
)
if
isinstance
(
x
,
Sequence
)
else
[
x
]
transformed_node_list
=
_as_list
(
transformed_node
)
static_node_list
=
_as_list
(
static_node
)
...
...
python/paddle/fluid/layers/rnn.py
浏览文件 @
edb61a52
...
...
@@ -33,6 +33,10 @@ from ..layer_helper import LayerHelper
from
..framework
import
_non_static_mode
from
..param_attr
import
ParamAttr
from
..data_feeder
import
check_variable_and_dtype
,
check_type
,
check_dtype
try
:
from
collections.abc
import
Sequence
except
:
from
collections
import
Sequence
__all__
=
[
'RNNCell'
,
...
...
@@ -163,7 +167,7 @@ class RNNCell(object):
# TODO: Add check for the illegal
if
isinstance
(
seq
,
dict
):
return
True
return
(
isinstance
(
seq
,
collections
.
Sequence
)
and
return
(
isinstance
(
seq
,
Sequence
)
and
not
isinstance
(
seq
,
six
.
string_types
))
class
Shape
(
object
):
...
...
python/paddle/fluid/layers/utils.py
浏览文件 @
edb61a52
...
...
@@ -21,6 +21,10 @@ from ..framework import Block, Variable, _non_static_mode
from
..data_feeder
import
convert_dtype
,
check_variable_and_dtype
,
check_type
,
check_dtype
from
..layer_helper
import
LayerHelper
from
sys
import
version_info
try
:
from
collections.abc
import
Sequence
except
:
from
collections
import
Sequence
def
convert_to_list
(
value
,
n
,
name
,
dtype
=
int
):
...
...
@@ -74,8 +78,7 @@ def is_sequence(seq):
"""
if
isinstance
(
seq
,
dict
):
return
True
return
(
isinstance
(
seq
,
collections
.
Sequence
)
and
not
isinstance
(
seq
,
six
.
string_types
))
return
(
isinstance
(
seq
,
Sequence
)
and
not
isinstance
(
seq
,
six
.
string_types
))
def
_hash_with_id
(
*
args
):
...
...
@@ -148,7 +151,7 @@ def _sequence_like(instance, args):
return
type
(
instance
)((
key
,
result
[
key
])
for
key
in
six
.
iterkeys
(
instance
))
elif
(
isinstance
(
instance
,
tuple
)
and
hasattr
(
instance
,
"_fields"
)
and
isinstance
(
instance
.
_fields
,
collections
.
Sequence
)
and
isinstance
(
instance
.
_fields
,
Sequence
)
and
all
(
isinstance
(
f
,
six
.
string_types
)
for
f
in
instance
.
_fields
)):
# This is a namedtuple
return
type
(
instance
)(
*
args
)
...
...
python/paddle/fluid/tests/unittests/gradient_checker.py
浏览文件 @
edb61a52
...
...
@@ -27,6 +27,10 @@ import paddle.fluid.core as core
from
paddle.fluid.executor
import
Executor
from
paddle.fluid.backward
import
_append_grad_suffix_
,
_as_list
from
paddle.fluid.framework
import
_test_eager_guard
try
:
from
collections.abc
import
Sequence
except
:
from
collections
import
Sequence
def
_product
(
t
):
...
...
@@ -91,7 +95,7 @@ def var_to_np_array_in_scope(scope, place, name):
def
make_jacobian
(
x
,
y_size
,
np_dtype
):
if
isinstance
(
x
,
fluid
.
framework
.
Variable
):
return
np
.
zeros
((
_product
(
x
.
shape
),
y_size
),
dtype
=
np_dtype
)
elif
isinstance
(
x
,
collections
.
Sequence
):
elif
isinstance
(
x
,
Sequence
):
jacobians
=
list
(
filter
(
lambda
t
:
t
is
not
None
,
(
make_jacobian
(
item
,
y_size
,
np_dtype
)
for
item
in
x
)))
...
...
python/paddle/nn/layer/rnn.py
浏览文件 @
edb61a52
...
...
@@ -37,6 +37,10 @@ from paddle import in_dynamic_mode
from
paddle.framework
import
core
from
paddle.static
import
default_startup_program
from
paddle.static
import
program_guard
try
:
from
collections.abc
import
Sequence
except
:
from
collections
import
Sequence
__all__
=
[]
...
...
@@ -197,7 +201,7 @@ class RNNCellBase(Layer):
# TODO: Add check for the illegal
if
isinstance
(
seq
,
dict
):
return
True
return
(
isinstance
(
seq
,
collections
.
Sequence
)
and
return
(
isinstance
(
seq
,
Sequence
)
and
not
isinstance
(
seq
,
six
.
string_types
))
class
Shape
(
object
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录