Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
4e09b089
P
Paddle
项目概览
PaddlePaddle
/
Paddle
接近 2 年 前同步成功
通知
2323
Star
20933
Fork
5424
代码
文件
提交
分支
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看板
未验证
提交
4e09b089
编写于
11月 15, 2022
作者:
N
Nyakku Shigure
提交者:
GitHub
11月 15, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[CodeStyle][F821] fix remaining F821 issues (#47968)
* [CodeStyle][F821] fix remained F821 issues * refine comment * fix _set_item
上级
aa08b769
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
41 addition
and
19 deletion
+41
-19
.flake8
.flake8
+5
-1
python/paddle/distributed/auto_parallel/completion.py
python/paddle/distributed/auto_parallel/completion.py
+6
-2
python/paddle/distributed/auto_parallel/cost/tensor_cost.py
python/paddle/distributed/auto_parallel/cost/tensor_cost.py
+2
-2
python/paddle/distributed/auto_parallel/operators/dist_reduce_sum_p.py
.../distributed/auto_parallel/operators/dist_reduce_sum_p.py
+1
-1
python/paddle/fluid/tests/unittests/dygraph_to_static/test_closure_analysis.py
...ests/unittests/dygraph_to_static/test_closure_analysis.py
+4
-0
python/paddle/fluid/tests/unittests/dygraph_to_static/yolov3.py
.../paddle/fluid/tests/unittests/dygraph_to_static/yolov3.py
+3
-1
python/paddle/fluid/tests/unittests/gradient_checker.py
python/paddle/fluid/tests/unittests/gradient_checker.py
+6
-6
python/paddle/fluid/tests/unittests/test_auto_parallel_reshard_serial.py
...luid/tests/unittests/test_auto_parallel_reshard_serial.py
+8
-4
python/paddle/fluid/tests/unittests/test_reorder_lod_tensor.py
...n/paddle/fluid/tests/unittests/test_reorder_lod_tensor.py
+3
-1
python/paddle/fluid/tests/unittests/test_weight_normalization.py
...paddle/fluid/tests/unittests/test_weight_normalization.py
+3
-1
未找到文件。
.flake8
浏览文件 @
4e09b089
...
@@ -23,7 +23,7 @@ ignore =
...
@@ -23,7 +23,7 @@ ignore =
# F, see https://flake8.pycqa.org/en/latest/user/error-codes.html
# F, see https://flake8.pycqa.org/en/latest/user/error-codes.html
F405,
F405,
F811,F8
21,F8
41,
F811,F841,
# W, see https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes
# W, see https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes
W503
W503
...
@@ -33,3 +33,7 @@ per-file-ignores =
...
@@ -33,3 +33,7 @@ per-file-ignores =
python/paddle/fluid/tests/unittests/collective/fleet/test_hdfs1.py:E101,W191
python/paddle/fluid/tests/unittests/collective/fleet/test_hdfs1.py:E101,W191
# Ignore unused imports in __init__.py
# Ignore unused imports in __init__.py
__init__.py: F401
__init__.py: F401
# Ignore undefined variables in CMake config and some dygraph_to_static tests
.cmake-format.py: F821
python/paddle/fluid/tests/unittests/dygraph_to_static/test_loop.py: F821
python/paddle/fluid/tests/unittests/dygraph_to_static/test_closure_analysis.py: F821
python/paddle/distributed/auto_parallel/completion.py
浏览文件 @
4e09b089
...
@@ -1510,8 +1510,12 @@ class Completer:
...
@@ -1510,8 +1510,12 @@ class Completer:
self
.
_dist_context
.
set_op_dist_attr_for_program
(
self
.
_dist_context
.
set_op_dist_attr_for_program
(
grad_op
,
grad_op_dist_attr
grad_op
,
grad_op_dist_attr
)
)
grad_op_dist_attr
.
impl_type
=
fwd_op_dist_attr
.
impl_type
grad_op_dist_attr
.
impl_type
=
(
grad_op_dist_attr
.
impl_idx
=
fwd_op_dist_attr
.
impl_idx
fwd_op_dist_attr
.
impl_type
# noqa: F821
)
grad_op_dist_attr
.
impl_idx
=
(
fwd_op_dist_attr
.
impl_idx
# noqa: F821
)
continue
continue
...
...
python/paddle/distributed/auto_parallel/cost/tensor_cost.py
浏览文件 @
4e09b089
...
@@ -100,9 +100,9 @@ class TensorCost:
...
@@ -100,9 +100,9 @@ class TensorCost:
if
dtype
==
paddle
.
float32
or
dtype
==
paddle
.
int32
:
if
dtype
==
paddle
.
float32
or
dtype
==
paddle
.
int32
:
dtype_factor
=
4
dtype_factor
=
4
elif
node
.
dtype
==
paddle
.
int64
:
elif
dtype
==
paddle
.
int64
:
dtype_factor
=
8
dtype_factor
=
8
elif
node
.
dtype
==
paddle
.
uint8
:
elif
dtype
==
paddle
.
uint8
:
dtype_factor
=
1
dtype_factor
=
1
else
:
else
:
dtype_factor
=
2
dtype_factor
=
2
...
...
python/paddle/distributed/auto_parallel/operators/dist_reduce_sum_p.py
浏览文件 @
4e09b089
...
@@ -141,7 +141,7 @@ class DistributedReduceSumPrimtiveImpl0(DistributedOperatorImpl):
...
@@ -141,7 +141,7 @@ class DistributedReduceSumPrimtiveImpl0(DistributedOperatorImpl):
def
backward
(
ctx
,
*
args
,
**
kwargs
):
def
backward
(
ctx
,
*
args
,
**
kwargs
):
raise
RuntimeError
(
raise
RuntimeError
(
"primitive operator does NOT have backward function, op type: {}"
.
format
(
"primitive operator does NOT have backward function, op type: {}"
.
format
(
str
(
op
.
type
)
str
(
op
.
type
)
# noqa: F821
)
)
)
)
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/test_closure_analysis.py
浏览文件 @
4e09b089
...
@@ -299,6 +299,8 @@ class TestPushPopTrans(unittest.TestCase):
...
@@ -299,6 +299,8 @@ class TestPushPopTrans(unittest.TestCase):
print
(
paddle
.
jit
.
to_static
(
vlist_of_dict
)(
x
))
print
(
paddle
.
jit
.
to_static
(
vlist_of_dict
)(
x
))
def
test4
(
self
):
def
test4
(
self
):
import
numpy
as
np
def
vlist_of_dict
(
x
):
def
vlist_of_dict
(
x
):
a
=
np
.
array
([
1
,
2
,
3
])
a
=
np
.
array
([
1
,
2
,
3
])
for
i
in
range
(
3
):
for
i
in
range
(
3
):
...
@@ -310,6 +312,8 @@ class TestPushPopTrans(unittest.TestCase):
...
@@ -310,6 +312,8 @@ class TestPushPopTrans(unittest.TestCase):
print
(
paddle
.
jit
.
to_static
(
vlist_of_dict
)(
x
))
print
(
paddle
.
jit
.
to_static
(
vlist_of_dict
)(
x
))
def
test5
(
self
):
def
test5
(
self
):
import
numpy
as
np
def
vlist_of_dict
(
x
):
def
vlist_of_dict
(
x
):
a
=
np
.
array
([
1
,
2
,
3
])
a
=
np
.
array
([
1
,
2
,
3
])
for
i
in
range
(
3
):
for
i
in
range
(
3
):
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/yolov3.py
浏览文件 @
4e09b089
...
@@ -296,7 +296,9 @@ class YOLOv3(fluid.dygraph.Layer):
...
@@ -296,7 +296,9 @@ class YOLOv3(fluid.dygraph.Layer):
blocks
=
self
.
block
(
inputs
)
blocks
=
self
.
block
(
inputs
)
for
i
,
block
in
enumerate
(
blocks
):
for
i
,
block
in
enumerate
(
blocks
):
if
i
>
0
:
if
i
>
0
:
block
=
fluid
.
layers
.
concat
(
input
=
[
route
,
block
],
axis
=
1
)
block
=
fluid
.
layers
.
concat
(
input
=
[
route
,
block
],
axis
=
1
# noqa: F821
)
route
,
tip
=
self
.
yolo_blocks
[
i
](
block
)
route
,
tip
=
self
.
yolo_blocks
[
i
](
block
)
block_out
=
self
.
block_outputs
[
i
](
tip
)
block_out
=
self
.
block_outputs
[
i
](
tip
)
self
.
outputs
.
append
(
block_out
)
self
.
outputs
.
append
(
block_out
)
...
...
python/paddle/fluid/tests/unittests/gradient_checker.py
浏览文件 @
4e09b089
...
@@ -59,7 +59,7 @@ def _get_item(t, i, np_dtype):
...
@@ -59,7 +59,7 @@ def _get_item(t, i, np_dtype):
raise
ValueError
(
"Not supported data type "
+
str
(
np_dtype
))
raise
ValueError
(
"Not supported data type "
+
str
(
np_dtype
))
def
_set_item
(
t
,
i
,
e
,
np_dtype
):
def
_set_item
(
t
,
i
,
e
,
np_dtype
,
place
):
if
np_dtype
==
np
.
float16
:
if
np_dtype
==
np
.
float16
:
np_t
=
np
.
array
(
t
).
astype
(
np
.
float16
)
np_t
=
np
.
array
(
t
).
astype
(
np
.
float16
)
shape
=
np_t
.
shape
shape
=
np_t
.
shape
...
@@ -145,14 +145,14 @@ def _compute_numerical_jacobian(program, x, y, place, scope, delta):
...
@@ -145,14 +145,14 @@ def _compute_numerical_jacobian(program, x, y, place, scope, delta):
for
i
in
range
(
x_size
):
for
i
in
range
(
x_size
):
orig
=
_get_item
(
x_t
,
i
,
np_type
)
orig
=
_get_item
(
x_t
,
i
,
np_type
)
x_pos
=
orig
+
delta
x_pos
=
orig
+
delta
_set_item
(
x_t
,
i
,
x_pos
,
np_type
)
_set_item
(
x_t
,
i
,
x_pos
,
np_type
,
place
)
y_pos
=
run
()
y_pos
=
run
()
x_neg
=
orig
-
delta
x_neg
=
orig
-
delta
_set_item
(
x_t
,
i
,
x_neg
,
np_type
)
_set_item
(
x_t
,
i
,
x_neg
,
np_type
,
place
)
y_neg
=
run
()
y_neg
=
run
()
_set_item
(
x_t
,
i
,
orig
,
np_type
)
_set_item
(
x_t
,
i
,
orig
,
np_type
,
place
)
for
j
in
range
(
len
(
y
)):
for
j
in
range
(
len
(
y
)):
jacobian
[
j
][
i
,
:]
=
(
y_pos
[
j
]
-
y_neg
[
j
])
/
delta
/
2.0
jacobian
[
j
][
i
,
:]
=
(
y_pos
[
j
]
-
y_neg
[
j
])
/
delta
/
2.0
...
@@ -207,7 +207,7 @@ def _compute_analytical_jacobian(program, x, y, place, scope):
...
@@ -207,7 +207,7 @@ def _compute_analytical_jacobian(program, x, y, place, scope):
filted_idx
,
filted_dx
=
zip
(
*
filted
)
filted_idx
,
filted_dx
=
zip
(
*
filted
)
for
i
in
range
(
y_size
):
for
i
in
range
(
y_size
):
_set_item
(
dy_t
,
i
,
1
,
np_type
)
_set_item
(
dy_t
,
i
,
1
,
np_type
,
place
)
dx_res
=
exe
.
run
(
program
,
scope
=
scope
,
fetch_list
=
filted_dx
)
dx_res
=
exe
.
run
(
program
,
scope
=
scope
,
fetch_list
=
filted_dx
)
...
@@ -220,7 +220,7 @@ def _compute_analytical_jacobian(program, x, y, place, scope):
...
@@ -220,7 +220,7 @@ def _compute_analytical_jacobian(program, x, y, place, scope):
dx
[
dx_idx
].
shape
,
dtype
=
np_type
dx
[
dx_idx
].
shape
,
dtype
=
np_type
).
flatten
()
).
flatten
()
_set_item
(
dy_t
,
i
,
0
,
np_type
)
_set_item
(
dy_t
,
i
,
0
,
np_type
,
place
)
return
jacobian
return
jacobian
...
...
python/paddle/fluid/tests/unittests/test_auto_parallel_reshard_serial.py
浏览文件 @
4e09b089
...
@@ -60,8 +60,12 @@ class MLPLayer(nn.Layer):
...
@@ -60,8 +60,12 @@ class MLPLayer(nn.Layer):
def
forward
(
self
,
input
):
def
forward
(
self
,
input
):
if
_global_parallel_strategy
==
"pp"
:
if
_global_parallel_strategy
==
"pp"
:
auto
.
shard_tensor
(
self
.
linear0
.
weight
,
PP_MESH_0
,
[
None
,
None
])
auto
.
shard_tensor
(
auto
.
shard_tensor
(
self
.
linear1
.
weight
,
PP_MESH_1
,
[
None
,
None
])
self
.
linear0
.
weight
,
PP_MESH_0
,
[
None
,
None
]
# noqa: F821
)
auto
.
shard_tensor
(
self
.
linear1
.
weight
,
PP_MESH_1
,
[
None
,
None
]
# noqa: F821
)
else
:
else
:
auto
.
shard_tensor
(
auto
.
shard_tensor
(
self
.
linear0
.
weight
,
_global_process_mesh
,
[
None
,
None
]
self
.
linear0
.
weight
,
_global_process_mesh
,
[
None
,
None
]
...
@@ -93,8 +97,8 @@ def mlp_forward(train_program, start_program):
...
@@ -93,8 +97,8 @@ def mlp_forward(train_program, start_program):
)
)
if
_global_parallel_strategy
==
"pp"
:
if
_global_parallel_strategy
==
"pp"
:
auto
.
shard_tensor
(
input
,
PP_MESH_0
,
[
None
,
None
])
auto
.
shard_tensor
(
input
,
PP_MESH_0
,
[
None
,
None
])
# noqa: F821
auto
.
shard_tensor
(
label
,
PP_MESH_1
,
[
None
,
None
])
auto
.
shard_tensor
(
label
,
PP_MESH_1
,
[
None
,
None
])
# noqa: F821
elif
_global_parallel_strategy
==
"dp"
:
elif
_global_parallel_strategy
==
"dp"
:
auto
.
shard_tensor
(
input
,
_global_process_mesh
,
[
"x"
,
None
])
auto
.
shard_tensor
(
input
,
_global_process_mesh
,
[
"x"
,
None
])
else
:
else
:
...
...
python/paddle/fluid/tests/unittests/test_reorder_lod_tensor.py
浏览文件 @
4e09b089
...
@@ -86,7 +86,9 @@ class TestReorderLoDTensor(unittest.TestCase):
...
@@ -86,7 +86,9 @@ class TestReorderLoDTensor(unittest.TestCase):
lod_level_i
=
np
.
random
.
randint
(
lod_level_i
=
np
.
random
.
randint
(
low
=
1
,
low
=
1
,
high
=
5
,
high
=
5
,
size
=
self
.
num_seq
if
i
==
0
else
sum
(
lod_level_i
),
size
=
self
.
num_seq
if
i
==
0
else
sum
(
lod_level_i
),
# noqa: F821
).
tolist
()
).
tolist
()
data_lod
.
append
(
lod_level_i
)
data_lod
.
append
(
lod_level_i
)
data_value
=
np
.
random
.
random
(
data_value
=
np
.
random
.
random
(
...
...
python/paddle/fluid/tests/unittests/test_weight_normalization.py
浏览文件 @
4e09b089
...
@@ -83,7 +83,9 @@ class TestWeightNormalization(unittest.TestCase):
...
@@ -83,7 +83,9 @@ class TestWeightNormalization(unittest.TestCase):
lod_level_i
=
np
.
random
.
randint
(
lod_level_i
=
np
.
random
.
randint
(
low
=
1
,
low
=
1
,
high
=
5
,
high
=
5
,
size
=
self
.
batch_size
if
i
==
0
else
sum
(
lod_level_i
),
size
=
self
.
batch_size
if
i
==
0
else
sum
(
lod_level_i
),
# noqa: F821
).
tolist
()
).
tolist
()
data_lod
.
append
(
lod_level_i
)
data_lod
.
append
(
lod_level_i
)
data_value
=
np
.
random
.
random
(
data_value
=
np
.
random
.
random
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录