From 8818deaf7463722cd6f54ecd9e1bb2375444b81f Mon Sep 17 00:00:00 2001 From: Chaitanya Prakash Bapat Date: Sat, 23 Feb 2019 03:13:48 -0500 Subject: [PATCH 1/3] large array support for randint --- src/operator/random/sampler.h | 4 ++-- tests/nightly/test_large_array.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/operator/random/sampler.h b/src/operator/random/sampler.h index 00963a6785ee..1a9bf7a4d169 100644 --- a/src/operator/random/sampler.h +++ b/src/operator/random/sampler.h @@ -96,8 +96,8 @@ struct UniformSampler { template struct SampleRandIntKernel { template - MSHADOW_XINLINE static void Map(int id, RandGenerator gen, - const int N, const int step, + MSHADOW_XINLINE static void Map(index_t id, RandGenerator gen, + const index_t N, const index_t step, index_t nParm, index_t nSample, const IType *lower, const IType *upper, OType *out) { RNG_KERNEL_LOOP(xpu, OType, id, gen, N, step, { diff --git a/tests/nightly/test_large_array.py b/tests/nightly/test_large_array.py index 0249f44932c2..69fe3bc2bae4 100644 --- a/tests/nightly/test_large_array.py +++ b/tests/nightly/test_large_array.py @@ -49,6 +49,17 @@ def test_ndarray_random_uniform(): a = nd.random.uniform(shape=(LARGE_X, SMALL_Y)) assert a[-1][0] != 0 +def test_ndarray_random_randint(): + a = nd.random.randint(100, 10000, shape=(LARGE_X, SMALL_Y)) + assert a.shape == (LARGE_X, SMALL_Y) + # check if randint can generate value greater than 2**32 (large) + low_large_value = 2**32 + high_large_value = 2**34 + a = nd.random.randint(low_large_value,high_large_value) + low = mx.nd.array([low_large_value],dtype='int64') + high = mx.nd.array([high_large_value],dtype='int64') + assert a.__gt__(low) & a.__lt__(high) + def test_ndarray_empty(): a = nd.empty((LARGE_X, SMALL_Y)) assert a.shape == (LARGE_X, SMALL_Y) From 482fdefe8a80bab12f892627f1d1ecb2e24902d5 Mon Sep 17 00:00:00 2001 From: Chaitanya Prakash Bapat Date: Sun, 24 Feb 2019 16:55:15 -0500 Subject: [PATCH 2/3] with seed for 2 random large array tests --- tests/nightly/test_large_array.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/nightly/test_large_array.py b/tests/nightly/test_large_array.py index 69fe3bc2bae4..a627467cb959 100644 --- a/tests/nightly/test_large_array.py +++ b/tests/nightly/test_large_array.py @@ -18,6 +18,7 @@ import mxnet as mx import numpy as np from mxnet import gluon, nd +from tests.python.unittest.common import with_seed # dimension constants MEDIUM_X = 10000 @@ -45,10 +46,12 @@ def test_ndarray_ones(): assert a[-1][0] == 1 assert nd.sum(a).asnumpy() == LARGE_SIZE +@with_seed() def test_ndarray_random_uniform(): a = nd.random.uniform(shape=(LARGE_X, SMALL_Y)) assert a[-1][0] != 0 +@with_seed() def test_ndarray_random_randint(): a = nd.random.randint(100, 10000, shape=(LARGE_X, SMALL_Y)) assert a.shape == (LARGE_X, SMALL_Y) From b30c37d3577a10ef4c0baeb70ae658d87a8dbaad Mon Sep 17 00:00:00 2001 From: Chaitanya Prakash Bapat Date: Fri, 1 Mar 2019 01:11:30 -0500 Subject: [PATCH 3/3] Trigger notification