manupa-arm commented on a change in pull request #8865:
URL: https://github.com/apache/tvm/pull/8865#discussion_r700379159
##########
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:
nit : this seems searching for whether at least one function have
linked_params, if so I think we dont need to continue searching. A further
suggestion is to break it out to a function for that check w/o needing to
maintain found_linked_params bool.
##########
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:
Why are we replacing the map here (as opposed to setting it) ?
--
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]