diff --git a/python/paddle/fluid/tests/unittests/xpu/test_activation_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_activation_op_xpu.py index 6a7e5f08b5e489511d2060d92dc0390dd4b18dbc..d50c0fecdeebc79a98f66037080d1a03d73f3924 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_activation_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_activation_op_xpu.py @@ -84,13 +84,33 @@ class XPUTestSigmoidOP(XPUOpTestWrapper): def set_case(self): self.op_type = "sigmoid" self.dtype = self.in_type + self.init_config() + out = 1 / (1 + np.exp(-self.x)) - x = np.random.uniform(-1, 1, [11, 17]).astype(self.dtype) - out = 1 / (1 + np.exp(-x)) self.attrs = {'use_xpu': True} - self.inputs = {'X': OpTest.np_dtype_to_fluid_dtype(x)} + self.inputs = {'X': OpTest.np_dtype_to_fluid_dtype(self.x)} self.outputs = {'Out': out} + def init_config(self): + self.x = np.random.uniform(-1, 1, [11, 17]).astype(self.dtype) + + class XPUTestSigmoid2(XPUTestSigmoid): + def init_config(self): + self.x = np.random.uniform(-2, 2, [100]).astype(self.dtype) + + class XPUTestSigmoid3(XPUTestSigmoid): + def init_config(self): + self.x = np.random.uniform(-2, 2, [10, 12, 15]).astype(self.dtype) + + class XPUTestSigmoid4(XPUTestSigmoid): + def init_config(self): + self.x = np.random.uniform(-2, 2, [19, 19]).astype(self.dtype) + + class XPUTestSigmoid5(XPUTestSigmoid): + def init_config(self): + self.x = np.random.uniform(-2, 2, + [10, 20, 30, 40]).astype(self.dtype) + support_types = get_xpu_op_support_types('sigmoid') for stype in support_types: @@ -292,14 +312,32 @@ class XPUTestSquareOP(XPUOpTestWrapper): def set_case(self): self.op_type = "square" self.dtype = self.in_type - - x = np.random.uniform(-1, 1, [11, 17]).astype(self.dtype) - out = np.square(x) + self.init_config() + out = np.square(self.x) self.attrs = {'use_xpu': True} - self.inputs = {'X': OpTest.np_dtype_to_fluid_dtype(x)} + self.inputs = {'X': OpTest.np_dtype_to_fluid_dtype(self.x)} self.outputs = {'Out': out} + def init_config(self): + self.x = np.random.uniform(-1, 1, [11, 17]).astype(self.dtype) + + class XPUTestSquare2(XPUTestSquare): + def init_config(self): + self.x = np.random.uniform(-2, 2, [100]).astype(self.dtype) + + class XPUTestSquare3(XPUTestSquare): + def init_config(self): + self.x = np.random.uniform(-2, 2, [1, 15, 19]).astype(self.dtype) + + class XPUTestSquare4(XPUTestSquare): + def init_config(self): + self.x = np.random.uniform(-2, 2, [100, 10]).astype(self.dtype) + + class XPUTestSquare5(XPUTestSquare): + def init_config(self): + self.x = np.random.uniform(-2, 2, [1, 2, 5, 17]).astype(self.dtype) + support_types = get_xpu_op_support_types('square') for stype in support_types: