Skip to content

Commit

Permalink
[Relay]Allow every runtime module to handle constants (#5885)
Browse files Browse the repository at this point in the history
* update source module

* address comment
  • Loading branch information
comaniac authored Jun 23, 2020
1 parent 9b745c6 commit 8108f59
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/target/source/source_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,18 @@ runtime::Module CreateMetadataModule(
// Wrap all submodules in the initialization wrapper.
std::unordered_map<std::string, std::vector<std::string>> sym_metadata;
for (runtime::Module it : modules) {
CHECK_EQ(it->type_key(), "c") << "Only csource submodule is handled for now";
String symbol = it.GetFunction("get_symbol")();
Array<String> variables = it.GetFunction("get_const_vars")();
std::vector<std::string> arrays;
for (size_t i = 0; i < variables.size(); i++) {
arrays.push_back(variables[i].operator std::string());
auto pf_sym = it.GetFunction("get_symbol");
auto pf_var = it.GetFunction("get_const_vars");
if (pf_sym != nullptr && pf_var != nullptr) {
String symbol = pf_sym();
Array<String> variables = pf_var();
std::vector<std::string> arrays;
for (size_t i = 0; i < variables.size(); i++) {
arrays.push_back(variables[i].operator std::string());
}
CHECK_EQ(sym_metadata.count(symbol), 0U) << "Found duplicated symbol: " << symbol;
sym_metadata[symbol] = arrays;
}
CHECK_EQ(sym_metadata.count(symbol), 0U) << "Found duplicated symbol: " << symbol;
sym_metadata[symbol] = arrays;
}

// Wrap the modules.
Expand Down

0 comments on commit 8108f59

Please sign in to comment.