Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
dab1896d
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看板
未验证
提交
dab1896d
编写于
12月 01, 2022
作者:
H
HongyuJia
提交者:
GitHub
12月 01, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
clean elem_arithmetic part4 unittest (#48465)
上级
ab85f87a
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
36 addition
and
46 deletion
+36
-46
python/paddle/fluid/tests/unittests/ipu/test_assign_op_ipu.py
...on/paddle/fluid/tests/unittests/ipu/test_assign_op_ipu.py
+2
-2
python/paddle/fluid/tests/unittests/ipu/test_dropout_op_ipu.py
...n/paddle/fluid/tests/unittests/ipu/test_dropout_op_ipu.py
+1
-1
python/paddle/fluid/tests/unittests/ipu/test_elemetwise_x_op_ipu.py
...dle/fluid/tests/unittests/ipu/test_elemetwise_x_op_ipu.py
+3
-3
python/paddle/fluid/tests/unittests/ipu/test_fill_any_like_op_ipu.py
...le/fluid/tests/unittests/ipu/test_fill_any_like_op_ipu.py
+2
-2
python/paddle/fluid/tests/unittests/ipu/test_fill_constant_op_ipu.py
...le/fluid/tests/unittests/ipu/test_fill_constant_op_ipu.py
+1
-1
python/paddle/fluid/tests/unittests/ipu/test_reshape_inplace_op_ipu.py
.../fluid/tests/unittests/ipu/test_reshape_inplace_op_ipu.py
+1
-1
python/paddle/fluid/tests/unittests/ipu/test_share_data_op_ipu.py
...addle/fluid/tests/unittests/ipu/test_share_data_op_ipu.py
+2
-2
python/paddle/fluid/tests/unittests/ipu/test_varname_inplace_ipu.py
...dle/fluid/tests/unittests/ipu/test_varname_inplace_ipu.py
+2
-2
python/paddle/fluid/tests/unittests/ps_dnn_model.py
python/paddle/fluid/tests/unittests/ps_dnn_model.py
+1
-3
python/paddle/fluid/tests/unittests/seresnext_net.py
python/paddle/fluid/tests/unittests/seresnext_net.py
+1
-1
python/paddle/fluid/tests/unittests/test_argsort_op.py
python/paddle/fluid/tests/unittests/test_argsort_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_assign_op.py
python/paddle/fluid/tests/unittests/test_assign_op.py
+2
-2
python/paddle/fluid/tests/unittests/test_backward.py
python/paddle/fluid/tests/unittests/test_backward.py
+2
-4
python/paddle/fluid/tests/unittests/test_case.py
python/paddle/fluid/tests/unittests/test_case.py
+2
-2
python/paddle/fluid/tests/unittests/test_complex_variable.py
python/paddle/fluid/tests/unittests/test_complex_variable.py
+1
-1
python/paddle/fluid/tests/unittests/test_cond.py
python/paddle/fluid/tests/unittests/test_cond.py
+7
-7
python/paddle/fluid/tests/unittests/test_dataset.py
python/paddle/fluid/tests/unittests/test_dataset.py
+3
-9
python/paddle/fluid/tests/unittests/test_executor_return_tensor_not_overwriting.py
.../unittests/test_executor_return_tensor_not_overwriting.py
+2
-2
未找到文件。
python/paddle/fluid/tests/unittests/ipu/test_assign_op_ipu.py
浏览文件 @
dab1896d
...
...
@@ -43,7 +43,7 @@ class TestBase(IPUOpTest):
name
=
self
.
feed_list
[
0
],
shape
=
self
.
feed_shape
[
0
],
dtype
=
'float32'
)
x
=
paddle
.
assign
(
x
)
out
=
paddle
.
fluid
.
layers
.
elementwise_
add
(
x
,
x
)
out
=
paddle
.
add
(
x
,
x
)
self
.
fetch_list
=
[
out
.
name
]
def
run_model
(
self
,
exec_mode
):
...
...
@@ -72,7 +72,7 @@ class TestAssignFp32Value(TestBase):
name
=
self
.
feed_list
[
0
],
shape
=
self
.
feed_shape
[
0
],
dtype
=
'float32'
)
assign
=
paddle
.
assign
(
self
.
assign_fp32
)
out
=
paddle
.
fluid
.
layers
.
elementwise_
add
(
x
,
assign
)
out
=
paddle
.
add
(
x
,
assign
)
self
.
fetch_list
=
[
out
.
name
]
...
...
python/paddle/fluid/tests/unittests/ipu/test_dropout_op_ipu.py
浏览文件 @
dab1896d
...
...
@@ -51,7 +51,7 @@ class TestBase(IPUOpTest):
name
=
self
.
feed_list
[
0
],
shape
=
self
.
feed_shape
[
0
],
dtype
=
'float32'
)
x
=
paddle
.
fluid
.
layers
.
dropout
(
x
,
**
self
.
attrs
)
out
=
paddle
.
fluid
.
layers
.
elementwise_
add
(
x
,
x
)
out
=
paddle
.
add
(
x
,
x
)
self
.
fetch_list
=
[
out
.
name
]
def
run_model
(
self
,
exec_mode
):
...
...
python/paddle/fluid/tests/unittests/ipu/test_elemetwise_x_op_ipu.py
浏览文件 @
dab1896d
...
...
@@ -126,17 +126,17 @@ class TestMul(IPUOpTest):
class
TestAdd
(
TestMul
):
def
set_test_op
(
self
):
self
.
op
=
paddle
.
fluid
.
layers
.
elementwise_
add
self
.
op
=
paddle
.
add
class
TestSub
(
TestMul
):
def
set_test_op
(
self
):
self
.
op
=
paddle
.
fluid
.
layers
.
elementwise_sub
self
.
op
=
paddle
.
subtract
class
TestDiv
(
TestMul
):
def
set_test_op
(
self
):
self
.
op
=
paddle
.
fluid
.
layers
.
elementwise_div
self
.
op
=
paddle
.
divide
class
TestMin
(
TestMul
):
...
...
python/paddle/fluid/tests/unittests/ipu/test_fill_any_like_op_ipu.py
浏览文件 @
dab1896d
...
...
@@ -47,7 +47,7 @@ class TestBase(IPUOpTest):
name
=
self
.
feed_list
[
0
],
shape
=
self
.
feed_shape
[
0
],
dtype
=
'float32'
)
x_fill
=
paddle
.
full_like
(
x
,
**
self
.
attrs
)
out
=
paddle
.
fluid
.
layers
.
elementwise_
add
(
x_fill
,
x_fill
)
out
=
paddle
.
add
(
x_fill
,
x_fill
)
self
.
fetch_list
=
[
out
.
name
]
def
run_model
(
self
,
exec_mode
):
...
...
@@ -71,7 +71,7 @@ class TestError(TestBase):
def
build_model
(
self
):
x
=
paddle
.
fluid
.
data
(
'x'
,
[
-
1
,
3
,
13
],
'float32'
)
x_fill
=
paddle
.
full_like
(
x
,
**
self
.
attrs
)
out
=
paddle
.
fluid
.
layers
.
elementwise_
add
(
x_fill
,
x_fill
)
out
=
paddle
.
add
(
x_fill
,
x_fill
)
self
.
fetch_list
=
[
out
.
name
]
def
test
(
self
):
...
...
python/paddle/fluid/tests/unittests/ipu/test_fill_constant_op_ipu.py
浏览文件 @
dab1896d
...
...
@@ -47,7 +47,7 @@ class TestBase(IPUOpTest):
@
IPUOpTest
.
static_graph
def
build_model
(
self
):
x
=
paddle
.
fluid
.
layers
.
fill_constant
(
**
self
.
attrs
)
out
=
paddle
.
fluid
.
layers
.
elementwise_
add
(
x
,
x
)
out
=
paddle
.
add
(
x
,
x
)
self
.
fetch_list
=
[
out
.
name
]
def
run_model
(
self
,
exec_mode
):
...
...
python/paddle/fluid/tests/unittests/ipu/test_reshape_inplace_op_ipu.py
浏览文件 @
dab1896d
...
...
@@ -50,7 +50,7 @@ class TestBase(IPUOpTest):
x
=
paddle
.
static
.
data
(
name
=
self
.
feed_list
[
0
],
shape
=
self
.
feed_shape
[
0
],
dtype
=
'float32'
)
add
=
paddle
.
fluid
.
layers
.
elementwise_
add
(
x
,
x
)
add
=
paddle
.
add
(
x
,
x
)
out
=
paddle
.
reshape
(
add
,
**
self
.
attrs
)
self
.
fetch_list
=
[
out
.
name
]
...
...
python/paddle/fluid/tests/unittests/ipu/test_share_data_op_ipu.py
浏览文件 @
dab1896d
...
...
@@ -48,7 +48,7 @@ class TestBase(IPUOpTest):
self
.
main_prog
.
global_block
().
append_op
(
type
=
"share_data"
,
inputs
=
{
"X"
:
x
},
outputs
=
{
'Out'
:
y
}
)
out
=
paddle
.
fluid
.
layers
.
elementwise_
add
(
y
,
y
)
out
=
paddle
.
add
(
y
,
y
)
self
.
fetch_list
=
[
out
.
name
]
def
run_model
(
self
,
exec_mode
):
...
...
@@ -82,7 +82,7 @@ class TestCase1(TestBase):
self
.
main_prog
.
global_block
().
append_op
(
type
=
"share_data"
,
inputs
=
{
"X"
:
x
},
outputs
=
{
'Out'
:
y
}
)
out
=
paddle
.
fluid
.
layers
.
elementwise_
add
(
x
,
y
)
out
=
paddle
.
add
(
x
,
y
)
self
.
fetch_list
=
[
out
.
name
]
...
...
python/paddle/fluid/tests/unittests/ipu/test_varname_inplace_ipu.py
浏览文件 @
dab1896d
...
...
@@ -59,9 +59,9 @@ class TestBase(IPUOpTest):
shape
=
self
.
feed_shape
[
0
],
dtype
=
self
.
feed_dtype
[
0
],
)
add1
=
paddle
.
fluid
.
layers
.
elementwise_
add
(
x
,
x
)
add1
=
paddle
.
add
(
x
,
x
)
reshape
=
paddle
.
reshape
(
add1
,
**
self
.
attrs
)
add2
=
paddle
.
fluid
.
layers
.
elementwise_
add
(
reshape
,
reshape
)
add2
=
paddle
.
add
(
reshape
,
reshape
)
scale1
=
paddle
.
scale
(
add2
)
scale2
=
paddle
.
scale
(
scale1
,
scale
=
1.3
,
bias
=
0.5
)
scale3
=
paddle
.
scale
(
scale2
,
scale
=
2
,
bias
=
0.7
)
...
...
python/paddle/fluid/tests/unittests/ps_dnn_model.py
浏览文件 @
dab1896d
...
...
@@ -230,9 +230,7 @@ class FlDNNLayer(nn.Layer):
with
paddle
.
fluid
.
device_guard
(
self
.
PART_B_JOINT_OP_DEVICE_FlAG
):
# joint point
interactive
=
paddle
.
fluid
.
layers
.
elementwise_add
(
bottom_a
,
bottom_b
)
interactive
=
paddle
.
add
(
bottom_a
,
bottom_b
)
return
interactive
def
top_layer
(
self
,
interactive
,
label_input
):
...
...
python/paddle/fluid/tests/unittests/seresnext_net.py
浏览文件 @
dab1896d
...
...
@@ -121,7 +121,7 @@ def bottleneck_block(input, num_filters, stride, cardinality, reduction_ratio):
short
=
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
)
)
img_shape
=
[
3
,
224
,
224
]
...
...
python/paddle/fluid/tests/unittests/test_argsort_op.py
浏览文件 @
dab1896d
...
...
@@ -95,7 +95,7 @@ class TestArgsortOpCPU(unittest.TestCase):
input
=
x
,
axis
=
self
.
axis
,
descending
=
self
.
descending
)
self
.
sorted_x
.
stop_gradient
=
False
loss
=
fluid
.
layers
.
elementwise_mul
(
self
.
sorted_x
,
label
)
loss
=
paddle
.
multiply
(
self
.
sorted_x
,
label
)
self
.
loss
=
paddle
.
sum
(
loss
)
def
forward
(
self
):
...
...
python/paddle/fluid/tests/unittests/test_assign_op.py
浏览文件 @
dab1896d
...
...
@@ -90,7 +90,7 @@ class TestAssignOpWithLoDTensorArray(unittest.TestCase):
y
=
fluid
.
layers
.
fill_constant
(
shape
=
[
100
,
10
],
dtype
=
'float32'
,
value
=
1
)
z
=
fluid
.
layers
.
elementwise_
add
(
x
=
x
,
y
=
y
)
z
=
paddle
.
add
(
x
=
x
,
y
=
y
)
i
=
fluid
.
layers
.
fill_constant
(
shape
=
[
1
],
dtype
=
'int64'
,
value
=
0
)
init_array
=
fluid
.
layers
.
array_write
(
x
=
z
,
i
=
i
)
array
=
fluid
.
layers
.
assign
(
init_array
)
...
...
@@ -144,7 +144,7 @@ class TestAssignOApi(unittest.TestCase):
y
=
fluid
.
layers
.
fill_constant
(
shape
=
[
100
,
10
],
dtype
=
'float32'
,
value
=
1
)
z
=
fluid
.
layers
.
elementwise_
add
(
x
=
x
,
y
=
y
)
z
=
paddle
.
add
(
x
=
x
,
y
=
y
)
i
=
fluid
.
layers
.
fill_constant
(
shape
=
[
1
],
dtype
=
'int64'
,
value
=
0
)
init_array
=
fluid
.
layers
.
array_write
(
x
=
z
,
i
=
i
)
array
=
paddle
.
assign
(
init_array
)
...
...
python/paddle/fluid/tests/unittests/test_backward.py
浏览文件 @
dab1896d
...
...
@@ -243,10 +243,8 @@ class SimpleNet(BackwardNet):
x3
,
size
=
[
100
,
64
],
param_attr
=
fluid
.
ParamAttr
(
name
=
'w2v'
)
)
# merge layers
x_merge
=
fluid
.
layers
.
elementwise_add
(
x_emb
,
x2_emb
,
name
=
'x_add_x2'
)
x2_merge
=
fluid
.
layers
.
elementwise_add
(
x2_emb
,
x3_emb
,
name
=
'x2_add_x3'
)
x_merge
=
paddle
.
add
(
x_emb
,
x2_emb
,
name
=
'x_add_x2'
)
x2_merge
=
paddle
.
add
(
x2_emb
,
x3_emb
,
name
=
'x2_add_x3'
)
# shared fc_w
predict
=
fluid
.
layers
.
fc
(
input
=
x_merge
,
...
...
python/paddle/fluid/tests/unittests/test_case.py
浏览文件 @
dab1896d
...
...
@@ -299,12 +299,12 @@ class TestMutiTask(unittest.TestCase):
adagrad
=
optimizer
.
Adagrad
(
learning_rate
=
0.001
)
def
fn_1
():
sum
=
layers
.
elementwise_mul
(
x
,
y
)
sum
=
paddle
.
multiply
(
x
,
y
)
loss
=
paddle
.
mean
(
sum
,
name
=
"f_1_loss"
)
adam
.
minimize
(
loss
)
def
fn_2
():
sum
=
layers
.
elementwise_mul
(
x
,
y
)
sum
=
paddle
.
multiply
(
x
,
y
)
loss
=
paddle
.
mean
(
sum
,
name
=
"f_2_loss"
)
adagrad
.
minimize
(
loss
)
...
...
python/paddle/fluid/tests/unittests/test_complex_variable.py
浏览文件 @
dab1896d
...
...
@@ -33,7 +33,7 @@ class TestComplexVariable(unittest.TestCase):
with
dg
.
guard
():
x
=
dg
.
to_variable
(
a
,
"x"
)
y
=
dg
.
to_variable
(
b
)
out
=
paddle
.
fluid
.
layers
.
elementwise_
add
(
x
,
y
)
out
=
paddle
.
add
(
x
,
y
)
self
.
assertIsNotNone
(
"{}"
.
format
(
out
))
np
.
testing
.
assert_allclose
(
out
.
numpy
(),
a
+
b
,
rtol
=
1e-05
)
...
...
python/paddle/fluid/tests/unittests/test_cond.py
浏览文件 @
dab1896d
...
...
@@ -310,15 +310,15 @@ class TestCondNestedControlFlow(unittest.TestCase):
def
less_than_branch
(
i
,
a
):
return
layers
.
cond
(
i
>=
3.0
,
lambda
:
layers
.
elementwise_
add
(
a
,
a
),
lambda
:
layers
.
elementwise_sub
(
a
,
a
),
lambda
:
paddle
.
add
(
a
,
a
),
lambda
:
paddle
.
subtract
(
a
,
a
),
)
def
greater_equal_branch
(
i
,
a
):
return
layers
.
cond
(
i
<
8.0
,
lambda
:
layers
.
elementwise_mul
(
a
,
a
),
lambda
:
layers
.
elementwise_div
(
a
,
a
),
lambda
:
paddle
.
multiply
(
a
,
a
),
lambda
:
paddle
.
divide
(
a
,
a
),
)
main_program
=
Program
()
...
...
@@ -374,12 +374,12 @@ class TestCondNestedControlFlow(unittest.TestCase):
a
<
b
,
lambda
:
fluid
.
layers
.
cond
(
a
-
b
<
-
1.0
,
lambda
:
fluid
.
layers
.
elementwise_
add
(
a
,
b
),
lambda
:
fluid
.
layers
.
elementwise_mul
(
a
,
b
),
lambda
:
paddle
.
add
(
a
,
b
),
lambda
:
paddle
.
multiply
(
a
,
b
),
),
lambda
:
fluid
.
layers
.
cond
(
a
==
b
,
lambda
:
fluid
.
layers
.
elementwise_sub
(
a
,
b
),
lambda
:
paddle
.
subtract
(
a
,
b
),
lambda
:
paddle
.
pow
(
a
,
b
),
),
)
...
...
python/paddle/fluid/tests/unittests/test_dataset.py
浏览文件 @
dab1896d
...
...
@@ -1029,9 +1029,7 @@ class TestDataset2(unittest.TestCase):
name
=
slot
,
shape
=
[
1
],
dtype
=
"float32"
,
lod_level
=
1
)
slots_vars
.
append
(
var
)
fake_cost
=
fluid
.
layers
.
elementwise_sub
(
slots_vars
[
0
],
slots_vars
[
-
1
]
)
fake_cost
=
paddle
.
subtract
(
slots_vars
[
0
],
slots_vars
[
-
1
])
fake_cost
=
paddle
.
mean
(
fake_cost
)
with
fluid
.
scope_guard
(
scope
):
place
=
fluid
.
CPUPlace
()
...
...
@@ -1101,9 +1099,7 @@ class TestDataset2(unittest.TestCase):
name
=
slot
,
shape
=
[
1
],
dtype
=
"float32"
,
lod_level
=
1
)
slots_vars
.
append
(
var
)
fake_cost
=
fluid
.
layers
.
elementwise_sub
(
slots_vars
[
0
],
slots_vars
[
-
1
]
)
fake_cost
=
paddle
.
subtract
(
slots_vars
[
0
],
slots_vars
[
-
1
])
fake_cost
=
paddle
.
mean
(
fake_cost
)
with
fluid
.
scope_guard
(
scope
):
place
=
fluid
.
CPUPlace
()
...
...
@@ -1234,9 +1230,7 @@ class TestDataset2(unittest.TestCase):
name
=
slot
,
shape
=
[
1
],
dtype
=
"float32"
,
lod_level
=
1
)
slots_vars
.
append
(
var
)
fake_cost
=
fluid
.
layers
.
elementwise_sub
(
slots_vars
[
0
],
slots_vars
[
-
1
]
)
fake_cost
=
paddle
.
subtract
(
slots_vars
[
0
],
slots_vars
[
-
1
])
fake_cost
=
paddle
.
mean
(
fake_cost
)
with
fluid
.
scope_guard
(
scope
):
place
=
fluid
.
CPUPlace
()
...
...
python/paddle/fluid/tests/unittests/test_executor_return_tensor_not_overwriting.py
浏览文件 @
dab1896d
...
...
@@ -75,7 +75,7 @@ class TestExecutorReturnTensorNotOverOverwritingWithLayers(unittest.TestCase):
def
calc_add_out
(
self
,
place
=
None
,
parallel
=
None
):
x
=
paddle
.
ones
(
shape
=
[
3
,
3
],
dtype
=
'float32'
)
y
=
paddle
.
ones
(
shape
=
[
3
,
3
],
dtype
=
'float32'
)
out
=
fluid
.
layers
.
elementwise_
add
(
x
=
x
,
y
=
y
)
out
=
paddle
.
add
(
x
=
x
,
y
=
y
)
program
=
fluid
.
default_main_program
()
if
parallel
:
program
=
fluid
.
CompiledProgram
(
program
).
with_data_parallel
(
...
...
@@ -88,7 +88,7 @@ class TestExecutorReturnTensorNotOverOverwritingWithLayers(unittest.TestCase):
def
calc_sub_out
(
self
,
place
=
None
,
parallel
=
None
):
x
=
paddle
.
ones
(
shape
=
[
2
,
2
],
dtype
=
'float32'
)
y
=
paddle
.
ones
(
shape
=
[
2
,
2
],
dtype
=
'float32'
)
out
=
fluid
.
layers
.
elementwise_sub
(
x
=
x
,
y
=
y
)
out
=
paddle
.
subtract
(
x
=
x
,
y
=
y
)
program
=
fluid
.
default_main_program
()
if
parallel
:
program
=
fluid
.
CompiledProgram
(
program
).
with_data_parallel
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录