Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Fix crash in random.shuffle operator #15041

Merged
merged 7 commits into from
May 23, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/operator/random/shuffle_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ namespace {
template<typename DType, typename Rand>
void Shuffle1D(DType* const out, const index_t size, Rand* const prnd) {
#ifdef USE_GNU_PARALLEL_SHUFFLE
auto rand_n = [prnd](index_t n) {
std::uniform_int_distribution<index_t> dist(0, n - 1);
auto rand_n = [prnd](uint32_t n) {
std::uniform_int_distribution<uint32_t> dist(0, n - 1);
return dist(*prnd);
};
__gnu_parallel::random_shuffle(out, out + size, rand_n);
Expand Down
3 changes: 3 additions & 0 deletions tests/python/unittest/test_random.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,9 +864,12 @@ def testLarge(data, repeat):
testSmall(mx.nd.arange(0, 3), 100, 40000)
testSmall(mx.nd.arange(0, 9).reshape((3, 3)), 100, 40000)
testSmall(mx.nd.arange(0, 18).reshape((3, 2, 3)), 100, 40000)
testSmall(mx.nd.arange(0, 10), 100, 40000)
# Test larger arrays
testLarge(mx.nd.arange(0, 100000).reshape((10, 10000)), 10)
testLarge(mx.nd.arange(0, 100000).reshape((10000, 10)), 10)
testLarge(mx.nd.arange(0, 100000), 10)


@with_seed()
def test_randint():
Expand Down