From ab48a43e97d0fda62bdb2eb819b6d2d0fc796eb8 Mon Sep 17 00:00:00 2001 From: JiangZhaoh <54654391+JiangZhaoh@users.noreply.github.com> Date: Fri, 21 Feb 2020 03:00:17 +0800 Subject: [PATCH] Fix flaky - test_operator_gpu.test_np_insert (#17620) * fix flaky * retrigger CI --- src/operator/numpy/np_insert_op_slice-inl.h | 2 +- src/operator/numpy/np_insert_op_tensor-inl.h | 2 +- tests/python/unittest/test_numpy_op.py | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/operator/numpy/np_insert_op_slice-inl.h b/src/operator/numpy/np_insert_op_slice-inl.h index 2a255524f47c..fdcd618f19ba 100644 --- a/src/operator/numpy/np_insert_op_slice-inl.h +++ b/src/operator/numpy/np_insert_op_slice-inl.h @@ -171,7 +171,7 @@ void NumpyInsertSliceCompute(const nnvm::NodeAttrs& attrs, Tensor indices(indices_ptr, Shape1(indices_len), s); Tensor sorted_indices(sorted_indices_ptr, Shape1(indices_len), s); Tensor order(order_ptr, Shape1(indices_len), s); - int num_bits = common::ilog2ui(static_cast(indices_len) - 1); + int num_bits = 8 * sizeof(int64_t); Kernel::Launch(s, indices_len, indices_ptr, start, step); Kernel::Launch(s, indices_len, 1, 0, 1, kWriteTo, order_ptr); mxnet::op::SortByKey(indices, order, true, &temp_storage, 0, num_bits, &sorted_indices); diff --git a/src/operator/numpy/np_insert_op_tensor-inl.h b/src/operator/numpy/np_insert_op_tensor-inl.h index 1c830717760a..f55136df04bf 100644 --- a/src/operator/numpy/np_insert_op_tensor-inl.h +++ b/src/operator/numpy/np_insert_op_tensor-inl.h @@ -199,7 +199,7 @@ void NumpyInsertTensorCompute(const nnvm::NodeAttrs& attrs, Tensor indices(indices_ptr, Shape1(indices_len), s); Tensor sorted_indices(sorted_indices_ptr, Shape1(indices_len), s); Tensor order(order_ptr, Shape1(indices_len), s); - int num_bits = common::ilog2ui(static_cast(indices_len) - 1); + int num_bits = 8 * sizeof(int64_t); Kernel::Launch(s, indices_len, indices_ptr, N, inputs[obj_pos].dptr()); Kernel::Launch(s, indices_len, 1, 0, 1, kWriteTo, order_ptr); diff --git a/tests/python/unittest/test_numpy_op.py b/tests/python/unittest/test_numpy_op.py index 12d2e4a9776a..45b64c26bb88 100644 --- a/tests/python/unittest/test_numpy_op.py +++ b/tests/python/unittest/test_numpy_op.py @@ -2661,7 +2661,7 @@ def GetNdim(tp): E = (1) F = (3, 1) G = (3, 2) - H = (5, 2, 3, 4) + H = (2, 2, 3, 8) config = [] # test scale index for idx in range(-1 * GetSize(A), GetSize(A) + 1): @@ -2705,7 +2705,7 @@ def GetNdim(tp): config.append(tuple([H, 0, 1, 3])) config.append(tuple([H, [1], E, 2])) config.append(tuple([H, [1], 1, 2])) - idx = _np.random.randint(-1 * H[3], H[3] + 1, size = (3)).tolist() + idx = _np.random.randint(-1 * H[3], H[3] + 1, size = (5)).tolist() config.append(tuple([H, idx, E, 3])) config.append(tuple([H, idx, 1, 3])) # test slice @@ -2728,9 +2728,9 @@ def GetNdim(tp): obj_onp = obj test_insert = TestInsert(obj=obj_mxnp, axis=axis) - a = mx.nd.random.uniform(-1.0, 1.0, shape=arr_shape).as_np_ndarray().astype(atype) + a = mx.nd.random.uniform(-10.0, 10.0, shape=arr_shape).as_np_ndarray().astype(atype) a.attach_grad() - b = mx.nd.random.uniform(-1.0, 1.0, shape=val_shape).as_np_ndarray().astype(btype) + b = mx.nd.random.uniform(-10.0, 10.0, shape=val_shape).as_np_ndarray().astype(btype) b.attach_grad() expected_ret = _np.insert(a.asnumpy(), obj_onp, b.asnumpy(), axis=axis) with mx.autograd.record():