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] expand_dims #1819

Merged
merged 7 commits into from
Oct 5, 2018
Merged

[RELAY][OP] expand_dims #1819

merged 7 commits into from
Oct 5, 2018

Conversation

junrushao
Copy link
Member

@junrushao junrushao commented Oct 4, 2018

This PR contains a relay operator, expand_dims.

TODO:

  • Docstrings
  • I didn't see a boundary checking for axis in topi. Did I miss anything?
  • API inconsistency with numpy.expand_dims. Our API looks like expand_dims(data, axis, num_newaxis=1), but numpy API is expand_dims(a, axis) . I think it is okay because ours seem to be a superset.
  • I implemented axis and num_newaxis as int. Wondering if it is possible to make them IndexExpr, so that axis could depend on some intermediate result of computation.

I am working on the docstring, and @tqchen could you help comment on the TODO 2, 3, 4?

Related issue: #1799

@tqchen
Copy link
Member

tqchen commented Oct 4, 2018

  • bound checking should be added to topi
  • It is intended as a superset and the default case is still numpy consistent
  • For now, int is fine

@tqchen
Copy link
Member

tqchen commented Oct 4, 2018

Please also request reviews from reviewers

@junrushao
Copy link
Member Author

@tqchen @srkreddy1238 Hey could you help review this PR?

@junrushao
Copy link
Member Author

Rebased to current master.

@tqchen
Copy link
Member

tqchen commented Oct 5, 2018

sorry, still need another rebase after #1821


num_newaxis : int
Number of axises to be inserted. Should be >= 0.
"""
Copy link
Member

Choose a reason for hiding this comment

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

Returns 
--------

Copy link
Member

Choose a reason for hiding this comment

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

The result. The number of dimensions is num_newaxis greater than that of the input.

Copy link
Member Author

Choose a reason for hiding this comment

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

@tqchen Sorry for my poor English...What does this sentence mean: "The number of dimensions is num_newaxis greater than that of the input."?

Copy link
Member

Choose a reason for hiding this comment

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

maybe result_dimension = source dimension + num_newaxis

Copy link
Member Author

Choose a reason for hiding this comment

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

@tqchen Good point! Like this?

result : relay.Expr
    The reshaped result. `result.ndim = data.ndim + num_newaxis`.

@tqchen
Copy link
Member

tqchen commented Oct 5, 2018

Please also add the operator to https://github.com/dmlc/tvm/blob/master/docs/langref/relay_op.rst


num_newaxis : int
Number of axises to be inserted. Should be >= 0.
"""
Copy link
Member

Choose a reason for hiding this comment

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

The result. The number of dimensions is num_newaxis greater than that of the input.

@junrushao junrushao mentioned this pull request Oct 5, 2018
66 tasks
@junrushao
Copy link
Member Author

@tqchen Should I add examples somewhere?

@tqchen tqchen merged commit 160eaf5 into apache:master Oct 5, 2018
FrozenGene pushed a commit to FrozenGene/tvm that referenced this pull request Dec 27, 2018
@junrushao junrushao deleted the relay-op branch January 6, 2022 02:50
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.

2 participants