diff --git a/framework/api/multithreading_case.py b/framework/api/multithreading_case.py index 1146fb4405..9a22808693 100644 --- a/framework/api/multithreading_case.py +++ b/framework/api/multithreading_case.py @@ -41,11 +41,12 @@ "paddlebase": [ "test_fill_diagonal_tensor.py", "test_multiplex.py", - "test_all.py", - "test_any.py", - "test_max.py", - "test_min.py", - "test_prod.py", + "test_sum.py", + "test_mean.py", + "test_nansum.py", + "test_Tensor_nansum.py", + "test_var.py", + "test_std.py", "test_Tensor_inner.py", "test_dot.py", "test_inner.py", diff --git a/framework/api/nn/rnn_base.py b/framework/api/nn/rnn_base.py index 62dc8492e1..f9a33f1f23 100644 --- a/framework/api/nn/rnn_base.py +++ b/framework/api/nn/rnn_base.py @@ -94,7 +94,7 @@ def numerical_gradients(self): tmp0, tmp1 = paddle.to_tensor(tmp0), paddle.to_tensor(tmp1) r1, r2 = self.solve_loss(tmp0), self.solve_loss(tmp1) g = (r1 - r2) / (2 * self.gap) - gradients.append(g[0]) + gradients.append(g.item()) return np.array(gradients).reshape(shape) def solve_loss(self, inputs): diff --git a/framework/api/paddlebase/test_all.py b/framework/api/paddlebase/test_all.py index 729c74ba49..ec307f9c1c 100644 --- a/framework/api/paddlebase/test_all.py +++ b/framework/api/paddlebase/test_all.py @@ -37,7 +37,7 @@ def test_all0(): default """ x = np.random.randint(-4, 4, (10,)) - res = np.array([np.all(x)]) + res = np.all(x) obj.base(res=res, x=x) @@ -47,7 +47,7 @@ def test_all1(): x: 2d-tensor """ x = np.random.randint(-4, 4, (10, 10)) - res = np.array([np.all(x)]) + res = np.all(x) obj.base(res=res, x=x) @@ -57,7 +57,7 @@ def test_all2(): x: 3d-tensor """ x = np.random.randint(-4, 4, (3, 4, 2)) - res = np.array([np.all(x)]) + res = np.all(x) obj.base(res=res, x=x) @@ -67,7 +67,7 @@ def test_all3(): x: 4d-tensor """ x = np.random.randint(-4, 4, (2, 4, 4, 2)) - res = np.array([np.all(x)]) + res = np.all(x) obj.base(res=res, x=x) diff --git a/framework/api/paddlebase/test_any.py b/framework/api/paddlebase/test_any.py index b4da059d40..a8262b7d98 100644 --- a/framework/api/paddlebase/test_any.py +++ b/framework/api/paddlebase/test_any.py @@ -37,7 +37,7 @@ def test_any0(): default """ x = np.random.randint(-4, 4, (10,)) - res = np.array([np.any(x)]) + res = np.any(x) obj.base(res=res, x=x) @@ -47,7 +47,7 @@ def test_any1(): x: 2d-tensor """ x = np.random.randint(-4, 4, (10, 10)) - res = np.array([np.any(x)]) + res = np.any(x) obj.base(res=res, x=x) @@ -57,7 +57,7 @@ def test_any2(): x: 3d-tensor """ x = np.random.randint(-4, 4, (3, 4, 2)) - res = np.array([np.any(x)]) + res = np.any(x) obj.base(res=res, x=x) @@ -67,7 +67,7 @@ def test_any3(): x: 4d-tensor """ x = np.random.randint(-4, 4, (2, 4, 4, 2)) - res = np.array([np.any(x)]) + res = np.any(x) obj.base(res=res, x=x) diff --git a/framework/api/paddlebase/test_max.py b/framework/api/paddlebase/test_max.py index 42aaeece81..c5d773d55a 100644 --- a/framework/api/paddlebase/test_max.py +++ b/framework/api/paddlebase/test_max.py @@ -37,7 +37,7 @@ def test_max_base(): max_base """ x_data = np.arange(6).reshape(2, 3).astype(np.float32) - res = np.array([5]) + res = np.max(x_data) obj.base(res=res, x=x_data) @@ -47,7 +47,7 @@ def test_max_2D_tensor(): max_2D_tensor """ x_data = np.arange(6).reshape(2, 3).astype(np.float32) - res = np.array([5]) + res = np.max(x_data) obj.run(res=res, x=x_data) @@ -112,5 +112,6 @@ def test_max_1(): special input """ x_data = np.array([[-1.00595951, -0.20009832], [-0.35623679, -0.95880121]]) - res = np.array([-0.20009832]) + res = np.max(x_data) + np.array(-0.20009832) obj.run(res=res, x=x_data, axis=[-2, 1], keepdim=False) diff --git a/framework/api/paddlebase/test_min.py b/framework/api/paddlebase/test_min.py index 52350dceb1..7e36015cef 100644 --- a/framework/api/paddlebase/test_min.py +++ b/framework/api/paddlebase/test_min.py @@ -37,7 +37,7 @@ def test_min_base(): min_base """ x_data = np.arange(6).reshape(2, 3).astype(np.float32) - res = np.array([0]) + res = np.min(x_data) obj.base(res=res, x=x_data) @@ -47,7 +47,7 @@ def test_min_2D_tensor(): min_2D_tensor """ x_data = np.arange(6).reshape(2, 3).astype(np.float32) - res = np.array([0]) + res = np.min(x_data) obj.run(res=res, x=x_data) @@ -99,7 +99,7 @@ def test_min_1(): special input """ x_data = np.array([[-1.00595951, -0.20009832], [-0.35623679, -0.95880121]]) - res = np.array([-1.00595951]) + res = np.min(x_data) obj.run(res=res, x=x_data, axis=[-2, 1], keepdim=False) diff --git a/framework/api/paddlebase/test_prod.py b/framework/api/paddlebase/test_prod.py index c9972b9af8..17bd06e72f 100644 --- a/framework/api/paddlebase/test_prod.py +++ b/framework/api/paddlebase/test_prod.py @@ -34,7 +34,7 @@ def test_prod_base(): axis=None """ x = np.array([[0.8, 0.4], [0.7, 0.9]]) - res = [np.prod(x)] + res = np.prod(x) obj.base(res=res, x=x) @@ -56,7 +56,7 @@ def test_prod2(): """ x = np.array([[0.8, 0.4], [0.7, 0.9]]) axis = 3 - obj.exception(mode="c", etype="InvalidArgumentError", x=x, axis=axis) + obj.exception(mode="c", etype="InvalidArgument", x=x, axis=axis) @pytest.mark.api_base_prod_parameters @@ -77,7 +77,7 @@ def test_prod4(): """ x = np.array([[0.8, 0.4], [0.7, 0.9]]) axis = [0, 1] - res = [0.2016] + res = np.array(0.2016) obj.run(res=res, x=x, axis=axis) @@ -88,7 +88,7 @@ def test_prod5(): """ x = np.array([[0.8, 0.4], [0.7, 0.9]]) axis = (0, 1) - res = [0.2016] + res = np.array(0.2016) obj.run(res=res, x=x, axis=axis) @@ -98,7 +98,7 @@ def test_prod6(): dtype=float32 """ x = np.array([[0.8, 0.4], [0.7, 0.9]]) - res = [np.prod(x)] + res = np.prod(x) obj.base(res=res, x=x, dtype="float32") @@ -134,7 +134,7 @@ def test_prod8(): dtype=int64 """ x = np.array([[8, 4], [7, 9]]) - res = [np.prod(x)] + res = np.prod(x) obj1.base(res=res, x=x, dtype="int64") @@ -144,7 +144,7 @@ def test_prod9(): input is int32, int64 """ x = np.array([[3, 5], [6, 2]]) - res = [np.prod(x)] + res = np.prod(x) obj1.run(res=res, x=x)