Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Relay]Allow every runtime module to handle constants #5885

Merged
merged 2 commits into from
Jun 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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