mbs-octoml commented on a change in pull request #9483:
URL: https://github.com/apache/tvm/pull/9483#discussion_r759585862
##########
File path: src/relay/backend/te_compiler.cc
##########
@@ -134,41 +144,78 @@ class TECompilerImpl : public TECompilerNode {
return mod;
}
+ void AddExterns(IRModule module) {
+ // Everything tagged with "Compiler" has been compiled, so remove those
definitions.
+ std::vector<GlobalVar> to_be_deleted;
+ for (const auto& kv : module->functions) {
+ if (kv.second->GetAttr<String>(attr::kCompiler).defined()) {
+ to_be_deleted.push_back(kv.first);
+ }
+ }
+ for (const auto& global_var : to_be_deleted) {
+ module->Remove(global_var);
+ }
+ // HOWEVER we still need a Relay definition to go with those now external
functions, so
+ // retrieve them from the cache and mark them with "ExternalSymbol".
+ for (const auto& kv1 : cache_) {
+ auto src_func = kv1.first->source_func;
+ ICHECK(src_func.defined());
+ if (src_func->GetAttr<String>(attr::kCompiler).defined()) {
+ for (const auto& kv2 : kv1.second->cached_func->funcs->functions) {
+ if (const auto* function_node = kv2.second.as<FunctionNode>()) {
+ // Abandon the existing function annotations.
+ Function function(function_node->params, function_node->body,
function_node->ret_type,
+ function_node->type_params, /*attrs=*/{},
function_node->span);
Review comment:
This is a classic 'double lifting confusion'.
Optional<DictAttrs> none = {};
Optional<DictAttrs> empty= DictAttrs();
The caller will have to be careful about which they mean...
--
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]