Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RELAY][OP] Support MXNet-style attributes for reshape_like #6851

Merged
merged 5 commits into from
Nov 6, 2020

Conversation

altanh
Copy link
Contributor

@altanh altanh commented Nov 4, 2020

This PR adds MXNet-style shape slicing attributes for reshape_like, to enable reshaping part of a shape (using part of another shape). In particular, this adds lhs_begin, lhs_end, rhs_begin, rhs_end.

cc @kevinthesun @icemelon9 @junrushao1994

Copy link
Contributor

@giuseros giuseros 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 overall,, only minor changes

python/tvm/relay/op/transform.py Show resolved Hide resolved
@@ -62,6 +62,9 @@ Expr MakeRepeat(Expr data, int repeats, int axis);

Expr MakeReshape(Expr data, Array<Integer> newshape);

Expr MakeReshapeLike(Expr lhs, Expr rhs, int64_t lhs_begin, Integer lhs_end, int64_t rhs_begin,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why {lhs,rhs}_begin is int64_t and {lhs,rhs}_end is Integer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did this because the beginning index (in both cases) must always be an integer, but the end index can be None which means I must use a nullable Integer wrapper. I could make everything Integer and check that beginning is always defined. I did feel a bit weird using int64_t directly since everything else seem to use int but the value wrapped by Integer is int64_t so that's why I chose it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed that the Attrs I defined uses int and not int64_t so I'll probably just use int since other code mostly uses it.

tests/python/relay/test_op_level3.py Show resolved Hide resolved
Copy link
Contributor

@electriclilies electriclilies left a comment

Choose a reason for hiding this comment

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

Overall looks good, just one style comment

src/relay/op/tensor/transform.cc Show resolved Hide resolved
Copy link
Contributor

@giuseros giuseros left a comment

Choose a reason for hiding this comment

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

Thanks for addressing the comments! LGTM

@junrushao junrushao merged commit df6a796 into apache:main Nov 6, 2020
@junrushao
Copy link
Member

Thanks @altanh @tkonolige @electriclilies @jroesch @giuseros! It is now merged :-)

trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Dec 2, 2020
)

* add MXNet-style reshape_like attrs support

* lint

* document, switch to int, add more tests, style

* add example usage in documentation

* fix doc formatting
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Dec 4, 2020
)

* add MXNet-style reshape_like attrs support

* lint

* document, switch to int, add more tests, style

* add example usage in documentation

* fix doc formatting
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Dec 4, 2020
)

* add MXNet-style reshape_like attrs support

* lint

* document, switch to int, add more tests, style

* add example usage in documentation

* fix doc formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants