From 7b6066eb4b6f78e6c7fb90790e36043981396da7 Mon Sep 17 00:00:00 2001 From: Rohit Kumar Srivastava Date: Tue, 10 Sep 2019 21:25:33 -0700 Subject: [PATCH] Reducing memory footprint of one_hot for Large Array Testing (#16136) * reducing memory footprint of one_hot for Large Tensor * removing one_hot from large_vector and changing large_array test to incorporate large vector part of the test --- tests/nightly/test_large_array.py | 10 +++++----- tests/nightly/test_large_vector.py | 9 --------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/tests/nightly/test_large_array.py b/tests/nightly/test_large_array.py index 7622b76a3120..99856f770d5c 100644 --- a/tests/nightly/test_large_array.py +++ b/tests/nightly/test_large_array.py @@ -25,6 +25,7 @@ # dimension constants MEDIUM_X = 10000 +VLARGE_X = 4300000000 LARGE_X = 100000000 SMALL_X = 100 SMALL_Y = 50 @@ -1197,12 +1198,11 @@ def test_slice_axis(): def test_one_hot(): - a = nd.array(np.zeros(SMALL_Y)) - a[0] = 1 - a[-1] = 1 - b = nd.one_hot(a, LARGE_X) + #default dtype of ndarray is float32 which cannot index elements over 2^32 + a = nd.array([1, (VLARGE_X - 1)], dtype=np.int64) + b = nd.one_hot(a, VLARGE_X) b[0][1] == 1 - b[-1][1] == 1 + b[1][-1] == 1 def test_full(): diff --git a/tests/nightly/test_large_vector.py b/tests/nightly/test_large_vector.py index b59a4462d922..e3407792f2da 100644 --- a/tests/nightly/test_large_vector.py +++ b/tests/nightly/test_large_vector.py @@ -714,15 +714,6 @@ def test_full(): assert a[-1] == 3 -def test_one_hot(): - a = nd.zeros(10) - a[0] = 1 - a[-1] = 1 - b = nd.one_hot(a, LARGE_X) - assert b[0][1] == 1 - assert b[-1][1] == 1 - - if __name__ == '__main__': import nose nose.runmodule()