21
21
22
22
class PReluTest (OpTest ):
23
23
def setUp (self ):
24
+ print ('setUp' )
25
+ import sys
26
+ sys .stdout .flush ()
24
27
self .op_type = "prelu"
25
28
self .initTestCase ()
26
29
x_np = np .random .normal (size = (3 , 5 , 5 , 10 )).astype ("float32" )
@@ -39,32 +42,45 @@ def setUp(self):
39
42
alpha_np = np .random .rand (* x_np .shape ).astype ("float32" )
40
43
self .inputs = {'X' : x_np , 'Alpha' : alpha_np }
41
44
42
- import sys
43
- print ('self.inputs' , self .inputs )
44
- sys .stdout .flush ()
45
-
46
45
out_np = np .maximum (self .inputs ['X' ], 0. )
47
46
out_np = out_np + np .minimum (self .inputs ['X' ],
48
47
0. ) * self .inputs ['Alpha' ]
49
48
assert out_np is not self .inputs ['X' ]
49
+ self .outputs = {'Out' : out_np }
50
+
51
+ def tearDown (self ):
52
+ print ('tearDown' )
50
53
import sys
51
- print ('self.outputs' , self .outputs )
52
54
sys .stdout .flush ()
53
- self .outputs = {'Out' : out_np }
55
+ del self .outputs
56
+ del self .inputs
54
57
55
58
def initTestCase (self ):
56
59
self .attrs = {'mode' : "channel" }
57
60
58
- def test_check_output (self ):
61
+ def test_check_4_output (self ):
62
+ print ('test_check_0_output' )
63
+ import sys
64
+ sys .stdout .flush ()
59
65
self .check_output ()
60
66
61
- def test_check_grad (self ):
62
- self . check_grad ([ 'X' , 'Alpha' ], 'Out ' )
63
-
64
- def test_check_grad_ignore_x ( self ):
67
+ def test_check_0_grad_2_ignore_x (self ):
68
+ print ( 'test_check_2_grad_2_ignore_x ' )
69
+ import sys
70
+ sys . stdout . flush ()
65
71
self .check_grad (['Alpha' ], 'Out' , no_grad_set = set ('X' ))
66
72
67
- def test_check_grad_ignore_alpha (self ):
73
+ # TODO(minqiyang): remove the order of tests
74
+ def test_check_1_grad_1 (self ):
75
+ print ('test_check_1_grad_1' )
76
+ import sys
77
+ sys .stdout .flush ()
78
+ self .check_grad (['X' , 'Alpha' ], 'Out' )
79
+
80
+ def test_check_3_grad_3_ignore_alpha (self ):
81
+ print ('test_check_3_grad_3_ignore_alpha' )
82
+ import sys
83
+ sys .stdout .flush ()
68
84
self .check_grad (['X' ], 'Out' , no_grad_set = set ('Alpha' ))
69
85
70
86
@@ -73,15 +89,14 @@ def initTestCase(self):
73
89
self .attrs = {'mode' : "all" }
74
90
75
91
76
- class TestCase2 (PReluTest ):
77
- def initTestCase (self ):
78
- self .attrs = {'mode' : "channel" }
79
-
80
-
81
- class TestCase3 (PReluTest ):
82
- def initTestCase (self ):
83
- self .attrs = {'mode' : "element" }
84
-
92
+ #class TestCase2(PReluTest):
93
+ # def initTestCase(self):
94
+ # self.attrs = {'mode': "channel"}
95
+ #
96
+ #
97
+ #class TestCase3(PReluTest):
98
+ # def initTestCase(self):
99
+ # self.attrs = {'mode': "element"}
85
100
86
101
if __name__ == "__main__" :
87
102
unittest .main ()
0 commit comments