-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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] Modify create_executor to pass params #8418
Conversation
2a937d8
to
9bc6874
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks @mikepapadim for the contribution!
@@ -555,6 +559,9 @@ def create_executor(kind="debug", mod=None, device=None, target="llvm"): | |||
else: | |||
device = _nd.device(str(target), 0) | |||
|
|||
if params is not None: | |||
mod = IRModule.from_expr(bind_params_by_name(mod["main"], params)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to consider what if the mod does not contain a "main" function, or the mod contains multiple functions(subgraphs), each with a different params dict?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine to throw an error if cannot find "main" in the Module, so ignore this comment. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, and it is passing all the CI stages.
9bc6874
to
fd4effd
Compare
Merged now. Thanks @mikepapadim |
* Overload create_executor to accept params * [fix] Add stringdoc for new param in create_executor
* Overload create_executor to accept params * [fix] Add stringdoc for new param in create_executor
Following the forum discussion (https://discuss.tvm.apache.org/t/questions-about-tvm-executors-and-its-apis/10289/3) and the tutorials https://tvm.apache.org/docs/tutorials/frontend/from_keras.html#sphx-glr-tutorials-frontend-from-keras-py and https://tvm.apache.org/docs/tutorials/frontend/from_onnx.html#compile-the-model-with-relay there is some performance mismatch between the two apis.
This repo captures the performance issue.
It seems when one uses the relay API as in the example below,
params
are not passed properly to the TIR and all optimizations regarding constants (i.e., constant folding) are prevented. Therefore, this leads to a performance mismatch with therelay.vm.compile(mod, target=target, params=params)
.Example usage:
This PR modifies the above to accept:
With this modification
relay.vm.compile
andrelay.create_executor
generate the same bytecodes while applying the same opts.@jroesch @tqchen @YuchenJin @ZihengJiang