From 5cfab3b1a89c13e67676a71f5e1189faf1ad6f5f Mon Sep 17 00:00:00 2001 From: shibeiji Date: Tue, 13 Apr 2021 14:50:39 +0800 Subject: [PATCH] fix code review alarms --- .../cpu/minimum_grad_cpu_kernel.cc | 9 +++++---- tests/st/ops/cpu/test_minimum_grad_op.py | 4 ++-- tests/st/ops/cpu/test_minimum_op.py | 18 +++++++++--------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/mindspore/ccsrc/backend/kernel_compiler/cpu/minimum_grad_cpu_kernel.cc b/mindspore/ccsrc/backend/kernel_compiler/cpu/minimum_grad_cpu_kernel.cc index a6d3847684..239e5763f1 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/cpu/minimum_grad_cpu_kernel.cc +++ b/mindspore/ccsrc/backend/kernel_compiler/cpu/minimum_grad_cpu_kernel.cc @@ -83,10 +83,11 @@ bool MinimumGradCPUKernel::Launch(const std::vector &inputs, } template -void MinimumGradRecTask(T *x, T *y, T *dout, T *dx, T *dy, size_t dim, size_t x_index, size_t y_index, - size_t dout_index, const std::vector &x_cargo, const std::vector &y_cargo, - const std::vector &dout_cargo, const std::vector &x_shape, - const std::vector &y_shape, const std::vector &dout_shape) { +void MinimumGradRecTask(const T *x, const T *y, const T *dout, T *dx, T *dy, const size_t dim, const size_t x_index, + const size_t y_index, const size_t dout_index, const std::vector &x_cargo, + const std::vector &y_cargo, const std::vector &dout_cargo, + const std::vector &x_shape, const std::vector &y_shape, + const std::vector &dout_shape) { for (size_t i = 0; i < dout_shape[dim]; i++) { size_t x_i = x_shape[dim] == dout_shape[dim] ? i * x_cargo[dim] : 0; size_t y_i = y_shape[dim] == dout_shape[dim] ? i * y_cargo[dim] : 0; diff --git a/tests/st/ops/cpu/test_minimum_grad_op.py b/tests/st/ops/cpu/test_minimum_grad_op.py index 0f0d7eb096..95e2ec071c 100644 --- a/tests/st/ops/cpu/test_minimum_grad_op.py +++ b/tests/st/ops/cpu/test_minimum_grad_op.py @@ -64,7 +64,7 @@ def gen_data(inputA_np, inputB_np, grad_=None): @pytest.mark.level0 -@pytest.mark.platform_x86_cpu_training +@pytest.mark.platform_x86_cpu @pytest.mark.env_onecard def test_min_tensor_grad_4d(): inputA_np = np.random.randn(1, 3, 2, 2).astype(np.float32) @@ -76,7 +76,7 @@ def test_min_tensor_grad_4d(): @pytest.mark.level0 -@pytest.mark.platform_x86_cpu_training +@pytest.mark.platform_x86_cpu @pytest.mark.env_onecard def test_min_tensor_grad_result(): inputA = np.array([[[[0.659578], [0.49113268], [0.75909054], [0.71681815], [0.30421826]]], diff --git a/tests/st/ops/cpu/test_minimum_op.py b/tests/st/ops/cpu/test_minimum_op.py index 0009c5c07a..d99ab22ca8 100644 --- a/tests/st/ops/cpu/test_minimum_op.py +++ b/tests/st/ops/cpu/test_minimum_op.py @@ -42,7 +42,7 @@ class TwoTensorsMinimum(Cell): @pytest.mark.level0 -@pytest.mark.platform_x86_cpu_training +@pytest.mark.platform_x86_cpu @pytest.mark.env_onecard def test_minimum_constScalar_tensor_int(): x = Tensor(np.array([[2, 3, 4], [100, 200, 300]]).astype(np.int32)) @@ -55,7 +55,7 @@ def test_minimum_constScalar_tensor_int(): @pytest.mark.level0 -@pytest.mark.platform_x86_cpu_training +@pytest.mark.platform_x86_cpu @pytest.mark.env_onecard def test_minimum_two_tensors_Not_Broadcast_int(): prop = 100 if np.random.random() > 0.5 else -100 @@ -70,7 +70,7 @@ def test_minimum_two_tensors_Not_Broadcast_int(): @pytest.mark.level0 -@pytest.mark.platform_x86_cpu_training +@pytest.mark.platform_x86_cpu @pytest.mark.env_onecard def test_minimum_two_tensors_Broadcast_int(): prop = 100 if np.random.random() > 0.5 else -100 @@ -85,7 +85,7 @@ def test_minimum_two_tensors_Broadcast_int(): @pytest.mark.level0 -@pytest.mark.platform_x86_cpu_training +@pytest.mark.platform_x86_cpu @pytest.mark.env_onecard def test_minimum_two_tensors_Broadcast_oneDimension_int(): prop = 100 if np.random.random() > 0.5 else -100 @@ -100,7 +100,7 @@ def test_minimum_two_tensors_Broadcast_oneDimension_int(): @pytest.mark.level0 -@pytest.mark.platform_x86_cpu_training +@pytest.mark.platform_x86_cpu @pytest.mark.env_onecard def test_minimum_two_tensors_notBroadcast_all_oneDimension_int(): x = Tensor(np.array([[2]]).astype(np.int32)) @@ -114,7 +114,7 @@ def test_minimum_two_tensors_notBroadcast_all_oneDimension_int(): @pytest.mark.level0 -@pytest.mark.platform_x86_cpu_training +@pytest.mark.platform_x86_cpu @pytest.mark.env_onecard def test_minimum_two_tensors_notBroadcast_float32(): prop = 100 if np.random.random() > 0.5 else -100 @@ -132,7 +132,7 @@ def test_minimum_two_tensors_notBroadcast_float32(): @pytest.mark.level0 -@pytest.mark.platform_x86_cpu_training +@pytest.mark.platform_x86_cpu @pytest.mark.env_onecard def test_minimum_two_tensors_notBroadcast_float16(): prop = 100 if np.random.random() > 0.5 else -100 @@ -150,7 +150,7 @@ def test_minimum_two_tensors_notBroadcast_float16(): @pytest.mark.level0 -@pytest.mark.platform_x86_cpu_training +@pytest.mark.platform_x86_cpu @pytest.mark.env_onecard def test_minimum_two_tensors_Broadcast_float16(): prop = 100 if np.random.random() > 0.5 else -100 @@ -168,7 +168,7 @@ def test_minimum_two_tensors_Broadcast_float16(): @pytest.mark.level0 -@pytest.mark.platform_x86_cpu_training +@pytest.mark.platform_x86_cpu @pytest.mark.env_onecard def test_minimum_two_tensors_notBroadcast_float64(): prop = 100 if np.random.random() > 0.5 else -100