-
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
[RUNTIME] Support module based interface runtime #5753
Conversation
@FrozenGene please let us know when it is ready for review |
sure. i will update the status inside this pr and will notify you after completion. |
4ca9e56
to
5563dea
Compare
9ecd15f
to
3391c66
Compare
@tqchen I think you could start to review the core part now and wish to listen your feedback. All the functionality (except the new |
gental ping @tqchen I am working on debug_graph_runtime / vm, but i think you could start to review core part :-) |
I will spend sometime to review the PR this week |
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.
@FrozenGene : Thanks for the PR! Great work 👍
I have done initial round of review. Please find some high level comments and some queries. Hope it helps. Thanks!
bd8063b
to
2f16dde
Compare
Thanks @FrozenGene I made some initial comments. Would like to followup on the general design directions. The PR as it is implements the features we want. However, it is equally important to think about the minimalism. In particular, we want to implement the feature using a minimum set of concepts(APIs). The runtime module based interface is more like a interface convention instead of a common implementation that we use for packaging. We can imagine different kinds of implementations, GraphRuntimeFactory is one of them(for graph executions). We would also like as much de-coupling as possible. So the ley challenge is -- how can we implement the features using as a minimum set of API interface as possible. We can dissect the current API into two category of functionalities
Notably, F0 and F1 does not have to use the same runtime.module implementations. Minimum Design for F0If we focus on F0, we can find that we only need one interface for graph runtime in the C++ side(via Module API) -- the creation function: from tvm.contrib import graph_runtime
gmod = graph_runtime.GraphModule(mod['resnet18'](tvm.cpu(0))) Notably, in the use cases of F0, we do not need the GraphRuntimeFactory wrapper(as the wrapper itself is primarily for backward compatiblity reasons). Minimum Design for F1If we do not need to support the additional features(e.g. disable We would certainly need the DiscussionsFrom the above discussions, we can find that the only really necessary API is the factory creation function. We could certainly expose The current way of implementing One potential way to address the problem is to still use a compositional API: mod = relay.build()
# return a new GraphFactoryModule with params removed
# mod_no_params does not need the GraphFactoryModule wrapping.
mod_no_params = mod["remove_params"]()
# no params will be exported
mod_no_params.export_library("xyz.so")
# params will be exported
mod.export_library("xyz.so") We can discuss more API naming choices. Another parallel thread is how to create a debug runtime(if available). In this case, we could simply do |
names.emplace_back(v.first); | ||
arrays.emplace_back(const_cast<DLTensor*>(v.second.operator->())); | ||
} | ||
uint64_t sz = arrays.size(); |
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.
With the MetadataModule
, we should be able to remove the serialization and deserialization of params for GraphRuntime and the factory. That may affect downstream users. I can take a stab on it later.
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.
Could you give me a link about this MetadataModule?
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.
It was introduced in #5770. We should not do it in this pr. This just makes you aware of it.
cc @zhiics please https://tvm.apache.org/docs/contribute/code_review.html#approve-and-request-changes-explicitly @jwfromm can you also take a look? |
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
@FrozenGene : Sorry for late pitch in! With the latest change, i am not able to find dealing with multiple modules like previously done. Can you please point me to one or give an example how to do it. Thanks! |
@ANSHUMAN87 Ah...yes. Latest change of this pr doesn't contain this part. The main reasons is our compiler doesn't be ready for it. For example, imagine we have one resnet18 model and resnet50 model for CPU, our compiler will not generate unique name for them. Both models will have the same function name like |
@FrozenGene : Thanks a lot! I got it now. So may be we add this as a note in the original issue tracker for this feature. So that we can comeback to it at later point. |
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 @FrozenGene 👍
I have listed it in original RFC (#5038) |
Thanks @FrozenGene , this PR is now merged. Thanks @zhiics @ANSHUMAN87 |
This pr supports #5038.