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

Relaxing type requirements for slice_like op #14097

Merged
merged 4 commits into from
Feb 14, 2019

Conversation

ptrendx
Copy link
Member

@ptrendx ptrendx commented Feb 8, 2019

Description

Currently the type of the second argument in slice_like op (shape_from ) needs to be the same as the first argument, even though only its (second argument's) shape is used. This PR relaxes that so slice_like accepts any type for the shape_from argument.

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • 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)
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

@vandanavk
Copy link
Contributor

@mxnet-label-bot add [Operator, pr-awaiting-review]

@marcoabreu marcoabreu added Operator pr-awaiting-review PR is waiting for code review labels Feb 8, 2019
Copy link
Contributor

@ChaiBapchya ChaiBapchya left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the contribution!
2 comments -

Could you rephrase this in your PR description - "Currently the type of the second shape_from argument in slice_like op needs to be the same as the first argument, even though only its shape is used."
I didn't understand what you mean by "even though only "its" shape is used" Do you mean the shape of the first argument is used?

And maybe consider generalizing the unittest initialization (unless it is essential)

@@ -2515,6 +2515,20 @@ def test_slice_like():
assert_allclose(xx, xgrad.asnumpy())
assert_allclose(xgrad1.asnumpy(), mx.nd.zeros_like(xgrad1).asnumpy())

@with_seed()
def test_slice_like_different_types():
x = [[ 1., 2., 3., 4.],
Copy link
Contributor

Choose a reason for hiding this comment

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

Though this example looks good, I am afraid it is specific. Do you mind using randomized shape, size and NDarray initalization to ensure this is generic?

Copy link
Member Author

Choose a reason for hiding this comment

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

Those parameters do not matter for this test (and they are already tested in the dedicated test of slice_like op functionality) - the values for x and y were taken from the example from slice_like documentation. The only thing that matters is the type of y in this test. Before this PR this code would not work - it would throw an exception during type inference. With this PR, this code works (as it should).

Copy link
Contributor

Choose a reason for hiding this comment

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

Alright. Makes sense. Thanks for the explanation.

@eric-haibin-lin
Copy link
Member

@zhreshold

Copy link
Member

@zhreshold zhreshold left a comment

Choose a reason for hiding this comment

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

Looks good

@zhreshold zhreshold merged commit 73a9f1c into apache:master Feb 14, 2019
stephenrawls pushed a commit to stephenrawls/incubator-mxnet that referenced this pull request Feb 16, 2019
* Relaxing types for slice_like op

* Added test

* Fix typo in test

* Fix lint
jessr92 pushed a commit to jessr92/incubator-mxnet that referenced this pull request Feb 19, 2019
* Relaxing types for slice_like op

* Added test

* Fix typo in test

* Fix lint
drivanov pushed a commit to drivanov/incubator-mxnet that referenced this pull request Mar 4, 2019
* Relaxing types for slice_like op

* Added test

* Fix typo in test

* Fix lint
vdantu pushed a commit to vdantu/incubator-mxnet that referenced this pull request Mar 31, 2019
* Relaxing types for slice_like op

* Added test

* Fix typo in test

* Fix lint
haohuanw pushed a commit to haohuanw/incubator-mxnet that referenced this pull request Jun 23, 2019
* Relaxing types for slice_like op

* Added test

* Fix typo in test

* Fix lint
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Operator pr-awaiting-review PR is waiting for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants