Skip to content

Commit 4e508f7

Browse files
access2rohitRohit Kumar Srivastava
authored andcommitted
Reducing memory footprint of one_hot for Large Array Testing (apache#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
1 parent 0c942ca commit 4e508f7

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

tests/nightly/test_large_array.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
# dimension constants
2727
MEDIUM_X = 10000
28+
VLARGE_X = 4300000000
2829
LARGE_X = 100000000
2930
SMALL_X = 100
3031
SMALL_Y = 50
@@ -1197,12 +1198,11 @@ def test_slice_axis():
11971198

11981199

11991200
def test_one_hot():
1200-
a = nd.array(np.zeros(SMALL_Y))
1201-
a[0] = 1
1202-
a[-1] = 1
1203-
b = nd.one_hot(a, LARGE_X)
1201+
#default dtype of ndarray is float32 which cannot index elements over 2^32
1202+
a = nd.array([1, (VLARGE_X - 1)], dtype=np.int64)
1203+
b = nd.one_hot(a, VLARGE_X)
12041204
b[0][1] == 1
1205-
b[-1][1] == 1
1205+
b[1][-1] == 1
12061206

12071207

12081208
def test_full():

tests/nightly/test_large_vector.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -714,15 +714,6 @@ def test_full():
714714
assert a[-1] == 3
715715

716716

717-
def test_one_hot():
718-
a = nd.zeros(10)
719-
a[0] = 1
720-
a[-1] = 1
721-
b = nd.one_hot(a, LARGE_X)
722-
assert b[0][1] == 1
723-
assert b[-1][1] == 1
724-
725-
726717
if __name__ == '__main__':
727718
import nose
728719
nose.runmodule()

0 commit comments

Comments
 (0)