kparzysz-quic commented on a change in pull request #8865:
URL: https://github.com/apache/tvm/pull/8865#discussion_r700398690
##########
File path: src/target/llvm/codegen_hexagon.cc
##########
@@ -706,12 +706,42 @@ runtime::Module BuildHexagon(IRModule mod, Target target)
{
std::unique_ptr<llvm::TargetMachine> tm = GetLLVMTargetMachine(target);
std::unique_ptr<llvm::LLVMContext> ctx(new llvm::LLVMContext());
std::unique_ptr<CodeGenHexagon> cg(new CodeGenHexagon());
- cg->Init("TVMHexagonModule", tm.get(), ctx.get(), false, false, false);
+
+ std::vector<PrimFunc> funcs;
+ std::string entry_func;
+ Map<String, LinkedParam> linked_params;
+ bool found_linked_params = false;
+ bool could_have_linked_params =
target->GetAttr<Bool>("link-params").value_or(Bool(false));
+
for (auto kv : mod->functions) {
ICHECK(kv.second->IsInstance<PrimFuncNode>()) << "Can only lower IR Module
with PrimFuncs";
+ if (could_have_linked_params &&
+ kv.first->name_hint ==
::tvm::runtime::symbol::tvm_lookup_linked_param) {
+ Map<String, ObjectRef> attrs_dict = Downcast<Map<String,
ObjectRef>>(kv.second->attrs->dict);
+ CHECK(attrs_dict.find(::tvm::tir::attr::kLinkedParams) !=
attrs_dict.end())
+ << "no " << ::tvm::tir::attr::kLinkedParams << " attribute found!";
+ linked_params =
+ Downcast<Map<String,
LinkedParam>>(attrs_dict[::tvm::tir::attr::kLinkedParams]);
+ found_linked_params = true;
+ continue;
Review comment:
This is traversing all functions and
- if `f` is a "linked-params" function, we set it aside,
- otherwise we add `f` to the list of functions for codegen.
We need to skip the "linked-params" function, because the codegen path for
it is different. We create the bool variable so that we know to generate the
linked parameters function later on, but the variable is not the only effect of
the loop, so there isn't much to gain by extracting it into a separate function.
##########
File path: src/target/llvm/codegen_hexagon.cc
##########
@@ -706,12 +706,42 @@ runtime::Module BuildHexagon(IRModule mod, Target target)
{
std::unique_ptr<llvm::TargetMachine> tm = GetLLVMTargetMachine(target);
std::unique_ptr<llvm::LLVMContext> ctx(new llvm::LLVMContext());
std::unique_ptr<CodeGenHexagon> cg(new CodeGenHexagon());
- cg->Init("TVMHexagonModule", tm.get(), ctx.get(), false, false, false);
+
+ std::vector<PrimFunc> funcs;
+ std::string entry_func;
+ Map<String, LinkedParam> linked_params;
+ bool found_linked_params = false;
+ bool could_have_linked_params =
target->GetAttr<Bool>("link-params").value_or(Bool(false));
+
for (auto kv : mod->functions) {
ICHECK(kv.second->IsInstance<PrimFuncNode>()) << "Can only lower IR Module
with PrimFuncs";
+ if (could_have_linked_params &&
+ kv.first->name_hint ==
::tvm::runtime::symbol::tvm_lookup_linked_param) {
+ Map<String, ObjectRef> attrs_dict = Downcast<Map<String,
ObjectRef>>(kv.second->attrs->dict);
+ CHECK(attrs_dict.find(::tvm::tir::attr::kLinkedParams) !=
attrs_dict.end())
+ << "no " << ::tvm::tir::attr::kLinkedParams << " attribute found!";
+ linked_params =
Review comment:
What do you mean by "replacing" the map? `Map` is an `ObjectRef`, so
we're not really copying anything here.
--
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]