tqchen commented on code in PR #15244:
URL: https://github.com/apache/tvm/pull/15244#discussion_r1292525719
##########
python/tvm/contrib/torch/optimize_torch.py:
##########
@@ -51,14 +51,6 @@ def forward(self, *torch_inputs: Tuple[torch.Tensor]):
return ret
-@register_func("script_torch.save_to_base64")
Review Comment:
let us keep torch related functionalities untouched for now, since it would
be good to first focus on runtime module serialization mechanism that **do
not** handle shared libraries, but mainly binary exportables.
##########
include/tvm/target/codegen.h:
##########
@@ -47,6 +47,37 @@ using runtime::TVMRetValue;
*/
runtime::Module Build(IRModule mod, Target target);
+/*!
+ * \brief Serialize runtime module including its submodules
+ * \param mod The runtime module to serialize including its import tree.
+ * \param include_dso By default, include the info of DSOExportable modules.
If disabled, an error
+ * will be raised when encountering DSO modules.
+ */
+std::string SerializeModuleToBytes(const runtime::Module& mod, bool
include_dso = true);
Review Comment:
These functions should remain internal and avoid exposing for now
##########
src/target/codegen.cc:
##########
@@ -83,17 +89,20 @@ class ModuleSerializer {
for (const auto& group : mod_group_vec_) {
ICHECK_NE(group.size(), 0) << "Every allocated group must have at least
one module";
- if (!group[0]->IsDSOExportable()) {
+ if (group[0]->IsBinarySerializable()) {
Review Comment:
When we are in export_dso mode, we should first check if it is
IsDSOExportable,
```c++
if (export_dso) {
if (group[0]->IsDSOExportable()) {
if (group[0]->IsBinarySerializable()) {
}
} else {
CHECK(group[0]->IsBinarySerializable());
}
```
```
##########
src/node/structural_hash.cc:
##########
@@ -360,6 +361,39 @@ struct ADTObjTrait {
TVM_REGISTER_REFLECTION_VTABLE(runtime::ADTObj, ADTObjTrait);
+struct ModuleNodeTrait {
+ static constexpr const std::nullptr_t VisitAttrs = nullptr;
+ static void SHashReduce(const runtime::ModuleNode* key, SHashReducer
hash_reduce) {
Review Comment:
avoid structural equality check of runtime module as it is not guaranteed to
be valid for all. In this case let us avoid use structural equality for check
and instead do some special handling
--
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]