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

[MXNET-283] Error handling for non-positive reps of tile op #10417

Merged

Conversation

reminisce
Copy link
Contributor

Description

Address this issue.
#10288

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 http://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

  • If this change is a backward incompatible change, why must this change be made.
  • Interesting edge cases to note here

@@ -1462,6 +1463,10 @@ inline bool TileOpShape(const nnvm::NodeAttrs& attrs,
SHAPE_ASSIGN_CHECK(*out_attrs, 0, ishape);
return true;
}
// fix for https://github.com/apache/incubator-mxnet/issues/10288
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to put this in comment

def test_zero_reps():
a = np.array([[2, 3, 4], [5, 6, 7]], dtype=np.int32)
b = mx.nd.array(a, ctx=default_context(), dtype=a.dtype)
reps = (2, 0, 4, 5)
Copy link
Contributor

Choose a reason for hiding this comment

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

why was this supported previously? What was the behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would return an empty NDArray with some dim size equal to zero. I was following the NumPy's convention to implement the behavior. Since MXNet does not support empty NDArrays in any way, I think it's okay to move this to assert_exception test?

@@ -1462,6 +1463,10 @@ inline bool TileOpShape(const nnvm::NodeAttrs& attrs,
SHAPE_ASSIGN_CHECK(*out_attrs, 0, ishape);
return true;
}
// fix for https://github.com/apache/incubator-mxnet/issues/10288
for (size_t i = 0; i < reps.ndim(); ++i) {
CHECK_GT(reps[i], 0) << "invalid reps[" << i << "], dim size must be greater than zero";
Copy link
Contributor

Choose a reason for hiding this comment

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

"invalid reps=i" instead of "invalid reps[i]"

@reminisce reminisce force-pushed the add_error_handling_for_reps_tile_op branch from 392e834 to 49e69ad Compare April 6, 2018 05:59
@reminisce reminisce changed the title Error handling for non-positive reps of tile op [MXNET-283] Error handling for non-positive reps of tile op Apr 6, 2018
@anirudh2290
Copy link
Member

@piiswrong is this good to merge ?

@piiswrong piiswrong merged commit cbb7a5c into apache:master Apr 10, 2018
rahul003 pushed a commit to rahul003/mxnet that referenced this pull request Jun 4, 2018
…0417)

* Error handling for non-positive reps of tile op

* Address cr

* Fix unit test
zheng-da pushed a commit to zheng-da/incubator-mxnet that referenced this pull request Jun 28, 2018
…0417)

* Error handling for non-positive reps of tile op

* Address cr

* Fix unit test
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.

3 participants