Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
3900d562
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看板
未验证
提交
3900d562
编写于
12月 21, 2022
作者:
姜
姜永久
提交者:
GitHub
12月 21, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rm unittests eager guard test part15 layers2maxout (#48837)
上级
53ce406a
变更
10
展开全部
显示空白变更内容
内联
并排
Showing
10 changed file
with
18 addition
and
632 deletion
+18
-632
python/paddle/fluid/tests/unittests/test_layers.py
python/paddle/fluid/tests/unittests/test_layers.py
+4
-555
python/paddle/fluid/tests/unittests/test_limit_by_capacity_op.py
...paddle/fluid/tests/unittests/test_limit_by_capacity_op.py
+1
-7
python/paddle/fluid/tests/unittests/test_linalg_cond.py
python/paddle/fluid/tests/unittests/test_linalg_cond.py
+3
-19
python/paddle/fluid/tests/unittests/test_linspace.py
python/paddle/fluid/tests/unittests/test_linspace.py
+0
-6
python/paddle/fluid/tests/unittests/test_logical_op.py
python/paddle/fluid/tests/unittests/test_logical_op.py
+8
-10
python/paddle/fluid/tests/unittests/test_logit_op.py
python/paddle/fluid/tests/unittests/test_logit_op.py
+0
-6
python/paddle/fluid/tests/unittests/test_lookahead.py
python/paddle/fluid/tests/unittests/test_lookahead.py
+1
-7
python/paddle/fluid/tests/unittests/test_matmul_v2_op.py
python/paddle/fluid/tests/unittests/test_matmul_v2_op.py
+0
-10
python/paddle/fluid/tests/unittests/test_max_op.py
python/paddle/fluid/tests/unittests/test_max_op.py
+0
-5
python/paddle/fluid/tests/unittests/test_maxout_op.py
python/paddle/fluid/tests/unittests/test_maxout_op.py
+1
-7
未找到文件。
python/paddle/fluid/tests/unittests/test_layers.py
浏览文件 @
3900d562
此差异已折叠。
点击以展开。
python/paddle/fluid/tests/unittests/test_limit_by_capacity_op.py
浏览文件 @
3900d562
...
@@ -19,7 +19,6 @@ import numpy as np
...
@@ -19,7 +19,6 @@ import numpy as np
import
paddle
import
paddle
from
paddle.distributed.models.moe
import
utils
from
paddle.distributed.models.moe
import
utils
from
paddle.fluid
import
core
from
paddle.fluid
import
core
from
paddle.fluid.framework
import
_test_eager_guard
def
limit_by_capacity
(
expert_count
,
_capacity
,
n_worker
):
def
limit_by_capacity
(
expert_count
,
_capacity
,
n_worker
):
...
@@ -88,7 +87,7 @@ class TestLimitByCapacityInt64API(unittest.TestCase):
...
@@ -88,7 +87,7 @@ class TestLimitByCapacityInt64API(unittest.TestCase):
assert
all_close
(
self
.
out
,
res
[
0
],
self
.
n_worker
)
assert
all_close
(
self
.
out
,
res
[
0
],
self
.
n_worker
)
def
func
_dygraph_api
(
self
):
def
test
_dygraph_api
(
self
):
paddle
.
disable_static
(
self
.
place
)
paddle
.
disable_static
(
self
.
place
)
capacity
=
paddle
.
to_tensor
(
self
.
capacity
)
capacity
=
paddle
.
to_tensor
(
self
.
capacity
)
expert_count_tensor
=
paddle
.
to_tensor
(
self
.
expert_count
)
expert_count_tensor
=
paddle
.
to_tensor
(
self
.
expert_count
)
...
@@ -97,11 +96,6 @@ class TestLimitByCapacityInt64API(unittest.TestCase):
...
@@ -97,11 +96,6 @@ class TestLimitByCapacityInt64API(unittest.TestCase):
)
)
assert
all_close
(
self
.
out
,
out
.
numpy
(),
self
.
n_worker
)
assert
all_close
(
self
.
out
,
out
.
numpy
(),
self
.
n_worker
)
def
test_dygraph_api
(
self
):
with
_test_eager_guard
():
self
.
func_dygraph_api
()
self
.
func_dygraph_api
()
@
unittest
.
skipIf
(
@
unittest
.
skipIf
(
not
core
.
is_compiled_with_cuda
(),
"core is not compiled with CUDA"
not
core
.
is_compiled_with_cuda
(),
"core is not compiled with CUDA"
...
...
python/paddle/fluid/tests/unittests/test_linalg_cond.py
浏览文件 @
3900d562
...
@@ -18,7 +18,6 @@ import numpy as np
...
@@ -18,7 +18,6 @@ import numpy as np
import
paddle
import
paddle
import
paddle.static
as
static
import
paddle.static
as
static
from
paddle.fluid.framework
import
_test_eager_guard
p_list_n_n
=
(
"fro"
,
"nuc"
,
1
,
-
1
,
np
.
inf
,
-
np
.
inf
)
p_list_n_n
=
(
"fro"
,
"nuc"
,
1
,
-
1
,
np
.
inf
,
-
np
.
inf
)
p_list_m_n
=
(
None
,
2
,
-
2
)
p_list_m_n
=
(
None
,
2
,
-
2
)
...
@@ -92,21 +91,16 @@ class API_TestStaticCond(unittest.TestCase):
...
@@ -92,21 +91,16 @@ class API_TestStaticCond(unittest.TestCase):
class
API_TestDygraphCond
(
unittest
.
TestCase
):
class
API_TestDygraphCond
(
unittest
.
TestCase
):
def
func
_out
(
self
):
def
test
_out
(
self
):
paddle
.
disable_static
()
paddle
.
disable_static
()
# test calling results of 'cond' in dynamic mode
# test calling results of 'cond' in dynamic mode
x_list_n_n
,
x_list_m_n
=
gen_input
()
x_list_n_n
,
x_list_m_n
=
gen_input
()
test_dygraph_assert_true
(
self
,
x_list_n_n
,
p_list_n_n
+
p_list_m_n
)
test_dygraph_assert_true
(
self
,
x_list_n_n
,
p_list_n_n
+
p_list_m_n
)
test_dygraph_assert_true
(
self
,
x_list_m_n
,
p_list_m_n
)
test_dygraph_assert_true
(
self
,
x_list_m_n
,
p_list_m_n
)
def
test_out
(
self
):
with
_test_eager_guard
():
self
.
func_out
()
self
.
func_out
()
class
TestCondAPIError
(
unittest
.
TestCase
):
class
TestCondAPIError
(
unittest
.
TestCase
):
def
func
_dygraph_api_error
(
self
):
def
test
_dygraph_api_error
(
self
):
paddle
.
disable_static
()
paddle
.
disable_static
()
# test raising errors when 'cond' is called in dygraph mode
# test raising errors when 'cond' is called in dygraph mode
p_list_error
=
(
'fro_'
,
'_nuc'
,
-
0.7
,
0
,
1.5
,
3
)
p_list_error
=
(
'fro_'
,
'_nuc'
,
-
0.7
,
0
,
1.5
,
3
)
...
@@ -121,11 +115,6 @@ class TestCondAPIError(unittest.TestCase):
...
@@ -121,11 +115,6 @@ class TestCondAPIError(unittest.TestCase):
x_tensor
=
paddle
.
to_tensor
(
x
)
x_tensor
=
paddle
.
to_tensor
(
x
)
self
.
assertRaises
(
ValueError
,
paddle
.
linalg
.
cond
,
x_tensor
,
p
)
self
.
assertRaises
(
ValueError
,
paddle
.
linalg
.
cond
,
x_tensor
,
p
)
def
test_dygraph_api_error
(
self
):
with
_test_eager_guard
():
self
.
func_dygraph_api_error
()
self
.
func_dygraph_api_error
()
def
test_static_api_error
(
self
):
def
test_static_api_error
(
self
):
paddle
.
enable_static
()
paddle
.
enable_static
()
# test raising errors when 'cond' is called in static mode
# test raising errors when 'cond' is called in static mode
...
@@ -162,18 +151,13 @@ class TestCondAPIError(unittest.TestCase):
...
@@ -162,18 +151,13 @@ class TestCondAPIError(unittest.TestCase):
class
TestCondEmptyTensorInput
(
unittest
.
TestCase
):
class
TestCondEmptyTensorInput
(
unittest
.
TestCase
):
def
func
_dygraph_empty_tensor_input
(
self
):
def
test
_dygraph_empty_tensor_input
(
self
):
paddle
.
disable_static
()
paddle
.
disable_static
()
# test calling results of 'cond' when input is an empty tensor in dynamic mode
# test calling results of 'cond' when input is an empty tensor in dynamic mode
x_list_n_n
,
x_list_m_n
=
gen_empty_input
()
x_list_n_n
,
x_list_m_n
=
gen_empty_input
()
test_dygraph_assert_true
(
self
,
x_list_n_n
,
p_list_n_n
+
p_list_m_n
)
test_dygraph_assert_true
(
self
,
x_list_n_n
,
p_list_n_n
+
p_list_m_n
)
test_dygraph_assert_true
(
self
,
x_list_m_n
,
p_list_m_n
)
test_dygraph_assert_true
(
self
,
x_list_m_n
,
p_list_m_n
)
def
test_dygraph_empty_tensor_input
(
self
):
with
_test_eager_guard
():
self
.
func_dygraph_empty_tensor_input
()
self
.
func_dygraph_empty_tensor_input
()
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
paddle
.
enable_static
()
paddle
.
enable_static
()
...
...
python/paddle/fluid/tests/unittests/test_linspace.py
浏览文件 @
3900d562
...
@@ -20,7 +20,6 @@ from op_test import OpTest
...
@@ -20,7 +20,6 @@ from op_test import OpTest
import
paddle
import
paddle
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
from
paddle.fluid
import
Program
,
core
,
program_guard
from
paddle.fluid
import
Program
,
core
,
program_guard
from
paddle.fluid.framework
import
_test_eager_guard
class
TestLinspaceOpCommonCase
(
OpTest
):
class
TestLinspaceOpCommonCase
(
OpTest
):
...
@@ -128,11 +127,6 @@ class TestLinspaceAPI(unittest.TestCase):
...
@@ -128,11 +127,6 @@ class TestLinspaceAPI(unittest.TestCase):
self
.
assertEqual
((
out2
.
numpy
()
==
np_out2
).
all
(),
True
)
self
.
assertEqual
((
out2
.
numpy
()
==
np_out2
).
all
(),
True
)
self
.
assertEqual
((
out3
.
numpy
()
==
np_out3
).
all
(),
True
)
self
.
assertEqual
((
out3
.
numpy
()
==
np_out3
).
all
(),
True
)
def
test_api_eager_dygraph
(
self
):
with
_test_eager_guard
():
self
.
test_variable_input2
()
self
.
test_imperative
()
class
TestLinspaceOpError
(
unittest
.
TestCase
):
class
TestLinspaceOpError
(
unittest
.
TestCase
):
def
test_errors
(
self
):
def
test_errors
(
self
):
...
...
python/paddle/fluid/tests/unittests/test_logical_op.py
浏览文件 @
3900d562
...
@@ -17,7 +17,6 @@ import unittest
...
@@ -17,7 +17,6 @@ import unittest
import
numpy
as
np
import
numpy
as
np
import
paddle
import
paddle
from
paddle.fluid.framework
import
_test_eager_guard
from
paddle.framework
import
_non_static_mode
from
paddle.framework
import
_non_static_mode
from
paddle.static
import
Executor
,
Program
,
program_guard
from
paddle.static
import
Executor
,
Program
,
program_guard
...
@@ -106,7 +105,6 @@ def run_eager(x_np, y_np, op_str, use_gpu=False, binary_op=True):
...
@@ -106,7 +105,6 @@ def run_eager(x_np, y_np, op_str, use_gpu=False, binary_op=True):
if
use_gpu
and
paddle
.
is_compiled_with_cuda
():
if
use_gpu
and
paddle
.
is_compiled_with_cuda
():
place
=
paddle
.
CUDAPlace
(
0
)
place
=
paddle
.
CUDAPlace
(
0
)
paddle
.
disable_static
(
place
)
paddle
.
disable_static
(
place
)
with
_test_eager_guard
():
op
=
getattr
(
paddle
,
op_str
)
op
=
getattr
(
paddle
,
op_str
)
x
=
paddle
.
to_tensor
(
x_np
,
dtype
=
x_np
.
dtype
)
x
=
paddle
.
to_tensor
(
x_np
,
dtype
=
x_np
.
dtype
)
if
not
binary_op
:
if
not
binary_op
:
...
...
python/paddle/fluid/tests/unittests/test_logit_op.py
浏览文件 @
3900d562
...
@@ -18,7 +18,6 @@ import numpy as np
...
@@ -18,7 +18,6 @@ import numpy as np
from
op_test
import
OpTest
from
op_test
import
OpTest
import
paddle
import
paddle
from
paddle.fluid.framework
import
_test_eager_guard
np
.
random
.
seed
(
10
)
np
.
random
.
seed
(
10
)
...
@@ -117,11 +116,6 @@ class TestLogitAPI(unittest.TestCase):
...
@@ -117,11 +116,6 @@ class TestLogitAPI(unittest.TestCase):
x
=
paddle
.
fluid
.
data
(
name
=
'X2'
,
shape
=
[
100
],
dtype
=
'float32'
)
x
=
paddle
.
fluid
.
data
(
name
=
'X2'
,
shape
=
[
100
],
dtype
=
'float32'
)
self
.
assertRaises
(
TypeError
,
paddle
.
logit
,
x
,
dtype
=
'int32'
)
self
.
assertRaises
(
TypeError
,
paddle
.
logit
,
x
,
dtype
=
'int32'
)
def
test_api_eager_dygraph
(
self
):
with
_test_eager_guard
():
self
.
test_check_api
()
self
.
test_errors
()
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
unittest
.
main
()
unittest
.
main
()
python/paddle/fluid/tests/unittests/test_lookahead.py
浏览文件 @
3900d562
...
@@ -19,7 +19,6 @@ import numpy as np
...
@@ -19,7 +19,6 @@ import numpy as np
import
paddle
import
paddle
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
import
paddle.nn
as
nn
import
paddle.nn
as
nn
from
paddle.fluid.framework
import
_test_eager_guard
LOOKAHEAD_K
=
5
LOOKAHEAD_K
=
5
LOOKAHEAD_ALPHA
=
0.2
LOOKAHEAD_ALPHA
=
0.2
...
@@ -71,7 +70,7 @@ class TestLookAhead(unittest.TestCase):
...
@@ -71,7 +70,7 @@ class TestLookAhead(unittest.TestCase):
)
)
fast_param
=
latest_b
-
SGD_LR
*
b_grad
fast_param
=
latest_b
-
SGD_LR
*
b_grad
def
func_
test_look_ahead_dygraph
(
self
):
def
test_look_ahead_dygraph
(
self
):
BATCH_SIZE
=
16
BATCH_SIZE
=
16
BATCH_NUM
=
4
BATCH_NUM
=
4
EPOCH_NUM
=
4
EPOCH_NUM
=
4
...
@@ -152,11 +151,6 @@ class TestLookAhead(unittest.TestCase):
...
@@ -152,11 +151,6 @@ class TestLookAhead(unittest.TestCase):
train
(
layer
,
loader
,
loss_fn
,
lookahead
)
train
(
layer
,
loader
,
loss_fn
,
lookahead
)
def
test_look_ahead_dygraph
(
self
):
with
_test_eager_guard
():
self
.
func_test_look_ahead_dygraph
()
self
.
func_test_look_ahead_dygraph
()
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
unittest
.
main
()
unittest
.
main
()
python/paddle/fluid/tests/unittests/test_matmul_v2_op.py
浏览文件 @
3900d562
...
@@ -20,7 +20,6 @@ from op_test import OpTest, convert_float_to_uint16, get_numeric_gradient
...
@@ -20,7 +20,6 @@ from op_test import OpTest, convert_float_to_uint16, get_numeric_gradient
import
paddle
import
paddle
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
import
paddle.fluid.core
as
core
import
paddle.fluid.core
as
core
from
paddle.fluid.framework
import
_test_eager_guard
from
paddle.fluid.tests.unittests.testsuite
import
create_op
from
paddle.fluid.tests.unittests.testsuite
import
create_op
...
@@ -559,11 +558,6 @@ class TestMatMulV2API(unittest.TestCase):
...
@@ -559,11 +558,6 @@ class TestMatMulV2API(unittest.TestCase):
{
'FLAGS_gemm_use_half_precision_compute_type'
:
False
}
{
'FLAGS_gemm_use_half_precision_compute_type'
:
False
}
)
)
def
test_api_eager_dygraph
(
self
):
with
_test_eager_guard
():
self
.
test_dygraph
()
self
.
test_dygraph_fp16
()
class
TestComplexMatMulOp
(
OpTest
):
class
TestComplexMatMulOp
(
OpTest
):
def
setUp
(
self
):
def
setUp
(
self
):
...
@@ -732,10 +726,6 @@ class TestMatmulop(unittest.TestCase):
...
@@ -732,10 +726,6 @@ class TestMatmulop(unittest.TestCase):
paddle
.
enable_static
()
paddle
.
enable_static
()
def
func_dygraph_matmul
(
self
):
# noqa: F811
with
_test_eager_guard
():
self
.
func_dygraph_matmul
()
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
paddle
.
enable_static
()
paddle
.
enable_static
()
...
...
python/paddle/fluid/tests/unittests/test_max_op.py
浏览文件 @
3900d562
...
@@ -20,7 +20,6 @@ from test_sum_op import TestReduceOPTensorAxisBase
...
@@ -20,7 +20,6 @@ from test_sum_op import TestReduceOPTensorAxisBase
import
paddle
import
paddle
import
paddle.fluid.core
as
core
import
paddle.fluid.core
as
core
from
paddle.fluid.framework
import
_test_eager_guard
class
ApiMaxTest
(
unittest
.
TestCase
):
class
ApiMaxTest
(
unittest
.
TestCase
):
...
@@ -83,10 +82,6 @@ class ApiMaxTest(unittest.TestCase):
...
@@ -83,10 +82,6 @@ class ApiMaxTest(unittest.TestCase):
z_expected
=
np
.
array
(
np
.
max
(
np_x
,
axis
=
0
))
z_expected
=
np
.
array
(
np
.
max
(
np_x
,
axis
=
0
))
self
.
assertEqual
((
np_z
==
z_expected
).
all
(),
True
)
self
.
assertEqual
((
np_z
==
z_expected
).
all
(),
True
)
def
test_eager_api
(
self
):
with
_test_eager_guard
():
self
.
test_imperative_api
()
def
test_big_dimension
(
self
):
def
test_big_dimension
(
self
):
paddle
.
disable_static
()
paddle
.
disable_static
()
x
=
paddle
.
rand
(
shape
=
[
2
,
2
,
2
,
2
,
2
,
2
,
2
])
x
=
paddle
.
rand
(
shape
=
[
2
,
2
,
2
,
2
,
2
,
2
,
2
])
...
...
python/paddle/fluid/tests/unittests/test_maxout_op.py
浏览文件 @
3900d562
...
@@ -20,7 +20,6 @@ from op_test import OpTest
...
@@ -20,7 +20,6 @@ from op_test import OpTest
import
paddle
import
paddle
import
paddle.fluid.core
as
core
import
paddle.fluid.core
as
core
import
paddle.nn.functional
as
F
import
paddle.nn.functional
as
F
from
paddle.fluid.framework
import
_test_eager_guard
paddle
.
enable_static
()
paddle
.
enable_static
()
np
.
random
.
seed
(
1
)
np
.
random
.
seed
(
1
)
...
@@ -108,7 +107,7 @@ class TestMaxoutAPI(unittest.TestCase):
...
@@ -108,7 +107,7 @@ class TestMaxoutAPI(unittest.TestCase):
for
r
in
res
:
for
r
in
res
:
np
.
testing
.
assert_allclose
(
out_ref
,
r
,
rtol
=
1e-05
)
np
.
testing
.
assert_allclose
(
out_ref
,
r
,
rtol
=
1e-05
)
def
func_
test_dygraph_api
(
self
):
def
test_dygraph_api
(
self
):
paddle
.
disable_static
(
self
.
place
)
paddle
.
disable_static
(
self
.
place
)
x
=
paddle
.
to_tensor
(
self
.
x_np
)
x
=
paddle
.
to_tensor
(
self
.
x_np
)
out1
=
F
.
maxout
(
x
,
self
.
groups
,
self
.
axis
)
out1
=
F
.
maxout
(
x
,
self
.
groups
,
self
.
axis
)
...
@@ -136,11 +135,6 @@ class TestMaxoutAPI(unittest.TestCase):
...
@@ -136,11 +135,6 @@ class TestMaxoutAPI(unittest.TestCase):
x_float32
=
paddle
.
fluid
.
data
(
name
=
'x_float32'
,
shape
=
[
2
,
4
,
6
,
8
])
x_float32
=
paddle
.
fluid
.
data
(
name
=
'x_float32'
,
shape
=
[
2
,
4
,
6
,
8
])
self
.
assertRaises
(
ValueError
,
F
.
maxout
,
x_float32
,
2
,
2
)
self
.
assertRaises
(
ValueError
,
F
.
maxout
,
x_float32
,
2
,
2
)
def
test_dygraph_api
(
self
):
with
_test_eager_guard
():
self
.
func_test_dygraph_api
()
self
.
func_test_dygraph_api
()
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录