Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
11d7dae9
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
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看板
未验证
提交
11d7dae9
编写于
3月 12, 2023
作者:
W
wanghuancoder
提交者:
GitHub
3月 12, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Del old dygraph optest1 (#51417)
* delete old dygraph op test
上级
da551b2e
变更
14
显示空白变更内容
内联
并排
Showing
14 changed file
with
96 addition
and
76 deletion
+96
-76
python/paddle/fluid/tests/unittests/benchmark.py
python/paddle/fluid/tests/unittests/benchmark.py
+1
-1
python/paddle/fluid/tests/unittests/c_embedding_op_base.py
python/paddle/fluid/tests/unittests/c_embedding_op_base.py
+1
-1
python/paddle/fluid/tests/unittests/eager_op_test.py
python/paddle/fluid/tests/unittests/eager_op_test.py
+46
-29
python/paddle/fluid/tests/unittests/test_adaptive_max_pool1d.py
.../paddle/fluid/tests/unittests/test_adaptive_max_pool1d.py
+24
-17
python/paddle/fluid/tests/unittests/test_adaptive_max_pool2d.py
.../paddle/fluid/tests/unittests/test_adaptive_max_pool2d.py
+1
-1
python/paddle/fluid/tests/unittests/test_adaptive_max_pool3d.py
.../paddle/fluid/tests/unittests/test_adaptive_max_pool3d.py
+1
-1
python/paddle/fluid/tests/unittests/test_add_position_encoding_op.py
...le/fluid/tests/unittests/test_add_position_encoding_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_affine_channel_op.py
...on/paddle/fluid/tests/unittests/test_affine_channel_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_affine_grid_op.py
python/paddle/fluid/tests/unittests/test_affine_grid_op.py
+3
-5
python/paddle/fluid/tests/unittests/test_allclose_op.py
python/paddle/fluid/tests/unittests/test_allclose_op.py
+7
-7
python/paddle/fluid/tests/unittests/test_amp_check_finite_and_scale_op.py
...uid/tests/unittests/test_amp_check_finite_and_scale_op.py
+4
-4
python/paddle/fluid/tests/unittests/test_anchor_generator_op.py
.../paddle/fluid/tests/unittests/test_anchor_generator_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_angle_op.py
python/paddle/fluid/tests/unittests/test_angle_op.py
+3
-5
python/paddle/fluid/tests/unittests/test_linear_interp_v2_op.py
.../paddle/fluid/tests/unittests/test_linear_interp_v2_op.py
+2
-2
未找到文件。
python/paddle/fluid/tests/unittests/benchmark.py
浏览文件 @
11d7dae9
...
...
@@ -15,7 +15,7 @@
import
time
import
numpy
as
np
from
op_test
import
OpTest
from
eager_
op_test
import
OpTest
from
paddle.fluid.op
import
Operator
...
...
python/paddle/fluid/tests/unittests/c_embedding_op_base.py
浏览文件 @
11d7dae9
...
...
@@ -15,7 +15,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
eager_
op_test
import
OpTest
from
paddle.framework
import
core
...
...
python/paddle/fluid/tests/unittests/eager_op_test.py
浏览文件 @
11d7dae9
...
...
@@ -50,6 +50,17 @@ from white_list import (
op_threshold_white_list
,
)
from
paddle.fluid.wrapped_decorator
import
signature_safe_contextmanager
@
signature_safe_contextmanager
def
paddle_static_guard
():
try
:
paddle
.
enable_static
()
yield
finally
:
paddle
.
disable_static
()
def
check_out_dtype
(
api_fn
,
in_specs
,
expect_dtypes
,
target_index
=
0
,
**
configs
):
"""
...
...
@@ -66,14 +77,16 @@ def check_out_dtype(api_fn, in_specs, expect_dtypes, target_index=0, **configs):
check_out_dtype(fluid.layers.pad_constant_like, [([2,3,2,3], 'float64'), ([1, 3, 1,3], )], ['float32', 'float64', 'int64'], target_index=1, pad_value=0.)
"""
paddle
.
enable_static
()
with
paddle_static_guard
():
for
i
,
expect_dtype
in
enumerate
(
expect_dtypes
):
with
paddle
.
static
.
program_guard
(
paddle
.
static
.
Program
()):
input_t
=
[]
for
index
,
spec
in
enumerate
(
in_specs
):
if
len
(
spec
)
==
1
:
shape
=
spec
[
0
]
dtype
=
expect_dtype
if
target_index
==
index
else
'float32'
dtype
=
(
expect_dtype
if
target_index
==
index
else
'float32'
)
elif
len
(
spec
)
==
2
:
shape
,
dtype
=
spec
else
:
...
...
@@ -723,10 +736,8 @@ class OpTest(unittest.TestCase):
if
is_input
:
v
=
self
.
_create_var_from_numpy
(
np_value_temp
)
if
if_return_inputs_grad_dict
:
v
.
stop_gradient
=
False
if
hasattr
(
v
,
"retain_grads"
):
v
.
retain_grads
()
if
has_lod
:
...
...
@@ -887,6 +898,8 @@ class OpTest(unittest.TestCase):
)
if
not
kernel_sig
:
return
None
if
not
hasattr
(
self
,
"python_api"
):
print
(
kernel_sig
)
assert
hasattr
(
self
,
"python_api"
),
(
"Detect there is KernelSignature for `%s` op, please set the `self.python_api` if you set check_dygraph = True"
%
self
.
op_type
...
...
@@ -2256,6 +2269,10 @@ class OpTest(unittest.TestCase):
dygraph_outputs
=
self
.
_calc_python_api_output
(
place
,
inputs
,
outputs
)
if
dygraph_outputs
is
None
:
# missing KernelSignature, fall back to eager middle output.
dygraph_outs
=
self
.
_calc_dygraph_output
(
place
)
# if outputs is None, kernel sig is empty or other error is happens.
if
not
check_dygraph
or
dygraph_outputs
is
None
:
block
.
append_op
(
...
...
python/paddle/fluid/tests/unittests/test_adaptive_max_pool1d.py
浏览文件 @
11d7dae9
...
...
@@ -15,7 +15,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
check_out_dtype
from
eager_op_test
import
check_out_dtype
,
paddle_static_guard
import
paddle
import
paddle.fluid
as
fluid
...
...
@@ -93,13 +93,20 @@ class TestPool1D_API(unittest.TestCase):
np
.
testing
.
assert_allclose
(
result
.
numpy
(),
result_np
,
rtol
=
1e-05
)
def
check_adaptive_max_static_results
(
self
,
place
):
with
paddle_static_guard
():
with
fluid
.
program_guard
(
fluid
.
Program
(),
fluid
.
Program
()):
input
=
fluid
.
data
(
name
=
"input"
,
shape
=
[
2
,
3
,
32
],
dtype
=
"float32"
)
input
=
fluid
.
data
(
name
=
"input"
,
shape
=
[
2
,
3
,
32
],
dtype
=
"float32"
)
result
=
F
.
adaptive_max_pool1d
(
input
,
output_size
=
16
)
input_np
=
np
.
random
.
random
([
2
,
3
,
32
]).
astype
(
"float32"
)
result_np
=
max_pool1D_forward_naive
(
input_np
,
ksize
=
[
16
],
strides
=
[
2
],
paddings
=
[
0
],
adaptive
=
True
input_np
,
ksize
=
[
16
],
strides
=
[
2
],
paddings
=
[
0
],
adaptive
=
True
,
)
exe
=
fluid
.
Executor
(
place
)
...
...
python/paddle/fluid/tests/unittests/test_adaptive_max_pool2d.py
浏览文件 @
11d7dae9
...
...
@@ -15,7 +15,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
check_out_dtype
from
eager_
op_test
import
check_out_dtype
import
paddle
import
paddle.fluid
as
fluid
...
...
python/paddle/fluid/tests/unittests/test_adaptive_max_pool3d.py
浏览文件 @
11d7dae9
...
...
@@ -15,7 +15,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
check_out_dtype
from
eager_
op_test
import
check_out_dtype
import
paddle
import
paddle.fluid
as
fluid
...
...
python/paddle/fluid/tests/unittests/test_add_position_encoding_op.py
浏览文件 @
11d7dae9
...
...
@@ -15,7 +15,7 @@ import math
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
eager_
op_test
import
OpTest
def
add_position_encoding
(
input
,
alpha
=
1.0
,
beta
=
1.0
):
...
...
python/paddle/fluid/tests/unittests/test_affine_channel_op.py
浏览文件 @
11d7dae9
...
...
@@ -18,7 +18,7 @@ Unit testing for affine_channel_op
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
eager_
op_test
import
OpTest
def
affine_channel
(
x
,
scale
,
bias
,
layout
):
...
...
python/paddle/fluid/tests/unittests/test_affine_grid_op.py
浏览文件 @
11d7dae9
...
...
@@ -15,7 +15,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
eager_
op_test
import
OpTest
import
paddle
...
...
@@ -133,12 +133,10 @@ class TestAffineGridOp(OpTest):
}
def
test_check_output
(
self
):
self
.
check_output
(
check_eager
=
True
)
self
.
check_output
()
def
test_check_grad_normal
(
self
):
self
.
check_grad
(
[
'Theta'
],
'Output'
,
no_grad_set
=
[
'OutputShape'
],
check_eager
=
True
)
self
.
check_grad
([
'Theta'
],
'Output'
,
no_grad_set
=
[
'OutputShape'
])
def
initTestCase
(
self
):
self
.
theta_shape
=
(
17
,
2
,
3
)
...
...
python/paddle/fluid/tests/unittests/test_allclose_op.py
浏览文件 @
11d7dae9
...
...
@@ -15,7 +15,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
eager_
op_test
import
OpTest
import
paddle
import
paddle.fluid.core
as
core
...
...
@@ -55,7 +55,7 @@ class TestAllcloseOp(OpTest):
}
def
test_check_output
(
self
):
self
.
check_output
(
check_eager
=
True
)
self
.
check_output
()
class
TestAllcloseOpException
(
TestAllcloseOp
):
...
...
@@ -63,28 +63,28 @@ class TestAllcloseOpException(TestAllcloseOp):
def
test_rtol_num
():
self
.
inputs
[
'Rtol'
]
=
np
.
array
([
1e-05
,
1e-05
]).
astype
(
"float64"
)
self
.
inputs
[
'Atol'
]
=
np
.
array
([
1e-08
]).
astype
(
"float64"
)
self
.
check_output
(
check_eager
=
True
)
self
.
check_output
()
self
.
assertRaises
(
ValueError
,
test_rtol_num
)
def
test_rtol_type
():
self
.
inputs
[
'Rtol'
]
=
np
.
array
([
5
]).
astype
(
"int32"
)
self
.
inputs
[
'Atol'
]
=
np
.
array
([
1e-08
]).
astype
(
"float64"
)
self
.
check_output
(
check_eager
=
True
)
self
.
check_output
()
self
.
assertRaises
(
ValueError
,
test_rtol_type
)
def
test_atol_num
():
self
.
inputs
[
'Rtol'
]
=
np
.
array
([
1e-05
]).
astype
(
"float64"
)
self
.
inputs
[
'Atol'
]
=
np
.
array
([
1e-08
,
1e-08
]).
astype
(
"float64"
)
self
.
check_output
(
check_eager
=
True
)
self
.
check_output
()
self
.
assertRaises
(
ValueError
,
test_atol_num
)
def
test_atol_type
():
self
.
inputs
[
'Rtol'
]
=
np
.
array
([
1e-05
]).
astype
(
"float64"
)
self
.
inputs
[
'Atol'
]
=
np
.
array
([
8
]).
astype
(
"int32"
)
self
.
check_output
(
check_eager
=
True
)
self
.
check_output
()
self
.
assertRaises
(
ValueError
,
test_atol_type
)
...
...
@@ -198,7 +198,7 @@ class TestAllcloseOpFloat16(TestAllcloseOp):
if
core
.
is_compiled_with_cuda
():
place
=
core
.
CUDAPlace
(
0
)
if
core
.
is_float16_supported
(
place
):
self
.
check_output_with_place
(
place
,
check_eager
=
True
)
self
.
check_output_with_place
(
place
)
class
TestAllcloseOpFloat32
(
TestAllcloseOp
):
...
...
python/paddle/fluid/tests/unittests/test_amp_check_finite_and_scale_op.py
浏览文件 @
11d7dae9
...
...
@@ -15,7 +15,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
eager_
op_test
import
OpTest
import
paddle.static.amp.amp_nn
as
amp_nn
...
...
@@ -44,7 +44,7 @@ class TestCheckFiniteAndUnscaleOp(OpTest):
self
.
dtype
=
np
.
float32
def
test_check_output
(
self
):
self
.
check_output
(
check_eager
=
True
)
self
.
check_output
()
class
TestCheckFiniteAndUnscaleOpWithNan
(
OpTest
):
...
...
@@ -69,7 +69,7 @@ class TestCheckFiniteAndUnscaleOpWithNan(OpTest):
def
test_check_output
(
self
):
# When input contains nan, do not check the output,
# since the output may be nondeterministic and will be discarded.
self
.
check_output
(
no_check_set
=
[
'Out'
]
,
check_eager
=
True
)
self
.
check_output
(
no_check_set
=
[
'Out'
])
class
TestCheckFiniteAndUnscaleOpWithInf
(
OpTest
):
...
...
@@ -94,7 +94,7 @@ class TestCheckFiniteAndUnscaleOpWithInf(OpTest):
def
test_check_output
(
self
):
# When input contains inf, do not check the output,
# since the output may be nondeterministic and will be discarded.
self
.
check_output
(
no_check_set
=
[
'Out'
]
,
check_eager
=
True
)
self
.
check_output
(
no_check_set
=
[
'Out'
])
if
__name__
==
'__main__'
:
...
...
python/paddle/fluid/tests/unittests/test_anchor_generator_op.py
浏览文件 @
11d7dae9
...
...
@@ -15,7 +15,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
eager_
op_test
import
OpTest
def
anchor_generator_in_python
(
...
...
python/paddle/fluid/tests/unittests/test_angle_op.py
浏览文件 @
11d7dae9
...
...
@@ -15,7 +15,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
eager_
op_test
import
OpTest
import
paddle
from
paddle
import
static
...
...
@@ -49,7 +49,7 @@ class TestAngleOpFloat(OpTest):
self
.
outputs
=
{
'Out'
:
out_ref
}
def
test_check_output
(
self
):
self
.
check_output
(
check_eager
=
True
)
self
.
check_output
()
def
test_check_grad
(
self
):
self
.
check_grad
(
...
...
@@ -58,7 +58,6 @@ class TestAngleOpFloat(OpTest):
user_defined_grads
=
[
angle_grad
(
self
.
x
,
np
.
ones_like
(
self
.
x
)
/
self
.
x
.
size
)
],
check_eager
=
True
,
)
...
...
@@ -75,7 +74,7 @@ class TestAngleOpComplex(OpTest):
self
.
outputs
=
{
'Out'
:
out_ref
}
def
test_check_output
(
self
):
self
.
check_output
(
check_eager
=
True
)
self
.
check_output
()
def
test_check_grad
(
self
):
self
.
check_grad
(
...
...
@@ -84,7 +83,6 @@ class TestAngleOpComplex(OpTest):
user_defined_grads
=
[
angle_grad
(
self
.
x
,
np
.
ones_like
(
self
.
x
)
/
self
.
x
.
size
)
],
check_eager
=
True
,
)
...
...
python/paddle/fluid/tests/unittests/test_linear_interp_v2_op.py
浏览文件 @
11d7dae9
...
...
@@ -16,7 +16,7 @@ import platform
import
unittest
import
numpy
as
np
from
eager_op_test
import
OpTest
from
eager_op_test
import
OpTest
,
paddle_static_guard
import
paddle
import
paddle.fluid
as
fluid
...
...
@@ -401,7 +401,7 @@ class TestResizeLinearOpUint8(OpTest):
class
TestLinearInterpOpError
(
unittest
.
TestCase
):
def
test_error
(
self
):
with
paddle
.
fluid
.
framework
.
_static_guard
():
with
paddle_static_guard
():
with
program_guard
(
Program
(),
Program
()):
def
input_shape_error
():
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录