-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Fix NDArrayIter cant pad when size is large #17001
Conversation
python/mxnet/io/io.py
Outdated
if pad > self.num_data: | ||
while True: | ||
if pad <= self.num_data: | ||
break | ||
second_data = self._getdata(data_source, end=self.num_data) | ||
second_data = self._concat(second_data, self._getdata(data_source, end=self.num_data)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can it be replaced with nd.repeat, in order to remove Python while-loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea
7d21b43
to
84d95df
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you!
python/mxnet/io/io.py
Outdated
@@ -709,23 +709,29 @@ def _getdata(self, data_source, start=None, end=None): | |||
|
|||
def _concat(self, first_data, second_data): | |||
"""Helper function to concat two NDArrays.""" | |||
if (not first_data) and (not second_data): | |||
return [] | |||
elif (not first_data) or (not second_data): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The four lines 712 to 715 could be replaced with the line 714 to 715.
if not first_data or not second_data:
return first_data if first_data else second_data
When first_data and second_data are both [], it will return [] too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
84d95df
to
a081fe6
Compare
Description
Fixes #16996
Checklist
Essentials
Please feel free to remove inapplicable items for your PR.
Changes
Comments
@samskalicky