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

Fix NDArrayIter cant pad when size is large #17001

Merged
merged 2 commits into from
Dec 9, 2019

Conversation

stu1130
Copy link
Contributor

@stu1130 stu1130 commented Dec 7, 2019

Description

Fixes #16996

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to the relevant JIRA issue created (except PRs with tiny changes)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
  • Code is well-documented:
  • For user-facing API changes, API doc string has been updated.
  • For new C++ functions in header files, their functionalities and arguments are documented.
  • For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
  • Check the API doc at https://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

  • Feature1, tests, (and when applicable, API doc)
  • Feature2, tests, (and when applicable, API doc)

Comments

@samskalicky

@stu1130 stu1130 requested a review from szha as a code owner December 7, 2019 00:41
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))
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea

Copy link
Member

@wkcn wkcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you!

@@ -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):
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@roywei roywei merged commit 251e6f6 into apache:master Dec 9, 2019
@stu1130 stu1130 deleted the fix_scala_env branch January 21, 2020 23:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mx.io.NDArrayIter cant pad when size is large
3 participants