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

Commit

Permalink
make MXDataIter work without indices (#7456)
Browse files Browse the repository at this point in the history
indices are optional, custom cpp iterators providing data batches
without indices should work while using MXDataIter.
  • Loading branch information
saswatac authored and piiswrong committed Aug 24, 2017
1 parent b710636 commit 4b94360
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions python/mxnet/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,10 +815,13 @@ def getindex(self):
check_call(_LIB.MXDataIterGetIndex(self.handle,
ctypes.byref(index_data),
ctypes.byref(index_size)))
address = ctypes.addressof(index_data.contents)
dbuffer = (ctypes.c_uint64* index_size.value).from_address(address)
np_index = np.frombuffer(dbuffer, dtype=np.uint64)
return np_index.copy()
if index_size.value:
address = ctypes.addressof(index_data.contents)
dbuffer = (ctypes.c_uint64* index_size.value).from_address(address)
np_index = np.frombuffer(dbuffer, dtype=np.uint64)
return np_index.copy()
else:
return None

def getpad(self):
pad = ctypes.c_int(0)
Expand Down

0 comments on commit 4b94360

Please sign in to comment.