diff --git a/python/paddle/fluid/tests/unittests/test_activation_op.py b/python/paddle/fluid/tests/unittests/test_activation_op.py index a607c7b2ee292b6af67933284dcd00703e808719..80af8dd5339499961f5f4d8615cd047ca233b47b 100644 --- a/python/paddle/fluid/tests/unittests/test_activation_op.py +++ b/python/paddle/fluid/tests/unittests/test_activation_op.py @@ -42,7 +42,6 @@ class TestSqrtOpError(unittest.TestCase): class TestActivation(OpTest): def setUp(self): self.op_type = "exp" - self.dtype = np.float32 self.init_dtype() self.init_kernel_type() @@ -61,7 +60,7 @@ class TestActivation(OpTest): self.check_grad(['X'], 'Out') def init_dtype(self): - self.dtype = np.float32 + self.dtype = np.float64 def init_kernel_type(self): pass @@ -78,6 +77,9 @@ class TestSigmoid(TestActivation): self.inputs = {'X': OpTest.np_dtype_to_fluid_dtype(x)} self.outputs = {'Out': out} + def init_dtype(self): + self.dtype = np.float32 + def test_check_grad(self): if self.dtype == np.float16: return @@ -105,7 +107,6 @@ class TestTanh(TestActivation): def setUp(self): self.op_type = "tanh" self.init_dtype() - x = np.random.uniform(0.1, 1, [11, 17]).astype(self.dtype) out = np.tanh(x) @@ -117,6 +118,12 @@ class TestTanh(TestActivation): return self.check_grad(['X'], 'Out') + def init_dtype(self): + #TODO If dtype is float64, the output (Out) has diff at CPUPlace + # when using and not using inplace. Therefore, set dtype as float32 + # for now. + self.dtype = np.float32 + class TestAtan(TestActivation): def setUp(self): diff --git a/python/paddle/fluid/tests/unittests/test_add_position_encoding_op.py b/python/paddle/fluid/tests/unittests/test_add_position_encoding_op.py index dd09ecf701352eb809640ece10c9293c941fc623..e7a13bafb5cc3576efde45cdffcd9700782f6e75 100644 --- a/python/paddle/fluid/tests/unittests/test_add_position_encoding_op.py +++ b/python/paddle/fluid/tests/unittests/test_add_position_encoding_op.py @@ -28,7 +28,7 @@ class TestAddPositionEncodingTensorOp(OpTest): the prepared section for add position encoding op """ self.op_type = "add_position_encoding" - self.dtype = np.float32 + self.dtype = np.float64 self.init_input_output() self.inputs = {'X': OpTest.np_dtype_to_fluid_dtype(self.x), } @@ -82,7 +82,7 @@ class TestAddPositionEncodingLoDTensorOp(OpTest): the prepared section for add position encoding LoDTensor op """ self.op_type = "add_position_encoding" - self.dtype = np.float32 + self.dtype = np.float64 self.init_input_output() self.inputs = {'X': (self.x, self.lod), } diff --git a/python/paddle/fluid/tests/unittests/test_assign_op.py b/python/paddle/fluid/tests/unittests/test_assign_op.py index 63308dc9f5b608c3abe1a51d6df629201f25d804..dc58003272065d02a377aa0ec6ae1b4dcad05224 100644 --- a/python/paddle/fluid/tests/unittests/test_assign_op.py +++ b/python/paddle/fluid/tests/unittests/test_assign_op.py @@ -26,7 +26,7 @@ from paddle.fluid import compiler, Program, program_guard class TestAssignOp(op_test.OpTest): def setUp(self): self.op_type = "assign" - x = np.random.random(size=(100, 10)) + x = np.random.random(size=(100, 10)).astype('float64') self.inputs = {'X': x} self.outputs = {'Out': x} diff --git a/python/paddle/fluid/tests/unittests/test_bilinear_interp_op.py b/python/paddle/fluid/tests/unittests/test_bilinear_interp_op.py index 85ca76897b2c1461ea7f13ce7ce02148ed602955..f59c8d607829299a862a16a1ba489e81a11ab766 100755 --- a/python/paddle/fluid/tests/unittests/test_bilinear_interp_op.py +++ b/python/paddle/fluid/tests/unittests/test_bilinear_interp_op.py @@ -100,7 +100,7 @@ class TestBilinearInterpOp(OpTest): self.data_layout = 'NCHW' self.init_test_case() self.op_type = "bilinear_interp" - input_np = np.random.random(self.input_shape).astype("float32") + input_np = np.random.random(self.input_shape).astype("float64") if self.data_layout == "NCHW": in_h = self.input_shape[2] @@ -402,7 +402,7 @@ class TestBilinearInterpOp_attr_tensor(OpTest): 'align_corners': self.align_corners, } - input_np = np.random.random(self.input_shape).astype("float32") + input_np = np.random.random(self.input_shape).astype("float64") self.inputs = {'X': input_np} if self.scale_by_1Dtensor: diff --git a/python/paddle/fluid/tests/unittests/test_bilinear_tensor_product_op.py b/python/paddle/fluid/tests/unittests/test_bilinear_tensor_product_op.py index 61be164f2c608d5eb6759e2e73209faab8fe2f68..0db669bc1f9508f90111d6c04e6730ef3433de29 100644 --- a/python/paddle/fluid/tests/unittests/test_bilinear_tensor_product_op.py +++ b/python/paddle/fluid/tests/unittests/test_bilinear_tensor_product_op.py @@ -26,11 +26,11 @@ class TestBilinearTensorProductOp(OpTest): size0 = 5 size1 = 4 size2 = 5 - a = np.random.random((batch_size, size0)).astype("float32") - b = np.random.random((batch_size, size1)).astype("float32") - w = np.random.random((size2, size0, size1)).astype("float32") - bias = np.random.random((1, size2)).astype("float32") - output = np.zeros((batch_size, size2)).astype("float32") + a = np.random.random((batch_size, size0)).astype("float64") + b = np.random.random((batch_size, size1)).astype("float64") + w = np.random.random((size2, size0, size1)).astype("float64") + bias = np.random.random((1, size2)).astype("float64") + output = np.zeros((batch_size, size2)).astype("float64") for i in range(size2): w_i = w[i, :, :] output[:, i] = np.sum(np.matmul(a, w_i) * b, axis=1) diff --git a/python/paddle/fluid/tests/unittests/test_center_loss.py b/python/paddle/fluid/tests/unittests/test_center_loss.py index f6dd3c1eefa643fffcf11bb9b1f8dd78ba2564ea..1408fb249ff27b7da8cebfec56d3e8fb8713ef9e 100644 --- a/python/paddle/fluid/tests/unittests/test_center_loss.py +++ b/python/paddle/fluid/tests/unittests/test_center_loss.py @@ -23,7 +23,7 @@ import paddle.fluid.core as core class TestCenterLossOp(OpTest): def setUp(self): self.op_type = "center_loss" - self.dtype = np.float32 + self.dtype = np.float64 self.init_dtype_type() batch_size = 12 feet_dim = 10 @@ -34,9 +34,9 @@ class TestCenterLossOp(OpTest): self.config() self.attrs['need_update'] = self.need_update labels = np.random.randint(cluster_num, size=batch_size, dtype='int64') - feat = np.random.random((batch_size, feet_dim)).astype(np.float32) - centers = np.random.random((cluster_num, feet_dim)).astype(np.float32) - var_sum = np.zeros((cluster_num, feet_dim), dtype=np.float32) + feat = np.random.random((batch_size, feet_dim)).astype(np.float64) + centers = np.random.random((cluster_num, feet_dim)).astype(np.float64) + var_sum = np.zeros((cluster_num, feet_dim), dtype=np.float64) centers_select = centers[labels] output = feat - centers_select diff_square = np.square(output).reshape(batch_size, feet_dim) @@ -51,7 +51,7 @@ class TestCenterLossOp(OpTest): var_sum[i] /= (1 + cout[i]) var_sum *= 0.1 result = centers + var_sum - rate = np.array([0.1]).astype(np.float32) + rate = np.array([0.1]).astype(np.float64) self.inputs = { 'X': feat, diff --git a/python/paddle/fluid/tests/unittests/test_concat_op.py b/python/paddle/fluid/tests/unittests/test_concat_op.py index 30334de1de28a9824200e74ddc686bca43967937..c09aebff581c323e4d3eec7f95408849c28a082f 100644 --- a/python/paddle/fluid/tests/unittests/test_concat_op.py +++ b/python/paddle/fluid/tests/unittests/test_concat_op.py @@ -40,7 +40,7 @@ class TestConcatOp(OpTest): } def get_dtype(self): - return "float32" + return "float64" def test_check_output(self): self.check_output() diff --git a/python/paddle/fluid/tests/unittests/test_crop_op.py b/python/paddle/fluid/tests/unittests/test_crop_op.py index 902b8605babafbaad78185fce576abd700ce7785..aebba403c3471f799fcbd3ba5304e267d5f268ba 100644 --- a/python/paddle/fluid/tests/unittests/test_crop_op.py +++ b/python/paddle/fluid/tests/unittests/test_crop_op.py @@ -49,13 +49,13 @@ class TestCropOp(OpTest): self.initTestCase() if self.crop_by_input: self.inputs = { - 'X': np.random.random(self.x_shape).astype("float32"), - 'Y': np.random.random(self.crop_shape).astype("float32") + 'X': np.random.random(self.x_shape).astype("float64"), + 'Y': np.random.random(self.crop_shape).astype("float64") } else: self.attrs['shape'] = self.crop_shape self.inputs = { - 'X': np.random.random(self.x_shape).astype("float32"), + 'X': np.random.random(self.x_shape).astype("float64"), } if self.offset_by_input: self.inputs['Offsets'] = np.array(self.offsets).astype('int32') diff --git a/python/paddle/fluid/tests/unittests/test_crop_tensor_op.py b/python/paddle/fluid/tests/unittests/test_crop_tensor_op.py index a4d5b849ab5b73c383a2f4e415b5402cbe3d90e3..7507d2fd186d325b9afd7a60f60dd6dce1941894 100644 --- a/python/paddle/fluid/tests/unittests/test_crop_tensor_op.py +++ b/python/paddle/fluid/tests/unittests/test_crop_tensor_op.py @@ -52,13 +52,13 @@ class TestCropTensorOp(OpTest): if self.shape_by_input: self.inputs = { - 'X': np.random.random(self.x_shape).astype("float32"), + 'X': np.random.random(self.x_shape).astype("float64"), 'Shape': np.array(self.crop_shape).astype("int32") } else: self.attrs['shape'] = self.crop_shape self.inputs = { - 'X': np.random.random(self.x_shape).astype("float32"), + 'X': np.random.random(self.x_shape).astype("float64"), } if self.offset_by_input: self.inputs['Offsets'] = np.array(self.offsets).astype('int32') @@ -144,7 +144,7 @@ class TestCropTensorOpTensorAttr(OpTest): shape_tensor.append(("x" + str(index), np.ones( (1)).astype('int32') * ele)) self.inputs = { - 'X': np.random.random(self.x_shape).astype("float32"), + 'X': np.random.random(self.x_shape).astype("float64"), 'ShapeTensor': shape_tensor } self.attrs['shape'] = self.shape_attr @@ -155,7 +155,7 @@ class TestCropTensorOpTensorAttr(OpTest): offsets_tensor.append(("x" + str(index), np.ones( (1)).astype('int32') * ele)) self.inputs = { - 'X': np.random.random(self.x_shape).astype("float32"), + 'X': np.random.random(self.x_shape).astype("float64"), 'OffsetsTensor': offsets_tensor } self.attrs['offsets'] = self.offsets_attr diff --git a/python/paddle/fluid/tests/unittests/test_cross_entropy2_op.py b/python/paddle/fluid/tests/unittests/test_cross_entropy2_op.py index 813d90b426e6c9bc7850bcab92b1c7d590cff945..e9f7e6ef050eaf08d8905a49f7b2757ee7c80e2c 100644 --- a/python/paddle/fluid/tests/unittests/test_cross_entropy2_op.py +++ b/python/paddle/fluid/tests/unittests/test_cross_entropy2_op.py @@ -20,7 +20,7 @@ import six class CrossEntropy2OpTestBase(OpTest): def initParameters(self): - return [32, 64], 'float32', -100, False + return [32, 64], 'float64', -100, False def calc_output(self, logits, label, ignore_index): ret = np.zeros(shape=label.shape, dtype=logits.dtype) @@ -78,17 +78,17 @@ class CrossEntropy2OpTest2RemoveLastDim(CrossEntropy2OpTestBase): class CrossEntropy2OpTest3(CrossEntropy2OpTestBase): def initParameters(self): - return [4, 8, 16, 32], 'float32', -100, False + return [4, 8, 16, 32], 'float64', -100, False class CrossEntropy2OpTest3RemoveLastDim(CrossEntropy2OpTestBase): def initParameters(self): - return [4, 8, 16, 32], 'float32', -100, True + return [4, 8, 16, 32], 'float64', -100, True class CrossEntropy2OpTest4(CrossEntropy2OpTestBase): def initParameters(self): - return [4, 8, 16, 32], 'float32', 3, False + return [4, 8, 16, 32], 'float64', 3, False if __name__ == '__main__': diff --git a/python/paddle/fluid/tests/unittests/test_cross_entropy_op.py b/python/paddle/fluid/tests/unittests/test_cross_entropy_op.py index fc4b47732176fbc93679e68b8fa90ca581fd404e..9018003d71ff902bfbb4eb819db1ab469365ede6 100644 --- a/python/paddle/fluid/tests/unittests/test_cross_entropy_op.py +++ b/python/paddle/fluid/tests/unittests/test_cross_entropy_op.py @@ -112,7 +112,7 @@ class TestCrossEntropyOp2(TestCrossEntropyOp): self.soft_label = True def init_dtype_type(self): - self.dtype = np.float32 + self.dtype = np.float64 def init_bs_class_num(self): self.batch_size = 5 @@ -142,7 +142,7 @@ class TestCrossEntropyOp3(TestCrossEntropyOp): self.soft_label = True def init_dtype_type(self): - self.dtype = np.float32 + self.dtype = np.float64 def init_bs_class_num(self): self.batch_size = 5 @@ -229,7 +229,7 @@ class TestCrossEntropyOp5(TestCrossEntropyOp): self.soft_label = True def init_dtype_type(self): - self.dtype = np.float32 + self.dtype = np.float64 def init_bs_class_num(self): self.class_num = 37 @@ -269,7 +269,7 @@ class TestCrossEntropyOp6(TestCrossEntropyOp): self.soft_label = True def init_dtype_type(self): - self.dtype = np.float32 + self.dtype = np.float64 def init_bs_class_num(self): self.class_num = 17 diff --git a/python/paddle/fluid/tests/unittests/test_elementwise_add_op.py b/python/paddle/fluid/tests/unittests/test_elementwise_add_op.py index 3f3ccfc07f9e2853c71a1e467ec92ca576e4f9e6..7cda45609c648f17340395e422bb29847ddc5f4e 100644 --- a/python/paddle/fluid/tests/unittests/test_elementwise_add_op.py +++ b/python/paddle/fluid/tests/unittests/test_elementwise_add_op.py @@ -27,7 +27,7 @@ class TestElementwiseAddOp(OpTest): def setUp(self): self.op_type = "elementwise_add" - self.dtype = np.float32 + self.dtype = np.float64 self.axis = -1 self.init_dtype() self.init_input_output() diff --git a/python/paddle/fluid/tests/unittests/test_elementwise_div_op.py b/python/paddle/fluid/tests/unittests/test_elementwise_div_op.py index 3c012ad00c672f56fb0415ed8a5908e712c52ba8..5b9c072f0a40c09c2f875e28be72f739e92d724a 100644 --- a/python/paddle/fluid/tests/unittests/test_elementwise_div_op.py +++ b/python/paddle/fluid/tests/unittests/test_elementwise_div_op.py @@ -22,7 +22,7 @@ from op_test import OpTest class ElementwiseDivOp(OpTest): def setUp(self): self.op_type = "elementwise_div" - self.dtype = np.float32 + self.dtype = np.float64 self.init_dtype() """ Warning CPU gradient check error! @@ -57,8 +57,8 @@ class TestElementwiseDivOp_scalar(ElementwiseDivOp): def setUp(self): self.op_type = "elementwise_div" self.inputs = { - 'X': np.random.uniform(0.1, 1, [2, 3, 4]).astype(np.float32), - 'Y': np.random.uniform(0.1, 1, [1]).astype(np.float32) + 'X': np.random.uniform(0.1, 1, [2, 3, 4]).astype(np.float64), + 'Y': np.random.uniform(0.1, 1, [1]).astype(np.float64) } self.outputs = {'Out': self.inputs['X'] / self.inputs['Y']} @@ -67,8 +67,8 @@ class TestElementwiseDivOp_Vector(ElementwiseDivOp): def setUp(self): self.op_type = "elementwise_div" self.inputs = { - 'X': np.random.uniform(0.1, 1, [32]).astype("float32"), - 'Y': np.random.uniform(0.1, 1, [32]).astype("float32") + 'X': np.random.uniform(0.1, 1, [32]).astype("float64"), + 'Y': np.random.uniform(0.1, 1, [32]).astype("float64") } self.outputs = {'Out': np.divide(self.inputs['X'], self.inputs['Y'])} @@ -77,8 +77,8 @@ class TestElementwiseDivOp_broadcast_0(ElementwiseDivOp): def setUp(self): self.op_type = "elementwise_div" self.inputs = { - 'X': np.random.uniform(0.1, 1, [2, 3, 4]).astype("float32"), - 'Y': np.random.uniform(0.1, 1, [2]).astype("float32") + 'X': np.random.uniform(0.1, 1, [2, 3, 4]).astype("float64"), + 'Y': np.random.uniform(0.1, 1, [2]).astype("float64") } self.attrs = {'axis': 0} @@ -92,8 +92,8 @@ class TestElementwiseDivOp_broadcast_1(ElementwiseDivOp): def setUp(self): self.op_type = "elementwise_div" self.inputs = { - 'X': np.random.uniform(0.1, 1, [2, 3, 4]).astype("float32"), - 'Y': np.random.uniform(0.1, 1, [3]).astype("float32") + 'X': np.random.uniform(0.1, 1, [2, 3, 4]).astype("float64"), + 'Y': np.random.uniform(0.1, 1, [3]).astype("float64") } self.attrs = {'axis': 1} @@ -107,8 +107,8 @@ class TestElementwiseDivOp_broadcast_2(ElementwiseDivOp): def setUp(self): self.op_type = "elementwise_div" self.inputs = { - 'X': np.random.uniform(0.1, 1, [2, 3, 4]).astype("float32"), - 'Y': np.random.uniform(0.1, 1, [4]).astype("float32") + 'X': np.random.uniform(0.1, 1, [2, 3, 4]).astype("float64"), + 'Y': np.random.uniform(0.1, 1, [4]).astype("float64") } self.outputs = { @@ -121,8 +121,8 @@ class TestElementwiseDivOp_broadcast_3(ElementwiseDivOp): def setUp(self): self.op_type = "elementwise_div" self.inputs = { - 'X': np.random.uniform(0.1, 1, [2, 3, 4, 5]).astype("float32"), - 'Y': np.random.uniform(0.1, 1, [3, 4]).astype("float32") + 'X': np.random.uniform(0.1, 1, [2, 3, 4, 5]).astype("float64"), + 'Y': np.random.uniform(0.1, 1, [3, 4]).astype("float64") } self.attrs = {'axis': 1} @@ -136,8 +136,8 @@ class TestElementwiseDivOp_broadcast_4(ElementwiseDivOp): def setUp(self): self.op_type = "elementwise_div" self.inputs = { - 'X': np.random.uniform(0.1, 1, [2, 3, 4]).astype("float32"), - 'Y': np.random.uniform(0.1, 1, [2, 1, 4]).astype("float32") + 'X': np.random.uniform(0.1, 1, [2, 3, 4]).astype("float64"), + 'Y': np.random.uniform(0.1, 1, [2, 1, 4]).astype("float64") } self.outputs = {'Out': np.divide(self.inputs['X'], self.inputs['Y'])} @@ -146,8 +146,8 @@ class TestElementwiseDivOp_broadcast_5(ElementwiseDivOp): def setUp(self): self.op_type = "elementwise_div" self.inputs = { - 'X': np.random.uniform(0.1, 1, [2, 3, 4, 5]).astype("float32"), - 'Y': np.random.uniform(0.1, 1, [2, 3, 1, 5]).astype("float32") + 'X': np.random.uniform(0.1, 1, [2, 3, 4, 5]).astype("float64"), + 'Y': np.random.uniform(0.1, 1, [2, 3, 1, 5]).astype("float64") } self.outputs = {'Out': np.divide(self.inputs['X'], self.inputs['Y'])} @@ -156,8 +156,8 @@ class TestElementwiseDivOp_commonuse_1(ElementwiseDivOp): def setUp(self): self.op_type = "elementwise_div" self.inputs = { - 'X': np.random.uniform(0.1, 1, [2, 3, 4]).astype("float32"), - 'Y': np.random.uniform(0.1, 1, [1, 1, 4]).astype("float32"), + 'X': np.random.uniform(0.1, 1, [2, 3, 4]).astype("float64"), + 'Y': np.random.uniform(0.1, 1, [1, 1, 4]).astype("float64"), } self.outputs = {'Out': np.divide(self.inputs['X'], self.inputs['Y'])} @@ -166,8 +166,8 @@ class TestElementwiseDivOp_commonuse_2(ElementwiseDivOp): def setUp(self): self.op_type = "elementwise_div" self.inputs = { - 'X': np.random.uniform(0.1, 1, [2, 3, 1, 5]).astype("float32"), - 'Y': np.random.uniform(0.1, 1, [2, 1, 4, 1]).astype("float32"), + 'X': np.random.uniform(0.1, 1, [2, 3, 1, 5]).astype("float64"), + 'Y': np.random.uniform(0.1, 1, [2, 1, 4, 1]).astype("float64"), } self.outputs = {'Out': np.divide(self.inputs['X'], self.inputs['Y'])} @@ -176,8 +176,8 @@ class TestElementwiseDivOp_xsize_lessthan_ysize(ElementwiseDivOp): def setUp(self): self.op_type = "elementwise_div" self.inputs = { - 'X': np.random.uniform(0.1, 1, [4, 5]).astype("float32"), - 'Y': np.random.uniform(0.1, 1, [2, 3, 4, 5]).astype("float32"), + 'X': np.random.uniform(0.1, 1, [4, 5]).astype("float64"), + 'Y': np.random.uniform(0.1, 1, [2, 3, 4, 5]).astype("float64"), } self.attrs = {'axis': 2} diff --git a/python/paddle/fluid/tests/unittests/test_elementwise_mul_op.py b/python/paddle/fluid/tests/unittests/test_elementwise_mul_op.py index 89cfc33b84d2675c87abf7c061ce352f11c85884..a07bb86c5cea65f64d4df52351db46ab04677358 100644 --- a/python/paddle/fluid/tests/unittests/test_elementwise_mul_op.py +++ b/python/paddle/fluid/tests/unittests/test_elementwise_mul_op.py @@ -28,7 +28,7 @@ class ElementwiseMulOp(OpTest): def setUp(self): self.op_type = "elementwise_mul" - self.dtype = np.float32 + self.dtype = np.float64 self.axis = -1 self.init_dtype() self.init_input_output() @@ -83,8 +83,8 @@ class TestElementwiseMulOp_scalar(ElementwiseMulOp): def setUp(self): self.op_type = "elementwise_mul" self.inputs = { - 'X': np.random.rand(10, 3, 4).astype(np.float32), - 'Y': np.random.rand(1).astype(np.float32) + 'X': np.random.rand(10, 3, 4).astype(np.float64), + 'Y': np.random.rand(1).astype(np.float64) } self.outputs = {'Out': self.inputs['X'] * self.inputs['Y']} self.init_kernel_type() diff --git a/python/paddle/fluid/tests/unittests/test_elementwise_sub_op.py b/python/paddle/fluid/tests/unittests/test_elementwise_sub_op.py index e602718b87cfc2b76e2062d1970ad1e01c36c2b6..a2e2168f336da419202d2616af967b01455eddfd 100644 --- a/python/paddle/fluid/tests/unittests/test_elementwise_sub_op.py +++ b/python/paddle/fluid/tests/unittests/test_elementwise_sub_op.py @@ -22,8 +22,8 @@ class TestElementwiseOp(OpTest): def setUp(self): self.op_type = "elementwise_sub" self.inputs = { - 'X': np.random.uniform(0.1, 1, [2, 3, 4, 5]).astype("float32"), - 'Y': np.random.uniform(0.1, 1, [2, 3, 4, 5]).astype("float32") + 'X': np.random.uniform(0.1, 1, [2, 3, 4, 5]).astype("float64"), + 'Y': np.random.uniform(0.1, 1, [2, 3, 4, 5]).astype("float64") } self.outputs = {'Out': self.inputs['X'] - self.inputs['Y']} @@ -46,8 +46,8 @@ class TestElementwiseSubOp_scalar(TestElementwiseOp): def setUp(self): self.op_type = "elementwise_sub" self.inputs = { - 'X': np.random.rand(10, 3, 4).astype(np.float32), - 'Y': np.random.rand(1).astype(np.float32) + 'X': np.random.rand(10, 3, 4).astype(np.float64), + 'Y': np.random.rand(1).astype(np.float64) } self.outputs = {'Out': self.inputs['X'] - self.inputs['Y']} @@ -56,8 +56,8 @@ class TestElementwiseSubOp_Vector(TestElementwiseOp): def setUp(self): self.op_type = "elementwise_sub" self.inputs = { - 'X': np.random.random((100, )).astype("float32"), - 'Y': np.random.random((100, )).astype("float32") + 'X': np.random.random((100, )).astype("float64"), + 'Y': np.random.random((100, )).astype("float64") } self.outputs = {'Out': self.inputs['X'] - self.inputs['Y']} @@ -66,8 +66,8 @@ class TestElementwiseSubOp_broadcast_0(TestElementwiseOp): def setUp(self): self.op_type = "elementwise_sub" self.inputs = { - 'X': np.random.rand(2, 13, 4).astype(np.float32), - 'Y': np.random.rand(2).astype(np.float32) + 'X': np.random.rand(2, 13, 4).astype(np.float64), + 'Y': np.random.rand(2).astype(np.float64) } self.attrs = {'axis': 0} @@ -80,8 +80,8 @@ class TestElementwiseSubOp_broadcast_1(TestElementwiseOp): def setUp(self): self.op_type = "elementwise_sub" self.inputs = { - 'X': np.random.rand(2, 3, 4).astype(np.float32), - 'Y': np.random.rand(3).astype(np.float32) + 'X': np.random.rand(2, 3, 4).astype(np.float64), + 'Y': np.random.rand(3).astype(np.float64) } self.attrs = {'axis': 1} @@ -94,8 +94,8 @@ class TestElementwiseSubOp_broadcast_2(TestElementwiseOp): def setUp(self): self.op_type = "elementwise_sub" self.inputs = { - 'X': np.random.rand(2, 3, 4).astype(np.float32), - 'Y': np.random.rand(4).astype(np.float32) + 'X': np.random.rand(2, 3, 4).astype(np.float64), + 'Y': np.random.rand(4).astype(np.float64) } self.outputs = { @@ -107,8 +107,8 @@ class TestElementwiseSubOp_broadcast_3(TestElementwiseOp): def setUp(self): self.op_type = "elementwise_sub" self.inputs = { - 'X': np.random.rand(2, 3, 4, 5).astype(np.float32), - 'Y': np.random.rand(3, 4).astype(np.float32) + 'X': np.random.rand(2, 3, 4, 5).astype(np.float64), + 'Y': np.random.rand(3, 4).astype(np.float64) } self.attrs = {'axis': 1} @@ -121,8 +121,8 @@ class TestElementwiseSubOp_broadcast_4(TestElementwiseOp): def setUp(self): self.op_type = "elementwise_sub" self.inputs = { - 'X': np.random.rand(2, 3, 4, 5).astype(np.float32), - 'Y': np.random.rand(2, 3, 1, 5).astype(np.float32) + 'X': np.random.rand(2, 3, 4, 5).astype(np.float64), + 'Y': np.random.rand(2, 3, 1, 5).astype(np.float64) } self.outputs = {'Out': self.inputs['X'] - self.inputs['Y']} @@ -131,8 +131,8 @@ class TestElementwiseSubOp_commonuse_1(TestElementwiseOp): def setUp(self): self.op_type = "elementwise_sub" self.inputs = { - 'X': np.random.rand(2, 3, 4).astype(np.float32), - 'Y': np.random.rand(1, 1, 4).astype(np.float32) + 'X': np.random.rand(2, 3, 4).astype(np.float64), + 'Y': np.random.rand(1, 1, 4).astype(np.float64) } self.outputs = {'Out': self.inputs['X'] - self.inputs['Y']} @@ -141,8 +141,8 @@ class TestElementwiseSubOp_commonuse_2(TestElementwiseOp): def setUp(self): self.op_type = "elementwise_sub" self.inputs = { - 'X': np.random.rand(2, 3, 1, 5).astype(np.float32), - 'Y': np.random.rand(2, 1, 4, 1).astype(np.float32) + 'X': np.random.rand(2, 3, 1, 5).astype(np.float64), + 'Y': np.random.rand(2, 1, 4, 1).astype(np.float64) } self.outputs = {'Out': self.inputs['X'] - self.inputs['Y']} @@ -151,8 +151,8 @@ class TestElementwiseSubOp_xsize_lessthan_ysize(TestElementwiseOp): def setUp(self): self.op_type = "elementwise_sub" self.inputs = { - 'X': np.random.rand(4, 5).astype(np.float32), - 'Y': np.random.rand(2, 3, 4, 5).astype(np.float32) + 'X': np.random.rand(4, 5).astype(np.float64), + 'Y': np.random.rand(2, 3, 4, 5).astype(np.float64) } self.attrs = {'axis': 2}