|
|
|
@ -55,9 +55,9 @@ class TestReshapeOpDimInfer1(TestReshapeOp):
|
|
|
|
|
|
|
|
|
|
class TestReshapeOpDimInfer2(TestReshapeOp):
|
|
|
|
|
def init_data(self):
|
|
|
|
|
self.ori_shape = (2, 2, 6)
|
|
|
|
|
self.new_shape = (2, 0, 3, -1)
|
|
|
|
|
self.infered_shape = (2, 2, 3, -1)
|
|
|
|
|
self.ori_shape = (10, 2, 6)
|
|
|
|
|
self.new_shape = (10, 0, 3, -1)
|
|
|
|
|
self.infered_shape = (10, 2, 3, -1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# situation 2: have shape(list, no tensor), have actual shape(Tensor)
|
|
|
|
@ -78,9 +78,9 @@ class TestReshapeOpWithInputShape(OpTest):
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def init_data(self):
|
|
|
|
|
self.ori_shape = (6, 5)
|
|
|
|
|
self.new_shape = (0, -1, 5)
|
|
|
|
|
self.actual_shape = (2, 3, 5)
|
|
|
|
|
self.ori_shape = (6, 20)
|
|
|
|
|
self.new_shape = (0, -1, 20)
|
|
|
|
|
self.actual_shape = (2, 3, 20)
|
|
|
|
|
|
|
|
|
|
def test_check_output(self):
|
|
|
|
|
self.check_output(no_check_set=['XShape'])
|
|
|
|
@ -111,9 +111,9 @@ class TestReshapeOp_attr_ShapeTensor(OpTest):
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def init_data(self):
|
|
|
|
|
self.ori_shape = (2, 25)
|
|
|
|
|
self.new_shape = (5, 10)
|
|
|
|
|
self.infered_shape = (5, 10)
|
|
|
|
|
self.ori_shape = (4, 25)
|
|
|
|
|
self.new_shape = (10, 10)
|
|
|
|
|
self.infered_shape = (10, 10)
|
|
|
|
|
self.shape = (-1, -1)
|
|
|
|
|
|
|
|
|
|
def test_check_output(self):
|
|
|
|
@ -125,18 +125,18 @@ class TestReshapeOp_attr_ShapeTensor(OpTest):
|
|
|
|
|
|
|
|
|
|
class TestReshapeOpDimInfer1_attr_ShapeTensor(TestReshapeOp_attr_ShapeTensor):
|
|
|
|
|
def init_data(self):
|
|
|
|
|
self.ori_shape = (5, 10)
|
|
|
|
|
self.new_shape = (5, -1, 5)
|
|
|
|
|
self.infered_shape = (5, -1, 5)
|
|
|
|
|
self.ori_shape = (5, 20)
|
|
|
|
|
self.new_shape = (5, -1, 20)
|
|
|
|
|
self.infered_shape = (5, -1, 20)
|
|
|
|
|
self.shape = (5, -1, -1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestReshapeOpDimInfer2_attr_ShapeTensor(TestReshapeOp_attr_ShapeTensor):
|
|
|
|
|
def init_data(self):
|
|
|
|
|
self.ori_shape = (2, 2, 6)
|
|
|
|
|
self.new_shape = (2, 0, 3, -1)
|
|
|
|
|
self.infered_shape = (2, 2, 3, -1)
|
|
|
|
|
self.shape = (2, 0, 3, -1)
|
|
|
|
|
self.ori_shape = (10, 2, 6)
|
|
|
|
|
self.new_shape = (10, 0, 3, -1)
|
|
|
|
|
self.infered_shape = (10, 2, 3, -1)
|
|
|
|
|
self.shape = (10, 0, 3, -1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Situation 4: have shape(Tensor), no actual shape(Tensor)
|
|
|
|
@ -157,9 +157,9 @@ class TestReshapeOp_attr_OnlyShape(OpTest):
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def init_data(self):
|
|
|
|
|
self.ori_shape = (2, 25)
|
|
|
|
|
self.new_shape = (5, 10)
|
|
|
|
|
self.infered_shape = (5, 10)
|
|
|
|
|
self.ori_shape = (4, 25)
|
|
|
|
|
self.new_shape = (10, 10)
|
|
|
|
|
self.infered_shape = (10, 10)
|
|
|
|
|
|
|
|
|
|
def test_check_output(self):
|
|
|
|
|
self.check_output(no_check_set=['XShape'])
|
|
|
|
@ -170,18 +170,18 @@ class TestReshapeOp_attr_OnlyShape(OpTest):
|
|
|
|
|
|
|
|
|
|
class TestReshapeOpDimInfer1_attr_OnlyShape(TestReshapeOp_attr_OnlyShape):
|
|
|
|
|
def init_data(self):
|
|
|
|
|
self.ori_shape = (5, 10)
|
|
|
|
|
self.new_shape = (5, -1, 5)
|
|
|
|
|
self.infered_shape = (5, -1, 5)
|
|
|
|
|
self.ori_shape = (5, 20)
|
|
|
|
|
self.new_shape = (5, -1, 10)
|
|
|
|
|
self.infered_shape = (5, -1, 10)
|
|
|
|
|
self.shape = (5, -1, -1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestReshapeOpDimInfer2_attr_OnlyShape(TestReshapeOp_attr_OnlyShape):
|
|
|
|
|
def init_data(self):
|
|
|
|
|
self.ori_shape = (2, 2, 6)
|
|
|
|
|
self.new_shape = (2, 0, 3, -1)
|
|
|
|
|
self.infered_shape = (2, 2, 3, -1)
|
|
|
|
|
self.shape = (2, 0, 3, -1)
|
|
|
|
|
self.ori_shape = (10, 2, 6)
|
|
|
|
|
self.new_shape = (10, 0, 3, -1)
|
|
|
|
|
self.infered_shape = (10, 2, 3, -1)
|
|
|
|
|
self.shape = (10, 0, 3, -1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# test int8 data type on CPU
|
|
|
|
@ -207,9 +207,9 @@ class TestReshapeInt8Op(OpTest):
|
|
|
|
|
self.dtype = np.int8
|
|
|
|
|
|
|
|
|
|
def init_data(self):
|
|
|
|
|
self.ori_shape = (2, 2, 6)
|
|
|
|
|
self.new_shape = (2, 0, 3, -1)
|
|
|
|
|
self.infered_shape = (2, 2, 3, -1)
|
|
|
|
|
self.ori_shape = (10, 2, 6)
|
|
|
|
|
self.new_shape = (10, 0, 3, -1)
|
|
|
|
|
self.infered_shape = (10, 2, 3, -1)
|
|
|
|
|
|
|
|
|
|
def test_check_output(self):
|
|
|
|
|
self.check_output_with_place(
|
|
|
|
|