未验证 提交 f64d0066 编写于 作者: J juncaipeng 提交者: GitHub

Change several tests to inherit the right parent class, test=develop (#21652)

* change several tests to use the right parent class, test=develop

* add dtype for TestLoDTensorAndSelectedRowsOp, test=develop
上级 fbbd94a6
......@@ -65,7 +65,7 @@ class TestCase3(TestClipByNormOp):
self.max_norm = 1.0
class TestClipByNormOpWithSelectedRows(OpTest):
class TestClipByNormOpWithSelectedRows(unittest.TestCase):
def check_with_place(self, place):
self.config_test_case()
scope = core.Scope()
......
......@@ -171,6 +171,9 @@ class TestDropoutOpWithSeed(OpTest):
self.check_grad(['X'], 'Out', max_relative_error=0.05)
@unittest.skipIf(
not core.is_compiled_with_cuda() or not core.op_support_gpu("dropout"),
"core is not compiled with CUDA or core is not support dropout")
class TestFP16DropoutOp(OpTest):
def setUp(self):
self.op_type = "dropout"
......@@ -192,10 +195,12 @@ class TestFP16DropoutOp(OpTest):
self.fix_seed = True
def test_check_output(self):
if core.is_compiled_with_cuda() and core.op_support_gpu("dropout"):
self.check_output_with_place(core.CUDAPlace(0), atol=1e-3)
@unittest.skipIf(
not core.is_compiled_with_cuda() or not core.op_support_gpu("dropout"),
"core is not compiled with CUDA or core is not support dropout")
class TestFP16DropoutOp2(TestFP16DropoutOp):
def init_test_case(self):
self.input_size = [32, 64, 3]
......
......@@ -81,7 +81,7 @@ class TestFillConstantOp4(OpTest):
self.check_output()
class TestFillConstantOpWithSelectedRows(OpTest):
class TestFillConstantOpWithSelectedRows(unittest.TestCase):
def check_with_place(self, place):
scope = core.Scope()
# create Out Variable
......
......@@ -55,7 +55,7 @@ class TestFillOp2(OpTest):
self.check_output(check_dygraph=False)
class TestFillOp3(OpTest):
class TestFillOp3(unittest.TestCase):
def check_with_place(self, place, f_cpu):
scope = core.Scope()
# create Out Variable
......
......@@ -21,7 +21,7 @@ import paddle.fluid.core as core
from paddle.fluid.op import Operator
class TestLookupSpraseTable(OpTest):
class TestLookupSpraseTable(unittest.TestCase):
def check_with_place(self, place):
scope = core.Scope()
......
......@@ -85,7 +85,7 @@ class TestLookupTableOpWithTensorIdsAndPadding(TestLookupTableOpWithTensorIds):
pass
class TestLookupTableWIsSelectedRows(OpTest):
class TestLookupTableWIsSelectedRows(unittest.TestCase):
def prepare_ids(self, scope, place):
ids_tensor = scope.var('Ids').get_tensor()
ids_array = np.array([[0], [4], [3], [5]]).astype("int64")
......@@ -250,7 +250,7 @@ class TestLookupTableOpWithTensorIdsAndPaddingInt8(
pass
class TestLookupTableWIsSelectedRowsInt8(OpTest):
class TestLookupTableWIsSelectedRowsInt8(unittest.TestCase):
def prepare_ids(self, scope, place):
ids_tensor = scope.var('Ids').get_tensor()
ids_array = np.array([[0], [4], [3], [5]]).astype("int64")
......
......@@ -84,7 +84,7 @@ class TestLookupTableOpWithTensorIdsAndPadding(TestLookupTableOpWithTensorIds):
pass
class TestLookupTableWIsSelectedRows(OpTest):
class TestLookupTableWIsSelectedRows(unittest.TestCase):
def prepare_ids(self, scope, place):
ids_tensor = scope.var('Ids').get_tensor()
ids_array = np.array([0, 4, 3, 5]).astype("int64")
......
......@@ -48,7 +48,7 @@ class TestSumOp(OpTest):
pass
class TestSelectedRowsSumOp(OpTest):
class TestSelectedRowsSumOp(unittest.TestCase):
def setUp(self):
self.height = 10
self.row_numel = 12
......@@ -144,6 +144,7 @@ class TestLoDTensorAndSelectedRowsOp(TestSelectedRowsSumOp):
self.height = 10
self.row_numel = 12
self.rows = [0, 1, 2, 2, 4, 5, 6]
self.dtype = np.float32
def check_with_place(self, place, inplace):
scope = core.Scope()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册