[Relay][VirtualDevice] Expose WithFields to Python to do proper copy in ExprMutator#11882
Merged
Conversation
mbs-octoml
approved these changes
Jun 27, 2022
Contributor
mbs-octoml
left a comment
There was a problem hiding this comment.
LGTM, thanks and sorry for the glitch. Just some nits to make the API more convenient as per the c++ API.
| fn, | ||
| list(new_params), | ||
| new_body, | ||
| fn.ret_type, |
Contributor
There was a problem hiding this comment.
You can elide all the fn.* args since WithFields is designed to make it easy to preserve everything that's unchanged from the original expression.
|
|
||
|
|
||
| @tvm._ffi.register_func("relay.FunctionWithFields") | ||
| def FunctionWithFields(function, params, body, ret_type, ty_params, attrs, virtual_device, span): |
Contributor
There was a problem hiding this comment.
I think defaulting all params after function to None will mimic the c++ version and support the above suggestion.
| return Function(params, body, ret_type, ty_params, attrs); | ||
| }); | ||
| TVM_REGISTER_GLOBAL("relay.ir.FunctionWithFields") | ||
| .set_body_typed([](Function function, tvm::Array<Var> params, Expr body, Type ret_type, |
Contributor
There was a problem hiding this comment.
Preserve the Optional<...> on all params after function to support the above suggestions.
Member
|
@tvm-bot rerun |
masahi
approved these changes
Jun 27, 2022
areusch
approved these changes
Jun 27, 2022
1921f44 to
ad5dcd7
Compare
blackkker
pushed a commit
to blackkker/tvm
that referenced
this pull request
Jul 7, 2022
…in ExprMutator (apache#11882) * [Relay][VirtualDevice] Expose WithFields to Python to do proper copy in ExprMutator * [Relay] give FunctionWithFields optional arguments * [lint] fix wrong line length * [lint] missing newline * [doc] add doc string to FunctionWithFields
masahi
pushed a commit
to masahi/tvm
that referenced
this pull request
Jul 15, 2022
…in ExprMutator (apache#11882) * [Relay][VirtualDevice] Expose WithFields to Python to do proper copy in ExprMutator * [Relay] give FunctionWithFields optional arguments * [lint] fix wrong line length * [lint] missing newline * [doc] add doc string to FunctionWithFields
mikeseven
pushed a commit
to mikeseven/tvm
that referenced
this pull request
Sep 27, 2023
…in ExprMutator (apache#11882) * [Relay][VirtualDevice] Expose WithFields to Python to do proper copy in ExprMutator * [Relay] give FunctionWithFields optional arguments * [lint] fix wrong line length * [lint] missing newline * [doc] add doc string to FunctionWithFields
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As discussed in https://discuss.tvm.apache.org/t/relay-function-virtual-device-property/12958
@mbs-octoml