diff --git a/src/target/metadata_module.cc b/src/target/metadata_module.cc index dab5cd558911..6fa6c9b85f7d 100644 --- a/src/target/metadata_module.cc +++ b/src/target/metadata_module.cc @@ -124,15 +124,17 @@ static runtime::Module CreateCppMetadataModule( target_module = const_loader_mod; } - runtime::metadata::Metadata runtime_metadata = ConvertMetaData(metadata); - - if (metadata->executor == runtime::kTvmExecutorAot && runtime->name == relay::kTvmRuntimeCpp) { - if (target->kind->name == "c") { - auto metadata_module = CreateCSourceCppMetadataModule(runtime_metadata); - metadata_module->Import(target_module); - target_module = metadata_module; - } else { - CHECK(false) << "Don't know how to create MetadataModule for target type " << target->str(); + if (metadata.defined()) { + runtime::metadata::Metadata runtime_metadata = ConvertMetaData(metadata); + + if (metadata->executor == runtime::kTvmExecutorAot && runtime->name == relay::kTvmRuntimeCpp) { + if (target->kind->name == "c") { + auto metadata_module = CreateCSourceCppMetadataModule(runtime_metadata); + metadata_module->Import(target_module); + target_module = metadata_module; + } else { + CHECK(false) << "Don't know how to create MetadataModule for target type " << target->str(); + } } }