From f020e19636b66d693a22094a6f084f710bd83835 Mon Sep 17 00:00:00 2001 From: Peilin Wang Date: Thu, 3 Sep 2020 23:42:22 -0400 Subject: [PATCH] add int32 support to greater gpu kernel fix ci --- .../kernel_compiler/gpu/math/broadcast_gpu_kernel.cc | 3 +++ tests/st/ops/gpu/test_broadcast_op.py | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/mindspore/ccsrc/backend/kernel_compiler/gpu/math/broadcast_gpu_kernel.cc b/mindspore/ccsrc/backend/kernel_compiler/gpu/math/broadcast_gpu_kernel.cc index 6109f72e8e..850a1c7da4 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/gpu/math/broadcast_gpu_kernel.cc +++ b/mindspore/ccsrc/backend/kernel_compiler/gpu/math/broadcast_gpu_kernel.cc @@ -109,6 +109,9 @@ MS_REG_GPU_KERNEL_ONE( BroadcastOpGpuKernel, half) // int32 +MS_REG_GPU_KERNEL_ONE( + Greater, KernelAttr().AddInputAttr(kNumberTypeInt32).AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeBool), + BroadcastOpGpuKernel, int) MS_REG_GPU_KERNEL_ONE( Less, KernelAttr().AddInputAttr(kNumberTypeInt32).AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeBool), BroadcastOpGpuKernel, int) diff --git a/tests/st/ops/gpu/test_broadcast_op.py b/tests/st/ops/gpu/test_broadcast_op.py index 4681b608b5..6de4c2b1e2 100644 --- a/tests/st/ops/gpu/test_broadcast_op.py +++ b/tests/st/ops/gpu/test_broadcast_op.py @@ -43,6 +43,9 @@ def test_nobroadcast(): output_ms = P.Greater()(Tensor(x1_np), Tensor(x2_np)) output_np = x1_np > x2_np assert np.allclose(output_ms.asnumpy(), output_np) + output_ms = P.Greater()(Tensor(x1_np_int32), Tensor(x2_np_int32)) + output_np = x1_np_int32 > x2_np_int32 + assert np.allclose(output_ms.asnumpy(), output_np) output_ms = P.Less()(Tensor(x1_np), Tensor(x2_np)) output_np = x1_np < x2_np @@ -132,6 +135,9 @@ def test_broadcast(): output_ms = P.Greater()(Tensor(x1_np), Tensor(x2_np)) output_np = x1_np > x2_np assert np.allclose(output_ms.asnumpy(), output_np) + output_ms = P.Greater()(Tensor(x1_np_int32), Tensor(x2_np_int32)) + output_np = x1_np_int32 > x2_np_int32 + assert np.allclose(output_ms.asnumpy(), output_np) output_ms = P.Less()(Tensor(x1_np), Tensor(x2_np)) output_np = x1_np < x2_np @@ -175,6 +181,9 @@ def test_broadcast_diff_dims(): output_ms = P.Maximum()(Tensor(x1_np), Tensor(x2_np)) output_np = np.maximum(x1_np, x2_np) assert np.allclose(output_ms.asnumpy(), output_np) + output_ms = P.Greater()(Tensor(x1_np_int32), Tensor(x2_np_int32)) + output_np = x1_np_int32 > x2_np_int32 + assert np.allclose(output_ms.asnumpy(), output_np) output_ms = P.Greater()(Tensor(x1_np), Tensor(x2_np)) output_np = x1_np > x2_np