Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
2005d45a
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
2005d45a
编写于
11月 29, 2022
作者:
H
HongyuJia
提交者:
GitHub
11月 29, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
clean elem_arithmetic part3 unittest (#48462)
上级
048e0c55
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
45 addition
and
51 deletion
+45
-51
python/paddle/fluid/tests/unittests/dist_fleet_simnet_bow.py
python/paddle/fluid/tests/unittests/dist_fleet_simnet_bow.py
+3
-3
python/paddle/fluid/tests/unittests/dist_se_resnext.py
python/paddle/fluid/tests/unittests/dist_se_resnext.py
+1
-1
python/paddle/fluid/tests/unittests/dygraph_to_static/darknet.py
...paddle/fluid/tests/unittests/dygraph_to_static/darknet.py
+1
-1
python/paddle/fluid/tests/unittests/dygraph_to_static/seq2seq_dygraph_model.py
...ests/unittests/dygraph_to_static/seq2seq_dygraph_model.py
+6
-9
python/paddle/fluid/tests/unittests/dygraph_to_static/simnet_dygraph_model.py
...tests/unittests/dygraph_to_static/simnet_dygraph_model.py
+2
-2
python/paddle/fluid/tests/unittests/dygraph_to_static/simnet_dygraph_model_v2.py
...ts/unittests/dygraph_to_static/simnet_dygraph_model_v2.py
+1
-1
python/paddle/fluid/tests/unittests/dygraph_to_static/test_bmn.py
...addle/fluid/tests/unittests/dygraph_to_static/test_bmn.py
+11
-11
python/paddle/fluid/tests/unittests/dygraph_to_static/test_cycle_gan.py
...fluid/tests/unittests/dygraph_to_static/test_cycle_gan.py
+5
-5
python/paddle/fluid/tests/unittests/dygraph_to_static/test_mobile_net.py
...luid/tests/unittests/dygraph_to_static/test_mobile_net.py
+1
-1
python/paddle/fluid/tests/unittests/dygraph_to_static/test_ptb_lm.py
...le/fluid/tests/unittests/dygraph_to_static/test_ptb_lm.py
+2
-2
python/paddle/fluid/tests/unittests/dygraph_to_static/test_reinforcement_learning.py
...nittests/dygraph_to_static/test_reinforcement_learning.py
+2
-2
python/paddle/fluid/tests/unittests/dygraph_to_static/test_resnet.py
...le/fluid/tests/unittests/dygraph_to_static/test_resnet.py
+1
-1
python/paddle/fluid/tests/unittests/dygraph_to_static/test_se_resnet.py
...fluid/tests/unittests/dygraph_to_static/test_se_resnet.py
+1
-1
python/paddle/fluid/tests/unittests/dygraph_to_static/test_tsm.py
...addle/fluid/tests/unittests/dygraph_to_static/test_tsm.py
+1
-1
python/paddle/fluid/tests/unittests/dygraph_to_static/test_word2vec.py
.../fluid/tests/unittests/dygraph_to_static/test_word2vec.py
+1
-3
python/paddle/fluid/tests/unittests/dygraph_to_static/transformer_dygraph_model.py
.../unittests/dygraph_to_static/transformer_dygraph_model.py
+1
-2
python/paddle/fluid/tests/unittests/npu/test_amp_check_finite_and_scale_op_npu.py
...s/unittests/npu/test_amp_check_finite_and_scale_op_npu.py
+3
-3
python/paddle/fluid/tests/unittests/npu/test_elementwise_div_op_npu.py
.../fluid/tests/unittests/npu/test_elementwise_div_op_npu.py
+1
-1
python/paddle/fluid/tests/unittests/parallel_dygraph_sparse_embedding.py
...luid/tests/unittests/parallel_dygraph_sparse_embedding.py
+1
-1
未找到文件。
python/paddle/fluid/tests/unittests/dist_fleet_simnet_bow.py
浏览文件 @
2005d45a
...
...
@@ -57,7 +57,7 @@ def get_acc(cos_q_nt, cos_q_pt, batch_size):
cond
=
fluid
.
layers
.
less_than
(
cos_q_nt
,
cos_q_pt
)
cond
=
fluid
.
layers
.
cast
(
cond
,
dtype
=
'float64'
)
cond_3
=
paddle
.
sum
(
cond
)
acc
=
fluid
.
layers
.
elementwise_div
(
acc
=
paddle
.
divide
(
cond_3
,
fluid
.
layers
.
fill_constant
(
shape
=
[
1
],
value
=
batch_size
*
1.0
,
dtype
=
'float64'
...
...
@@ -68,13 +68,13 @@ def get_acc(cos_q_nt, cos_q_pt, batch_size):
def
get_loss
(
cos_q_pt
,
cos_q_nt
):
loss_op1
=
fluid
.
layers
.
elementwise_sub
(
loss_op1
=
paddle
.
subtract
(
fluid
.
layers
.
fill_constant_batch_size_like
(
input
=
cos_q_pt
,
shape
=
[
-
1
,
1
],
value
=
margin
,
dtype
=
'float32'
),
cos_q_pt
,
)
loss_op2
=
fluid
.
layers
.
elementwise_
add
(
loss_op1
,
cos_q_nt
)
loss_op2
=
paddle
.
add
(
loss_op1
,
cos_q_nt
)
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/dist_se_resnext.py
浏览文件 @
2005d45a
...
...
@@ -163,7 +163,7 @@ class SE_ResNeXt:
short
=
self
.
shortcut
(
input
,
num_filters
*
2
,
stride
)
return
fluid
.
layers
.
elementwise_add
(
x
=
short
,
y
=
scale
,
act
=
'relu'
)
return
paddle
.
nn
.
functional
.
relu
(
paddle
.
add
(
x
=
short
,
y
=
scale
)
)
def
conv_bn_layer
(
self
,
input
,
num_filters
,
filter_size
,
stride
=
1
,
groups
=
1
,
act
=
None
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/darknet.py
浏览文件 @
2005d45a
...
...
@@ -114,7 +114,7 @@ class BasicBlock(fluid.dygraph.Layer):
def
forward
(
self
,
inputs
):
conv1
=
self
.
conv1
(
inputs
)
conv2
=
self
.
conv2
(
conv1
)
out
=
fluid
.
layers
.
elementwise_add
(
x
=
inputs
,
y
=
conv2
,
act
=
None
)
out
=
paddle
.
add
(
x
=
inputs
,
y
=
conv2
)
return
out
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/seq2seq_dygraph_model.py
浏览文件 @
2005d45a
...
...
@@ -72,15 +72,13 @@ class BasicLSTMUnit(Layer):
concat_input_hidden
=
layers
.
concat
([
input
,
pre_hidden
],
1
)
gate_input
=
layers
.
matmul
(
x
=
concat_input_hidden
,
y
=
self
.
_weight
)
gate_input
=
layers
.
elementwise_
add
(
gate_input
,
self
.
_bias
)
gate_input
=
paddle
.
add
(
gate_input
,
self
.
_bias
)
i
,
j
,
f
,
o
=
layers
.
split
(
gate_input
,
num_or_sections
=
4
,
dim
=-
1
)
new_cell
=
layers
.
elementwise_
add
(
layers
.
elementwise_mul
(
new_cell
=
paddle
.
add
(
paddle
.
multiply
(
pre_cell
,
paddle
.
nn
.
functional
.
sigmoid
(
f
+
self
.
_forget_bias
)
),
layers
.
elementwise_mul
(
paddle
.
nn
.
functional
.
sigmoid
(
i
),
paddle
.
tanh
(
j
)
),
paddle
.
multiply
(
paddle
.
nn
.
functional
.
sigmoid
(
i
),
paddle
.
tanh
(
j
)),
)
new_hidden
=
paddle
.
tanh
(
new_cell
)
*
paddle
.
nn
.
functional
.
sigmoid
(
o
)
...
...
@@ -442,13 +440,12 @@ class BaseModel(fluid.dygraph.Layer):
np
.
array
(
noend_array
,
dtype
=
'float32'
)
)
step_log_probs
=
fluid
.
layers
.
elementwise_mul
(
step_log_probs
=
paddle
.
multiply
(
paddle
.
expand
(
fluid
.
layers
.
unsqueeze
(
beam_finished
,
[
2
]),
[
-
1
,
-
1
,
self
.
tar_vocab_size
],
),
noend_mask_tensor
,
axis
=-
1
,
)
-
fluid
.
layers
.
elementwise_mul
(
step_log_probs
,
(
beam_finished
-
1
),
axis
=
0
)
...
...
@@ -693,7 +690,7 @@ class AttentionModel(fluid.dygraph.Layer):
if
mask
is
not
None
:
attn
=
paddle
.
transpose
(
attn
,
[
1
,
0
,
2
])
attn
=
fluid
.
layers
.
elementwise_add
(
attn
,
mask
*
1000000000
,
-
1
)
attn
=
paddle
.
add
(
attn
,
mask
*
1000000000
)
attn
=
paddle
.
transpose
(
attn
,
[
1
,
0
,
2
])
weight
=
fluid
.
layers
.
softmax
(
attn
)
weight_memory
=
fluid
.
layers
.
matmul
(
weight
,
memory
)
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/simnet_dygraph_model.py
浏览文件 @
2005d45a
...
...
@@ -171,7 +171,7 @@ class ElementwiseAddLayer:
"""
operation
"""
add
=
fluid
.
layers
.
elementwise_
add
(
x
,
y
)
add
=
paddle
.
add
(
x
,
y
)
return
add
...
...
@@ -190,7 +190,7 @@ class ElementwiseSubLayer:
"""
operation
"""
sub
=
fluid
.
layers
.
elementwise_sub
(
x
,
y
)
sub
=
paddle
.
subtract
(
x
,
y
)
return
sub
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/simnet_dygraph_model_v2.py
浏览文件 @
2005d45a
...
...
@@ -187,7 +187,7 @@ class ElementwiseSubLayer:
"""
operation
"""
sub
=
paddle
.
fluid
.
layers
.
elementwise_sub
(
x
,
y
)
sub
=
paddle
.
subtract
(
x
,
y
)
return
sub
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/test_bmn.py
浏览文件 @
2005d45a
...
...
@@ -330,11 +330,11 @@ def bmn_loss_func(
coef_1
=
0.5
*
ratio
epsilon
=
0.000001
# temp = fluid.layers.log(pred_score + epsilon)
loss_pos
=
fluid
.
layers
.
elementwise_mul
(
loss_pos
=
paddle
.
multiply
(
fluid
.
layers
.
log
(
pred_score
+
epsilon
),
pmask
)
loss_pos
=
coef_1
*
fluid
.
layers
.
reduce_mean
(
loss_pos
)
loss_neg
=
fluid
.
layers
.
elementwise_mul
(
loss_neg
=
paddle
.
multiply
(
fluid
.
layers
.
log
(
1.0
-
pred_score
+
epsilon
),
(
1.0
-
pmask
)
)
loss_neg
=
coef_0
*
fluid
.
layers
.
reduce_mean
(
loss_neg
)
...
...
@@ -348,14 +348,14 @@ def bmn_loss_func(
def
pem_reg_loss_func
(
pred_score
,
gt_iou_map
,
mask
):
gt_iou_map
=
fluid
.
layers
.
elementwise_mul
(
gt_iou_map
,
mask
)
gt_iou_map
=
paddle
.
multiply
(
gt_iou_map
,
mask
)
u_hmask
=
fluid
.
layers
.
cast
(
x
=
gt_iou_map
>
0.7
,
dtype
=
DATATYPE
)
u_mmask
=
paddle
.
logical_and
(
gt_iou_map
<=
0.7
,
gt_iou_map
>
0.3
)
u_mmask
=
fluid
.
layers
.
cast
(
x
=
u_mmask
,
dtype
=
DATATYPE
)
u_lmask
=
paddle
.
logical_and
(
gt_iou_map
<=
0.3
,
gt_iou_map
>=
0.0
)
u_lmask
=
fluid
.
layers
.
cast
(
x
=
u_lmask
,
dtype
=
DATATYPE
)
u_lmask
=
fluid
.
layers
.
elementwise_mul
(
u_lmask
,
mask
)
u_lmask
=
paddle
.
multiply
(
u_lmask
,
mask
)
num_h
=
fluid
.
layers
.
cast
(
paddle
.
sum
(
u_hmask
),
dtype
=
DATATYPE
)
num_m
=
fluid
.
layers
.
cast
(
paddle
.
sum
(
u_mmask
),
dtype
=
DATATYPE
)
...
...
@@ -367,7 +367,7 @@ def bmn_loss_func(
0.0
,
1.0
,
[
gt_iou_map
.
shape
[
1
],
gt_iou_map
.
shape
[
2
]]
).
astype
(
DATATYPE
)
)
u_smmask
=
fluid
.
layers
.
elementwise_mul
(
u_mmask
,
u_smmask
)
u_smmask
=
paddle
.
multiply
(
u_mmask
,
u_smmask
)
u_smmask
=
fluid
.
layers
.
cast
(
x
=
(
u_smmask
>
(
1.0
-
r_m
)),
dtype
=
DATATYPE
)
r_l
=
num_h
/
num_l
...
...
@@ -376,23 +376,23 @@ def bmn_loss_func(
0.0
,
1.0
,
[
gt_iou_map
.
shape
[
1
],
gt_iou_map
.
shape
[
2
]]
).
astype
(
DATATYPE
)
)
u_slmask
=
fluid
.
layers
.
elementwise_mul
(
u_lmask
,
u_slmask
)
u_slmask
=
paddle
.
multiply
(
u_lmask
,
u_slmask
)
u_slmask
=
fluid
.
layers
.
cast
(
x
=
(
u_slmask
>
(
1.0
-
r_l
)),
dtype
=
DATATYPE
)
weights
=
u_hmask
+
u_smmask
+
u_slmask
weights
.
stop_gradient
=
True
loss
=
fluid
.
layers
.
square_error_cost
(
pred_score
,
gt_iou_map
)
loss
=
fluid
.
layers
.
elementwise_mul
(
loss
,
weights
)
loss
=
paddle
.
multiply
(
loss
,
weights
)
loss
=
0.5
*
paddle
.
sum
(
loss
)
/
paddle
.
sum
(
weights
)
return
loss
def
pem_cls_loss_func
(
pred_score
,
gt_iou_map
,
mask
):
gt_iou_map
=
fluid
.
layers
.
elementwise_mul
(
gt_iou_map
,
mask
)
gt_iou_map
=
paddle
.
multiply
(
gt_iou_map
,
mask
)
gt_iou_map
.
stop_gradient
=
True
pmask
=
fluid
.
layers
.
cast
(
x
=
(
gt_iou_map
>
0.9
),
dtype
=
DATATYPE
)
nmask
=
fluid
.
layers
.
cast
(
x
=
(
gt_iou_map
<=
0.9
),
dtype
=
DATATYPE
)
nmask
=
fluid
.
layers
.
elementwise_mul
(
nmask
,
mask
)
nmask
=
paddle
.
multiply
(
nmask
,
mask
)
num_positive
=
paddle
.
sum
(
pmask
)
num_entries
=
num_positive
+
paddle
.
sum
(
nmask
)
...
...
@@ -400,11 +400,11 @@ def bmn_loss_func(
coef_0
=
0.5
*
ratio
/
(
ratio
-
1
)
coef_1
=
0.5
*
ratio
epsilon
=
0.000001
loss_pos
=
fluid
.
layers
.
elementwise_mul
(
loss_pos
=
paddle
.
multiply
(
fluid
.
layers
.
log
(
pred_score
+
epsilon
),
pmask
)
loss_pos
=
coef_1
*
paddle
.
sum
(
loss_pos
)
loss_neg
=
fluid
.
layers
.
elementwise_mul
(
loss_neg
=
paddle
.
multiply
(
fluid
.
layers
.
log
(
1.0
-
pred_score
+
epsilon
),
nmask
)
loss_neg
=
coef_0
*
paddle
.
sum
(
loss_neg
)
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/test_cycle_gan.py
浏览文件 @
2005d45a
...
...
@@ -91,8 +91,8 @@ class Cycle_Gan(fluid.dygraph.Layer):
cyc_A
=
self
.
build_generator_resnet_9blocks_b
(
fake_B
)
cyc_B
=
self
.
build_generator_resnet_9blocks_a
(
fake_A
)
diff_A
=
paddle
.
abs
(
fluid
.
layers
.
elementwise_sub
(
x
=
input_A
,
y
=
cyc_A
))
diff_B
=
paddle
.
abs
(
fluid
.
layers
.
elementwise_sub
(
x
=
input_B
,
y
=
cyc_B
))
diff_A
=
paddle
.
abs
(
paddle
.
subtract
(
x
=
input_A
,
y
=
cyc_A
))
diff_B
=
paddle
.
abs
(
paddle
.
subtract
(
x
=
input_B
,
y
=
cyc_B
))
cyc_A_loss
=
fluid
.
layers
.
reduce_mean
(
diff_A
)
*
lambda_A
cyc_B_loss
=
fluid
.
layers
.
reduce_mean
(
diff_B
)
*
lambda_B
cyc_loss
=
cyc_A_loss
+
cyc_B_loss
...
...
@@ -106,7 +106,7 @@ class Cycle_Gan(fluid.dygraph.Layer):
idt_A
=
self
.
build_generator_resnet_9blocks_a
(
input_B
)
idt_loss_A
=
(
fluid
.
layers
.
reduce_mean
(
paddle
.
abs
(
fluid
.
layers
.
elementwise_sub
(
x
=
input_B
,
y
=
idt_A
))
paddle
.
abs
(
paddle
.
subtract
(
x
=
input_B
,
y
=
idt_A
))
)
*
lambda_B
*
lambda_identity
...
...
@@ -115,12 +115,12 @@ class Cycle_Gan(fluid.dygraph.Layer):
idt_B
=
self
.
build_generator_resnet_9blocks_b
(
input_A
)
idt_loss_B
=
(
fluid
.
layers
.
reduce_mean
(
paddle
.
abs
(
fluid
.
layers
.
elementwise_sub
(
x
=
input_A
,
y
=
idt_B
))
paddle
.
abs
(
paddle
.
subtract
(
x
=
input_A
,
y
=
idt_B
))
)
*
lambda_A
*
lambda_identity
)
idt_loss
=
fluid
.
layers
.
elementwise_
add
(
idt_loss_A
,
idt_loss_B
)
idt_loss
=
paddle
.
add
(
idt_loss_A
,
idt_loss_B
)
g_loss
=
cyc_loss
+
G
+
idt_loss
return
(
fake_A
,
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/test_mobile_net.py
浏览文件 @
2005d45a
...
...
@@ -326,7 +326,7 @@ class InvertedResidualUnit(fluid.dygraph.Layer):
y
=
self
.
_bottleneck_conv
(
y
,
if_act
=
True
)
y
=
self
.
_linear_conv
(
y
,
if_act
=
False
)
if
ifshortcut
:
y
=
fluid
.
layers
.
elementwise_
add
(
inputs
,
y
)
y
=
paddle
.
add
(
inputs
,
y
)
return
y
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/test_ptb_lm.py
浏览文件 @
2005d45a
...
...
@@ -96,7 +96,7 @@ class SimpleLSTMRNN(fluid.Layer):
nn
=
fluid
.
layers
.
concat
([
step_input
,
pre_hidden
],
1
)
gate_input
=
fluid
.
layers
.
matmul
(
x
=
nn
,
y
=
weight_1
)
gate_input
=
fluid
.
layers
.
elementwise_
add
(
gate_input
,
bias
)
gate_input
=
paddle
.
add
(
gate_input
,
bias
)
i
,
j
,
f
,
o
=
fluid
.
layers
.
split
(
gate_input
,
num_or_sections
=
4
,
dim
=-
1
)
...
...
@@ -214,7 +214,7 @@ class PtbModel(fluid.Layer):
)
projection
=
fluid
.
layers
.
matmul
(
rnn_out
,
self
.
softmax_weight
)
projection
=
fluid
.
layers
.
elementwise_
add
(
projection
,
self
.
softmax_bias
)
projection
=
paddle
.
add
(
projection
,
self
.
softmax_bias
)
loss
=
fluid
.
layers
.
softmax_with_cross_entropy
(
logits
=
projection
,
label
=
label
,
soft_label
=
False
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/test_reinforcement_learning.py
浏览文件 @
2005d45a
...
...
@@ -124,7 +124,7 @@ def train(args, place, to_static):
mask
.
stop_gradient
=
True
loss_probs
=
fluid
.
layers
.
log
(
loss_probs
)
loss_probs
=
fluid
.
layers
.
elementwise_mul
(
loss_probs
,
mask
)
loss_probs
=
paddle
.
multiply
(
loss_probs
,
mask
)
loss_probs
=
paddle
.
sum
(
loss_probs
,
axis
=-
1
)
policy
.
saved_log_probs
.
append
(
loss_probs
)
...
...
@@ -151,7 +151,7 @@ def train(args, place, to_static):
_R
=
-
1
*
R
*
R_numpy
_R
=
to_variable
(
_R
)
_R
.
stop_gradient
=
True
cur_loss
=
fluid
.
layers
.
elementwise_mul
(
_R
,
log_prob
)
cur_loss
=
paddle
.
multiply
(
_R
,
log_prob
)
policy_loss
.
append
(
cur_loss
)
policy_loss
=
fluid
.
layers
.
concat
(
policy_loss
)
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/test_resnet.py
浏览文件 @
2005d45a
...
...
@@ -133,7 +133,7 @@ class BottleneckBlock(fluid.dygraph.Layer):
else
:
short
=
self
.
short
(
inputs
)
y
=
fluid
.
layers
.
elementwise_
add
(
x
=
short
,
y
=
conv2
)
y
=
paddle
.
add
(
x
=
short
,
y
=
conv2
)
layer_helper
=
fluid
.
layer_helper
.
LayerHelper
(
self
.
full_name
(),
act
=
'relu'
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/test_se_resnet.py
浏览文件 @
2005d45a
...
...
@@ -215,7 +215,7 @@ class BottleneckBlock(fluid.dygraph.Layer):
else
:
short
=
self
.
short
(
inputs
)
y
=
fluid
.
layers
.
elementwise_add
(
x
=
short
,
y
=
scale
,
act
=
'relu'
)
y
=
paddle
.
nn
.
functional
.
relu
(
paddle
.
add
(
x
=
short
,
y
=
scale
)
)
return
y
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/test_tsm.py
浏览文件 @
2005d45a
...
...
@@ -133,7 +133,7 @@ class BottleneckBlock(fluid.dygraph.Layer):
short
=
inputs
else
:
short
=
self
.
short
(
inputs
)
y
=
fluid
.
layers
.
elementwise_add
(
x
=
short
,
y
=
conv2
,
act
=
"relu"
)
y
=
paddle
.
nn
.
functional
.
relu
(
paddle
.
add
(
x
=
short
,
y
=
conv2
)
)
return
y
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/test_word2vec.py
浏览文件 @
2005d45a
...
...
@@ -257,9 +257,7 @@ class SkipGram(fluid.dygraph.Layer):
# center_words_emb = [batch_size, embedding_size]
# target_words_emb = [batch_size, embedding_size]
word_sim
=
fluid
.
layers
.
elementwise_mul
(
center_words_emb
,
target_words_emb
)
word_sim
=
paddle
.
multiply
(
center_words_emb
,
target_words_emb
)
word_sim
=
paddle
.
sum
(
word_sim
,
axis
=-
1
)
pred
=
paddle
.
nn
.
functional
.
sigmoid
(
word_sim
)
...
...
python/paddle/fluid/tests/unittests/dygraph_to_static/transformer_dygraph_model.py
浏览文件 @
2005d45a
...
...
@@ -756,13 +756,12 @@ class Transformer(Layer):
def
mask_probs
(
probs
,
finished
,
noend_mask_tensor
):
finished
=
layers
.
cast
(
finished
,
dtype
=
probs
.
dtype
)
probs
=
layers
.
elementwise_mul
(
probs
=
paddle
.
multiply
(
paddle
.
expand
(
layers
.
unsqueeze
(
finished
,
[
2
]),
[
-
1
,
-
1
,
self
.
trg_vocab_size
],
),
noend_mask_tensor
,
axis
=-
1
,
)
-
layers
.
elementwise_mul
(
probs
,
(
finished
-
1
),
axis
=
0
)
return
probs
...
...
python/paddle/fluid/tests/unittests/npu/test_amp_check_finite_and_scale_op_npu.py
浏览文件 @
2005d45a
...
...
@@ -45,7 +45,7 @@ class TestCheckFiniteAndUnscale(unittest.TestCase):
inputs
=
{
"FloatStatus"
:
float_status
},
outputs
=
{
"FloatStatusOut"
:
float_status
},
)
c
=
paddle
.
fluid
.
layers
.
elementwise_div
(
a
,
b
)
c
=
paddle
.
divide
(
a
,
b
)
out
,
found_inf
=
check_finite_and_unscale
(
[
c
],
scale
,
float_status
=
float_status
)
...
...
@@ -115,7 +115,7 @@ class TestCheckFiniteAndUnscaleClearFloatStatus(unittest.TestCase):
inputs
=
{
"FloatStatus"
:
float_status
},
outputs
=
{
"FloatStatusOut"
:
float_status
},
)
c
=
paddle
.
fluid
.
layers
.
elementwise_div
(
a
,
b
)
c
=
paddle
.
divide
(
a
,
b
)
out
,
found_inf
=
check_finite_and_unscale
(
[
c
],
scale
,
float_status
=
float_status
)
...
...
@@ -127,7 +127,7 @@ class TestCheckFiniteAndUnscaleClearFloatStatus(unittest.TestCase):
inputs
=
{
"FloatStatus"
:
float_status
},
outputs
=
{
"FloatStatusOut"
:
float_status
},
)
d
=
paddle
.
fluid
.
layers
.
elementwise_
add
(
a
,
b
)
d
=
paddle
.
add
(
a
,
b
)
out
,
found_inf
=
check_finite_and_unscale
(
[
d
],
scale
,
float_status
=
float_status
)
...
...
python/paddle/fluid/tests/unittests/npu/test_elementwise_div_op_npu.py
浏览文件 @
2005d45a
...
...
@@ -133,7 +133,7 @@ class TestElementwiseDivNet(unittest.TestCase):
e
=
paddle
.
multiply
(
a
,
b
)
f
=
paddle
.
multiply
(
c
,
d
)
f
.
stop_gradient
=
True
g
=
fluid
.
layers
.
elementwise_div
(
e
,
f
)
g
=
paddle
.
divide
(
e
,
f
)
fc_1
=
fluid
.
layers
.
fc
(
input
=
g
,
size
=
128
)
prediction
=
fluid
.
layers
.
fc
(
input
=
fc_1
,
size
=
2
,
act
=
'softmax'
)
...
...
python/paddle/fluid/tests/unittests/parallel_dygraph_sparse_embedding.py
浏览文件 @
2005d45a
...
...
@@ -66,7 +66,7 @@ class SimpleNet(fluid.Layer):
def
forward
(
self
,
input
,
label
):
x_emb
=
self
.
embedding
(
input
)
fc
=
fluid
.
layers
.
matmul
(
x_emb
,
self
.
softmax_weight
)
fc
=
fluid
.
layers
.
elementwise_
add
(
fc
,
self
.
softmax_bias
)
fc
=
paddle
.
add
(
fc
,
self
.
softmax_bias
)
projection
=
paddle
.
reshape
(
fc
,
shape
=
[
-
1
,
self
.
vocab_size
])
loss
=
fluid
.
layers
.
softmax_with_cross_entropy
(
logits
=
projection
,
label
=
label
,
soft_label
=
False
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录