sunggg commented on code in PR #15244:
URL: https://github.com/apache/tvm/pull/15244#discussion_r1262484934
##########
src/node/structural_hash.cc:
##########
@@ -360,6 +360,46 @@ struct ADTObjTrait {
TVM_REGISTER_REFLECTION_VTABLE(runtime::ADTObj, ADTObjTrait);
+struct ModuleNodeTrait {
+ static constexpr const std::nullptr_t VisitAttrs = nullptr;
+ static constexpr std::nullptr_t SHashReduce = nullptr;
+ static constexpr std::nullptr_t SEqualReduce = nullptr;
+};
+
+TVM_REGISTER_REFLECTION_VTABLE(runtime::ModuleNode, ModuleNodeTrait)
+ .set_creator([](const std::string& blob) {
+ dmlc::MemoryStringStream mstrm(const_cast<std::string*>(&blob));
+ support::Base64InStream b64strm(&mstrm);
+ b64strm.InitPosition();
+ // retrieve derived type key
+ dmlc::Stream* stream = static_cast<dmlc::Stream*>(&b64strm);
+ std::string derived_type;
+ stream->Read(&derived_type);
+ // pick up the deserializer
+ std::string load_func_key = "runtime.module.loadbinary_"+derived_type;
+ const auto* load_func = runtime::Registry::Get(load_func_key);
+ ICHECK(load_func) << load_func_key << " is not registered.";
+ // deserialize
+ runtime::Module rtmod = (*load_func)(&b64strm);
+ return RefToObjectPtr::Get(rtmod);
+ })
+ .set_repr_bytes([](const Object* n) -> std::string {
+ const auto* rtmod = static_cast<const runtime::ModuleNode*>(n);
+ std::string blob;
+ dmlc::MemoryStringStream mstrm(&blob);
+ support::Base64OutStream b64strm(&mstrm);
Review Comment:
Thanks for the catch! This is addressed by using
https://github.com/apache/tvm/blob/main/src/runtime/dso_library.cc#L152 which
also collects import tree.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]