|
|
|
@ -219,5 +219,70 @@ class TestCPULoDTensorArrayOpGrad(unittest.TestCase):
|
|
|
|
|
self.assertAlmostEqual(1.0, g_out_sum, delta=0.1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestLoDTensorArrayError(unittest.TestCase):
|
|
|
|
|
def test_errors(self):
|
|
|
|
|
with program_guard(Program(), Program()):
|
|
|
|
|
x = numpy.random.random((10)).astype("float32")
|
|
|
|
|
x2 = layers.data(name='x', shape=[10])
|
|
|
|
|
table = lod_rank_table(x2, level=0)
|
|
|
|
|
|
|
|
|
|
def test_x_Variable():
|
|
|
|
|
rank_table = lod_tensor_to_array(x=x, table=table)
|
|
|
|
|
|
|
|
|
|
self.assertRaises(TypeError, test_x_Variable)
|
|
|
|
|
|
|
|
|
|
table2 = numpy.random.random((2)).astype("int64")
|
|
|
|
|
|
|
|
|
|
def test_table_Variable():
|
|
|
|
|
rank_table = lod_tensor_to_array(x=x2, table=table2)
|
|
|
|
|
|
|
|
|
|
self.assertRaises(TypeError, test_table_Variable)
|
|
|
|
|
|
|
|
|
|
def test_x_list_Variable():
|
|
|
|
|
rank_table = lod_tensor_to_array(x=[x], table=table)
|
|
|
|
|
|
|
|
|
|
self.assertRaises(TypeError, test_x_list_Variable)
|
|
|
|
|
|
|
|
|
|
def test_table_list_Variable():
|
|
|
|
|
rank_table = lod_tensor_to_array(x=x2, table=[table2])
|
|
|
|
|
|
|
|
|
|
self.assertRaises(TypeError, test_table_list_Variable)
|
|
|
|
|
|
|
|
|
|
array = lod_tensor_to_array(x2, table)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestArrayLoDTensorError(unittest.TestCase):
|
|
|
|
|
def test_errors(self):
|
|
|
|
|
with program_guard(Program(), Program()):
|
|
|
|
|
x = numpy.random.random((10)).astype("float32")
|
|
|
|
|
x2 = layers.data(name='x', shape=[10])
|
|
|
|
|
table = lod_rank_table(x2, level=0)
|
|
|
|
|
array = lod_tensor_to_array(x2, table)
|
|
|
|
|
|
|
|
|
|
def test_x_Variable():
|
|
|
|
|
rank_table = array_to_lod_tensor(x=x, table=table)
|
|
|
|
|
|
|
|
|
|
self.assertRaises(TypeError, test_x_Variable)
|
|
|
|
|
|
|
|
|
|
table2 = numpy.random.random((2)).astype("int64")
|
|
|
|
|
|
|
|
|
|
def test_table_Variable():
|
|
|
|
|
rank_table = array_to_lod_tensor(x=array, table=table2)
|
|
|
|
|
|
|
|
|
|
self.assertRaises(TypeError, test_table_Variable)
|
|
|
|
|
|
|
|
|
|
def test_x_list_Variable():
|
|
|
|
|
rank_table = array_to_lod_tensor(x=[x], table=table)
|
|
|
|
|
|
|
|
|
|
self.assertRaises(TypeError, test_x_list_Variable)
|
|
|
|
|
|
|
|
|
|
def test_table_list_Variable():
|
|
|
|
|
rank_table = array_to_lod_tensor(x=x2, table=[table2])
|
|
|
|
|
|
|
|
|
|
self.assertRaises(TypeError, test_table_list_Variable)
|
|
|
|
|
|
|
|
|
|
array = array_to_lod_tensor(x2, table)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
unittest.main()
|
|
|
|
|