未验证 提交 5c9feef1 编写于 作者: 姜永久 提交者: GitHub

rm unittest eager guard part1 (#48797)

* rm unittest eager guard part1

* review

* reset spwan runner base

* reset op_test

* rm test_type_core
上级 7fc25f22
...@@ -21,7 +21,6 @@ os.environ[str("GLOG_vmodule")] = str("nan_inf_utils_detail=10") ...@@ -21,7 +21,6 @@ os.environ[str("GLOG_vmodule")] = str("nan_inf_utils_detail=10")
import paddle import paddle
import paddle.nn as nn import paddle.nn as nn
from paddle.fluid.framework import _test_eager_guard
np.random.seed(0) np.random.seed(0)
...@@ -114,6 +113,4 @@ def run_check(): ...@@ -114,6 +113,4 @@ def run_check():
if __name__ == '__main__': if __name__ == '__main__':
with _test_eager_guard():
run_check()
run_check() run_check()
...@@ -18,7 +18,6 @@ import unittest ...@@ -18,7 +18,6 @@ import unittest
import numpy as np import numpy as np
import paddle import paddle
from paddle.fluid.framework import _test_eager_guard
class TestDygraphFleetAPI(unittest.TestCase): class TestDygraphFleetAPI(unittest.TestCase):
...@@ -50,6 +49,4 @@ class TestDygraphFleetAPI(unittest.TestCase): ...@@ -50,6 +49,4 @@ class TestDygraphFleetAPI(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
with _test_eager_guard():
pass
unittest.main() unittest.main()
...@@ -22,7 +22,6 @@ import paddle ...@@ -22,7 +22,6 @@ 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.backward import _append_grad_suffix_, _as_list from paddle.fluid.backward import _append_grad_suffix_, _as_list
from paddle.fluid.framework import _test_eager_guard
def _product(t): def _product(t):
...@@ -769,10 +768,7 @@ def double_grad_check_for_dygraph( ...@@ -769,10 +768,7 @@ def double_grad_check_for_dygraph(
x_init = _as_list(x_init) x_init = _as_list(x_init)
paddle.disable_static() paddle.disable_static()
with _test_eager_guard(): eager_double_grad = get_eager_double_grad(func, x_init, y_grads_init, place)
eager_double_grad = get_eager_double_grad(
func, x_init, y_grads_init, place
)
paddle.enable_static() paddle.enable_static()
static_double_grad = get_static_double_grad( static_double_grad = get_static_double_grad(
...@@ -935,10 +931,7 @@ def triple_grad_check_for_dygraph( ...@@ -935,10 +931,7 @@ def triple_grad_check_for_dygraph(
x_init = _as_list(x_init) x_init = _as_list(x_init)
paddle.disable_static() paddle.disable_static()
with _test_eager_guard(): eager_triple_grad = get_eager_triple_grad(func, x_init, y_grads_init, place)
eager_triple_grad = get_eager_triple_grad(
func, x_init, y_grads_init, place
)
paddle.enable_static() paddle.enable_static()
static_triple_grad = get_static_triple_grad( static_triple_grad = get_static_triple_grad(
......
...@@ -19,7 +19,6 @@ import numpy as np ...@@ -19,7 +19,6 @@ import numpy as np
import paddle import paddle
import paddle.distributed as dist import paddle.distributed as dist
import paddle.fluid as fluid import paddle.fluid as fluid
from paddle.fluid.framework import _test_eager_guard
from paddle.nn import Linear from paddle.nn import Linear
paddle.seed(1024) paddle.seed(1024)
...@@ -69,7 +68,6 @@ class SimpleNet(fluid.Layer): ...@@ -69,7 +68,6 @@ class SimpleNet(fluid.Layer):
class TestDistTraning(unittest.TestCase): class TestDistTraning(unittest.TestCase):
def test_multiple_gpus(self): def test_multiple_gpus(self):
self.trainer_id = dist.get_rank() self.trainer_id = dist.get_rank()
with _test_eager_guard():
self.pg = dist.init_parallel_env() self.pg = dist.init_parallel_env()
model_a = SimpleNet(self.trainer_id) model_a = SimpleNet(self.trainer_id)
......
...@@ -17,12 +17,10 @@ import unittest ...@@ -17,12 +17,10 @@ import unittest
import numpy as np import numpy as np
import paddle import paddle
import paddle.fluid.core as core
from paddle.fluid.framework import _test_eager_guard
class TensorTypeTest(unittest.TestCase): class TensorTypeTest(unittest.TestCase):
def func_type_totensor(self): def test_type_totensor(self):
paddle.disable_static() paddle.disable_static()
inx = np.array([1, 2]) inx = np.array([1, 2])
tensorx = paddle.to_tensor(inx) tensorx = paddle.to_tensor(inx)
...@@ -30,12 +28,7 @@ class TensorTypeTest(unittest.TestCase): ...@@ -30,12 +28,7 @@ class TensorTypeTest(unittest.TestCase):
expectx = "<class 'paddle.Tensor'>" expectx = "<class 'paddle.Tensor'>"
self.assertEqual((typex_str == expectx), True) self.assertEqual((typex_str == expectx), True)
def test_type_totensor(self): def test_type_Tensor(self):
with _test_eager_guard():
self.func_type_totensor()
self.func_type_totensor()
def func_type_Tensor(self):
paddle.disable_static() paddle.disable_static()
inx = np.array([1, 2]) inx = np.array([1, 2])
tensorx = paddle.Tensor(inx) tensorx = paddle.Tensor(inx)
...@@ -49,29 +42,6 @@ class TensorTypeTest(unittest.TestCase): ...@@ -49,29 +42,6 @@ class TensorTypeTest(unittest.TestCase):
expectx = "<class 'paddle.Tensor'>" expectx = "<class 'paddle.Tensor'>"
self.assertEqual((typex_str == expectx), True) self.assertEqual((typex_str == expectx), True)
def test_type_Tensor(self):
with _test_eager_guard():
self.func_type_Tensor()
self.func_type_Tensor()
def func_type_core(self):
paddle.disable_static()
inx = np.array([1, 2])
tensorx = core.VarBase(inx)
typex_str = str(type(tensorx))
expectx = "<class 'paddle.Tensor'>"
self.assertEqual((typex_str == expectx), True)
tensorx = paddle.framework.VarBase(inx)
typex_str = str(type(tensorx))
expectx = "<class 'paddle.Tensor'>"
self.assertEqual((typex_str == expectx), True)
def test_type_core(self):
with _test_eager_guard():
pass
self.func_type_core()
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.
先完成此消息的编辑!
想要评论请 注册