提交 f4379a91 编写于 作者: J juncaipeng 提交者: Tao Luo

Update the precision of some op tests from fp32 to fp64 (#21847)

上级 538c8489
...@@ -26,8 +26,8 @@ class TestSequenceConcat(OpTest): ...@@ -26,8 +26,8 @@ class TestSequenceConcat(OpTest):
self.out_lod = [19, 11] self.out_lod = [19, 11]
def setUp(self): def setUp(self):
x1 = np.random.random(size=(10, 80)).astype('float32') x1 = np.random.random(size=(10, 80)).astype('float64')
x2 = np.random.random(size=(20, 80)).astype('float32') x2 = np.random.random(size=(20, 80)).astype('float64')
self.setLoD() self.setLoD()
out = np.concatenate((x1[0:self.lod1[0]], x2[0:self.lod2[0]], out = np.concatenate((x1[0:self.lod1[0]], x2[0:self.lod2[0]],
......
...@@ -21,8 +21,8 @@ from op_test import OpTest ...@@ -21,8 +21,8 @@ from op_test import OpTest
class TestSequenceExpand(OpTest): class TestSequenceExpand(OpTest):
def set_data(self): def set_data(self):
x_data = np.random.uniform(0.1, 1, [3, 40]).astype('float32') x_data = np.random.uniform(0.1, 1, [3, 40]).astype('float64')
y_data = np.random.uniform(0.1, 1, [8, 1]).astype('float32') y_data = np.random.uniform(0.1, 1, [8, 1]).astype('float64')
y_lod = [[1, 3, 4]] y_lod = [[1, 3, 4]]
self.inputs = {'X': x_data, 'Y': (y_data, y_lod)} self.inputs = {'X': x_data, 'Y': (y_data, y_lod)}
...@@ -80,8 +80,8 @@ class TestSequenceExpand(OpTest): ...@@ -80,8 +80,8 @@ 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('float32') x_data = np.random.uniform(0.1, 1, [5, 1]).astype('float64')
y_data = np.random.uniform(0.1, 1, [13, 1]).astype('float32') 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)}
self.attrs = {'ref_level': 1} self.attrs = {'ref_level': 1}
...@@ -89,9 +89,9 @@ class TestSequenceExpandCase1(TestSequenceExpand): ...@@ -89,9 +89,9 @@ 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('float32') x_data = np.random.uniform(0.1, 1, [1, 2, 2]).astype('float64')
x_lod = [[1]] x_lod = [[1]]
y_data = np.random.uniform(0.1, 1, [2, 2, 2]).astype('float32') y_data = np.random.uniform(0.1, 1, [2, 2, 2]).astype('float64')
y_lod = [[2], [1, 1]] y_lod = [[2], [1, 1]]
self.inputs = {'X': (x_data, x_lod), 'Y': (y_data, y_lod)} self.inputs = {'X': (x_data, x_lod), 'Y': (y_data, y_lod)}
self.attrs = {'ref_level': 0} self.attrs = {'ref_level': 0}
...@@ -99,9 +99,9 @@ class TestSequenceExpandCase2(TestSequenceExpand): ...@@ -99,9 +99,9 @@ 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('float32') x_data = np.random.uniform(0.1, 1, [4, 1]).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('float32') y_data = np.random.uniform(0.1, 1, [8, 1]).astype('float64')
y_lod = [[2, 2, 2, 2]] y_lod = [[2, 2, 2, 2]]
self.inputs = {'X': (x_data, x_lod), 'Y': (y_data, y_lod)} self.inputs = {'X': (x_data, x_lod), 'Y': (y_data, y_lod)}
...@@ -109,17 +109,17 @@ class TestSequenceExpandCase3(TestSequenceExpand): ...@@ -109,17 +109,17 @@ 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 * 2, 1])
x_data = np.array(data).reshape([5, 2]).astype('float32') x_data = np.array(data).reshape([5, 2]).astype('float64')
x_lod = [[2, 3]] x_lod = [[2, 3]]
y_data = np.random.uniform(0.1, 1, [5, 1]).astype('float32') y_data = np.random.uniform(0.1, 1, [5, 1]).astype('float64')
y_lod = [[2], [2, 3]] y_lod = [[2], [2, 3]]
self.inputs = {'X': (x_data, x_lod), 'Y': (y_data, y_lod)} self.inputs = {'X': (x_data, x_lod), 'Y': (y_data, y_lod)}
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('float32') x_data = np.random.uniform(0.1, 1, [6, 1]).astype('float64')
y_data = np.random.uniform(0.1, 1, [13, 1]).astype('float32') 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)}
self.attrs = {'ref_level': 1} self.attrs = {'ref_level': 1}
...@@ -127,9 +127,9 @@ class TestSequenceExpandCase5(TestSequenceExpand): ...@@ -127,9 +127,9 @@ 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('float32') x_data = np.random.uniform(0.1, 1, [4, 1]).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('float32') 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]]
self.inputs = {'X': (x_data, x_lod), 'Y': (y_data, y_lod)} self.inputs = {'X': (x_data, x_lod), 'Y': (y_data, y_lod)}
......
...@@ -26,8 +26,8 @@ class TestSequenceExpandAs(OpTest): ...@@ -26,8 +26,8 @@ class TestSequenceExpandAs(OpTest):
self.compute() self.compute()
def set_data(self): def set_data(self):
x_data = np.random.uniform(0.1, 1, [3, 40]).astype('float32') x_data = np.random.uniform(0.1, 1, [3, 40]).astype('float64')
y_data = np.random.uniform(0.1, 1, [8, 1]).astype('float32') y_data = np.random.uniform(0.1, 1, [8, 1]).astype('float64')
y_lod = [[1, 3, 4]] y_lod = [[1, 3, 4]]
self.inputs = {'X': x_data, 'Y': (y_data, y_lod)} self.inputs = {'X': x_data, 'Y': (y_data, y_lod)}
...@@ -57,27 +57,27 @@ class TestSequenceExpandAs(OpTest): ...@@ -57,27 +57,27 @@ 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('float32') x_data = np.random.uniform(0.1, 1, [5, 1]).astype('float64')
x_lod = [[2, 3]] x_lod = [[2, 3]]
y_data = np.random.uniform(0.1, 1, [10, 1]).astype('float32') 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]]
self.inputs = {'X': (x_data, x_lod), 'Y': (y_data, y_lod)} self.inputs = {'X': (x_data, x_lod), 'Y': (y_data, y_lod)}
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('float32') x_data = np.random.uniform(0.1, 1, [5, 1]).astype('float64')
x_lod = [[2, 3]] x_lod = [[2, 3]]
y_data = np.random.uniform(0.1, 1, [10, 1]).astype('float32') 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]]
self.inputs = {'X': (x_data, x_lod), 'Y': (y_data, y_lod)} self.inputs = {'X': (x_data, x_lod), 'Y': (y_data, y_lod)}
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('float32') x_data = np.random.uniform(0.1, 1, [1, 2, 2]).astype('float64')
x_lod = [[1]] x_lod = [[1]]
y_data = np.random.uniform(0.1, 1, [2, 2, 2]).astype('float32') y_data = np.random.uniform(0.1, 1, [2, 2, 2]).astype('float64')
y_lod = [[2]] y_lod = [[2]]
self.inputs = {'X': (x_data, x_lod), 'Y': (y_data, y_lod)} self.inputs = {'X': (x_data, x_lod), 'Y': (y_data, y_lod)}
......
...@@ -23,7 +23,7 @@ class TestSequencePadOp(OpTest): ...@@ -23,7 +23,7 @@ class TestSequencePadOp(OpTest):
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
self.dtype = 'float32' self.dtype = 'float64'
def set_data(self): def set_data(self):
x_data = np.random.uniform(0.1, 0.5, self.x_shape).astype(self.dtype) x_data = np.random.uniform(0.1, 0.5, self.x_shape).astype(self.dtype)
...@@ -84,7 +84,7 @@ class TestSequencePadOp2(TestSequencePadOp): ...@@ -84,7 +84,7 @@ class TestSequencePadOp2(TestSequencePadOp):
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 = [1.0, 2.0, 3.0, 4.0]
self.padded_length = -1 self.padded_length = -1
self.dtype = 'float32' self.dtype = 'float64'
class TestSequencePadOp3(TestSequencePadOp): class TestSequencePadOp3(TestSequencePadOp):
...@@ -93,7 +93,7 @@ class TestSequencePadOp3(TestSequencePadOp): ...@@ -93,7 +93,7 @@ class TestSequencePadOp3(TestSequencePadOp):
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
self.dtype = 'float32' self.dtype = 'float64'
class TestSequencePadOp4(TestSequencePadOp): class TestSequencePadOp4(TestSequencePadOp):
...@@ -102,7 +102,7 @@ class TestSequencePadOp4(TestSequencePadOp): ...@@ -102,7 +102,7 @@ class TestSequencePadOp4(TestSequencePadOp):
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 = [1.0, 2.0, 3.0, 4.0]
self.padded_length = 7 self.padded_length = 7
self.dtype = 'float32' self.dtype = 'float64'
class TestSequencePadOp5(TestSequencePadOp): class TestSequencePadOp5(TestSequencePadOp):
...@@ -111,7 +111,7 @@ class TestSequencePadOp5(TestSequencePadOp): ...@@ -111,7 +111,7 @@ class TestSequencePadOp5(TestSequencePadOp):
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
self.dtype = 'float32' self.dtype = 'float64'
class TestSequencePadOp6(TestSequencePadOp): class TestSequencePadOp6(TestSequencePadOp):
...@@ -120,7 +120,7 @@ class TestSequencePadOp6(TestSequencePadOp): ...@@ -120,7 +120,7 @@ class TestSequencePadOp6(TestSequencePadOp):
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 = [[1.0, 2.0], [3.0, 4.0]]
self.padded_length = -1 self.padded_length = -1
self.dtype = 'float32' self.dtype = 'float64'
class TestSequencePadOp7(TestSequencePadOp): class TestSequencePadOp7(TestSequencePadOp):
...@@ -129,7 +129,7 @@ class TestSequencePadOp7(TestSequencePadOp): ...@@ -129,7 +129,7 @@ class TestSequencePadOp7(TestSequencePadOp):
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
self.dtype = 'float32' self.dtype = 'float64'
class TestSequencePadOp8(TestSequencePadOp): class TestSequencePadOp8(TestSequencePadOp):
...@@ -138,7 +138,7 @@ class TestSequencePadOp8(TestSequencePadOp): ...@@ -138,7 +138,7 @@ class TestSequencePadOp8(TestSequencePadOp):
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
self.dtype = 'float32' self.dtype = 'float64'
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -24,7 +24,7 @@ class TestSequenceReshape(OpTest): ...@@ -24,7 +24,7 @@ class TestSequenceReshape(OpTest):
def init_data(self): def init_data(self):
self.dimension = 12 self.dimension = 12
self.x_lod = [[4, 1, 3, 3]] self.x_lod = [[4, 1, 3, 3]]
self.x = np.random.uniform(0.1, 1, [11, 24]).astype('float32') self.x = np.random.uniform(0.1, 1, [11, 24]).astype('float64')
def setUp(self): def setUp(self):
self.init_data() self.init_data()
...@@ -42,7 +42,7 @@ class TestSequenceReshape(OpTest): ...@@ -42,7 +42,7 @@ class TestSequenceReshape(OpTest):
offset = (seq_len * x_width) / dimension offset = (seq_len * x_width) / dimension
assert int(offset) * dimension == seq_len * x_width assert int(offset) * dimension == seq_len * x_width
out_lod[0].append(int(offset)) out_lod[0].append(int(offset))
out = np.zeros(shape=(sum(out_lod[0]), dimension)).astype('float32') out = np.zeros(shape=(sum(out_lod[0]), dimension)).astype('float64')
out.ravel()[:] = x.ravel()[:] out.ravel()[:] = x.ravel()[:]
return out, out_lod return out, out_lod
...@@ -57,28 +57,28 @@ class TestSequenceReshape_reduce(TestSequenceReshape): ...@@ -57,28 +57,28 @@ class TestSequenceReshape_reduce(TestSequenceReshape):
def init_data(self): def init_data(self):
self.dimension = 24 self.dimension = 24
self.x_lod = [[4, 2, 2, 4]] self.x_lod = [[4, 2, 2, 4]]
self.x = np.random.uniform(0.1, 1, [12, 12]).astype('float32') self.x = np.random.uniform(0.1, 1, [12, 12]).astype('float64')
class TestSequenceReshape_same(TestSequenceReshape): class TestSequenceReshape_same(TestSequenceReshape):
def init_data(self): def init_data(self):
self.dimension = 12 self.dimension = 12
self.x_lod = [[4, 2, 2, 4]] self.x_lod = [[4, 2, 2, 4]]
self.x = np.random.uniform(0.1, 1, [12, 12]).astype('float32') self.x = np.random.uniform(0.1, 1, [12, 12]).astype('float64')
class TestSequenceReshape_reduce_seq_len0(TestSequenceReshape): class TestSequenceReshape_reduce_seq_len0(TestSequenceReshape):
def init_data(self): def init_data(self):
self.dimension = 24 self.dimension = 24
self.x_lod = [[0, 6, 0, 2, 4]] self.x_lod = [[0, 6, 0, 2, 4]]
self.x = np.random.uniform(0.1, 1, [12, 12]).astype('float32') self.x = np.random.uniform(0.1, 1, [12, 12]).astype('float64')
class TestSequenceReshape_reduce_seq_len0_case1(TestSequenceReshape): class TestSequenceReshape_reduce_seq_len0_case1(TestSequenceReshape):
def init_data(self): def init_data(self):
self.dimension = 24 self.dimension = 24
self.x_lod = [[0, 2, 8, 2, 0]] self.x_lod = [[0, 2, 8, 2, 0]]
self.x = np.random.uniform(0.1, 1, [12, 12]).astype('float32') self.x = np.random.uniform(0.1, 1, [12, 12]).astype('float64')
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -24,12 +24,12 @@ class TestSequenceScatterOp(OpTest): ...@@ -24,12 +24,12 @@ class TestSequenceScatterOp(OpTest):
def setUp(self): def setUp(self):
self.op_type = "sequence_scatter" self.op_type = "sequence_scatter"
X_data = np.random.uniform(0.1, 1.0, [3, 6]).astype('float32') X_data = np.random.uniform(0.1, 1.0, [3, 6]).astype('float64')
Ids_data = np.array([[0], [1], [2], [5], [4], [3], [0], [1], [3], [2], Ids_data = np.array([[0], [1], [2], [5], [4], [3], [0], [1], [3], [2],
[5], [4]]).astype('int64') [5], [4]]).astype('int64')
Ids_lod = self.init_lod() Ids_lod = self.init_lod()
Updates_data = np.random.uniform(0.1, 1.0, [12, 1]).astype('float32') Updates_data = np.random.uniform(0.1, 1.0, [12, 1]).astype('float64')
Updates_lod = Ids_lod Updates_lod = Ids_lod
Out_data = np.copy(X_data) Out_data = np.copy(X_data)
......
...@@ -27,9 +27,9 @@ class TestSequenceSoftmaxOp(OpTest): ...@@ -27,9 +27,9 @@ class TestSequenceSoftmaxOp(OpTest):
self.use_cudnn = False self.use_cudnn = False
self.init_op_type() self.init_op_type()
x = np.random.uniform(0.1, 1, (110, 1)).astype("float32") x = np.random.uniform(0.1, 1, (110, 1)).astype("float64")
self.init_lod() self.init_lod()
out = np.zeros((110, 1)).astype("float32") out = np.zeros((110, 1)).astype("float64")
offset = 0 offset = 0
for i in range(len(self.lod[0])): for i in range(len(self.lod[0])):
if (self.lod[0][i] == 0): if (self.lod[0][i] == 0):
......
...@@ -22,7 +22,7 @@ class TestSequenceUnpadOp(OpTest): ...@@ -22,7 +22,7 @@ class TestSequenceUnpadOp(OpTest):
def init(self): def init(self):
self.length = [2, 3, 4] self.length = [2, 3, 4]
self.x_shape = (3, 40) self.x_shape = (3, 40)
self.dtype = "float32" self.dtype = "float64"
def compute(self): def compute(self):
assert len(self.length) == self.x_shape[0] assert len(self.length) == self.x_shape[0]
...@@ -58,7 +58,7 @@ class TestSequenceUnpadOp2(TestSequenceUnpadOp): ...@@ -58,7 +58,7 @@ class TestSequenceUnpadOp2(TestSequenceUnpadOp):
def init(self): def init(self):
self.length = [2, 3, 4] self.length = [2, 3, 4]
self.x_shape = (3, 5, 4, 3) self.x_shape = (3, 5, 4, 3)
self.dtype = "float32" self.dtype = "float64"
class TestSequenceUnpadOp3(TestSequenceUnpadOp): class TestSequenceUnpadOp3(TestSequenceUnpadOp):
......
...@@ -33,9 +33,9 @@ class TestSigmoidCrossEntropyWithLogitsOp1(OpTest): ...@@ -33,9 +33,9 @@ class TestSigmoidCrossEntropyWithLogitsOp1(OpTest):
self.inputs = { self.inputs = {
'X': logit( 'X': logit(
np.random.uniform(0, 1, (batch_size, num_classes)) np.random.uniform(0, 1, (batch_size, num_classes))
.astype("float32")), .astype("float64")),
'Label': np.random.randint(0, 2, (batch_size, num_classes)) 'Label': np.random.randint(0, 2, (batch_size, num_classes))
.astype("float32") .astype("float64")
} }
# Fw Pass is implemented as elementwise sigmoid followed by # Fw Pass is implemented as elementwise sigmoid followed by
...@@ -65,9 +65,9 @@ class TestSigmoidCrossEntropyWithLogitsOp2(OpTest): ...@@ -65,9 +65,9 @@ class TestSigmoidCrossEntropyWithLogitsOp2(OpTest):
self.inputs = { self.inputs = {
'X': logit( 'X': logit(
np.random.uniform(0, 1, (batch_size, num_classes)) np.random.uniform(0, 1, (batch_size, num_classes))
.astype("float32")), .astype("float64")),
'Label': np.random.randint(-1, 2, (batch_size, num_classes)) 'Label': np.random.randint(-1, 2, (batch_size, num_classes))
.astype("float32") .astype("float64")
} }
self.attrs = {'ignore_index': ignore_index, } self.attrs = {'ignore_index': ignore_index, }
# Fw Pass is implemented as elementwise sigmoid followed by # Fw Pass is implemented as elementwise sigmoid followed by
...@@ -98,9 +98,9 @@ class TestSigmoidCrossEntropyWithLogitsOp3(OpTest): ...@@ -98,9 +98,9 @@ class TestSigmoidCrossEntropyWithLogitsOp3(OpTest):
self.inputs = { self.inputs = {
'X': logit( 'X': logit(
np.random.uniform(0, 1, (batch_size, num_classes)) np.random.uniform(0, 1, (batch_size, num_classes))
.astype("float32")), .astype("float64")),
'Label': np.random.uniform(0, 1, (batch_size, num_classes)) 'Label': np.random.uniform(0, 1, (batch_size, num_classes))
.astype("float32") .astype("float64")
} }
# Fw Pass is implemented as elementwise sigmoid followed by # Fw Pass is implemented as elementwise sigmoid followed by
...@@ -127,9 +127,9 @@ class TestSigmoidCrossEntropyWithNorm(OpTest): ...@@ -127,9 +127,9 @@ class TestSigmoidCrossEntropyWithNorm(OpTest):
self.inputs = { self.inputs = {
'X': logit( 'X': logit(
np.random.uniform(0, 1, (batch_size, num_classes)) np.random.uniform(0, 1, (batch_size, num_classes))
.astype("float32")), .astype("float64")),
'Label': np.random.randint(-1, 2, (batch_size, num_classes)) 'Label': np.random.randint(-1, 2, (batch_size, num_classes))
.astype("float32") .astype("float64")
} }
self.attrs = {'ignore_index': ignore_index, 'normalize': True} self.attrs = {'ignore_index': ignore_index, 'normalize': True}
sigmoid_X = expit(self.inputs['X']) sigmoid_X = expit(self.inputs['X'])
...@@ -160,9 +160,9 @@ class TestSigmoidCrossEntropyWithLogitsOp5(OpTest): ...@@ -160,9 +160,9 @@ class TestSigmoidCrossEntropyWithLogitsOp5(OpTest):
self.inputs = { self.inputs = {
'X': logit( 'X': logit(
np.random.uniform(0, 1, tuple(batch_size + [num_classes])) np.random.uniform(0, 1, tuple(batch_size + [num_classes]))
.astype("float32")), .astype("float64")),
'Label': np.random.uniform(0, 1, tuple(batch_size + [num_classes])) 'Label': np.random.uniform(0, 1, tuple(batch_size + [num_classes]))
.astype("float32") .astype("float64")
} }
# Fw Pass is implemented as elementwise sigmoid followed by # Fw Pass is implemented as elementwise sigmoid followed by
...@@ -189,9 +189,9 @@ class TestSigmoidCrossEntropyWithNorm2(OpTest): ...@@ -189,9 +189,9 @@ class TestSigmoidCrossEntropyWithNorm2(OpTest):
self.inputs = { self.inputs = {
'X': logit( 'X': logit(
np.random.uniform(0, 1, tuple(batch_size + [num_classes])) np.random.uniform(0, 1, tuple(batch_size + [num_classes]))
.astype("float32")), .astype("float64")),
'Label': np.random.randint(-1, 2, tuple(batch_size + [num_classes])) 'Label': np.random.randint(-1, 2, tuple(batch_size + [num_classes]))
.astype("float32") .astype("float64")
} }
self.attrs = {'ignore_index': ignore_index, 'normalize': True} self.attrs = {'ignore_index': ignore_index, 'normalize': True}
sigmoid_X = expit(self.inputs['X']) sigmoid_X = expit(self.inputs['X'])
...@@ -222,9 +222,9 @@ class TestSigmoidCrossEntropyWithLogitsOp6(OpTest): ...@@ -222,9 +222,9 @@ class TestSigmoidCrossEntropyWithLogitsOp6(OpTest):
self.inputs = { self.inputs = {
'X': logit( 'X': logit(
np.random.uniform(0, 1, tuple(batch_size + [num_classes])) np.random.uniform(0, 1, tuple(batch_size + [num_classes]))
.astype("float32")), .astype("float64")),
'Label': np.random.randint(0, 2, tuple(batch_size + [num_classes])) 'Label': np.random.randint(0, 2, tuple(batch_size + [num_classes]))
.astype("float32") .astype("float64")
} }
# Fw Pass is implemented as elementwise sigmoid followed by # Fw Pass is implemented as elementwise sigmoid followed by
......
...@@ -65,7 +65,7 @@ class TestSigmoidFocalLossOp1(OpTest): ...@@ -65,7 +65,7 @@ class TestSigmoidFocalLossOp1(OpTest):
self.set_argument() self.set_argument()
dims = (self.num_anchors, self.num_classes) dims = (self.num_anchors, self.num_classes)
X = np.random.standard_normal(dims).astype("float32") X = np.random.standard_normal(dims).astype("float64")
L = np.random.randint(0, self.num_classes + 1, L = np.random.randint(0, self.num_classes + 1,
(dims[0], 1)).astype("int32") (dims[0], 1)).astype("int32")
F = np.zeros(1) F = np.zeros(1)
...@@ -85,7 +85,7 @@ class TestSigmoidFocalLossOp1(OpTest): ...@@ -85,7 +85,7 @@ class TestSigmoidFocalLossOp1(OpTest):
loss = sigmoid_focal_loss_forward( loss = sigmoid_focal_loss_forward(
self.inputs['X'], self.inputs['Label'], self.inputs['FgNum'], self.inputs['X'], self.inputs['Label'], self.inputs['FgNum'],
self.gamma, self.alpha, self.num_classes) self.gamma, self.alpha, self.num_classes)
self.outputs = {'Out': loss.astype('float32')} self.outputs = {'Out': loss.astype('float64')}
def test_check_output(self): def test_check_output(self):
self.check_output() self.check_output()
......
...@@ -25,7 +25,7 @@ class TestSignOp(OpTest): ...@@ -25,7 +25,7 @@ class TestSignOp(OpTest):
def setUp(self): def setUp(self):
self.op_type = "sign" self.op_type = "sign"
self.inputs = { self.inputs = {
'X': np.random.uniform(-10, 10, (10, 10)).astype("float32") 'X': np.random.uniform(-10, 10, (10, 10)).astype("float64")
} }
self.outputs = {'Out': np.sign(self.inputs['X'])} self.outputs = {'Out': np.sign(self.inputs['X'])}
......
...@@ -37,7 +37,7 @@ class TestSliceOp(OpTest): ...@@ -37,7 +37,7 @@ class TestSliceOp(OpTest):
} }
def config(self): def config(self):
self.input = np.random.random([3, 4, 5, 6]).astype("float32") self.input = np.random.random([3, 4, 5, 6]).astype("float64")
self.starts = [1, 0, 2] self.starts = [1, 0, 2]
self.ends = [3, 3, 4] self.ends = [3, 3, 4]
self.axes = [0, 1, 2] self.axes = [0, 1, 2]
...@@ -53,7 +53,7 @@ class TestSliceOp(OpTest): ...@@ -53,7 +53,7 @@ class TestSliceOp(OpTest):
class TestCase1(TestSliceOp): class TestCase1(TestSliceOp):
def config(self): def config(self):
self.input = np.random.random([3, 4, 5, 6]).astype("float32") self.input = np.random.random([3, 4, 5, 6]).astype("float64")
self.starts = [-3, 0, 2] self.starts = [-3, 0, 2]
self.ends = [3, 100, -1] self.ends = [3, 100, -1]
self.axes = [0, 1, 2] self.axes = [0, 1, 2]
...@@ -63,7 +63,7 @@ class TestCase1(TestSliceOp): ...@@ -63,7 +63,7 @@ class TestCase1(TestSliceOp):
class TestCase2(TestSliceOp): class TestCase2(TestSliceOp):
def config(self): def config(self):
self.input = np.random.random([3, 4, 5, 6]).astype("float32") self.input = np.random.random([3, 4, 5, 6]).astype("float64")
self.starts = [-3, 0, 2] self.starts = [-3, 0, 2]
self.ends = [3, 100, -1] self.ends = [3, 100, -1]
self.axes = [0, 1, 3] self.axes = [0, 1, 3]
...@@ -87,7 +87,7 @@ class TestSliceOp_decs_dim(OpTest): ...@@ -87,7 +87,7 @@ class TestSliceOp_decs_dim(OpTest):
} }
def config(self): def config(self):
self.input = np.random.random([3, 4, 5, 6]).astype("float32") self.input = np.random.random([3, 4, 5, 6]).astype("float64")
self.starts = [1, 0, 2] self.starts = [1, 0, 2]
self.ends = [2, 3, 4] self.ends = [2, 3, 4]
self.axes = [0, 1, 2] self.axes = [0, 1, 2]
...@@ -104,7 +104,7 @@ class TestSliceOp_decs_dim(OpTest): ...@@ -104,7 +104,7 @@ class TestSliceOp_decs_dim(OpTest):
class TestSliceOp_decs_dim_2(TestSliceOp_decs_dim): class TestSliceOp_decs_dim_2(TestSliceOp_decs_dim):
def config(self): def config(self):
self.input = np.random.random([3, 4, 5, 6]).astype("float32") self.input = np.random.random([3, 4, 5, 6]).astype("float64")
self.starts = [1, 0, 2] self.starts = [1, 0, 2]
self.ends = [2, 1, 4] self.ends = [2, 1, 4]
self.axes = [0, 1, 2] self.axes = [0, 1, 2]
...@@ -115,7 +115,7 @@ class TestSliceOp_decs_dim_2(TestSliceOp_decs_dim): ...@@ -115,7 +115,7 @@ class TestSliceOp_decs_dim_2(TestSliceOp_decs_dim):
class TestSliceOp_decs_dim_3(TestSliceOp_decs_dim): class TestSliceOp_decs_dim_3(TestSliceOp_decs_dim):
def config(self): def config(self):
self.input = np.random.random([3, 4, 5, 6]).astype("float32") self.input = np.random.random([3, 4, 5, 6]).astype("float64")
self.starts = [-1, 0, 2] self.starts = [-1, 0, 2]
self.ends = [1000000, 1, 4] self.ends = [1000000, 1, 4]
self.axes = [0, 1, 2] self.axes = [0, 1, 2]
...@@ -126,7 +126,7 @@ class TestSliceOp_decs_dim_3(TestSliceOp_decs_dim): ...@@ -126,7 +126,7 @@ class TestSliceOp_decs_dim_3(TestSliceOp_decs_dim):
class TestSliceOp_decs_dim_4(TestSliceOp_decs_dim): class TestSliceOp_decs_dim_4(TestSliceOp_decs_dim):
def config(self): def config(self):
self.input = np.random.random([3, 4, 5, 7]).astype("float32") self.input = np.random.random([3, 4, 5, 7]).astype("float64")
self.starts = [0, 1, 2, 3] self.starts = [0, 1, 2, 3]
self.ends = [1, 2, 3, 4] self.ends = [1, 2, 3, 4]
self.axes = [0, 1, 2, 3] self.axes = [0, 1, 2, 3]
...@@ -137,7 +137,7 @@ class TestSliceOp_decs_dim_4(TestSliceOp_decs_dim): ...@@ -137,7 +137,7 @@ class TestSliceOp_decs_dim_4(TestSliceOp_decs_dim):
class TestSliceOp_decs_dim_5(TestSliceOp_decs_dim): class TestSliceOp_decs_dim_5(TestSliceOp_decs_dim):
def config(self): def config(self):
self.input = np.random.random([3, 4, 5, 6]).astype("float32") self.input = np.random.random([3, 4, 5, 6]).astype("float64")
self.starts = [-1] self.starts = [-1]
self.ends = [1000000] self.ends = [1000000]
self.axes = [3] self.axes = [3]
...@@ -148,7 +148,7 @@ class TestSliceOp_decs_dim_5(TestSliceOp_decs_dim): ...@@ -148,7 +148,7 @@ class TestSliceOp_decs_dim_5(TestSliceOp_decs_dim):
class TestSliceOp_decs_dim_6(TestSliceOp_decs_dim): class TestSliceOp_decs_dim_6(TestSliceOp_decs_dim):
def config(self): def config(self):
self.input = np.random.random([3, 4, 5, 6]).astype("float32") self.input = np.random.random([3, 4, 5, 6]).astype("float64")
self.starts = [0, 1, 2, 3] self.starts = [0, 1, 2, 3]
self.ends = [1, 2, 3, 4] self.ends = [1, 2, 3, 4]
self.axes = [0, 1, 2, 3] self.axes = [0, 1, 2, 3]
...@@ -179,7 +179,7 @@ class TestSliceOp_starts_ListTensor(OpTest): ...@@ -179,7 +179,7 @@ class TestSliceOp_starts_ListTensor(OpTest):
} }
def config(self): def config(self):
self.input = np.random.random([3, 4, 5, 6]).astype("float32") self.input = np.random.random([3, 4, 5, 6]).astype("float64")
self.starts = [1, 0, 2] self.starts = [1, 0, 2]
self.ends = [3, 3, 4] self.ends = [3, 3, 4]
self.axes = [0, 1, 2] self.axes = [0, 1, 2]
...@@ -219,7 +219,7 @@ class TestSliceOp_decs_dim_starts_ListTensor(OpTest): ...@@ -219,7 +219,7 @@ class TestSliceOp_decs_dim_starts_ListTensor(OpTest):
} }
def config(self): def config(self):
self.input = np.random.random([3, 4, 5, 6]).astype("float32") self.input = np.random.random([3, 4, 5, 6]).astype("float64")
self.starts = [1, 0, 2] self.starts = [1, 0, 2]
self.ends = [2, 3, 4] self.ends = [2, 3, 4]
self.axes = [0, 1, 2] self.axes = [0, 1, 2]
...@@ -239,7 +239,7 @@ class TestSliceOp_decs_dim_starts_ListTensor(OpTest): ...@@ -239,7 +239,7 @@ class TestSliceOp_decs_dim_starts_ListTensor(OpTest):
class TestSliceOp_decs_dim_5_starts_ListTensor( class TestSliceOp_decs_dim_5_starts_ListTensor(
TestSliceOp_decs_dim_starts_ListTensor): TestSliceOp_decs_dim_starts_ListTensor):
def config(self): def config(self):
self.input = np.random.random([3, 4, 5, 6]).astype("float32") self.input = np.random.random([3, 4, 5, 6]).astype("float64")
self.starts = [-1] self.starts = [-1]
self.ends = [1000000] self.ends = [1000000]
self.axes = [3] self.axes = [3]
...@@ -271,7 +271,7 @@ class TestSliceOp_decs_dim_starts_OneTensor(OpTest): ...@@ -271,7 +271,7 @@ class TestSliceOp_decs_dim_starts_OneTensor(OpTest):
} }
def config(self): def config(self):
self.input = np.random.random([3, 4, 5, 6]).astype("float32") self.input = np.random.random([3, 4, 5, 6]).astype("float64")
self.starts = [1, 0, 2] self.starts = [1, 0, 2]
self.ends = [2, 3, 4] self.ends = [2, 3, 4]
self.axes = [0, 1, 2] self.axes = [0, 1, 2]
...@@ -309,7 +309,7 @@ class TestSliceOp_starts_OneTensor_ends_OneTensor(OpTest): ...@@ -309,7 +309,7 @@ class TestSliceOp_starts_OneTensor_ends_OneTensor(OpTest):
} }
def config(self): def config(self):
self.input = np.random.random([3, 4, 5, 6]).astype("float32") self.input = np.random.random([3, 4, 5, 6]).astype("float64")
self.starts = [1, 0, 2] self.starts = [1, 0, 2]
self.ends = [3, 3, 4] self.ends = [3, 3, 4]
self.axes = [0, 1, 2] self.axes = [0, 1, 2]
...@@ -346,7 +346,7 @@ class TestSliceOp_decs_dim_starts_and_ends_OneTensor(OpTest): ...@@ -346,7 +346,7 @@ class TestSliceOp_decs_dim_starts_and_ends_OneTensor(OpTest):
} }
def config(self): def config(self):
self.input = np.random.random([3, 4, 5, 6]).astype("float32") self.input = np.random.random([3, 4, 5, 6]).astype("float64")
self.starts = [1, 0, 2] self.starts = [1, 0, 2]
self.ends = [2, 1, 4] self.ends = [2, 1, 4]
self.axes = [0, 1, 2] self.axes = [0, 1, 2]
...@@ -388,7 +388,7 @@ class TestSliceOp_starts_OneTensor_ends_ListTensor(OpTest): ...@@ -388,7 +388,7 @@ class TestSliceOp_starts_OneTensor_ends_ListTensor(OpTest):
} }
def config(self): def config(self):
self.input = np.random.random([3, 4, 5, 6]).astype("float32") self.input = np.random.random([3, 4, 5, 6]).astype("float64")
self.starts = [1, 0, 2] self.starts = [1, 0, 2]
self.ends = [3, 3, 4] self.ends = [3, 3, 4]
self.axes = [0, 1, 2] self.axes = [0, 1, 2]
...@@ -483,7 +483,7 @@ class TestFP16_2(OpTest): ...@@ -483,7 +483,7 @@ class TestFP16_2(OpTest):
# Test python API # Test python API
class TestSliceAPI(unittest.TestCase): class TestSliceAPI(unittest.TestCase):
def test_1(self): def test_1(self):
input = np.random.random([3, 4, 5, 6]).astype("float32") input = np.random.random([3, 4, 5, 6]).astype("float64")
minus_1 = fluid.layers.fill_constant([1], "int32", -1) minus_1 = fluid.layers.fill_constant([1], "int32", -1)
minus_3 = fluid.layers.fill_constant([1], "int32", -3) minus_3 = fluid.layers.fill_constant([1], "int32", -3)
starts = fluid.layers.data( starts = fluid.layers.data(
...@@ -495,7 +495,7 @@ class TestSliceAPI(unittest.TestCase): ...@@ -495,7 +495,7 @@ class TestSliceAPI(unittest.TestCase):
name="x", name="x",
shape=[3, 4, 5, 6], shape=[3, 4, 5, 6],
append_batch_size=False, append_batch_size=False,
dtype="float32") dtype="float64")
out_1 = fluid.layers.slice( out_1 = fluid.layers.slice(
x, axes=[0, 1, 2], starts=[-3, 0, 2], ends=[3, 100, -1]) x, axes=[0, 1, 2], starts=[-3, 0, 2], ends=[3, 100, -1])
......
...@@ -42,7 +42,7 @@ class TestSoftmaxOp(OpTest): ...@@ -42,7 +42,7 @@ class TestSoftmaxOp(OpTest):
self.op_type = "softmax" self.op_type = "softmax"
self.use_cudnn = False self.use_cudnn = False
self.use_mkldnn = False self.use_mkldnn = False
self.dtype = np.float32 self.dtype = np.float64
self.init_kernel_type() self.init_kernel_type()
self.shape = self.get_x_shape() self.shape = self.get_x_shape()
self.axis = self.get_axis() self.axis = self.get_axis()
......
...@@ -126,7 +126,7 @@ class TestSoftmaxWithCrossEntropyOpFp16(TestSoftmaxWithCrossEntropyOp): ...@@ -126,7 +126,7 @@ class TestSoftmaxWithCrossEntropyOpFp16(TestSoftmaxWithCrossEntropyOp):
# NOTE: numpy float16 have very low accuracy, use float32 for numpy check. # NOTE: numpy float16 have very low accuracy, use float32 for numpy check.
logits = getattr( logits = getattr(
self, "logits", self, "logits",
np.random.uniform(0.1, 1.0, self.shape).astype(np.float32)) np.random.uniform(0.1, 1.0, self.shape).astype(np.float64))
softmax = np.apply_along_axis(stable_softmax, self.axis, logits) softmax = np.apply_along_axis(stable_softmax, self.axis, logits)
axis_dim = self.shape[self.axis] axis_dim = self.shape[self.axis]
...@@ -425,7 +425,7 @@ class TestSoftmaxWithCrossEntropyOpBoundary0(TestSoftmaxWithCrossEntropyOp): ...@@ -425,7 +425,7 @@ class TestSoftmaxWithCrossEntropyOpBoundary0(TestSoftmaxWithCrossEntropyOp):
self.shape = [3, 5, 7, 11] self.shape = [3, 5, 7, 11]
self.axis = -1 self.axis = -1
self.ignore_index = -1 self.ignore_index = -1
self.dtype = np.float32 self.dtype = np.float64
self.logits = np.full(self.shape, -500.0).astype(self.dtype) self.logits = np.full(self.shape, -500.0).astype(self.dtype)
...@@ -442,7 +442,7 @@ class TestSoftmaxWithCrossEntropyOpBoundary1(TestSoftmaxWithCrossEntropyOp): ...@@ -442,7 +442,7 @@ class TestSoftmaxWithCrossEntropyOpBoundary1(TestSoftmaxWithCrossEntropyOp):
self.shape = [3, 5, 7, 11] self.shape = [3, 5, 7, 11]
self.axis = -1 self.axis = -1
self.ignore_index = -1 self.ignore_index = -1
self.dtype = np.float32 self.dtype = np.float64
self.logits = np.full(self.shape, 1000.0).astype(self.dtype) self.logits = np.full(self.shape, 1000.0).astype(self.dtype)
self.logits[:, :, 0, :] = -1000.0 self.logits[:, :, 0, :] = -1000.0
......
...@@ -58,9 +58,9 @@ class TestSpaceToDepthOp(OpTest): ...@@ -58,9 +58,9 @@ class TestSpaceToDepthOp(OpTest):
self.one_d_len = 32 * 48 * 3 * 3 self.one_d_len = 32 * 48 * 3 * 3
self.blocksize = 2 self.blocksize = 2
self.x = np.random.random(self.ori_shape).astype('float32') self.x = np.random.random(self.ori_shape).astype('float64')
self.x_1d = np.reshape(self.x, self.one_d_len) self.x_1d = np.reshape(self.x, self.one_d_len)
self.out = np.zeros(self.infered_shape).astype('float32') self.out = np.zeros(self.infered_shape).astype('float64')
self.out_1d = np.reshape(self.out, self.one_d_len) self.out_1d = np.reshape(self.out, self.one_d_len)
self.forward = 1 self.forward = 1
...@@ -82,9 +82,9 @@ class TestSpaceToDepthOpBasic(TestSpaceToDepthOp): ...@@ -82,9 +82,9 @@ class TestSpaceToDepthOpBasic(TestSpaceToDepthOp):
self.one_d_len = 32 * 32 * 3 * 3 self.one_d_len = 32 * 32 * 3 * 3
self.blocksize = 2 self.blocksize = 2
self.x = np.random.random(self.ori_shape).astype('float32') self.x = np.random.random(self.ori_shape).astype('float64')
self.x_1d = np.reshape(self.x, self.one_d_len) self.x_1d = np.reshape(self.x, self.one_d_len)
self.out = np.zeros(self.infered_shape).astype('float32') self.out = np.zeros(self.infered_shape).astype('float64')
self.out_1d = np.reshape(self.out, self.one_d_len) self.out_1d = np.reshape(self.out, self.one_d_len)
self.forward = 1 self.forward = 1
...@@ -110,9 +110,9 @@ class TestSpaceToDepthOpWithStride3(TestSpaceToDepthOp): ...@@ -110,9 +110,9 @@ class TestSpaceToDepthOpWithStride3(TestSpaceToDepthOp):
self.one_d_len = 32 * 81 * 2 * 2 self.one_d_len = 32 * 81 * 2 * 2
self.blocksize = 3 self.blocksize = 3
self.x = np.random.random(self.ori_shape).astype('float32') self.x = np.random.random(self.ori_shape).astype('float64')
self.x_1d = np.reshape(self.x, self.one_d_len) self.x_1d = np.reshape(self.x, self.one_d_len)
self.out = np.zeros(self.infered_shape).astype('float32') self.out = np.zeros(self.infered_shape).astype('float64')
self.out_1d = np.reshape(self.out, self.one_d_len) self.out_1d = np.reshape(self.out, self.one_d_len)
self.forward = 1 self.forward = 1
...@@ -124,9 +124,9 @@ class TestSpaceToDepthOpWithNotSquare(TestSpaceToDepthOp): ...@@ -124,9 +124,9 @@ class TestSpaceToDepthOpWithNotSquare(TestSpaceToDepthOp):
self.one_d_len = 32 * 81 * 3 * 2 self.one_d_len = 32 * 81 * 3 * 2
self.blocksize = 3 self.blocksize = 3
self.x = np.random.random(self.ori_shape).astype('float32') self.x = np.random.random(self.ori_shape).astype('float64')
self.x_1d = np.reshape(self.x, self.one_d_len) self.x_1d = np.reshape(self.x, self.one_d_len)
self.out = np.zeros(self.infered_shape).astype('float32') self.out = np.zeros(self.infered_shape).astype('float64')
self.out_1d = np.reshape(self.out, self.one_d_len) self.out_1d = np.reshape(self.out, self.one_d_len)
self.forward = 1 self.forward = 1
......
...@@ -49,9 +49,9 @@ class TestSpectralNormOpNoGrad(OpTest): ...@@ -49,9 +49,9 @@ class TestSpectralNormOpNoGrad(OpTest):
def setUp(self): def setUp(self):
self.initTestCase() self.initTestCase()
self.op_type = 'spectral_norm' self.op_type = 'spectral_norm'
weight = np.random.random(self.weight_shape).astype('float32') weight = np.random.random(self.weight_shape).astype('float64')
u = np.random.normal(0., 1., self.u_shape).astype('float32') u = np.random.normal(0., 1., self.u_shape).astype('float64')
v = np.random.normal(0., 1., self.v_shape).astype('float32') v = np.random.normal(0., 1., self.v_shape).astype('float64')
self.attrs = { self.attrs = {
"dim": self.dim, "dim": self.dim,
......
...@@ -34,7 +34,7 @@ class TestSplitOp(OpTest): ...@@ -34,7 +34,7 @@ class TestSplitOp(OpTest):
for i in range(len(out))]} for i in range(len(out))]}
def get_dtype(self): def get_dtype(self):
return "float32" return "float64"
def _set_op_type(self): def _set_op_type(self):
self.op_type = "split" self.op_type = "split"
...@@ -71,7 +71,7 @@ class TestSplitOp_2(OpTest): ...@@ -71,7 +71,7 @@ class TestSplitOp_2(OpTest):
self.indices_or_sections = 3 self.indices_or_sections = 3
def get_dtype(self): def get_dtype(self):
return "float32" return "float64"
def _set_op_type(self): def _set_op_type(self):
self.op_type = "split" self.op_type = "split"
...@@ -107,7 +107,7 @@ class TestSplitOp_AxisTensor(OpTest): ...@@ -107,7 +107,7 @@ class TestSplitOp_AxisTensor(OpTest):
self.indices_or_sections = 3 self.indices_or_sections = 3
def get_dtype(self): def get_dtype(self):
return "float32" return "float64"
def _set_op_type(self): def _set_op_type(self):
self.op_type = "split" self.op_type = "split"
...@@ -153,7 +153,7 @@ class TestSplitOp_SectionsTensor(OpTest): ...@@ -153,7 +153,7 @@ class TestSplitOp_SectionsTensor(OpTest):
self.indices_or_sections = [2, 3] self.indices_or_sections = [2, 3]
def get_dtype(self): def get_dtype(self):
return "float32" return "float64"
def _set_op_type(self): def _set_op_type(self):
self.op_type = "split" self.op_type = "split"
...@@ -189,7 +189,7 @@ class TestSplitOp_unk_section(OpTest): ...@@ -189,7 +189,7 @@ class TestSplitOp_unk_section(OpTest):
self.indices_or_sections = [2, 3] self.indices_or_sections = [2, 3]
def get_dtype(self): def get_dtype(self):
return "float32" return "float64"
def _set_op_type(self): def _set_op_type(self):
self.op_type = "split" self.op_type = "split"
......
...@@ -25,7 +25,7 @@ class TestSppOp(OpTest): ...@@ -25,7 +25,7 @@ class TestSppOp(OpTest):
def setUp(self): def setUp(self):
self.op_type = "spp" self.op_type = "spp"
self.init_test_case() self.init_test_case()
input = np.random.random(self.shape).astype("float32") input = np.random.random(self.shape).astype("float64")
nsize, csize, hsize, wsize = input.shape nsize, csize, hsize, wsize = input.shape
out_level_flatten = [] out_level_flatten = []
for i in range(self.pyramid_height): for i in range(self.pyramid_height):
...@@ -50,13 +50,13 @@ class TestSppOp(OpTest): ...@@ -50,13 +50,13 @@ class TestSppOp(OpTest):
else: else:
output = np.concatenate((output, out_level_flatten[i]), 1) output = np.concatenate((output, out_level_flatten[i]), 1)
# output = np.concatenate(out_level_flatten.tolist(), 0); # output = np.concatenate(out_level_flatten.tolist(), 0);
self.inputs = {'X': input.astype('float32'), } self.inputs = {'X': input.astype('float64'), }
self.attrs = { self.attrs = {
'pyramid_height': self.pyramid_height, 'pyramid_height': self.pyramid_height,
'pooling_type': self.pool_type 'pooling_type': self.pool_type
} }
self.outputs = {'Out': output.astype('float32')} self.outputs = {'Out': output.astype('float64')}
def test_check_output(self): def test_check_output(self):
self.check_output() self.check_output()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册