提交 bf978fff 编写于 作者: Z zhupengyang 提交者: Tao Luo

all cases use large shape (#22084)

flatten, flatten2, gather, gather_nd, group_norm, gru,
gru_unit, reduce_max, reduce_min, reduce_mean, reduce_sum,
reshape, scatter_nd_add, sequence_expand, sequence_expand_as,
sequence_pad
上级 7d8d4599
...@@ -82,7 +82,7 @@ class TestSequenceExpand(OpTest): ...@@ -82,7 +82,7 @@ class TestSequenceExpand(OpTest):
class TestSequenceExpandCase1(TestSequenceExpand): class TestSequenceExpandCase1(TestSequenceExpand):
def set_data(self): def set_data(self):
x_data = np.random.uniform(0.1, 1, [5, 1]).astype('float64') x_data = np.random.uniform(0.1, 1, [5, 20]).astype('float64')
y_data = np.random.uniform(0.1, 1, [13, 1]).astype('float64') y_data = np.random.uniform(0.1, 1, [13, 1]).astype('float64')
y_lod = [[2, 3], [2, 2, 3, 3, 3]] y_lod = [[2, 3], [2, 2, 3, 3, 3]]
self.inputs = {'X': x_data, 'Y': (y_data, y_lod)} self.inputs = {'X': x_data, 'Y': (y_data, y_lod)}
...@@ -91,7 +91,7 @@ class TestSequenceExpandCase1(TestSequenceExpand): ...@@ -91,7 +91,7 @@ class TestSequenceExpandCase1(TestSequenceExpand):
class TestSequenceExpandCase2(TestSequenceExpand): class TestSequenceExpandCase2(TestSequenceExpand):
def set_data(self): def set_data(self):
x_data = np.random.uniform(0.1, 1, [1, 2, 2]).astype('float64') x_data = np.random.uniform(0.1, 1, [1, 2, 50]).astype('float64')
x_lod = [[1]] x_lod = [[1]]
y_data = np.random.uniform(0.1, 1, [2, 2, 2]).astype('float64') y_data = np.random.uniform(0.1, 1, [2, 2, 2]).astype('float64')
y_lod = [[2], [1, 1]] y_lod = [[2], [1, 1]]
...@@ -101,7 +101,7 @@ class TestSequenceExpandCase2(TestSequenceExpand): ...@@ -101,7 +101,7 @@ class TestSequenceExpandCase2(TestSequenceExpand):
class TestSequenceExpandCase3(TestSequenceExpand): class TestSequenceExpandCase3(TestSequenceExpand):
def set_data(self): def set_data(self):
x_data = np.random.uniform(0.1, 1, [4, 1]).astype('float64') x_data = np.random.uniform(0.1, 1, [4, 25]).astype('float64')
x_lod = [[1, 1, 1, 1]] x_lod = [[1, 1, 1, 1]]
y_data = np.random.uniform(0.1, 1, [8, 1]).astype('float64') y_data = np.random.uniform(0.1, 1, [8, 1]).astype('float64')
y_lod = [[2, 2, 2, 2]] y_lod = [[2, 2, 2, 2]]
...@@ -110,8 +110,8 @@ class TestSequenceExpandCase3(TestSequenceExpand): ...@@ -110,8 +110,8 @@ class TestSequenceExpandCase3(TestSequenceExpand):
class TestSequenceExpandCase4(TestSequenceExpand): class TestSequenceExpandCase4(TestSequenceExpand):
def set_data(self): def set_data(self):
data = np.random.uniform(0.1, 1, [5 * 2, 1]) data = np.random.uniform(0.1, 1, [5 * 20, 1])
x_data = np.array(data).reshape([5, 2]).astype('float64') x_data = np.array(data).reshape([5, 20]).astype('float64')
x_lod = [[2, 3]] x_lod = [[2, 3]]
y_data = np.random.uniform(0.1, 1, [5, 1]).astype('float64') y_data = np.random.uniform(0.1, 1, [5, 1]).astype('float64')
y_lod = [[2], [2, 3]] y_lod = [[2], [2, 3]]
...@@ -120,7 +120,7 @@ class TestSequenceExpandCase4(TestSequenceExpand): ...@@ -120,7 +120,7 @@ class TestSequenceExpandCase4(TestSequenceExpand):
class TestSequenceExpandCase5(TestSequenceExpand): class TestSequenceExpandCase5(TestSequenceExpand):
def set_data(self): def set_data(self):
x_data = np.random.uniform(0.1, 1, [6, 1]).astype('float64') x_data = np.random.uniform(0.1, 1, [6, 20]).astype('float64')
y_data = np.random.uniform(0.1, 1, [13, 1]).astype('float64') y_data = np.random.uniform(0.1, 1, [13, 1]).astype('float64')
y_lod = [[2, 4], [2, 2, 3, 0, 3, 3]] y_lod = [[2, 4], [2, 2, 3, 0, 3, 3]]
self.inputs = {'X': x_data, 'Y': (y_data, y_lod)} self.inputs = {'X': x_data, 'Y': (y_data, y_lod)}
...@@ -129,7 +129,7 @@ class TestSequenceExpandCase5(TestSequenceExpand): ...@@ -129,7 +129,7 @@ class TestSequenceExpandCase5(TestSequenceExpand):
class TestSequenceExpandCase6(TestSequenceExpand): class TestSequenceExpandCase6(TestSequenceExpand):
def set_data(self): def set_data(self):
x_data = np.random.uniform(0.1, 1, [4, 1]).astype('float64') x_data = np.random.uniform(0.1, 1, [4, 25]).astype('float64')
x_lod = [[1, 1, 0, 1, 1]] x_lod = [[1, 1, 0, 1, 1]]
y_data = np.random.uniform(0.1, 1, [8, 1]).astype('float64') y_data = np.random.uniform(0.1, 1, [8, 1]).astype('float64')
y_lod = [[0, 2, 4, 2, 0]] y_lod = [[0, 2, 4, 2, 0]]
......
...@@ -59,7 +59,7 @@ class TestSequenceExpandAs(OpTest): ...@@ -59,7 +59,7 @@ class TestSequenceExpandAs(OpTest):
class TestSequenceExpandAsCase1(TestSequenceExpandAs): class TestSequenceExpandAsCase1(TestSequenceExpandAs):
def set_data(self): def set_data(self):
x_data = np.random.uniform(0.1, 1, [5, 1]).astype('float64') x_data = np.random.uniform(0.1, 1, [5, 20]).astype('float64')
x_lod = [[2, 3]] x_lod = [[2, 3]]
y_data = np.random.uniform(0.1, 1, [10, 1]).astype('float64') y_data = np.random.uniform(0.1, 1, [10, 1]).astype('float64')
y_lod = [[2, 2, 0, 3, 3]] y_lod = [[2, 2, 0, 3, 3]]
...@@ -68,7 +68,7 @@ class TestSequenceExpandAsCase1(TestSequenceExpandAs): ...@@ -68,7 +68,7 @@ class TestSequenceExpandAsCase1(TestSequenceExpandAs):
class TestSequenceExpandAsCase2(TestSequenceExpandAs): class TestSequenceExpandAsCase2(TestSequenceExpandAs):
def set_data(self): def set_data(self):
x_data = np.random.uniform(0.1, 1, [5, 1]).astype('float64') x_data = np.random.uniform(0.1, 1, [5, 20]).astype('float64')
x_lod = [[2, 3]] x_lod = [[2, 3]]
y_data = np.random.uniform(0.1, 1, [10, 1]).astype('float64') y_data = np.random.uniform(0.1, 1, [10, 1]).astype('float64')
y_lod = [[0, 4, 0, 6, 0]] y_lod = [[0, 4, 0, 6, 0]]
...@@ -77,7 +77,7 @@ class TestSequenceExpandAsCase2(TestSequenceExpandAs): ...@@ -77,7 +77,7 @@ class TestSequenceExpandAsCase2(TestSequenceExpandAs):
class TestSequenceExpandAsCase3(TestSequenceExpandAs): class TestSequenceExpandAsCase3(TestSequenceExpandAs):
def set_data(self): def set_data(self):
x_data = np.random.uniform(0.1, 1, [1, 2, 2]).astype('float64') x_data = np.random.uniform(0.1, 1, [1, 2, 50]).astype('float64')
x_lod = [[1]] x_lod = [[1]]
y_data = np.random.uniform(0.1, 1, [2, 2, 2]).astype('float64') y_data = np.random.uniform(0.1, 1, [2, 2, 2]).astype('float64')
y_lod = [[2]] y_lod = [[2]]
......
...@@ -82,16 +82,16 @@ class TestSequencePadOp(OpTest): ...@@ -82,16 +82,16 @@ class TestSequencePadOp(OpTest):
class TestSequencePadOp2(TestSequencePadOp): class TestSequencePadOp2(TestSequencePadOp):
def set_attr(self): def set_attr(self):
self.x_shape = [12, 4] self.x_shape = [12, 10]
self.x_len_lod = [[2, 3, 4, 3]] self.x_len_lod = [[2, 3, 4, 3]]
self.pad_value = [1.0, 2.0, 3.0, 4.0] self.pad_value = np.random.random((10))
self.padded_length = -1 self.padded_length = -1
self.dtype = 'float64' self.dtype = 'float64'
class TestSequencePadOp3(TestSequencePadOp): class TestSequencePadOp3(TestSequencePadOp):
def set_attr(self): def set_attr(self):
self.x_shape = [12, 4] self.x_shape = [12, 10]
self.x_len_lod = [[2, 3, 4, 3]] self.x_len_lod = [[2, 3, 4, 3]]
self.pad_value = [1.0] self.pad_value = [1.0]
self.padded_length = 7 self.padded_length = 7
...@@ -100,16 +100,16 @@ class TestSequencePadOp3(TestSequencePadOp): ...@@ -100,16 +100,16 @@ class TestSequencePadOp3(TestSequencePadOp):
class TestSequencePadOp4(TestSequencePadOp): class TestSequencePadOp4(TestSequencePadOp):
def set_attr(self): def set_attr(self):
self.x_shape = [12, 4] self.x_shape = [12, 10]
self.x_len_lod = [[2, 3, 4, 3]] self.x_len_lod = [[2, 3, 4, 3]]
self.pad_value = [1.0, 2.0, 3.0, 4.0] self.pad_value = np.random.random((10))
self.padded_length = 7 self.padded_length = 7
self.dtype = 'float64' self.dtype = 'float64'
class TestSequencePadOp5(TestSequencePadOp): class TestSequencePadOp5(TestSequencePadOp):
def set_attr(self): def set_attr(self):
self.x_shape = [12, 2, 2] self.x_shape = [12, 2, 5]
self.x_len_lod = [[2, 3, 4, 3]] self.x_len_lod = [[2, 3, 4, 3]]
self.pad_value = [1.0] self.pad_value = [1.0]
self.padded_length = -1 self.padded_length = -1
...@@ -118,16 +118,16 @@ class TestSequencePadOp5(TestSequencePadOp): ...@@ -118,16 +118,16 @@ class TestSequencePadOp5(TestSequencePadOp):
class TestSequencePadOp6(TestSequencePadOp): class TestSequencePadOp6(TestSequencePadOp):
def set_attr(self): def set_attr(self):
self.x_shape = [12, 2, 2] self.x_shape = [12, 2, 5]
self.x_len_lod = [[2, 3, 4, 3]] self.x_len_lod = [[2, 3, 4, 3]]
self.pad_value = [[1.0, 2.0], [3.0, 4.0]] self.pad_value = np.random.random((2, 5))
self.padded_length = -1 self.padded_length = -1
self.dtype = 'float64' self.dtype = 'float64'
class TestSequencePadOp7(TestSequencePadOp): class TestSequencePadOp7(TestSequencePadOp):
def set_attr(self): def set_attr(self):
self.x_shape = [12, 2, 2] self.x_shape = [12, 2, 5]
self.x_len_lod = [[2, 3, 4, 3]] self.x_len_lod = [[2, 3, 4, 3]]
self.pad_value = [1.0] self.pad_value = [1.0]
self.padded_length = 7 self.padded_length = 7
...@@ -136,7 +136,7 @@ class TestSequencePadOp7(TestSequencePadOp): ...@@ -136,7 +136,7 @@ class TestSequencePadOp7(TestSequencePadOp):
class TestSequencePadOp8(TestSequencePadOp): class TestSequencePadOp8(TestSequencePadOp):
def set_attr(self): def set_attr(self):
self.x_shape = [12, 2, 2] self.x_shape = [12, 2, 5]
self.x_len_lod = [[0, 8, 0, 4, 0]] self.x_len_lod = [[0, 8, 0, 4, 0]]
self.pad_value = [1.0] self.pad_value = [1.0]
self.padded_length = 10 self.padded_length = 10
......
...@@ -55,8 +55,8 @@ class TestFlattenOp(TestFlattenOp): ...@@ -55,8 +55,8 @@ class TestFlattenOp(TestFlattenOp):
class TestFlattenOpWithDefaultAxis(TestFlattenOp): class TestFlattenOpWithDefaultAxis(TestFlattenOp):
def init_test_case(self): def init_test_case(self):
self.in_shape = (3, 2, 2, 3) self.in_shape = (10, 2, 2, 3)
self.new_shape = (3, 12) self.new_shape = (10, 12)
def init_attrs(self): def init_attrs(self):
self.attrs = {} self.attrs = {}
......
...@@ -52,8 +52,8 @@ class TestFlattenOp(TestFlattenOp): ...@@ -52,8 +52,8 @@ class TestFlattenOp(TestFlattenOp):
class TestFlattenOpWithDefaultAxis(TestFlattenOp): class TestFlattenOpWithDefaultAxis(TestFlattenOp):
def init_test_case(self): def init_test_case(self):
self.in_shape = (3, 2, 2, 3) self.in_shape = (10, 2, 2, 3)
self.new_shape = (3, 12) self.new_shape = (10, 12)
def init_attrs(self): def init_attrs(self):
self.attrs = {} self.attrs = {}
......
...@@ -47,8 +47,7 @@ class TestGatherNdOpWithLowIndex(OpTest): ...@@ -47,8 +47,7 @@ class TestGatherNdOpWithLowIndex(OpTest):
def setUp(self): def setUp(self):
self.op_type = "gather_nd" self.op_type = "gather_nd"
xnp = np.array( xnp = np.random.uniform(0, 100, (10, 10)).astype("float64")
[[65, 17, 2], [14, 25, 1], [76, 22, 3]]).astype("float64")
index = np.array([[1], [2]]).astype("int64") index = np.array([[1], [2]]).astype("int64")
self.inputs = {'X': xnp, 'Index': index} self.inputs = {'X': xnp, 'Index': index}
...@@ -69,8 +68,7 @@ class TestGatherNdOpWithSameIndexAsX(OpTest): ...@@ -69,8 +68,7 @@ class TestGatherNdOpWithSameIndexAsX(OpTest):
def setUp(self): def setUp(self):
self.op_type = "gather_nd" self.op_type = "gather_nd"
xnp = np.array( xnp = np.random.uniform(0, 100, (10, 10)).astype("float64")
[[65, 17, 2], [14, 25, 1], [76, 22, 3]]).astype("float64")
index = np.array([[1, 1], [2, 1]]).astype("int64") index = np.array([[1, 1], [2, 1]]).astype("int64")
self.inputs = {'X': xnp, 'Index': index} self.inputs = {'X': xnp, 'Index': index}
......
...@@ -62,7 +62,7 @@ class TestCase2(TestGatherOp): ...@@ -62,7 +62,7 @@ class TestCase2(TestGatherOp):
""" """
For int64_t index type For int64_t index type
""" """
self.x_shape = (10) self.x_shape = (100)
self.x_type = "float64" self.x_type = "float64"
self.index = [1, 3, 5] self.index = [1, 3, 5]
self.index_type = "int64" self.index_type = "int64"
......
...@@ -45,7 +45,7 @@ class TestGroupNormOp(OpTest): ...@@ -45,7 +45,7 @@ class TestGroupNormOp(OpTest):
self.op_type = "group_norm" self.op_type = "group_norm"
self.data_format = "NCHW" self.data_format = "NCHW"
self.dtype = np.float64 self.dtype = np.float64
self.shape = (2, 4, 3, 5) self.shape = (2, 100, 3, 5)
self.attrs = {'epsilon': 1e-5, 'groups': 2, 'data_layout': "NCHW"} self.attrs = {'epsilon': 1e-5, 'groups': 2, 'data_layout': "NCHW"}
self.compare_between_place = False self.compare_between_place = False
self.init_test_case() self.init_test_case()
......
...@@ -107,7 +107,7 @@ class TestGRUOp(OpTest): ...@@ -107,7 +107,7 @@ class TestGRUOp(OpTest):
def setUp(self): def setUp(self):
self.op_type = "gru" self.op_type = "gru"
self.lod = [[2, 4, 3]] self.lod = [[2, 4, 3]]
self.D = 5 self.D = 40
self.is_reverse = False self.is_reverse = False
self.with_h0 = True self.with_h0 = True
self.with_bias = True self.with_bias = True
...@@ -169,27 +169,23 @@ class TestGRUOriginMode(TestGRUOp): ...@@ -169,27 +169,23 @@ class TestGRUOriginMode(TestGRUOp):
class TestGRUOp2(TestGRUOp): class TestGRUOp2(TestGRUOp):
def set_confs(self): def set_confs(self):
self.D = 19
self.dtype = 'float64' self.dtype = 'float64'
class TestGRUOp2Len0(TestGRUOp): class TestGRUOp2Len0(TestGRUOp):
def set_confs(self): def set_confs(self):
self.D = 19
self.lod = [[2, 0, 4]] self.lod = [[2, 0, 4]]
self.dtype = 'float64' self.dtype = 'float64'
class TestGRUOp2OriginMode(TestGRUOp): class TestGRUOp2OriginMode(TestGRUOp):
def set_confs(self): def set_confs(self):
self.D = 19
self.dtype = 'float64' self.dtype = 'float64'
self.origin_mode = True self.origin_mode = True
class TestGRUOp2OriginModeLen0(TestGRUOp): class TestGRUOp2OriginModeLen0(TestGRUOp):
def set_confs(self): def set_confs(self):
self.D = 19
self.lod = [[0, 3, 4]] self.lod = [[0, 3, 4]]
self.dtype = 'float64' self.dtype = 'float64'
self.origin_mode = True self.origin_mode = True
...@@ -197,7 +193,6 @@ class TestGRUOp2OriginModeLen0(TestGRUOp): ...@@ -197,7 +193,6 @@ class TestGRUOp2OriginModeLen0(TestGRUOp):
class TestGRUOp2OriginModeLastLen0(TestGRUOp): class TestGRUOp2OriginModeLastLen0(TestGRUOp):
def set_confs(self): def set_confs(self):
self.D = 19
self.lod = [[0, 3, 0]] self.lod = [[0, 3, 0]]
self.dtype = 'float64' self.dtype = 'float64'
self.origin_mode = True self.origin_mode = True
......
...@@ -45,7 +45,7 @@ def relu(x): ...@@ -45,7 +45,7 @@ def relu(x):
class TestGRUUnitOp(OpTest): class TestGRUUnitOp(OpTest):
batch_size = 5 batch_size = 5
frame_size = 10 frame_size = 40
activate = { activate = {
GRUActivationType.identity: identity, GRUActivationType.identity: identity,
GRUActivationType.sigmoid: sigmoid, GRUActivationType.sigmoid: sigmoid,
......
...@@ -333,7 +333,7 @@ class TestKeepDimReduceSumMultiAxises(OpTest): ...@@ -333,7 +333,7 @@ class TestKeepDimReduceSumMultiAxises(OpTest):
class TestReduceSumWithDimOne(OpTest): class TestReduceSumWithDimOne(OpTest):
def setUp(self): def setUp(self):
self.op_type = "reduce_sum" self.op_type = "reduce_sum"
self.inputs = {'X': np.random.random((10, 1, 1)).astype("float64")} self.inputs = {'X': np.random.random((100, 1, 1)).astype("float64")}
self.attrs = {'dim': [1, 2], 'keep_dim': True} self.attrs = {'dim': [1, 2], 'keep_dim': True}
self.outputs = { self.outputs = {
'Out': self.inputs['X'].sum(axis=tuple(self.attrs['dim']), 'Out': self.inputs['X'].sum(axis=tuple(self.attrs['dim']),
...@@ -350,7 +350,7 @@ class TestReduceSumWithDimOne(OpTest): ...@@ -350,7 +350,7 @@ class TestReduceSumWithDimOne(OpTest):
class TestReduceSumWithNumelOne(OpTest): class TestReduceSumWithNumelOne(OpTest):
def setUp(self): def setUp(self):
self.op_type = "reduce_sum" self.op_type = "reduce_sum"
self.inputs = {'X': np.random.random((1, 1)).astype("float64")} self.inputs = {'X': np.random.random((100, 1)).astype("float64")}
self.attrs = {'dim': [1], 'keep_dim': False} self.attrs = {'dim': [1], 'keep_dim': False}
self.outputs = { self.outputs = {
'Out': self.inputs['X'].sum(axis=tuple(self.attrs['dim']), 'Out': self.inputs['X'].sum(axis=tuple(self.attrs['dim']),
...@@ -367,7 +367,7 @@ class TestReduceSumWithNumelOne(OpTest): ...@@ -367,7 +367,7 @@ class TestReduceSumWithNumelOne(OpTest):
class TestReduceMeanWithDimOne(OpTest): class TestReduceMeanWithDimOne(OpTest):
def setUp(self): def setUp(self):
self.op_type = "reduce_mean" self.op_type = "reduce_mean"
self.inputs = {'X': np.random.random((10, 1, 1)).astype("float64")} self.inputs = {'X': np.random.random((100, 1, 1)).astype("float64")}
self.attrs = {'dim': [1], 'keep_dim': False} self.attrs = {'dim': [1], 'keep_dim': False}
self.outputs = { self.outputs = {
'Out': self.inputs['X'].mean( 'Out': self.inputs['X'].mean(
...@@ -384,7 +384,7 @@ class TestReduceMeanWithDimOne(OpTest): ...@@ -384,7 +384,7 @@ class TestReduceMeanWithDimOne(OpTest):
class TestReduceMeanWithNumelOne(OpTest): class TestReduceMeanWithNumelOne(OpTest):
def setUp(self): def setUp(self):
self.op_type = "reduce_mean" self.op_type = "reduce_mean"
self.inputs = {'X': np.random.random((1, 1)).astype("float64")} self.inputs = {'X': np.random.random((100, 1)).astype("float64")}
self.attrs = {'dim': [1], 'keep_dim': True} self.attrs = {'dim': [1], 'keep_dim': True}
self.outputs = { self.outputs = {
'Out': self.inputs['X'].mean( 'Out': self.inputs['X'].mean(
...@@ -401,7 +401,7 @@ class TestReduceMeanWithNumelOne(OpTest): ...@@ -401,7 +401,7 @@ class TestReduceMeanWithNumelOne(OpTest):
class TestReduceAll(OpTest): class TestReduceAll(OpTest):
def setUp(self): def setUp(self):
self.op_type = "reduce_sum" self.op_type = "reduce_sum"
self.inputs = {'X': np.random.random((1, 1, 1)).astype("float64")} self.inputs = {'X': np.random.random((100, 1, 1)).astype("float64")}
self.attrs = {'reduce_all': True, 'keep_dim': False} self.attrs = {'reduce_all': True, 'keep_dim': False}
self.outputs = {'Out': self.inputs['X'].sum()} self.outputs = {'Out': self.inputs['X'].sum()}
...@@ -415,7 +415,7 @@ class TestReduceAll(OpTest): ...@@ -415,7 +415,7 @@ class TestReduceAll(OpTest):
class Test1DReduceWithAxes1(OpTest): class Test1DReduceWithAxes1(OpTest):
def setUp(self): def setUp(self):
self.op_type = "reduce_sum" self.op_type = "reduce_sum"
self.inputs = {'X': np.random.random(1).astype("float64")} self.inputs = {'X': np.random.random(100).astype("float64")}
self.attrs = {'dim': [0], 'keep_dim': False} self.attrs = {'dim': [0], 'keep_dim': False}
self.outputs = {'Out': self.inputs['X'].sum(axis=0)} self.outputs = {'Out': self.inputs['X'].sum(axis=0)}
......
...@@ -55,9 +55,9 @@ class TestReshapeOpDimInfer1(TestReshapeOp): ...@@ -55,9 +55,9 @@ class TestReshapeOpDimInfer1(TestReshapeOp):
class TestReshapeOpDimInfer2(TestReshapeOp): class TestReshapeOpDimInfer2(TestReshapeOp):
def init_data(self): def init_data(self):
self.ori_shape = (2, 2, 6) self.ori_shape = (10, 2, 6)
self.new_shape = (2, 0, 3, -1) self.new_shape = (10, 0, 3, -1)
self.infered_shape = (2, 2, 3, -1) self.infered_shape = (10, 2, 3, -1)
# situation 2: have shape(list, no tensor), have actual shape(Tensor) # situation 2: have shape(list, no tensor), have actual shape(Tensor)
...@@ -78,9 +78,9 @@ class TestReshapeOpWithInputShape(OpTest): ...@@ -78,9 +78,9 @@ class TestReshapeOpWithInputShape(OpTest):
} }
def init_data(self): def init_data(self):
self.ori_shape = (6, 5) self.ori_shape = (6, 20)
self.new_shape = (0, -1, 5) self.new_shape = (0, -1, 20)
self.actual_shape = (2, 3, 5) self.actual_shape = (2, 3, 20)
def test_check_output(self): def test_check_output(self):
self.check_output(no_check_set=['XShape']) self.check_output(no_check_set=['XShape'])
...@@ -111,9 +111,9 @@ class TestReshapeOp_attr_ShapeTensor(OpTest): ...@@ -111,9 +111,9 @@ class TestReshapeOp_attr_ShapeTensor(OpTest):
} }
def init_data(self): def init_data(self):
self.ori_shape = (2, 25) self.ori_shape = (4, 25)
self.new_shape = (5, 10) self.new_shape = (10, 10)
self.infered_shape = (5, 10) self.infered_shape = (10, 10)
self.shape = (-1, -1) self.shape = (-1, -1)
def test_check_output(self): def test_check_output(self):
...@@ -125,18 +125,18 @@ class TestReshapeOp_attr_ShapeTensor(OpTest): ...@@ -125,18 +125,18 @@ class TestReshapeOp_attr_ShapeTensor(OpTest):
class TestReshapeOpDimInfer1_attr_ShapeTensor(TestReshapeOp_attr_ShapeTensor): class TestReshapeOpDimInfer1_attr_ShapeTensor(TestReshapeOp_attr_ShapeTensor):
def init_data(self): def init_data(self):
self.ori_shape = (5, 10) self.ori_shape = (5, 20)
self.new_shape = (5, -1, 5) self.new_shape = (5, -1, 20)
self.infered_shape = (5, -1, 5) self.infered_shape = (5, -1, 20)
self.shape = (5, -1, -1) self.shape = (5, -1, -1)
class TestReshapeOpDimInfer2_attr_ShapeTensor(TestReshapeOp_attr_ShapeTensor): class TestReshapeOpDimInfer2_attr_ShapeTensor(TestReshapeOp_attr_ShapeTensor):
def init_data(self): def init_data(self):
self.ori_shape = (2, 2, 6) self.ori_shape = (10, 2, 6)
self.new_shape = (2, 0, 3, -1) self.new_shape = (10, 0, 3, -1)
self.infered_shape = (2, 2, 3, -1) self.infered_shape = (10, 2, 3, -1)
self.shape = (2, 0, 3, -1) self.shape = (10, 0, 3, -1)
# Situation 4: have shape(Tensor), no actual shape(Tensor) # Situation 4: have shape(Tensor), no actual shape(Tensor)
...@@ -157,9 +157,9 @@ class TestReshapeOp_attr_OnlyShape(OpTest): ...@@ -157,9 +157,9 @@ class TestReshapeOp_attr_OnlyShape(OpTest):
} }
def init_data(self): def init_data(self):
self.ori_shape = (2, 25) self.ori_shape = (4, 25)
self.new_shape = (5, 10) self.new_shape = (10, 10)
self.infered_shape = (5, 10) self.infered_shape = (10, 10)
def test_check_output(self): def test_check_output(self):
self.check_output(no_check_set=['XShape']) self.check_output(no_check_set=['XShape'])
...@@ -170,18 +170,18 @@ class TestReshapeOp_attr_OnlyShape(OpTest): ...@@ -170,18 +170,18 @@ class TestReshapeOp_attr_OnlyShape(OpTest):
class TestReshapeOpDimInfer1_attr_OnlyShape(TestReshapeOp_attr_OnlyShape): class TestReshapeOpDimInfer1_attr_OnlyShape(TestReshapeOp_attr_OnlyShape):
def init_data(self): def init_data(self):
self.ori_shape = (5, 10) self.ori_shape = (5, 20)
self.new_shape = (5, -1, 5) self.new_shape = (5, -1, 10)
self.infered_shape = (5, -1, 5) self.infered_shape = (5, -1, 10)
self.shape = (5, -1, -1) self.shape = (5, -1, -1)
class TestReshapeOpDimInfer2_attr_OnlyShape(TestReshapeOp_attr_OnlyShape): class TestReshapeOpDimInfer2_attr_OnlyShape(TestReshapeOp_attr_OnlyShape):
def init_data(self): def init_data(self):
self.ori_shape = (2, 2, 6) self.ori_shape = (10, 2, 6)
self.new_shape = (2, 0, 3, -1) self.new_shape = (10, 0, 3, -1)
self.infered_shape = (2, 2, 3, -1) self.infered_shape = (10, 2, 3, -1)
self.shape = (2, 0, 3, -1) self.shape = (10, 0, 3, -1)
# test int8 data type on CPU # test int8 data type on CPU
...@@ -207,9 +207,9 @@ class TestReshapeInt8Op(OpTest): ...@@ -207,9 +207,9 @@ class TestReshapeInt8Op(OpTest):
self.dtype = np.int8 self.dtype = np.int8
def init_data(self): def init_data(self):
self.ori_shape = (2, 2, 6) self.ori_shape = (10, 2, 6)
self.new_shape = (2, 0, 3, -1) self.new_shape = (10, 0, 3, -1)
self.infered_shape = (2, 2, 3, -1) self.infered_shape = (10, 2, 3, -1)
def test_check_output(self): def test_check_output(self):
self.check_output_with_place( self.check_output_with_place(
......
...@@ -65,12 +65,10 @@ class TestScatterNdAddSimpleOp(OpTest): ...@@ -65,12 +65,10 @@ class TestScatterNdAddSimpleOp(OpTest):
def setUp(self): def setUp(self):
self.op_type = "scatter_nd_add" self.op_type = "scatter_nd_add"
#ref_np = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8]).astype("float32")
ref_np = np.random.random([100]).astype("float64") ref_np = np.random.random([100]).astype("float64")
index_np = np.random.randint(0, 100, [100, 1]).astype("int32") index_np = np.random.randint(0, 100, [100, 1]).astype("int32")
updates_np = np.random.random([100]).astype("float64") updates_np = np.random.random([100]).astype("float64")
expect_np = numpy_scatter_nd_add(ref_np.copy(), index_np, updates_np) expect_np = numpy_scatter_nd_add(ref_np.copy(), index_np, updates_np)
#expect_np = [ 0. 23. 12. 14. 4. 17. 6. 7. 8.]
self.inputs = {'X': ref_np, 'Index': index_np, 'Updates': updates_np} self.inputs = {'X': ref_np, 'Index': index_np, 'Updates': updates_np}
self.outputs = {'Out': expect_np} self.outputs = {'Out': expect_np}
...@@ -89,13 +87,11 @@ class TestScatterNdAddWithEmptyIndex(OpTest): ...@@ -89,13 +87,11 @@ class TestScatterNdAddWithEmptyIndex(OpTest):
def setUp(self): def setUp(self):
self.op_type = "scatter_nd_add" self.op_type = "scatter_nd_add"
ref_np = np.array([[65, 17], [-14, -25]]).astype("float64") ref_np = np.random.random((10, 10)).astype("float64")
index_np = np.array([[], []]).astype("int32") index_np = np.array([[], []]).astype("int32")
updates_np = np.array([[[-1, -2], [1, 2]], updates_np = np.random.random((2, 10, 10)).astype("float64")
[[3, 4], [-3, -4]]]).astype("float64")
expect_np = numpy_scatter_nd_add(ref_np.copy(), index_np, updates_np) expect_np = numpy_scatter_nd_add(ref_np.copy(), index_np, updates_np)
#expect_np = [[67, 19], [-16, -27]]
self.inputs = {'X': ref_np, 'Index': index_np, 'Updates': updates_np} self.inputs = {'X': ref_np, 'Index': index_np, 'Updates': updates_np}
self.outputs = {'Out': expect_np} self.outputs = {'Out': expect_np}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册