From 73d8f574d19d6debdcff929a376e450365e2b14f Mon Sep 17 00:00:00 2001 From: JiangZhaoh Date: Tue, 18 Feb 2020 06:49:31 +0000 Subject: [PATCH] fix flaky --- 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 | 4 ++-- 3 files changed, 4 insertions(+), 4 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 5467758859e1..07aa37b1de66 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