-
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] Invoke tvm::build from relay compile_engine and interpreter #4723
Conversation
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.
Why isnt this a line by line translation?
ddf0ec9
to
ef0acee
Compare
Sorry I missed a few things at the beginning and just added them. Do you mean translating this part line by line, https://github.com/apache/incubator-tvm/blob/master/python/tvm/build_module.py#L509-L650? Some of the type checks are not needed in C++, and the signature of https://github.com/apache/incubator-tvm/blob/bfb4884e47f7d2c759b2ee707aa18acf35116380/python/tvm/relay/backend/_backend.py#L65-L88 is a lot simpler. Also, |
ef0acee
to
b889a8f
Compare
I know very little about tvm Module and relay build, so I might get something wrong. |
@hlu1 Can we simply remove this packed function and directly invoke tvm::build from compile_engine and interpreter? We have two separate pipelines from Python and C++. I think we can probably directly use tvm.build from python and tvm::build from C++. So we don't really need to interoperate between them. |
@zhiics, makes sense. Will do. |
b889a8f
to
226d2d1
Compare
src/relay/backend/compile_engine.cc
Outdated
} else { | ||
LOG(FATAL) << "relay.backend.build is not registered"; | ||
m = build(value->cached_func->funcs, key->target, key->target, BuildConfig::Current()); |
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.
according to the syntax we had in Python, should we do the following?
m = build(value->cached_func->funcs, key->target, Target(nullptr), BuildConfig::Current());
Same to the one in intepreter.cc
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.
Fixed
226d2d1
to
ba4ed82
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 @hlu1 @MarisaKirisame |
relay.backend.build
is implemented in python and is used in C++ in https://github.com/apache/incubator-tvm/blob/c69092ae0d39f9a5161f098d933d0a2ec570a2c5/src/relay/backend/interpreter.cc#L422 and https://github.com/apache/incubator-tvm/blob/ce807fe83825bce666ed1834ab24b5d6ddfa6bca/src/relay/backend/compile_engine.cc#L602Similar to
relay.backend.lower
https://github.com/apache/incubator-tvm/blob/ce807fe83825bce666ed1834ab24b5d6ddfa6bca/src/relay/backend/compile_engine.cc#L731-L738invoke tvm::build instead of
LOG(FATAL)
whenrelay.backend.build
cannot be found, for example, in pure C++ environment.@jroesch, @MarisaKirisame please review :)