masahi commented on a change in pull request #10283:
URL: https://github.com/apache/tvm/pull/10283#discussion_r817112104
##########
File path: src/runtime/metadata.cc
##########
@@ -52,5 +62,65 @@ TensorInfo::TensorInfo(const struct ::TVMTensorInfo* data)
TVM_REGISTER_OBJECT_TYPE(TensorInfoNode);
} // namespace metadata
+
+class MetadataModuleNode : public ::tvm::runtime::ModuleNode {
+ public:
+ explicit MetadataModuleNode(runtime::metadata::Metadata metadata) {
+ // CHECK((metadata.defined() && code.size() > 0) || (!metadata.defined()
&& code.size() == 0))
+ // << "metadata and code must both be either defined (when passed from
compiler) or undefined
+ // "
+ // << "(when passed from runtime)";
+ metadata_ = metadata;
+ // code_ = code;
+ }
+
+ const char* type_key() const { return "metadata_module"; }
+
+ static Module LoadFromBinary() {
+ return
Module(make_object<MetadataModuleNode>(runtime::metadata::Metadata()));
+ }
+
+ void SaveToBinary(dmlc::Stream* stream) final {}
+
+ PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) {
+ if (name == "get_metadata") {
+ return PackedFunc([this, sptr_to_self](TVMArgs args, TVMRetValue* rv) {
+ if (!metadata_.defined()) {
+ TVMFunctionHandle f_handle;
+ int32_t ret_code = TVMBackendGetFuncFromEnv(this, "get_c_metadata",
&f_handle);
Review comment:
See https://github.com/apache/tvm/pull/10283/files#r817105544
--
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]