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

Build multi models into one system-lib #7211

Closed
wants to merge 4 commits into from
Closed

Conversation

fantasyRqg
Copy link
Contributor

Deploy models on Android & iOS platform must use system-lib. Avoid usage of dlopen.
bundle_deploy demonstrated how to deploy a model which build a model which target system-lib

BUT we need more than one models

Related Discussions:

cc @wweic @zhiics

Please forgive me for my poor English

@FrozenGene
Copy link
Member

@kazum Could you help to review it? As it is somehow related with iOS.

@ziyu-guo
Copy link
Contributor

Quick question: how does this work with multiple TVM module libs compiled from same model, but with different batch size? Won't the names collide in the combined lib?

@fantasyRqg
Copy link
Contributor Author

/*!
* \brief Get unique name from name.
* \param name The orginal name.
* \return Updated name which is unique.
*/
std::string GetUniqueName(std::string name) {
for (size_t i = 0; i < name.length(); ++i) {
if (name[i] == '.') name[i] = '_';
}
while (true) {
auto it = name_map_.find(name);
if (it == name_map_.end()) {
name_map_[name] = 1;
return name;
} else {
std::ostringstream os;
os << name << "_" << it->second;
++(it->second);
name = os.str();
}
}
return name;
}
/*! \brief compiler cache lock*/
std::mutex mutex_;
/*! \brief internal name map to get an unique name */
std::unordered_map<std::string, int> name_map_;
/*! \brief internal compiler cache */
std::unordered_map<CCacheKey, CCacheValue> cache_;
/*! \brief internal compiler cache for shape funcs */
std::unordered_map<CCacheKey, CCacheValue> shape_func_cache_;
/*! \brief the cache key of the function that is being lowered currently*/
CCacheKey cur_ccache_key_;
};

GetUniqueName make sure function names will not collide

name_map_ will not be cleand even after CompileEngine::Global()->Clear();

@ziyu-guo

@fantasyRqg
Copy link
Contributor Author

Seems batch size is not handled by relay.build either.
My implementation just follow relay.build

@AlexanderSerov
Copy link
Contributor

Is this planned to be included in v0.8?

@jroesch
Copy link
Member

jroesch commented Jan 19, 2022

This PR appears to be out of date, please feel free to reopen it if this is not the case.

As part of the new year we are attempting to triage the project's open pull requests to ensure that code which
is ready for review and/or merging receives adequate attention.

Thanks again for your contribution, and feel free to reach out to discuss these changes.

@jroesch jroesch closed this Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants