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

Commit 2838fea

Browse files
author
Rohit Kumar Srivastava
committed
reducing memory footprint of one_hot for Large Tensor
1 parent 9675a2d commit 2838fea

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tests/nightly/test_large_vector.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -715,12 +715,13 @@ def test_full():
715715

716716

717717
def test_one_hot():
718-
a = nd.zeros(10)
719-
a[0] = 1
720-
a[-1] = 1
718+
#default dtype of ndarray is float32 which cannot index elements over 2^32
719+
a = nd.array([1], dtype=np.int64)
721720
b = nd.one_hot(a, LARGE_X)
722721
assert b[0][1] == 1
723-
assert b[-1][1] == 1
722+
a = nd.array([LARGE_X-1], dtype=np.int64)
723+
b = nd.one_hot(a, LARGE_X)
724+
assert b[0][-1] == 1
724725

725726

726727
if __name__ == '__main__':

0 commit comments

Comments
 (0)