Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
42c8d51a
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
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看板
未验证
提交
42c8d51a
编写于
11月 14, 2022
作者:
H
HongyuJia
提交者:
GitHub
11月 14, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
clean fluid elementwise_max (#47866)
上级
2182a4f9
变更
19
显示空白变更内容
内联
并排
Showing
19 changed file
with
27 addition
and
28 deletion
+27
-28
python/paddle/distributed/fleet/meta_optimizers/dygraph_optimizer/hybrid_parallel_optimizer.py
...optimizers/dygraph_optimizer/hybrid_parallel_optimizer.py
+1
-1
python/paddle/distributed/fleet/meta_optimizers/localsgd_optimizer.py
...e/distributed/fleet/meta_optimizers/localsgd_optimizer.py
+1
-1
python/paddle/distributed/fleet/meta_parallel/sharding/group_sharded_utils.py
...buted/fleet/meta_parallel/sharding/group_sharded_utils.py
+1
-1
python/paddle/distributed/fleet/meta_parallel/sharding/sharding_utils.py
...istributed/fleet/meta_parallel/sharding/sharding_utils.py
+1
-1
python/paddle/fluid/clip.py
python/paddle/fluid/clip.py
+3
-5
python/paddle/fluid/dygraph/learning_rate_scheduler.py
python/paddle/fluid/dygraph/learning_rate_scheduler.py
+2
-3
python/paddle/fluid/tests/unittests/dist_fleet_simnet_bow.py
python/paddle/fluid/tests/unittests/dist_fleet_simnet_bow.py
+1
-1
python/paddle/fluid/tests/unittests/dygraph_to_static/simnet_dygraph_model.py
...tests/unittests/dygraph_to_static/simnet_dygraph_model.py
+3
-1
python/paddle/fluid/tests/unittests/test_dist_fleet_ps.py
python/paddle/fluid/tests/unittests/test_dist_fleet_ps.py
+1
-1
python/paddle/fluid/tests/unittests/test_dist_fleet_ps11.py
python/paddle/fluid/tests/unittests/test_dist_fleet_ps11.py
+1
-1
python/paddle/fluid/tests/unittests/test_dist_fleet_ps12.py
python/paddle/fluid/tests/unittests/test_dist_fleet_ps12.py
+1
-1
python/paddle/fluid/tests/unittests/test_dist_fleet_ps13.py
python/paddle/fluid/tests/unittests/test_dist_fleet_ps13.py
+1
-1
python/paddle/fluid/tests/unittests/test_dist_fleet_ps2.py
python/paddle/fluid/tests/unittests/test_dist_fleet_ps2.py
+1
-1
python/paddle/fluid/tests/unittests/test_dist_fleet_ps3.py
python/paddle/fluid/tests/unittests/test_dist_fleet_ps3.py
+1
-1
python/paddle/fluid/tests/unittests/test_dist_fleet_ps4.py
python/paddle/fluid/tests/unittests/test_dist_fleet_ps4.py
+1
-1
python/paddle/fluid/tests/unittests/test_dist_fleet_ps5.py
python/paddle/fluid/tests/unittests/test_dist_fleet_ps5.py
+1
-1
python/paddle/fluid/tests/unittests/test_dist_fleet_ps6.py
python/paddle/fluid/tests/unittests/test_dist_fleet_ps6.py
+1
-1
python/paddle/fluid/tests/unittests/test_layers.py
python/paddle/fluid/tests/unittests/test_layers.py
+2
-4
python/paddle/incubate/distributed/models/moe/grad_clip.py
python/paddle/incubate/distributed/models/moe/grad_clip.py
+3
-1
未找到文件。
python/paddle/distributed/fleet/meta_optimizers/dygraph_optimizer/hybrid_parallel_optimizer.py
浏览文件 @
42c8d51a
...
...
@@ -160,7 +160,7 @@ class HybridParallelClipGrad:
)
clip_var
=
layers
.
elementwise_div
(
x
=
max_global_norm
,
y
=
layers
.
elementwise_max
(
x
=
global_norm_var_fp32
,
y
=
max_global_norm
),
y
=
paddle
.
maximum
(
x
=
global_norm_var_fp32
,
y
=
max_global_norm
),
)
clip_var_fp16
=
paddle
.
cast
(
clip_var
,
paddle
.
float16
)
for
p
,
g
in
params_grads
:
...
...
python/paddle/distributed/fleet/meta_optimizers/localsgd_optimizer.py
浏览文件 @
42c8d51a
...
...
@@ -468,7 +468,7 @@ class AdaptiveLocalSGDOptimizer(MetaOptimizerBase):
next_local_steps
=
layers
.
elementwise_min
(
next_local_steps
,
max_local_steps
)
next_local_steps
=
layers
.
elementwise_max
(
next_local_steps
=
paddle
.
maximum
(
next_local_steps
,
min_local_steps
)
layers
.
assign
(
next_local_steps
,
k_steps
)
...
...
python/paddle/distributed/fleet/meta_parallel/sharding/group_sharded_utils.py
浏览文件 @
42c8d51a
...
...
@@ -141,7 +141,7 @@ class GroupShardedClipGrad:
clip_var
=
layers
.
elementwise_div
(
x
=
max_global_norm
,
y
=
layers
.
elementwise_max
(
x
=
global_norm_var
,
y
=
max_global_norm
),
y
=
paddle
.
maximum
(
x
=
global_norm_var
,
y
=
max_global_norm
),
)
clip_var_fp16
=
paddle
.
cast
(
clip_var
,
paddle
.
float16
)
...
...
python/paddle/distributed/fleet/meta_parallel/sharding/sharding_utils.py
浏览文件 @
42c8d51a
...
...
@@ -138,7 +138,7 @@ class ShardingClipGrad:
clip_var
=
layers
.
elementwise_div
(
x
=
max_global_norm
,
y
=
layers
.
elementwise_max
(
x
=
global_norm_var
,
y
=
max_global_norm
),
y
=
paddle
.
maximum
(
x
=
global_norm_var
,
y
=
max_global_norm
),
)
clip_var_fp16
=
paddle
.
cast
(
clip_var
,
paddle
.
float16
)
...
...
python/paddle/fluid/clip.py
浏览文件 @
42c8d51a
...
...
@@ -550,7 +550,7 @@ class ClipGradByGlobalNorm(ClipGradBase):
need_clip
=
True
clip_var
=
layers
.
elementwise_div
(
x
=
max_global_norm
,
y
=
layers
.
elementwise_max
(
x
=
global_norm_var
,
y
=
max_global_norm
),
y
=
paddle
.
maximum
(
x
=
global_norm_var
,
y
=
max_global_norm
),
)
elif
global_norm_var
>
max_global_norm
:
# only when global_norm_var > max_global_norm, grad need clip
...
...
@@ -654,9 +654,7 @@ class ClipGradByGlobalNorm(ClipGradBase):
)
scale_var
=
layers
.
elementwise_div
(
x
=
max_global_norm
,
y
=
layers
.
elementwise_max
(
x
=
max_global_norm
,
y
=
global_norm_var
),
y
=
paddle
.
maximum
(
x
=
max_global_norm
,
y
=
global_norm_var
),
)
param_new_grad_name_dict
=
dict
()
for
p
,
g
in
params_grads
:
...
...
@@ -733,7 +731,7 @@ class ClipGradByGlobalNorm(ClipGradBase):
clip_var
=
self
.
context
[
self
.
group_name
+
"_clip"
]
group_scale_var
=
layers
.
elementwise_div
(
x
=
clip_var
,
y
=
layers
.
elementwise_max
(
x
=
clip_var
,
y
=
group_norm_var
),
y
=
paddle
.
maximum
(
x
=
clip_var
,
y
=
group_norm_var
),
)
assert
group_scale_var
.
shape
==
(
1
,)
self
.
context
[
group_scale_name
]
=
group_scale_var
...
...
python/paddle/fluid/dygraph/learning_rate_scheduler.py
浏览文件 @
42c8d51a
...
...
@@ -15,6 +15,7 @@
import
math
import
warnings
import
paddle
from
..
import
unique_name
from
..framework
import
Variable
from
..data_feeder
import
check_type
...
...
@@ -977,11 +978,9 @@ class ReduceLROnPlateau(LearningRateDecay):
self
.
num_bad_epochs
+=
1
if
self
.
num_bad_epochs
>
self
.
patience
:
from
..
import
layers
self
.
cooldown_counter
=
self
.
cooldown
self
.
num_bad_epochs
=
0
new_lr
=
layers
.
elementwise_max
(
new_lr
=
paddle
.
maximum
(
self
.
learning_rate
*
self
.
decay_rate
,
self
.
min_lr
)
if
self
.
learning_rate
-
new_lr
>
self
.
eps
:
...
...
python/paddle/fluid/tests/unittests/dist_fleet_simnet_bow.py
浏览文件 @
42c8d51a
...
...
@@ -74,7 +74,7 @@ def get_loss(cos_q_pt, cos_q_nt):
cos_q_pt
,
)
loss_op2
=
fluid
.
layers
.
elementwise_add
(
loss_op1
,
cos_q_nt
)
loss_op3
=
fluid
.
layers
.
elementwise_max
(
loss_op3
=
paddle
.
maximum
(
fluid
.
layers
.
fill_constant_batch_size_like
(
input
=
loss_op2
,
shape
=
[
-
1
,
1
],
value
=
0.0
,
dtype
=
'float32'
),
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/simnet_dygraph_model.py
浏览文件 @
42c8d51a
...
...
@@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
paddle
import
paddle.fluid
as
fluid
import
paddle.fluid.param_attr
as
attr
...
...
@@ -151,7 +153,7 @@ class ElementwiseMaxLayer:
"""
operation
"""
max
=
fluid
.
layers
.
elementwise_max
(
x
,
y
)
max
=
paddle
.
maximum
(
x
,
y
)
return
max
...
...
python/paddle/fluid/tests/unittests/test_dist_fleet_ps.py
浏览文件 @
42c8d51a
...
...
@@ -56,7 +56,7 @@ class TestPSPassWithBow(unittest.TestCase):
cos_q_pt
,
)
loss_op2
=
fluid
.
layers
.
elementwise_add
(
loss_op1
,
cos_q_nt
)
loss_op3
=
fluid
.
layers
.
elementwise_max
(
loss_op3
=
paddle
.
maximum
(
fluid
.
layers
.
fill_constant_batch_size_like
(
input
=
loss_op2
,
shape
=
[
-
1
,
1
],
value
=
0.0
,
dtype
=
'float32'
),
...
...
python/paddle/fluid/tests/unittests/test_dist_fleet_ps11.py
浏览文件 @
42c8d51a
...
...
@@ -56,7 +56,7 @@ class TestPSPassWithBow(unittest.TestCase):
cos_q_pt
,
)
loss_op2
=
fluid
.
layers
.
elementwise_add
(
loss_op1
,
cos_q_nt
)
loss_op3
=
fluid
.
layers
.
elementwise_max
(
loss_op3
=
paddle
.
maximum
(
fluid
.
layers
.
fill_constant_batch_size_like
(
input
=
loss_op2
,
shape
=
[
-
1
,
1
],
value
=
0.0
,
dtype
=
'float32'
),
...
...
python/paddle/fluid/tests/unittests/test_dist_fleet_ps12.py
浏览文件 @
42c8d51a
...
...
@@ -59,7 +59,7 @@ class TestPSPassWithBow(unittest.TestCase):
cos_q_pt
,
)
loss_op2
=
fluid
.
layers
.
elementwise_add
(
loss_op1
,
cos_q_nt
)
loss_op3
=
fluid
.
layers
.
elementwise_max
(
loss_op3
=
paddle
.
maximum
(
fluid
.
layers
.
fill_constant_batch_size_like
(
input
=
loss_op2
,
shape
=
[
-
1
,
1
],
value
=
0.0
,
dtype
=
'float32'
),
...
...
python/paddle/fluid/tests/unittests/test_dist_fleet_ps13.py
浏览文件 @
42c8d51a
...
...
@@ -60,7 +60,7 @@ class TestPSPassWithBow(unittest.TestCase):
cos_q_pt
,
)
loss_op2
=
fluid
.
layers
.
elementwise_add
(
loss_op1
,
cos_q_nt
)
loss_op3
=
fluid
.
layers
.
elementwise_max
(
loss_op3
=
paddle
.
maximum
(
fluid
.
layers
.
fill_constant_batch_size_like
(
input
=
loss_op2
,
shape
=
[
-
1
,
1
],
value
=
0.0
,
dtype
=
'float32'
),
...
...
python/paddle/fluid/tests/unittests/test_dist_fleet_ps2.py
浏览文件 @
42c8d51a
...
...
@@ -59,7 +59,7 @@ class TestPSPassWithBow(unittest.TestCase):
cos_q_pt
,
)
loss_op2
=
fluid
.
layers
.
elementwise_add
(
loss_op1
,
cos_q_nt
)
loss_op3
=
fluid
.
layers
.
elementwise_max
(
loss_op3
=
paddle
.
maximum
(
fluid
.
layers
.
fill_constant_batch_size_like
(
input
=
loss_op2
,
shape
=
[
-
1
,
1
],
value
=
0.0
,
dtype
=
'float32'
),
...
...
python/paddle/fluid/tests/unittests/test_dist_fleet_ps3.py
浏览文件 @
42c8d51a
...
...
@@ -56,7 +56,7 @@ class TestPSPassWithBow(unittest.TestCase):
cos_q_pt
,
)
loss_op2
=
fluid
.
layers
.
elementwise_add
(
loss_op1
,
cos_q_nt
)
loss_op3
=
fluid
.
layers
.
elementwise_max
(
loss_op3
=
paddle
.
maximum
(
fluid
.
layers
.
fill_constant_batch_size_like
(
input
=
loss_op2
,
shape
=
[
-
1
,
1
],
value
=
0.0
,
dtype
=
'float32'
),
...
...
python/paddle/fluid/tests/unittests/test_dist_fleet_ps4.py
浏览文件 @
42c8d51a
...
...
@@ -56,7 +56,7 @@ class TestPSPassWithBow(unittest.TestCase):
cos_q_pt
,
)
loss_op2
=
fluid
.
layers
.
elementwise_add
(
loss_op1
,
cos_q_nt
)
loss_op3
=
fluid
.
layers
.
elementwise_max
(
loss_op3
=
paddle
.
maximum
(
fluid
.
layers
.
fill_constant_batch_size_like
(
input
=
loss_op2
,
shape
=
[
-
1
,
1
],
value
=
0.0
,
dtype
=
'float32'
),
...
...
python/paddle/fluid/tests/unittests/test_dist_fleet_ps5.py
浏览文件 @
42c8d51a
...
...
@@ -56,7 +56,7 @@ class TestPSPassWithBow(unittest.TestCase):
cos_q_pt
,
)
loss_op2
=
fluid
.
layers
.
elementwise_add
(
loss_op1
,
cos_q_nt
)
loss_op3
=
fluid
.
layers
.
elementwise_max
(
loss_op3
=
paddle
.
maximum
(
fluid
.
layers
.
fill_constant_batch_size_like
(
input
=
loss_op2
,
shape
=
[
-
1
,
1
],
value
=
0.0
,
dtype
=
'float32'
),
...
...
python/paddle/fluid/tests/unittests/test_dist_fleet_ps6.py
浏览文件 @
42c8d51a
...
...
@@ -56,7 +56,7 @@ class TestPSPassWithBow(unittest.TestCase):
cos_q_pt
,
)
loss_op2
=
fluid
.
layers
.
elementwise_add
(
loss_op1
,
cos_q_nt
)
loss_op3
=
fluid
.
layers
.
elementwise_max
(
loss_op3
=
paddle
.
maximum
(
fluid
.
layers
.
fill_constant_batch_size_like
(
input
=
loss_op2
,
shape
=
[
-
1
,
1
],
value
=
0.0
,
dtype
=
'float32'
),
...
...
python/paddle/fluid/tests/unittests/test_layers.py
浏览文件 @
42c8d51a
...
...
@@ -652,14 +652,12 @@ class TestLayer(LayerTest):
min_eager_ret
=
layers
.
elementwise_min
(
to_variable
(
n
),
to_variable
(
n2
)
)
max_eager_ret
=
layers
.
elementwise_max
(
to_variable
(
n
),
to_variable
(
n2
)
)
max_eager_ret
=
paddle
.
maximum
(
to_variable
(
n
),
to_variable
(
n2
))
min_eager_ret_value
=
min_eager_ret
.
numpy
()
max_eager_ret_value
=
max_eager_ret
.
numpy
()
min_ret
=
layers
.
elementwise_min
(
to_variable
(
n
),
to_variable
(
n2
))
max_ret
=
layers
.
elementwise_max
(
to_variable
(
n
),
to_variable
(
n2
))
max_ret
=
paddle
.
maximum
(
to_variable
(
n
),
to_variable
(
n2
))
min_ret_value
=
min_ret
.
numpy
()
max_ret_value
=
max_ret
.
numpy
()
...
...
python/paddle/incubate/distributed/models/moe/grad_clip.py
浏览文件 @
42c8d51a
...
...
@@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
paddle
import
paddle.distributed
as
dist
from
paddle.fluid.clip
import
ClipGradBase
,
_squared_l2_norm
from
paddle.fluid.dygraph
import
base
as
imperative_base
...
...
@@ -213,7 +215,7 @@ class ClipGradForMOEByGlobalNorm(ClipGradBase):
)
clip_var
=
layers
.
elementwise_div
(
x
=
max_global_norm
,
y
=
layers
.
elementwise_max
(
x
=
global_norm_var
,
y
=
max_global_norm
),
y
=
paddle
.
maximum
(
x
=
global_norm_var
,
y
=
max_global_norm
),
)
for
p
,
g
in
params_grads
:
if
g
is
None
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录