diff --git a/framework/api/nn/test_alpha_dropout.py b/framework/api/nn/test_alpha_dropout.py index 662684f6ff..ba97c973df 100644 --- a/framework/api/nn/test_alpha_dropout.py +++ b/framework/api/nn/test_alpha_dropout.py @@ -258,8 +258,8 @@ def run(self, res_list, data=None, **kwargs): obj = TestAlphaDropout(paddle.nn.AlphaDropout) -np_random_tensor = np.array([[0.55355287, 0.20714243, 0.01162981], [0.51577556, 0.36369765, 0.26091650]]) -np_random_tensor_gpu = np.array([[0.00224779, 0.50324494, 0.13526054], [0.16112770, 0.79557019, 0.96897715]]) +np_random_tensor = np.array([[0.55355281, 0.20714243, 0.01162981], [0.51577556, 0.36369765, 0.26091650]]) +np_random_tensor_gpu = np.array([[0.35628906, 0.03034166, 0.70878232], [0.20091671, 0.02237142, 0.98958546]]) def numpy_alpha_dropout(x, p, random_tensor, training=True): diff --git a/framework/api/nn/test_initializer_kaiming_normal.py b/framework/api/nn/test_initializer_kaiming_normal.py index b40309638a..4c7adcce9f 100755 --- a/framework/api/nn/test_initializer_kaiming_normal.py +++ b/framework/api/nn/test_initializer_kaiming_normal.py @@ -35,6 +35,7 @@ def test_initializer_kaiming_normal_base(): """ base """ + obj.static = False np.random.seed(obj.seed) x = randtool("float", 0, 1, [2, 3, 4, 4, 4]) in_channels = 3 @@ -46,14 +47,14 @@ def test_initializer_kaiming_normal_base(): [ [ [ - [[0.6073261, 0.45953372], [-0.14565772, 1.4175302]], - [[-0.37328905, 0.14211036], [-0.11755048, 0.99755657]], + [[-0.7909662, -1.1310656], [-0.8929211, -1.4893157]], + [[-0.34479648, -1.6304922], [-1.3817989, -1.3706139]], ] ], [ [ - [[0.43749335, 0.84751886], [0.4232624, 0.53650147]], - [[0.9127629, 0.37381193], [0.12733835, 0.09655958]], + [[-0.47850963, -0.72494894], [-0.8955704, -0.46525073]], + [[-2.0812037, -1.1279415], [-1.2584791, -0.71123725]], ] ], ] @@ -79,6 +80,7 @@ def test_initializer_kaiming_normal1(): kernel_size = [2, 2, 2] fan_in=None """ + obj.dygraph = False np.random.seed(obj.seed) x = randtool("float", 0, 1, [2, 3, 4, 4, 4]) in_channels = 3 @@ -148,6 +150,7 @@ def test_initializer_kaiming_normal2(): kernel_size = [2, 2, 2], out_channels = 3 fan_in=None """ + obj.static = False np.random.seed(obj.seed) x = randtool("float", 0, 1, [2, 3, 4, 4, 4]) in_channels = 3 @@ -160,106 +163,106 @@ def test_initializer_kaiming_normal2(): [ [ [ - [1.8079153, 1.3419943, 1.6368787], - [1.3206803, 1.3285301, 2.5949469], - [1.1816999, 1.5280874, 1.4093121], + [-1.2293931e00, 1.6474673e-01, -2.8401414e-01], + [-6.2907767e-01, 1.2981658e-01, -3.9865896e-01], + [1.7846362e-01, 1.2978742e-01, -5.2754354e-01], ], [ - [0.9836161, 0.4292852, 0.96869326], - [1.2596482, 0.89616156, 2.050052], - [1.9295127, 1.9959155, 1.4872673], + [-5.9712392e-01, 1.9373848e-01, 3.2503450e-01], + [-1.7240536e-01, -1.5997417e-02, -3.7467605e-01], + [-5.6236964e-02, -3.8357538e-01, -5.8548778e-01], ], [ - [1.9612684, 1.8047585, 1.1946392], - [2.1696332, 1.7041223, 1.3986557], - [1.9911445, 1.2479898, 1.019885], + [-1.6922435e-02, -2.1196042e-01, -4.0865082e-01], + [-7.9716820e-01, -8.4401536e-01, -2.0227887e-01], + [-4.0591261e-01, -1.1363892e-01, -8.6436117e-01], ], ], [ [ - [0.7471266, 0.45052794, -0.3301444], - [-0.2506416, -0.07563769, 0.6927293], - [0.4357691, 0.39012286, 0.75422764], + [-7.5638346e-02, -1.1987197e00, -6.4783347e-01], + [-1.6888726e-01, -1.4597490e00, -8.9046276e-01], + [-8.1787658e-01, -1.4053460e00, -1.5710472e00], ], [ - [-0.12711209, 0.28128624, 0.78554773], - [-0.06531468, 0.07282922, 0.39616638], - [0.46107677, 0.6726326, -0.25717333], + [-6.7849517e-01, -1.2692145e00, -1.1689229e00], + [-1.5266550e00, -1.2151806e00, -1.3315181e-01], + [-4.8299670e-01, -6.5576518e-01, -1.1370872e00], ], [ - [0.02403371, 0.32709777, 0.3895478], - [0.08395495, -0.5431423, 0.21213472], - [0.47807518, 0.10497802, 0.45547783], + [-7.7800590e-01, -8.1772983e-01, -8.8980669e-01], + [-7.1756750e-01, -1.1117781e00, -7.7925450e-01], + [-8.4614724e-01, -4.3888152e-01, -1.9418462e-01], ], ], [ [ - [-0.11409266, -0.65414387, -0.02397479], - [0.13901153, -0.3198583, -0.01233158], - [-0.395255, -0.90410966, -0.75299025], + [1.8738854e-01, -6.3205600e-02, -1.2471273e00], + [-1.0930245e00, -6.3434601e-01, -1.9348118e-01], + [-1.8029436e-01, -4.1969761e-01, -2.0330581e-03], ], [ - [-0.6351704, -0.29878914, -0.38095522], - [-0.672151, 0.17700364, -0.6064391], - [-0.96716386, -0.2632199, -0.08827767], + [-6.0127503e-01, -8.4321177e-01, 3.0554351e-01], + [-2.4791284e-01, -4.1300362e-01, -4.5582914e-01], + [-5.5625337e-01, -1.8989690e-01, -8.2144463e-01], ], [ - [-0.4043926, -0.4363293, -0.634597], - [-0.80965, -0.5825709, -0.7071475], - [-0.43602312, -0.3779117, -0.38654584], + [-1.3463125e-01, -6.5465337e-01, -9.0536791e-01], + [-4.8383191e-01, -9.1629487e-01, -4.9039146e-01], + [-4.3889529e-01, -6.4557642e-01, -7.4583568e-02], ], ], ], [ [ [ - [1.6421847, 2.0826735, 0.9093389], - [1.3807209, 0.97100455, 0.62313694], - [1.1052526, -0.12076898, 0.6073525], + [-1.0147899e-01, -6.2926716e-01, -2.4559475e-02], + [-1.2822889e00, -6.7141855e-01, -1.0656639e-01], + [-3.7364462e-01, 1.0084603e00, -1.3760528e-01], ], [ - [1.3408954, 1.6324313, 0.86166024], - [1.215758, 0.76346004, 1.9437813], - [1.4425654, 2.0354588, 2.2760768], + [5.8644617e-01, 6.9772981e-02, -2.1342130e-01], + [1.1715784e-02, 2.2482160e-01, 1.0146233e-02], + [-3.7499946e-01, -3.9224863e-01, -7.4025083e-01], ], [ - [1.612518, 1.6097023, 1.3900883], - [1.2166656, 1.3412042, 1.0103409], - [2.384087, 1.6143353, 0.63767433], + [7.7382021e-02, 8.0774806e-02, -3.2082900e-01], + [-2.6685533e-01, -1.5581343e-02, -4.0582401e-01], + [-5.1589859e-01, -2.0472760e-01, 1.0251662e-01], ], ], [ [ - [0.9344932, 0.7502791, 0.9356491], - [0.83077097, -0.1439792, 0.91063046], - [1.0858068, -0.4682934, -0.3116704], + [-8.1672594e-02, -6.4358830e-01, -7.4224633e-01], + [-3.9935866e-01, -2.6977694e-01, -1.5822317e-01], + [-1.2727587e00, -1.8429492e00, -1.3995315e00], ], [ - [-0.17357627, 0.22383317, 0.22154495], - [0.91086394, 1.3141352, 0.77393717], - [-0.22694102, 0.6101852, 0.53859717], + [-1.4347632e00, -7.1152371e-01, -1.5185101e00], + [-1.4802868e00, -3.7698421e-01, -4.6810555e-01], + [-5.8762294e-01, -1.0453181e00, -1.3732103e00], ], [ - [0.14935881, 0.16077325, -0.1769408], - [0.16654044, 0.13467762, 0.27446923], - [0.41345596, 0.12491152, -0.01616757], + [-2.9586774e-01, -1.7793399e00, -1.4043761e00], + [-2.4744413e00, -1.0216242e00, -3.9117241e-01], + [-5.4959458e-01, -1.7778242e-01, -6.2528324e-01], ], ], [ [ - [-0.7843534, -1.361019, -0.7209854], - [-0.01214989, -0.091493, -0.2761633], - [-1.0982413, -0.17764747, 0.60795546], + [-3.9135692e-01, -7.4654871e-01, -8.5980344e-01], + [-5.5596483e-01, -8.6022276e-01, -4.7187939e-01], + [2.6867282e-01, -7.4003237e-01, -6.0833687e-01], ], [ - [0.21671566, -0.0447642, -0.5366475], - [-0.4699743, -0.76216847, -0.5679674], - [-0.8876607, -0.75843513, -0.5225089], + [-3.8614148e-01, -6.1232603e-01, -6.6018879e-01], + [-6.9704473e-02, 1.0533802e-01, -4.2883199e-01], + [-3.4579116e-01, -3.2097179e-01, -3.6408600e-01], ], [ - [-0.6694971, -0.55462015, -0.6366767], - [-0.58757335, -0.7921887, -1.32232], - [-0.3245315, -0.18136731, -0.4579403], + [-7.6128328e-01, -4.4913951e-01, -5.0139654e-01], + [-7.4650884e-01, -1.3220979e00, -2.2468255e-01], + [-3.5459071e-01, -9.0284270e-01, -1.2002969e00], ], ], ], @@ -285,6 +288,7 @@ def test_initializer_kaiming_normal3(): kernel_size = [3, 3, 3] stride = 2 fan_in=None """ + obj.dygraph = False np.random.seed(obj.seed) x = randtool("float", 0, 1, [2, 3, 4, 4, 4]) in_channels = 3 @@ -313,6 +317,7 @@ def test_initializer_kaiming_normal4(): kernel_size = [3, 3, 3] stride = 2 padding=1 fan_in=None """ + obj.static = False np.random.seed(obj.seed) x = randtool("float", 0, 1, [2, 3, 4, 4, 4]) in_channels = 3 @@ -322,8 +327,18 @@ def test_initializer_kaiming_normal4(): padding = 1 res = np.array( [ - [[[[0.5605063, -0.01152094], [0.594596, 0.2942711]], [[0.04425821, 0.34833288], [0.68170136, 0.99755657]]]], - [[[[0.1066306, 0.13953194], [0.57458216, 0.2565436]], [[0.09446661, 0.78999925], [0.8357021, 0.09655958]]]], + [ + [ + [[-0.09436481, -0.52511615], [-0.2361718, -1.0775778]], + [[-0.6832304, -1.0608681], [-1.0911332, -1.3706139]], + ] + ], + [ + [ + [[-0.4708487, -0.9790309], [-1.0599958, -0.71658564]], + [[-0.67799956, -0.91483], [-1.4096593, -0.71123725]], + ] + ], ] ) if paddle.device.is_compiled_with_cuda() is True: @@ -346,6 +361,7 @@ def test_initializer_kaiming_normal5(): kernel_size = [3, 3, 3] stride = 2 padding=0 groups=3 fan_in=None """ + obj.dygraph = False np.random.seed(obj.seed) x = randtool("float", 0, 1, [2, 3, 4, 4, 4]) in_channels = 3 @@ -381,6 +397,7 @@ def test_initializer_kaiming_normal6(): kernel_size = [3, 3, 3] stride = 1 padding=1 w=0.7 b=-0.3 fan_in=None """ + obj.static = False np.random.seed(obj.seed) x = randtool("float", 0, 1, [2, 3, 4, 4, 4]) in_channels = 3 @@ -392,17 +409,23 @@ def test_initializer_kaiming_normal6(): [ [ [ - [[0.6073261, 0.45953372], [-0.14565772, 1.4175302]], - [[-0.37328905, 0.14211036], [-0.11755048, 0.99755657]], + [[-0.7909662, -1.1310656], [-0.8929211, -1.4893157]], + [[-0.34479648, -1.6304922], [-1.3817989, -1.3706139]], + ], + [ + [[-1.1571394, -0.862601], [-0.35028014, -1.669127]], + [[-0.6303307, -0.5712432], [-0.94386023, -0.79027134]], ], - [[[0.43029046, 1.1630684], [0.31839165, 0.45435104]], [[1.4618211, 1.23204], [1.1701092, 0.7978793]]], ], [ [ - [[0.43749335, 0.84751886], [0.4232624, 0.53650147]], - [[0.9127629, 0.37381193], [0.12733835, 0.09655958]], + [[-0.47850963, -0.72494894], [-0.8955704, -0.46525073]], + [[-2.0812037, -1.1279415], [-1.2584791, -0.71123725]], + ], + [ + [[-0.26359233, -0.77682096], [0.08888325, -1.1907777]], + [[-0.711984, -0.962748], [-1.0660995, -0.72753334]], ], - [[[0.5512369, 0.7909282], [0.18140778, 0.47810355]], [[1.1312029, 0.74829596], [0.720579, 0.6829458]]], ], ] ) @@ -426,6 +449,7 @@ def test_initializer_kaiming_normal7(): kernel_size = [3, 3, 3] stride = 1 padding=1 w=0.7 b=-0.3 data_format="NDHWC" fan_in=None """ + obj.dygraph = False np.random.seed(obj.seed) x = randtool("float", 0, 1, [2, 3, 4, 4, 4]).transpose(0, 2, 3, 4, 1) in_channels = 3 @@ -476,6 +500,7 @@ def test_initializer_kaiming_normal8(): padding_mode = "reflect" fan_in=None """ + obj.static = False np.random.seed(obj.seed) x = randtool("float", 0, 1, [2, 3, 4, 4, 4]) in_channels = 3 @@ -488,14 +513,20 @@ def test_initializer_kaiming_normal8(): [ [ [ - [[1.1522751, 0.64449316, -0.1596964, 0.3406393], [0.85893476, -0.3124804, 0.82826024, 0.5503867]], - [[0.66155595, 0.3669618, 0.31739455, 0.08125566], [1.0070366, -0.11755048, 0.99755657, 0.4241258]], + [[-0.7709425, -1.1404827, -0.668229, -0.52970976], [-1.011386, -1.3369389, -1.4183304, -0.9493112]], + [ + [-1.6819147, -1.4077313, -1.1920983, -1.0478842], + [-1.9705657, -1.3817989, -1.3706139, -1.3906765], + ], ] ], [ [ - [[0.78231233, -0.03063385, 0.6058931, 0.2871665], [0.3692535, 0.17527363, 0.14924596, 0.85669655]], - [[0.4449456, -0.6211853, 0.58943945, 0.33447614], [0.19076191, 0.12733835, 0.09655958, 0.7136871]], + [[-1.9058132, -1.3477542, -2.2974548, -1.4315804], [-1.6657716, -0.9627812, -0.5090107, -1.208206]], + [ + [-1.6399553, -1.0677788, -1.1592116, -1.3022541], + [-1.9252254, -1.2584791, -0.71123725, -1.4129348], + ], ] ], ] @@ -521,6 +552,7 @@ def test_initializer_kaiming_normal9(): padding_mode = "replicate" fan_in=None """ + obj.dygraph = False np.random.seed(obj.seed) x = randtool("float", 0, 1, [2, 3, 4, 4, 4]) in_channels = 3 @@ -566,6 +598,7 @@ def test_initializer_kaiming_normal10(): padding_mode = "circular" fan_in=None """ + obj.static = False np.random.seed(obj.seed) x = randtool("float", 0, 1, [2, 3, 4, 4, 4]) in_channels = 3 @@ -578,14 +611,26 @@ def test_initializer_kaiming_normal10(): [ [ [ - [[1.1493586, 0.2857985, 0.4673859, 0.79607165], [0.92873603, 0.20516342, 0.7362683, 1.0331961]], - [[0.3038256, 1.1247545, 0.6776748, 0.12748581], [1.1636142, -0.11755048, 0.99755657, 0.32947105]], + [ + [-0.9033673, -0.59911644, -0.9873681, -0.5820413], + [-0.72792435, -1.2635299, -1.4326847, -1.1017292], + ], + [ + [-1.1342155, -0.85980403, -0.98183185, -1.1548347], + [-1.2128533, -1.3817989, -1.3706139, -1.0355732], + ], ] ], [ [ - [[0.26404598, -0.6576977, 0.13014497, 1.3358058], [0.40981585, 0.4426188, 0.16423123, 0.59834445]], - [[0.306283, -0.4172607, 0.73213583, 0.6948482], [1.0667173, 0.12733835, 0.09655958, 1.3202523]], + [ + [-0.5132503, -1.251071, -1.0599562, -0.46638155], + [-1.8439292, -1.3434633, -0.24912918, -0.79966164], + ], + [ + [-1.1400757, -0.7411515, -1.0659547, -1.1601791], + [-1.6739165, -1.2584791, -0.71123725, -0.27138665], + ], ] ], ] @@ -611,6 +656,7 @@ def test_initializer_kaiming_normal11(): padding_mode = "zeros" dilation = 2 fan_in=None """ + obj.dygraph = False np.random.seed(obj.seed) x = randtool("float", 0, 1, [2, 3, 4, 4, 4]) in_channels = 3 @@ -620,7 +666,7 @@ def test_initializer_kaiming_normal11(): padding = 1 dilation = 2 padding_mode = "zeros" - res = np.array([[[[[0.45051473, 0.24151678]]]], [[[[0.27564842, 0.26926237]]]]]) + res = np.array([[[[[0.45051473, 0.24151678]]]], [[[[0.27564842, 0.269262375]]]]]) if paddle.device.is_compiled_with_cuda() is True: obj.run( res=res, @@ -643,6 +689,7 @@ def test_initializer_kaiming_normal12(): padding_mode = "zeros" dilation = [2, 2, 2] fan_in=None """ + obj.static = False np.random.seed(obj.seed) x = randtool("float", 0, 1, [2, 3, 4, 4, 4]) in_channels = 3 @@ -652,7 +699,7 @@ def test_initializer_kaiming_normal12(): padding = 1 dilation = [2, 2, 2] padding_mode = "zeros" - res = np.array([[[[[0.45051473, 0.24151678]]]], [[[[0.27564842, 0.26926237]]]]]) + res = np.array([[[[[-0.12529811, -0.6268066]]]], [[[[-0.27629152, -0.6106175]]]]]) if paddle.device.is_compiled_with_cuda() is True: obj.run( res=res, @@ -675,6 +722,7 @@ def test_initializer_kaiming_normal13(): padding_mode = "zeros" dilation = (2, 2) fan_in=None """ + obj.dygraph = False np.random.seed(obj.seed) x = randtool("float", 0, 1, [2, 3, 4, 4, 4]) in_channels = 3 @@ -707,6 +755,7 @@ def test_initializer_kaiming_normal14(): padding_mode = "zeros" dilation = (2, 2, 2) padding = (1, 2, 2) fan_in=None """ + obj.static = False np.random.seed(obj.seed) x = randtool("float", 0, 1, [2, 3, 4, 4, 4]) in_channels = 3 @@ -718,8 +767,15 @@ def test_initializer_kaiming_normal14(): padding_mode = "zeros" res = np.array( [ - [[[[0.27735454, 0.176687, 0.2575486, 0.2179849], [0.4793579, 0.04378546, -0.26692072, 0.01292928]]]], - [[[[0.43240556, -0.07143027, 0.12640606, 0.29070508], [0.4951439, 0.5538594, -0.0941367, 0.19308226]]]], + [[[[-0.26683137, -0.26825666, -0.706546, -0.6865949], [-1.0431741, -0.745999, 0.11286625, -0.14300884]]]], + [ + [ + [ + [-0.6431576, -0.23594266, -0.9079815, -0.6381485], + [-0.72473156, -0.29327083, -0.23808132, -0.2543921], + ] + ] + ], ] ) if paddle.device.is_compiled_with_cuda() is True: @@ -744,6 +800,7 @@ def test_initializer_kaiming_normal15(): padding_mode = "zeros" dilation = (2, 2) padding = [1, 2] fan_in=None """ + obj.dygraph = False np.random.seed(obj.seed) x = randtool("float", 0, 1, [2, 3, 4, 4, 4]) in_channels = 3 @@ -781,6 +838,7 @@ def test_initializer_kaiming_normal16(): padding_mode = "zeros" dilation = (2, 2) padding = [1, 2] fan_in=1.2 """ + obj.static = False np.random.seed(obj.seed) x = randtool("float", 0, 1, [2, 3, 4, 4, 4]) in_channels = 3 @@ -792,8 +850,8 @@ def test_initializer_kaiming_normal16(): padding_mode = "zeros" res = np.array( [ - [[[[2.2786992, 1.4516317, 2.115977, 1.7909288], [3.9383252, 0.3597339, -2.192978, 0.10622477]]]], - [[[[3.552574, -0.58685935, 1.0385318, 2.3883858], [4.068023, 4.550418, -0.77341205, 1.5863327]]]], + [[[[-2.1922429, -2.203953, -5.8048663, -5.640952], [-8.570548, -6.129007, 0.92729086, -1.1749378]]]], + [[[[-5.284079, -1.9384664, -7.4598293, -5.2429237], [-5.954276, -2.409465, -1.9560382, -2.0900443]]]], ] ) if paddle.device.is_compiled_with_cuda() is True: @@ -818,6 +876,7 @@ def test_initializer_kaiming_normal17(): padding_mode = "zeros" dilation = (2, 2) padding = [1, 2] fan_in=2.3 """ + obj.dygraph = False np.random.seed(obj.seed) x = randtool("float", 0, 1, [2, 3, 4, 4, 4]) in_channels = 3 diff --git a/framework/api/nn/test_initializer_kaiming_uniform.py b/framework/api/nn/test_initializer_kaiming_uniform.py index d98096ac44..3db66c58cd 100755 --- a/framework/api/nn/test_initializer_kaiming_uniform.py +++ b/framework/api/nn/test_initializer_kaiming_uniform.py @@ -35,6 +35,7 @@ def test_initializer_kaiming_uniform_base(): """ base """ + obj.static = False np.random.seed(obj.seed) x = randtool("float", 0, 1, [2, 3, 2, 2]).astype("float32") in_channels = 3 @@ -44,7 +45,10 @@ def test_initializer_kaiming_uniform_base(): padding = 1 dilation = 1 res = np.array( - [[[[1.1869886, 2.3453705], [1.2281079, 1.0826794]]], [[[0.24804217, 1.8928909], [1.5467637, 1.5817381]]]] + [ + [[[-0.39864674, 0.44492644], [-2.1563835, -0.09215282]]], + [[[0.05160024, 0.5901147], [-1.3453339, -1.1876528]]], + ] ) if paddle.device.is_compiled_with_cuda() is True: obj.base( @@ -66,6 +70,7 @@ def test_initializer_kaiming_uniform1(): """ default """ + obj.dygraph = False np.random.seed(obj.seed) x = randtool("float", 0, 1, [2, 3, 2, 2]).astype("float32") in_channels = 3 @@ -114,6 +119,7 @@ def test_initializer_kaiming_uniform2(): """ dilation = 2 """ + obj.static = False np.random.seed(obj.seed) x = randtool("float", 0, 1, [2, 3, 2, 2]).astype("float32") in_channels = 3 @@ -126,18 +132,18 @@ def test_initializer_kaiming_uniform2(): [ [ [ - [0.39888406, 0.14239825, 0.84748095, 1.0942918, 0.7107052, 0.3309278], - [-0.9275552, -0.49287915, 0.6899886, 0.5361054, 0.00426798, -0.12755814], - [-0.75464916, -0.761385, 0.59295094, 0.64171284, -0.0829928, -0.01879808], - [1.0284215, 0.67908627, 0.7174556, 0.04409777, 0.47986156, 0.18009461], + [0.35504752, -0.37692446, 0.05799875, -0.16684613, 0.8788808, 0.23547846], + [-0.7535841, -0.3518779, 0.27215683, -0.1930912, -0.07401706, 0.26988265], + [-0.45363197, -0.6825423, -0.2646422, 0.31390566, 0.49114504, -0.20408536], + [-0.35144585, -0.3957303, -0.8134686, -0.36817482, -0.5290287, -0.54556954], ] ], [ [ - [0.3629937, -0.66693234, 0.7846964, 0.919392, 0.3969715, 0.6188619], - [-0.94021267, -0.453328, 0.5836061, 0.5021896, 0.07433788, -0.09116814], - [-0.65587324, -0.4368534, 0.44602627, 0.9121258, 0.00741166, -0.34975865], - [0.915076, 0.69684297, 0.84074783, 0.22948253, 0.43271816, 0.34738517], + [-0.04252443, 0.1658059, -0.09269778, 0.24450657, 0.45426783, 0.46441948], + [-0.7518698, -0.4010634, 0.37955555, 0.02937469, -0.13803437, 0.00215799], + [-0.4779903, -0.4235527, 0.08779142, -0.37562048, 0.09073773, 0.2590201], + [-0.31621772, -0.19313698, -0.8164357, -0.42716488, -0.47560513, -0.3033054], ] ], ] @@ -162,6 +168,7 @@ def test_initializer_kaiming_uniform3(): """ out_channels = 3 groups=3 data_format="NHWC" output_padding=1 """ + obj.dygraph = False np.random.seed(obj.seed) x = randtool("float", 0, 1, [2, 6, 2, 2]).astype("float32").transpose(0, 2, 3, 1) in_channels = 6 diff --git a/framework/api/nn/test_initializer_normal.py b/framework/api/nn/test_initializer_normal.py index 90cb26624a..83db761b43 100755 --- a/framework/api/nn/test_initializer_normal.py +++ b/framework/api/nn/test_initializer_normal.py @@ -36,6 +36,7 @@ def test_initializer_normal_base(): base weight_attr=paddle.nn.initializer.Normal(mean=0.0, std=2.0) """ + obj.static = False x = randtool("float", 0, 1, [2, 3, 4, 4]) in_channels = 3 out_channels = 1 @@ -43,7 +44,7 @@ def test_initializer_normal_base(): stride = 1 padding = 0 res = np.array( - [[[[9.696032, 6.2314734], [4.5925426, 19.060331]]], [[[14.223241, 13.581673], [6.131522, 9.923124]]]] + [[[[2.0433278, -0.2727771], [0.41961208, -5.5582423]]], [[[-1.3874869, -5.1710925], [3.2667, -2.1549852]]]] ) if paddle.device.is_compiled_with_cuda() is True: obj.base( @@ -65,6 +66,7 @@ def test_initializer_normal1(): kernel_size = [2, 2] stride = 2 padding=0 groups=3 weight_attr=paddle.nn.initializer.Normal(mean=0.0, std=2.0) """ + obj.dygraph = False np.random.seed(obj.seed) x = randtool("float", 0, 1, [2, 3, 4, 4]) in_channels = 3 @@ -100,6 +102,7 @@ def test_initializer_normal2(): kernel_size = [3, 3] stride = 1 padding=1 w=0.7 b=-0.3 data_format="NHWC" weight_attr=paddle.nn.initializer.Normal(mean=0.0, std=2.0) """ + obj.static = False np.random.seed(obj.seed) x = randtool("float", 0, 1, [2, 3, 4, 4]).transpose(0, 2, 3, 1) in_channels = 3 @@ -110,8 +113,8 @@ def test_initializer_normal2(): data_format = "NHWC" res = np.array( [ - [[[9.696032, 0.757347], [6.2314734, 1.9067024]], [[4.5925426, 0.7299702], [19.060331, 4.5685883]]], - [[[14.223241, 6.7473884], [13.581673, 4.739414]], [[6.131522, 1.6402493], [9.923124, 0.7511649]]], + [[[2.0433278, -8.995044], [-0.2727771, -1.7580405]], [[0.41961208, -8.936554], [-5.5582423, -10.978077]]], + [[[-1.3874869, -18.076727], [-5.1710925, -6.579859]], [[3.2667, -10.983443], [-2.1549852, -11.922855]]], ] ) if paddle.device.is_compiled_with_cuda() is True: @@ -135,6 +138,7 @@ def test_initializer_normal3(): padding_mode = "reflect" weight_attr=paddle.nn.initializer.Normal(mean=0.0, std=2.0) """ + obj.dygraph = False np.random.seed(obj.seed) x = randtool("float", 0, 1, [2, 3, 4, 4]) in_channels = 3 @@ -170,6 +174,7 @@ def test_initializer_normal4(): padding_mode = "replicate" weight_attr=paddle.nn.initializer.Normal(mean=-1.0, std=2.0) """ + obj.static = False np.random.seed(obj.seed) x = randtool("float", 0, 1, [2, 3, 4, 4]) in_channels = 3 @@ -180,8 +185,8 @@ def test_initializer_normal4(): padding_mode = "replicate" res = np.array( [ - [[[-0.25635287, 0.6774132, -3.2480803, -7.2378592], [-3.132905, -8.737241, 5.810273, -1.7762027]]], - [[[0.8862386, -0.61035603, 4.994542, -5.26088], [-6.272961, -9.037898, -3.7375047, -1.8376815]]], + [[[-19.855627, -16.224363, -5.913007, -7.2382164], [-9.950214, -12.91017, -18.8083, -12.357948]]], + [[[-9.542725, -13.213186, -14.944015, -10.585907], [-19.823824, -11.902721, -15.815616, -10.774846]]], ] ) if paddle.device.is_compiled_with_cuda() is True: @@ -205,6 +210,7 @@ def test_initializer_normal5(): padding_mode = "circular" weight_attr=paddle.nn.initializer.Normal(mean=2.0, std=5.0) """ + obj.dygraph = False np.random.seed(obj.seed) x = randtool("float", 0, 1, [2, 3, 4, 4]) in_channels = 3 @@ -240,6 +246,7 @@ def test_initializer_normal6(): padding_mode = "zeros" dilation = (2, 2) padding = [1, 2] weight_attr=paddle.nn.initializer.Normal(mean=-0.2, std=1.99) """ + obj.static = False np.random.seed(obj.seed) x = randtool("float", 0, 1, [2, 3, 4, 4]) in_channels = 3 @@ -249,7 +256,9 @@ def test_initializer_normal6(): padding = [1, 2] dilation = (2, 2) padding_mode = "zeros" - res = np.array([[[[6.9537334, 3.4081156, 2.5187492, 6.7148337]]], [[[3.6040933, 3.8371656, 2.5087252, 6.355131]]]]) + res = np.array( + [[[[-5.971743, 0.11934806, -5.1818447, -9.398735]]], [[[-5.281911, -2.1525862, -6.082208, -7.7175527]]]] + ) if paddle.device.is_compiled_with_cuda() is True: obj.run( res=res, diff --git a/framework/api/paddlebase/test_rand.py b/framework/api/paddlebase/test_rand.py index 9bb5be42d8..ec172c3071 100644 --- a/framework/api/paddlebase/test_rand.py +++ b/framework/api/paddlebase/test_rand.py @@ -64,7 +64,7 @@ def test_rand1(): """ obj.seed = 1 # res = np.array([[0, 7], [6, 0]]) - obj.exception(etype="NotFoundError", shape=[2, 2], dtype=np.int32) + obj.exception(etype="NotFound", shape=[2, 2], dtype=np.int32) @skip_platform_not_linux @@ -108,5 +108,5 @@ def test_rand5(): """ obj.places = [fluid.CUDAPlace(0)] obj.seed = 33 - res = np.array([[7.4177142e-04, 8.0607080e-01], [8.4463596e-01, 4.2317215e-01]]) + res = np.array([[0.7515413, 0.72745854], [0.7739062, 0.41597638]]) obj.run(res=res, shape=np.array([2, 2])) diff --git a/framework/api/paddlebase/test_randint.py b/framework/api/paddlebase/test_randint.py index 5a4a4f7347..8cc3ea68fe 100644 --- a/framework/api/paddlebase/test_randint.py +++ b/framework/api/paddlebase/test_randint.py @@ -11,7 +11,7 @@ import numpy as np sys.path.append("../..") -from utils.interceptor import skip_platform_not_linux +from utils.interceptor import skip_platform_not_linux, skip_not_compile_gpu class TestRandint(APIBase): @@ -34,13 +34,15 @@ def hook(self): obj = TestRandint(paddle.randint) +@skip_not_compile_gpu @skip_platform_not_linux @pytest.mark.api_base_randint_vartype def test_randint_base(): """ base """ - res = np.array([[9, 9], [5, 8]]) + obj.places = [paddle.CUDAPlace(0)] + res = np.array([[5, 4], [9, 2]]) obj.base(res=res, low=0, high=10, shape=[2, 2]) @@ -50,10 +52,12 @@ def test_randint(): """ default """ + obj.places = [paddle.CPUPlace()] res = np.array([[[9, 9], [5, 8], [3, 4]], [[9, 4], [4, 7], [2, 9]], [[8, 4], [6, 2], [9, 3]]]) obj.run(res=res, low=0, high=10, shape=[3, 3, 2]) +@skip_not_compile_gpu @skip_platform_not_linux @pytest.mark.api_base_randint_parameters def test_randint1(): @@ -61,7 +65,8 @@ def test_randint1(): seed = 1 """ obj.seed = 1 - res = np.array([[0, 7], [6, 0]]) + obj.places = [paddle.CUDAPlace(0)] + res = np.array([[2, 0], [9, 7]]) obj.run(res=res, low=0, high=10, shape=[2, 2]) @@ -82,6 +87,7 @@ def test_randint3(): dtype is int64 """ obj.seed = 1 + obj.places = [paddle.CPUPlace()] res = np.array([[0, 7], [6, 0]]) obj.run(res=res, low=0, high=10, shape=[2, 2], dtype=np.int64) @@ -93,7 +99,7 @@ def test_randint4(): exception dtype is float BUG """ # res = np.array([[9, 9], [5, 8]]) - obj.exception(etype="NotFoundError", low=0, high=10, shape=[2, 2], dtype=np.float32) + obj.exception(etype="NotFound", low=0, high=10, shape=[2, 2], dtype=np.float32) @skip_platform_not_linux @@ -103,7 +109,7 @@ def test_randint5(): exception low > high """ # res = np.array([[9, 9], [5, 8]]) - obj.exception(etype="InvalidArgumentError", low=100, high=10, shape=[2, 2]) + obj.exception(etype="InvalidArgument", low=100, high=10, shape=[2, 2]) @skip_platform_not_linux diff --git a/framework/api/paddlebase/test_randn.py b/framework/api/paddlebase/test_randn.py index 806dbc7282..7cd2627013 100644 --- a/framework/api/paddlebase/test_randn.py +++ b/framework/api/paddlebase/test_randn.py @@ -64,7 +64,7 @@ def test_randn1(): """ obj.seed = 1 # res = np.array([[0, 7], [6, 0]]) - obj.exception(etype="NotFoundError", shape=[2, 2], dtype=np.int32) + obj.exception(etype="NotFound", shape=[2, 2], dtype=np.int32) @skip_platform_not_linux @@ -108,5 +108,5 @@ def test_randn5(): """ obj.places = [fluid.CUDAPlace(0)] obj.seed = 1 - res = np.array([[-4.080414, -1.3719953], [0.2568497, 1.2351426]]) + res = np.array([[-0.296278, 2.676448], [-0.14084621, -0.84409523]]) obj.run(res=res, shape=np.array([2, 2])) diff --git a/framework/api/paddlebase/test_randperm.py b/framework/api/paddlebase/test_randperm.py index 71f75eca2c..46a79ead6c 100644 --- a/framework/api/paddlebase/test_randperm.py +++ b/framework/api/paddlebase/test_randperm.py @@ -12,7 +12,7 @@ import numpy as np sys.path.append("../..") -from utils.interceptor import skip_platform_not_linux +from utils.interceptor import skip_platform_not_linux, skip_not_compile_gpu class TestRandperm(APIBase): @@ -40,18 +40,21 @@ def test_randperm_base(): """ base """ + obj.places = [paddle.CPUPlace()] res = np.array([0, 1, 4, 3, 2, 5]) n = 6 obj.base(res=res, n=n) +@skip_not_compile_gpu @skip_platform_not_linux @pytest.mark.api_base_randperm_parameters def test_randperm(): """ default """ - res = np.array([9, 1, 7, 8, 2, 5, 6, 4, 3, 0]) + obj.places = [paddle.CUDAPlace(0)] + res = np.array([9, 4, 0, 7, 1, 5, 2, 3, 6, 8]) n = 10 obj.run(res=res, n=n) @@ -62,20 +65,23 @@ def test_randperm1(): """ seed = 1 """ + obj.places = [paddle.CPUPlace()] obj.seed = 1 res = np.array([6, 3, 7, 8, 9, 2, 1, 5, 4, 0]) n = 10 obj.run(res=res, n=n) +@skip_not_compile_gpu @skip_platform_not_linux @pytest.mark.api_base_randperm_parameters def test_randperm2(): """ dtype = np.float32 """ + obj.places = [paddle.CUDAPlace(0)] obj.seed = 33 - res = np.array([9.0, 1.0, 7.0, 8.0, 2.0, 5.0, 6.0, 4.0, 3.0, 0.0]) + res = np.array([9.0, 4.0, 0.0, 7.0, 1.0, 5.0, 2.0, 3.0, 6.0, 8.0]) n = 10 obj.run(res=res, n=n, dtype=np.float32) @@ -89,7 +95,7 @@ def test_randperm3(): obj.seed = 33 # res = np.array([0.0, 1.0, 6.0, 2.0, 9.0, 3.0, 5.0, 7.0, 4.0, 8.0]) n = -1 - obj.exception(etype="InvalidArgumentError", n=n, dtype=np.float32) + obj.exception(etype="InvalidArgument", n=n, dtype=np.float32) @skip_platform_not_linux @@ -101,4 +107,4 @@ def test_randperm4(): obj.seed = 33 # res = np.array([0.0, 1.0, 6.0, 2.0, 9.0, 3.0, 5.0, 7.0, 4.0, 8.0]) n = -1 - obj.exception(etype="NotFoundError", n=n, dtype=np.int8) + obj.exception(etype="NotFound", n=n, dtype=np.int8) diff --git a/framework/api/run_paddle_ci.sh b/framework/api/run_paddle_ci.sh index 2b31b23556..5e74f0375d 100644 --- a/framework/api/run_paddle_ci.sh +++ b/framework/api/run_paddle_ci.sh @@ -1,6 +1,7 @@ home=$PWD python3.7 -m pip install pytest python3.7 -m pip install scipy +export FLAGS_use_curand=1 case_dir_list=('fft' 'device' 'incubate' 'linalg' 'paddlebase' 'loss' 'nn' 'optimizer') result_array=() diff --git a/framework/run.sh b/framework/run.sh index 6890c99568..9a6063a9cb 100644 --- a/framework/run.sh +++ b/framework/run.sh @@ -2,7 +2,7 @@ home=$PWD echo "branch is ${AGILE_COMPILE_BRANCH}" python3.7 -m pip install pytest python3.7 -m pip install scipy - +export FLAGS_use_curand=1 # api cd api