未验证 提交 611f7ccc 编写于 作者: W wanghuancoder 提交者: GitHub

Del old dygraph MLU NPU (#51958)

* delete old dygraph, mlu npu do not use dygraph
上级 648ec795
......@@ -35,7 +35,7 @@ from test_sync_batch_norm_base_mlu import (
TestSyncBatchNormRunnerBase,
runtime_main,
)
from op_test import OpTest, _set_use_system_allocator
from eager_op_test import OpTest, _set_use_system_allocator
from test_sync_batch_norm_op import create_or_get_tensor
......
......@@ -17,7 +17,7 @@ import numpy as np
import sys
sys.path.append('..')
from op_test import OpTest
from eager_op_test import OpTest
import paddle.fluid.core as core
import paddle.fluid as fluid
from paddle.fluid import compiler, Program, program_guard
......@@ -56,7 +56,7 @@ class TestAbs(OpTest):
def test_check_grad(self):
self.check_grad_with_place(
self.place, ['X'], ['Out'], check_eager=False
self.place, ['X'], ['Out']
)
......@@ -88,7 +88,7 @@ class TestAbsHalf(OpTest):
def test_check_grad(self):
self.check_grad_with_place(
self.place, ['X'], ['Out'], check_eager=False
self.place, ['X'], ['Out']
)
......
......@@ -17,7 +17,7 @@ import numpy as np
import sys
sys.path.append('..')
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid as fluid
from paddle.fluid import compiler, Program, program_guard
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid as fluid
import paddle.fluid.core as core
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid as fluid
import paddle.fluid.core as core
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
paddle.enable_static()
......
......@@ -17,7 +17,7 @@ import numpy as np
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid as fluid
import paddle.fluid.core as core
......
......@@ -18,7 +18,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
paddle.enable_static()
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
paddle.enable_static()
......
......@@ -18,7 +18,7 @@ import sys
sys.path.append("..")
import op_test
import eager_op_test
import paddle
import paddle.fluid as fluid
import paddle.fluid.framework as framework
......@@ -28,7 +28,7 @@ paddle.enable_static()
numpy.random.seed(2022)
class TestAssignValueMLUOp(op_test.OpTest):
class TestAssignValueMLUOp(eager_op_test.OpTest):
def setUp(self):
self.set_mlu()
self.op_type = "assign_value"
......
......@@ -21,7 +21,7 @@ from paddle.fluid.op import Operator
import sys
sys.path.append('..')
from op_test import OpTest, _set_use_system_allocator
from eager_op_test import OpTest, _set_use_system_allocator
from paddle.fluid.framework import grad_var_name
import paddle.fluid as fluid
from paddle.fluid import Program, program_guard
......
......@@ -20,7 +20,7 @@ from paddle.fluid.op import Operator
import sys
sys.path.append("..")
from op_test import OpTest, _set_use_system_allocator
from eager_op_test import OpTest, _set_use_system_allocator
from paddle.fluid.framework import grad_var_name
import paddle.fluid as fluid
from paddle.fluid import Program, program_guard
......
......@@ -19,7 +19,7 @@ import unittest
import sys
sys.path.append('..')
from op_test import OpTest
from eager_op_test import OpTest
paddle.enable_static()
......
......@@ -19,7 +19,7 @@ import unittest
import sys
sys.path.append('..')
from op_test import OpTest
from eager_op_test import OpTest
from test_bce_with_logits_loss import (
call_bce_layer,
call_bce_functional,
......
......@@ -17,7 +17,7 @@ import numpy as np
import sys
sys.path.append('..')
from op_test import OpTest
from eager_op_test import OpTest
import paddle.fluid.core as core
import paddle.fluid as fluid
from paddle.nn.functional import interpolate
......
......@@ -17,7 +17,7 @@ import numpy as np
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid.core as core
......
......@@ -20,7 +20,7 @@ import numpy as np
import paddle
import paddle.fluid as fluid
from paddle.fluid import Program, program_guard
from op_test import OpTest
from eager_op_test import OpTest
paddle.enable_static()
......@@ -30,7 +30,6 @@ class TestClipOp(OpTest):
self.place = paddle.device.MLUPlace(0)
self.__class__.use_mlu = True
self.max_relative_error = 0.006
self.python_api = paddle.clip
self.inputs = {}
self.initTestCase()
......
......@@ -17,7 +17,7 @@ import numpy as np
import sys
sys.path.append('..')
from op_test import OpTest
from eager_op_test import OpTest
from paddle.fluid import core
import paddle
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid as fluid
from paddle.fluid import Program, program_guard
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest, skip_check_grad_ci
from eager_op_test import OpTest, skip_check_grad_ci
import paddle
import paddle.fluid as fluid
......
......@@ -23,7 +23,7 @@ import paddle
paddle.enable_static()
import paddle.fluid.core as core
import paddle.fluid as fluid
from op_test import OpTest
from eager_op_test import OpTest
from paddle.fluid import Program, program_guard
from test_conv2d_op_mlu import (
TestConv2DOp,
......
......@@ -20,7 +20,7 @@ sys.path.append("..")
import paddle
import paddle.fluid.core as core
import paddle.fluid as fluid
from op_test import OpTest
from eager_op_test import OpTest
from test_conv2d_op import conv2d_forward_naive
......
......@@ -21,7 +21,7 @@ import paddle.nn as nn
paddle.enable_static()
import paddle.fluid.core as core
import paddle.fluid as fluid
from paddle.fluid.tests.unittests.op_test import OpTest
from paddle.fluid.tests.unittests.eager_op_test import OpTest
def conv2dtranspose_forward_naive(input_, filter_, attrs):
......
......@@ -14,7 +14,7 @@
import unittest
import numpy as np
from paddle.fluid.tests.unittests.op_test import OpTest
from paddle.fluid.tests.unittests.eager_op_test import OpTest
import paddle
import paddle.fluid.core as core
import paddle.fluid as fluid
......
......@@ -21,8 +21,8 @@ import paddle.fluid as fluid
import sys
sys.path.append('..')
from op_test import OpTest
from test_deformable_conv_op import dconv_im2col_gemm, deform_conv2d_wrapper
from eager_op_test import OpTest
from test_deformable_conv_op import dconv_im2col_gemm
paddle.enable_static()
......@@ -31,7 +31,6 @@ class TestModulatedDeformableConvOp(OpTest):
def setUp(self):
self.place = paddle.device.MLUPlace(0)
self.__class__.use_mlu = True
self.python_api = deform_conv2d_wrapper
self.op_type = "deformable_conv"
self.init_type()
self.init_group()
......@@ -71,7 +70,7 @@ class TestModulatedDeformableConvOp(OpTest):
self.outputs = {'Output': output}
def test_check_output(self):
self.check_output_with_place(self.place, check_eager=False)
self.check_output_with_place(self.place)
def test_check_grad(self):
self.check_grad_with_place(
......@@ -79,7 +78,6 @@ class TestModulatedDeformableConvOp(OpTest):
{'Input', 'Offset', 'Mask', 'Filter'},
'Output',
max_relative_error=0.05,
check_eager=False,
)
def init_test_case(self):
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest, skip_check_grad_ci
from eager_op_test import OpTest, skip_check_grad_ci
import paddle
import paddle.fluid as fluid
......
......@@ -19,7 +19,7 @@ import paddle.fluid.core as core
import sys
sys.path.append('..')
from op_test import OpTest, skip_check_grad_ci
from eager_op_test import OpTest, skip_check_grad_ci
import paddle.fluid as fluid
from paddle.fluid import compiler, Program, program_guard
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest, skip_check_grad_ci
from eager_op_test import OpTest, skip_check_grad_ci
import paddle
import paddle.fluid as fluid
from paddle.fluid.core import ops
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest, skip_check_grad_ci
from eager_op_test import OpTest, skip_check_grad_ci
import paddle
import paddle.fluid as fluid
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest, skip_check_grad_ci
from eager_op_test import OpTest, skip_check_grad_ci
import paddle
import paddle.fluid as fluid
from paddle.fluid import Program, program_guard
......
......@@ -24,7 +24,7 @@ from paddle.fluid.op import Operator
import sys
sys.path.append('..')
from op_test import OpTest, skip_check_grad_ci
from eager_op_test import OpTest, skip_check_grad_ci
paddle.enable_static()
......
......@@ -20,7 +20,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
paddle.enable_static()
SEED = 2022
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest, skip_check_grad_ci
from eager_op_test import OpTest, skip_check_grad_ci
import paddle
import paddle.fluid as fluid
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid as fluid
......
......@@ -17,7 +17,7 @@ import sys
sys.path.append('..')
import numpy as np
from op_test import OpTest
from eager_op_test import OpTest
import paddle.fluid as fluid
import paddle
......@@ -29,7 +29,6 @@ def test_class1(op_type, typename):
def setUp(self):
self.set_mlu()
self.op_type = "expand_as_v2"
self.python_api = paddle.expand_as
x = np.random.rand(100).astype(typename)
target_tensor = np.random.rand(2, 100).astype(typename)
self.inputs = {'X': x}
......@@ -56,7 +55,6 @@ def test_class2(op_type, typename):
def setUp(self):
self.set_mlu()
self.op_type = "expand_as_v2"
self.python_api = paddle.expand_as
x = np.random.rand(10, 12).astype(typename)
target_tensor = np.random.rand(10, 12).astype(typename)
self.inputs = {'X': x}
......@@ -83,7 +81,6 @@ def test_class3(op_type, typename):
def setUp(self):
self.set_mlu()
self.op_type = "expand_as_v2"
self.python_api = paddle.expand_as
x = np.random.rand(2, 3, 20).astype(typename)
target_tensor = np.random.rand(2, 3, 20).astype(typename)
self.inputs = {'X': x}
......@@ -110,7 +107,6 @@ def test_class4(op_type, typename):
def setUp(self):
self.set_mlu()
self.op_type = "expand_as_v2"
self.python_api = paddle.expand_as
x = np.random.rand(1, 1, 7, 16).astype(typename)
target_tensor = np.random.rand(4, 6, 7, 16).astype(typename)
self.inputs = {'X': x}
......
......@@ -17,7 +17,7 @@ import sys
sys.path.append("..")
import unittest
import numpy as np
from op_test import OpTest
from eager_op_test import OpTest
import paddle.fluid as fluid
from paddle.fluid import compiler, Program, program_guard
import paddle
......@@ -32,7 +32,6 @@ class TestExpandV2OpRank1(OpTest):
self.place = paddle.device.MLUPlace(0)
self.__class__.use_mlu = True
self.init_data()
self.python_api = paddle.expand
self.inputs = {'X': np.random.random(self.ori_shape).astype("float32")}
self.attrs = {'shape': self.shape}
......@@ -45,10 +44,10 @@ class TestExpandV2OpRank1(OpTest):
self.expand_times = [1]
def test_check_output(self):
self.check_output_with_place(self.place, check_eager=False)
self.check_output_with_place(self.place)
def test_check_grad(self):
self.check_grad(['X'], 'Out', check_eager=True)
self.check_grad(['X'], 'Out')
class TestExpandV2OpRank2_DimExpanding(TestExpandV2OpRank1):
......@@ -121,7 +120,7 @@ class TestExpandV2OpRank1_tensor_attr(OpTest):
self.infer_expand_shape = [-1]
def test_check_output(self):
self.check_output_with_place(self.place, check_eager=False)
self.check_output_with_place(self.place)
def test_check_grad(self):
self.check_grad(['X'], 'Out')
......@@ -157,7 +156,7 @@ class TestExpandV2OpRank1_tensor(OpTest):
self.expand_shape = [2, 100]
def test_check_output(self):
self.check_output_with_place(self.place, check_eager=False)
self.check_output_with_place(self.place)
def test_check_grad(self):
self.check_grad(['X'], 'Out')
......@@ -177,7 +176,7 @@ class TestExpandV2OpInteger(OpTest):
self.outputs = {'Out': output}
def test_check_output(self):
self.check_output_with_place(self.place, check_eager=False)
self.check_output_with_place(self.place)
# Situation 5: input x is Bool
......@@ -192,7 +191,7 @@ class TestExpandV2OpBoolean(OpTest):
self.outputs = {'Out': output}
def test_check_output(self):
self.check_output_with_place(self.place, check_eager=False)
self.check_output_with_place(self.place)
# Situation 56: input x is Integer
......@@ -209,7 +208,7 @@ class TestExpandV2OpInt64_t(OpTest):
self.outputs = {'Out': output}
def test_check_output(self):
self.check_output_with_place(self.place, check_eager=False)
self.check_output_with_place(self.place)
class TestExpandV2Error(unittest.TestCase):
......
......@@ -19,7 +19,7 @@ sys.path.append("..")
import paddle
import unittest
import numpy as np
from op_test import OpTest
from eager_op_test import OpTest
paddle.enable_static()
......
......@@ -20,7 +20,7 @@ import paddle.fluid.core as core
from paddle.static import program_guard, Program
import unittest
import numpy as np
from op_test import OpTest
from eager_op_test import OpTest
from paddle.fluid.framework import convert_np_dtype_to_dtype_
paddle.enable_static()
......
......@@ -17,7 +17,7 @@ import numpy as np
import sys
sys.path.append('..')
from op_test import OpTest, convert_float_to_uint16
from eager_op_test import OpTest, convert_float_to_uint16
import paddle
import paddle.fluid.core as core
......
......@@ -19,7 +19,7 @@ import paddle
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
paddle.enable_static()
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid as fluid
......
......@@ -17,7 +17,7 @@ import numpy as np
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid as fluid
......
......@@ -18,7 +18,7 @@ import numpy as np
import sys
sys.path.append('..')
from op_test import OpTest
from eager_op_test import OpTest
import paddle
paddle.enable_static()
......@@ -31,7 +31,6 @@ class TestFloor(OpTest):
self.__class__.use_mlu = True
self.init_dtype()
self.__class__.no_need_check_grad = True
self.python_api = paddle.floor
np.random.seed(1024)
x = np.random.uniform(-1, 1, [10, 12]).astype(self.dtype)
......@@ -41,7 +40,7 @@ class TestFloor(OpTest):
self.outputs = {'Out': out}
def test_check_output(self):
self.check_output_with_place(self.place, check_eager=False)
self.check_output_with_place(self.place)
def init_dtype(self):
self.dtype = np.float32
......
......@@ -17,7 +17,7 @@ import sys
sys.path.append('..')
import numpy as np
from op_test import OpTest
from eager_op_test import OpTest
import paddle.fluid as fluid
import paddle
......@@ -46,7 +46,6 @@ def test_class1(op_type, typename):
def setUp(self):
self.set_mlu()
self.op_type = "gather_nd"
self.python_api = paddle.gather_nd
xnp = np.random.random((5, 20)).astype(typename)
self.inputs = {
'X': xnp,
......@@ -79,7 +78,6 @@ def test_class2(op_type, typename):
def setUp(self):
self.set_mlu()
self.op_type = "gather_nd"
self.python_api = paddle.gather_nd
xnp = np.random.random((5, 20)).astype(typename)
self.inputs = {'X': xnp, 'Index': np.array([1]).astype("int32")}
self.outputs = {'Out': self.inputs["X"][self.inputs["Index"]]}
......@@ -109,7 +107,6 @@ def test_class3(op_type, typename):
def setUp(self):
self.set_mlu()
self.op_type = "gather_nd"
self.python_api = paddle.gather_nd
xnp = np.random.uniform(0, 100, (10, 10)).astype(typename)
index = np.array([[1], [2]]).astype("int64")
......@@ -144,7 +141,6 @@ def test_class4(op_type, typename):
def setUp(self):
self.set_mlu()
self.op_type = "gather_nd"
self.python_api = paddle.gather_nd
xnp = np.random.uniform(0, 100, (10, 10)).astype(typename)
index = np.array([1, 2]).astype("int32")
......@@ -177,7 +173,6 @@ def test_class5(op_type, typename):
def setUp(self):
self.set_mlu()
self.op_type = "gather_nd"
self.python_api = paddle.gather_nd
xnp = np.random.uniform(0, 100, (10, 10)).astype(typename)
index = np.array([[1, 1], [2, 1]]).astype("int64")
......@@ -209,7 +204,6 @@ def test_class6(op_type, typename):
def setUp(self):
self.set_mlu()
self.op_type = "gather_nd"
self.python_api = paddle.gather_nd
shape = (5, 2, 3, 1, 10)
xnp = np.random.rand(*shape).astype(typename)
index = np.vstack(
......@@ -244,7 +238,6 @@ def test_class7(op_type, typename):
def setUp(self):
self.set_mlu()
self.op_type = "gather_nd"
self.python_api = paddle.gather_nd
shape = (2, 3, 4, 1, 10)
xnp = np.random.rand(*shape).astype(typename)
index = np.vstack(
......
......@@ -17,7 +17,7 @@ import numpy as np
import sys
sys.path.append('..')
from op_test import OpTest, convert_float_to_uint16
from eager_op_test import OpTest, convert_float_to_uint16
import paddle
import paddle.fluid as fluid
from paddle.framework import core
......@@ -38,7 +38,6 @@ class TestGatherOp(OpTest):
self.op_type = "gather"
self.place = paddle.MLUPlace(0)
self.__class__.use_mlu = True
self.python_api = paddle.gather
self.config()
xnp = np.random.random(self.x_shape).astype(self.x_type)
self.inputs = {
......
......@@ -22,7 +22,7 @@ from paddle.fluid.executor import Executor
import sys
sys.path.append('..')
from op_test import OpTest
from eager_op_test import OpTest
import paddle
paddle.enable_static()
......
......@@ -18,7 +18,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid as fluid
......
......@@ -19,7 +19,7 @@ import paddle.fluid.core as core
import sys
sys.path.append('..')
from op_test import OpTest
from eager_op_test import OpTest
paddle.enable_static()
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid as fluid
import paddle.nn.functional as F
......
......@@ -18,7 +18,7 @@ import paddle
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import numpy as np
import unittest
......
......@@ -17,7 +17,7 @@ import numpy as np
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid as fluid
from paddle.fluid import compiler, Program, program_guard
......
......@@ -20,7 +20,7 @@ import sys
sys.path.append("..")
import math
import paddle
from op_test import OpTest
from eager_op_test import OpTest
paddle.enable_static()
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid as fluid
......
......@@ -23,7 +23,7 @@ from functools import reduce
import sys
sys.path.append('..')
from op_test import _set_use_system_allocator
from eager_op_test import _set_use_system_allocator
from paddle.fluid import Program, program_guard
from paddle.static.amp.fp16_utils import (
_keep_layer_norm_scale_bias_to_fp32,
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
from test_activation_op import ref_leaky_relu
import paddle
import paddle.fluid as fluid
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid as fluid
......@@ -31,7 +31,6 @@ class TestActivation(OpTest):
self.op_type = "exp"
self.init_dtype()
self.init_kernel_type()
self.python_api = paddle.exp
np.random.seed(2049)
x = np.random.uniform(0.1, 1, [11, 17]).astype(self.dtype)
......@@ -59,7 +58,6 @@ class TestLog(TestActivation):
def setUp(self):
self.set_mlu()
self.op_type = "log"
self.python_api = paddle.log
self.init_dtype()
np.random.seed(1024)
......@@ -85,7 +83,6 @@ class TestLog2(TestActivation):
def setUp(self):
self.set_mlu()
self.op_type = "log2"
self.python_api = paddle.log2
self.init_dtype()
x = np.random.uniform(1, 10, [11, 17]).astype(self.dtype)
......@@ -137,7 +134,6 @@ class TestLog10(TestActivation):
def setUp(self):
self.set_mlu()
self.op_type = "log10"
self.python_api = paddle.log10
self.init_dtype()
x = np.random.uniform(0.1, 1, [11, 17]).astype(self.dtype)
......
......@@ -14,7 +14,7 @@
import unittest
import numpy as np
from paddle.fluid.tests.unittests.op_test import OpTest, convert_float_to_uint16
from paddle.fluid.tests.unittests.eager_op_test import OpTest, convert_float_to_uint16
import paddle
import paddle.fluid.core as core
import paddle.nn.functional as F
......@@ -45,7 +45,6 @@ class TestLogSoftmaxOp(OpTest):
def setUp(self):
self.op_type = 'log_softmax'
self.set_mlu()
self.python_api = F.log_softmax
self.dtype = 'float32'
self.shape = [2, 3, 4, 5]
self.axis = -1
......@@ -89,7 +88,6 @@ class TestLogSoftmaxOpFp16(OpTest):
def setUp(self):
self.op_type = 'log_softmax'
self.set_mlu()
self.python_api = F.log_softmax
self.dtype = 'float16'
self.shape = [2, 3, 4, 5]
self.axis = -1
......
......@@ -15,7 +15,7 @@
import sys
sys.path.append('..')
import op_test
import eager_op_test
import unittest
import numpy as np
import paddle
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid as fluid
......
......@@ -17,7 +17,7 @@ import sys
sys.path.append("..")
import numpy as np
from op_test import OpTest, skip_check_grad_ci
from eager_op_test import OpTest, skip_check_grad_ci
import paddle.fluid as fluid
import paddle
......@@ -44,7 +44,6 @@ class TestMaskedSelectOp(OpTest):
self.__class__.use_mlu = True
self.place = paddle.device.MLUPlace(0)
self.op_type = "masked_select"
self.python_api = paddle.masked_select
x = np.random.random(self.shape).astype('float32')
mask = np.array(np.random.randint(2, size=self.shape, dtype=bool))
out = np_masked_select(self.shape, x, mask)
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid as fluid
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid as fluid
from test_matmul_v2_op import reference_matmul
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid as fluid
from paddle.fluid import core
......
......@@ -17,7 +17,7 @@ import numpy as np
import sys
sys.path.append('..')
from op_test import OpTest, skip_check_grad_ci
from eager_op_test import OpTest, skip_check_grad_ci
import paddle.fluid as fluid
import paddle
from paddle.fluid import compiler, Program, program_guard, core
......
......@@ -19,7 +19,7 @@ from paddle.fluid.op import Operator
import sys
sys.path.append('..')
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid as fluid
import numpy
......
......@@ -17,7 +17,7 @@ import numpy as np
import sys
sys.path.append('..')
from op_test import OpTest
from eager_op_test import OpTest
import paddle.fluid.core as core
import paddle.fluid as fluid
import paddle.nn as nn
......
......@@ -18,7 +18,7 @@ import math
import sys
sys.path.append('..')
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid as fluid
import paddle.fluid.core as core
......
......@@ -22,7 +22,7 @@ from paddle.fluid import Program, program_guard
import sys
sys.path.append('..')
from op_test import OpTest
from eager_op_test import OpTest
from test_pool2d_op import (
pool2D_forward_naive,
avg_pool2D_forward_naive,
......
......@@ -17,7 +17,7 @@ import sys
sys.path.append('..')
import numpy as np
from op_test import OpTest
from eager_op_test import OpTest
import paddle.fluid as fluid
import paddle
import math
......
......@@ -17,7 +17,7 @@ import numpy as np
import sys
sys.path.append('..')
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid.core as core
from paddle.static import program_guard, Program
......@@ -64,7 +64,6 @@ class TestRandpermOp(OpTest):
self.op_type = "randperm"
self.place = paddle.device.MLUPlace(0)
self.__class__.use_mlu = True
self.python_api = paddle.randperm
self.n = 200
self.dtype = "int64"
......
......@@ -18,16 +18,12 @@ sys.path.append("..")
import paddle
import unittest
import numpy as np
from op_test import OpTest
from eager_op_test import OpTest
from functools import partial
paddle.enable_static()
def arange_wrapper(start, end, step, dtype=None):
return paddle.arange(start, end, step, dtype)
class TestRangeOp(OpTest):
def setUp(self):
self.op_type = "range"
......@@ -48,38 +44,33 @@ class TestRangeOp(OpTest):
def init_config(self):
self.dtype = np.float32
self.python_api = partial(arange_wrapper, dtype=self.dtype)
self.case = (0, 1, 0.2)
def test_check_output(self):
self.check_output_with_place(self.place, check_eager=False)
self.check_output_with_place(self.place)
class TestFloatRangeOpCase0(TestRangeOp):
def init_config(self):
self.dtype = np.float32
self.python_api = partial(arange_wrapper, dtype=self.dtype)
self.case = (0, 5, 1)
class TestInt32RangeOpCase0(TestRangeOp):
def init_config(self):
self.dtype = np.int32
self.python_api = partial(arange_wrapper, dtype=self.dtype)
self.case = (0, 5, 2)
class TestInt32RangeOpCase1(TestRangeOp):
def init_config(self):
self.dtype = np.int32
self.python_api = partial(arange_wrapper, dtype=self.dtype)
self.case = (10, 1, -2)
class TestInt32RangeOpCase2(TestRangeOp):
def init_config(self):
self.dtype = np.int32
self.python_api = partial(arange_wrapper, dtype=self.dtype)
self.case = (-1, -10, -2)
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest, skip_check_grad_ci
from eager_op_test import OpTest, skip_check_grad_ci
import paddle
paddle.enable_static()
......
......@@ -14,7 +14,7 @@
import unittest
import numpy as np
from paddle.fluid.tests.unittests.op_test import OpTest, skip_check_grad_ci
from paddle.fluid.tests.unittests.eager_op_test import OpTest, skip_check_grad_ci
import paddle
import paddle.fluid.core as core
import paddle.fluid as fluid
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid as fluid
......
......@@ -14,7 +14,7 @@
import unittest
import numpy as np
from paddle.fluid.tests.unittests.op_test import OpTest, skip_check_grad_ci
from paddle.fluid.tests.unittests.eager_op_test import OpTest, skip_check_grad_ci
import paddle
import paddle.fluid.core as core
import paddle.fluid as fluid
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid as fluid
......@@ -33,7 +33,6 @@ class TestProdOp(OpTest):
self.op_type = "reduce_prod"
self.place = paddle.device.MLUPlace(0)
self.__class__.use_mlu = True
self.python_api = raw_reduce_prod
self.init_data_type()
self.inputs = {'X': np.random.random((5, 6, 10)).astype(self.data_type)}
self.outputs = {'Out': self.inputs['X'].prod(axis=0)}
......@@ -42,7 +41,7 @@ class TestProdOp(OpTest):
self.data_type = "float32"
def test_check_output(self):
self.check_output_with_place(self.place, check_eager=False)
self.check_output_with_place(self.place)
class TestProd6DOp(OpTest):
......@@ -50,7 +49,6 @@ class TestProd6DOp(OpTest):
self.op_type = "reduce_prod"
self.place = paddle.device.MLUPlace(0)
self.__class__.use_mlu = True
self.python_api = raw_reduce_prod
self.init_data_type()
self.inputs = {
'X': np.random.random((5, 6, 2, 3, 4, 2)).astype(self.data_type)
......@@ -64,7 +62,7 @@ class TestProd6DOp(OpTest):
self.data_type = "float32"
def test_check_output(self):
self.check_output_with_place(self.place, check_eager=False)
self.check_output_with_place(self.place)
class TestProd8DOp(OpTest):
......@@ -72,7 +70,6 @@ class TestProd8DOp(OpTest):
self.op_type = "reduce_prod"
self.place = paddle.device.MLUPlace(0)
self.__class__.use_mlu = True
self.python_api = raw_reduce_prod
self.init_data_type()
self.inputs = {
'X': np.random.random((2, 5, 3, 2, 2, 3, 4, 2)).astype(
......@@ -88,7 +85,7 @@ class TestProd8DOp(OpTest):
self.data_type = "float32"
def test_check_output(self):
self.check_output_with_place(self.place, check_eager=False)
self.check_output_with_place(self.place)
if __name__ == '__main__':
......
......@@ -17,7 +17,7 @@ import numpy as np
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
paddle.enable_static()
......
......@@ -17,7 +17,7 @@ import paddle
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import numpy as np
import unittest
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid as fluid
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid as fluid
......
......@@ -23,7 +23,7 @@ import random
import sys
sys.path.append('..')
from op_test import OpTest
from eager_op_test import OpTest
sys.path.append("../rnn")
from rnn_numpy import SimpleRNN, LSTM, GRU
......
......@@ -18,7 +18,7 @@ import math
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
paddle.enable_static()
......
......@@ -17,7 +17,7 @@ import numpy as np
import sys
sys.path.append('..')
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid as fluid
import paddle.fluid.core as core
......
......@@ -20,7 +20,7 @@ import numpy as np
import os
import paddle
import paddle.fluid as fluid
from op_test import OpTest
from eager_op_test import OpTest
import paddle.fluid.core as core
from paddle.fluid.dygraph.base import switch_to_static_graph
......@@ -32,7 +32,6 @@ class TestScatterOp(OpTest):
self.op_type = "scatter"
self.place = paddle.device.MLUPlace(0)
self.__class__.use_mlu = True
self.python_api = paddle.scatter
ref_np = np.ones((3, 50)).astype("float32")
index_np = np.array([1, 2]).astype("int32")
updates_np = np.random.random((2, 50)).astype("float32")
......@@ -42,10 +41,10 @@ class TestScatterOp(OpTest):
self.outputs = {'Out': output_np}
def test_check_output(self):
self.check_output_with_place(self.place, check_eager=False)
self.check_output_with_place(self.place)
def test_check_grad(self):
self.check_grad(["X", "Updates"], "Out", check_eager=False)
self.check_grad(["X", "Updates"], "Out")
class TestScatterOp0(OpTest):
......@@ -53,7 +52,6 @@ class TestScatterOp0(OpTest):
self.op_type = "scatter"
self.place = paddle.device.MLUPlace(0)
self.__class__.use_mlu = True
self.python_api = paddle.scatter
ref_np = np.ones((3, 3)).astype("float32")
index_np = np.array([1, 2]).astype("int32")
updates_np = np.random.random((2, 3)).astype("float32")
......@@ -64,10 +62,10 @@ class TestScatterOp0(OpTest):
self.outputs = {'Out': output_np}
def test_check_output(self):
self.check_output_with_place(self.place, check_eager=False)
self.check_output_with_place(self.place)
def test_check_grad(self):
self.check_grad(["X", "Updates"], "Out", check_eager=False)
self.check_grad(["X", "Updates"], "Out")
class TestScatterOp1(OpTest):
......@@ -75,7 +73,6 @@ class TestScatterOp1(OpTest):
self.op_type = "scatter"
self.place = paddle.device.MLUPlace(0)
self.__class__.use_mlu = True
self.python_api = paddle.scatter
ref_np = np.ones((3, 3)).astype("float32")
zeros_np = np.zeros([2, 3]).astype('float32')
index_np = np.array([1, 1]).astype("int32")
......@@ -89,10 +86,10 @@ class TestScatterOp1(OpTest):
self.outputs = {'Out': output_np}
def test_check_output(self):
self.check_output_with_place(self.place, check_eager=False)
self.check_output_with_place(self.place)
def test_check_grad(self):
self.check_grad(["X", "Updates"], "Out", check_eager=False)
self.check_grad(["X", "Updates"], "Out")
class TestScatterOp2(OpTest):
......@@ -100,7 +97,6 @@ class TestScatterOp2(OpTest):
self.op_type = "scatter"
self.place = paddle.device.MLUPlace(0)
self.__class__.use_mlu = True
self.python_api = paddle.scatter
ref_np = np.ones((3, 3)).astype("float32")
index_np = np.array([1, 2]).astype("int64")
updates_np = np.random.random((2, 3)).astype("float32")
......@@ -110,10 +106,10 @@ class TestScatterOp2(OpTest):
self.outputs = {'Out': output_np}
def test_check_output(self):
self.check_output_with_place(self.place, check_eager=False)
self.check_output_with_place(self.place)
def test_check_grad(self):
self.check_grad(['X', 'Updates'], 'Out', check_eager=False)
self.check_grad(['X', 'Updates'], 'Out')
class TestScatterAPI(unittest.TestCase):
......@@ -230,7 +226,6 @@ class TestScatterOpFp16(OpTest):
self.op_type = "scatter"
self.place = paddle.device.MLUPlace(0)
self.__class__.use_mlu = True
self.python_api = paddle.scatter
ref_np = np.ones((3, 3)).astype("float16")
index_np = np.array([1, 2]).astype("int32")
updates_np = np.random.random((2, 3)).astype("float16")
......@@ -241,10 +236,10 @@ class TestScatterOpFp16(OpTest):
self.outputs = {'Out': output_np}
def test_check_output(self):
self.check_output_with_place(self.place, check_eager=False)
self.check_output_with_place(self.place)
def test_check_grad(self):
self.check_grad(["X", "Updates"], "Out", check_eager=False)
self.check_grad(["X", "Updates"], "Out")
class TestScatterInplaceAPI(TestScatterAPI):
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid as fluid
from paddle.fluid import core
......
......@@ -17,7 +17,7 @@ import numpy as np
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
# from paddle.fluid import core
......
......@@ -16,7 +16,7 @@ import numpy as np
import sys
sys.path.append('..')
from op_test import OpTest
from eager_op_test import OpTest
from scipy.special import logit
from scipy.special import expit
import paddle.fluid.core as core
......
......@@ -15,7 +15,7 @@
import numpy as np
import unittest
import sys
from paddle.fluid.tests.unittests.op_test import OpTest
from paddle.fluid.tests.unittests.eager_op_test import OpTest
import paddle
import paddle.fluid as fluid
......
......@@ -19,7 +19,7 @@ import paddle.fluid as fluid
import sys
sys.path.append('..')
from op_test import OpTest
from eager_op_test import OpTest
paddle.enable_static()
......
......@@ -18,7 +18,7 @@ import paddle.fluid.core as core
import sys
sys.path.append('..')
from op_test import OpTest
from eager_op_test import OpTest
import paddle.fluid as fluid
import paddle.fluid.layers as layers
import paddle
......
......@@ -17,7 +17,7 @@ import numpy as np
import sys
sys.path.append('..')
from op_test import OpTest
from eager_op_test import OpTest
import paddle.fluid.core as core
import paddle.fluid as fluid
from paddle.fluid import compiler, Program, program_guard
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid as fluid
from test_softmax_op import stable_softmax
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid as fluid
import paddle.fluid.core as core
......
......@@ -17,7 +17,7 @@ import numpy as np
import sys
sys.path.append('..')
from op_test import OpTest
from eager_op_test import OpTest
import paddle.fluid.core as core
import paddle.fluid as fluid
from paddle.fluid import compiler, Program, program_guard
......@@ -33,7 +33,6 @@ class TestSqrt(OpTest):
self.op_type = "sqrt"
self.dtype = 'float32'
self.set_mlu()
self.python_api = paddle.sqrt
np.random.seed(1023)
x = np.random.uniform(0.1, 1, [11, 17]).astype(self.dtype)
......@@ -47,7 +46,7 @@ class TestSqrt(OpTest):
self.place = paddle.device.MLUPlace(0)
def test_check_grad(self):
self.check_grad_with_place(self.place, ['X'], 'Out', check_eager=False)
self.check_grad_with_place(self.place, ['X'], 'Out')
def test_check_output(self):
self.check_output_with_place(self.place)
......@@ -58,7 +57,6 @@ class TestSqrtHalf(OpTest):
self.op_type = "sqrt"
self.dtype = 'float16'
self.set_mlu()
self.python_api = paddle.sqrt
np.random.seed(1023)
x = np.random.uniform(0.1, 1, [11, 17]).astype(self.dtype)
......@@ -73,7 +71,7 @@ class TestSqrtHalf(OpTest):
def test_check_grad(self):
self.check_grad_with_place(
self.place, ['X'], 'Out', check_eager=False, max_relative_error=0.85
self.place, ['X'], 'Out', max_relative_error=0.85
)
def test_check_output(self):
......
......@@ -18,7 +18,7 @@ from numpy import linalg as LA
import sys
sys.path.append('..')
from op_test import OpTest
from eager_op_test import OpTest
import paddle
from paddle import _C_ops, _legacy_C_ops
......
......@@ -18,7 +18,7 @@ import sys
sys.path.append("..")
import numpy as np
import paddle
from op_test import OpTest
from eager_op_test import OpTest
paddle.enable_static()
......
......@@ -22,7 +22,7 @@ import numpy as np
import paddle
import paddle.fluid as fluid
from paddle.fluid import compiler, Program, program_guard
from op_test import OpTest, convert_float_to_uint16
from eager_op_test import OpTest, convert_float_to_uint16
import paddle.fluid.core as core
paddle.enable_static()
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append('..')
from op_test import OpTest
from eager_op_test import OpTest
import paddle.fluid as fluid
import paddle
......
......@@ -15,7 +15,7 @@
import sys
sys.path.append('..')
from op_test import OpTest
from eager_op_test import OpTest
from test_strided_slice_op import strided_slice_native_forward
import numpy as np
import unittest
......@@ -31,7 +31,6 @@ class TestStrideSliceOp(OpTest):
self.place = paddle.device.MLUPlace(0)
self.__class__.use_mlu = True
self.op_type = 'strided_slice'
self.python_api = paddle.strided_slice
self.output = strided_slice_native_forward(
self.input, self.axes, self.starts, self.ends, self.strides
)
......@@ -47,11 +46,11 @@ class TestStrideSliceOp(OpTest):
}
def test_check_output(self):
self.check_output_with_place(self.place, check_eager=False)
self.check_output_with_place(self.place)
def test_check_grad(self):
self.check_grad_with_place(
self.place, set(['Input']), 'Out', check_eager=False
self.place, set(['Input']), 'Out'
)
def initTestCase(self):
......
......@@ -17,7 +17,7 @@ import unittest
import sys
sys.path.append("..")
from op_test import OpTest
from eager_op_test import OpTest
import paddle
import paddle.fluid as fluid
import paddle.fluid.core as core
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册