From 4b33fdf2742ca31a45598fc2938772fb8cfb2191 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Thu, 9 Dec 2021 15:54:28 -0600 Subject: [PATCH] [Hexagon] Detect link-params via IRModule instead of target attribute Additionally, restore the construction of target attributes in the Hexagon target. This was erroneously removed in PR#9352. That PR deprecated target attributes, but also added transferring these attributes to the new mechanism. Removing the attributes from tvm.target.hexagon eliminated them completely. Restoring the target attributes allow time to transition TVM clients to the new mechanisms. --- python/tvm/target/target.py | 16 +++++++++++++++- src/target/llvm/codegen_hexagon.cc | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/python/tvm/target/target.py b/python/tvm/target/target.py index 1c418e5cf216..c7f6d4199800 100644 --- a/python/tvm/target/target.py +++ b/python/tvm/target/target.py @@ -638,13 +638,27 @@ def create_llvm_options(cpu_ver, config): # pylint: disable=unused-argument args = [s.replace("=", "@") for s in llvm_options.split()] return "--llvm-options=" + ",".join(args) + # TVM target attributes string + def create_tvm_options(cpu_ver, config): # pylint: disable=unused-argument + """Create TVM target features string.""" + + features = { + "link_params": "link-params", + } + opts = "" + for k in config: + if k in features: + opts += " --" + features[k] + "=" + str(config[k]) + return opts + # Sim args os.environ["HEXAGON_SIM_ARGS"] = create_sim_options(cpu_ver, config) target_str = create_llvm_target(cpu_ver, config) llvm_str = create_llvm_options(cpu_ver, config) + tvm_str = create_tvm_options(cpu_ver, config) - args_list = target_str.split() + llvm_str.split() + args_list = target_str.split() + llvm_str.split() + tvm_str.split() return Target(" ".join(["hexagon"] + args_list)) diff --git a/src/target/llvm/codegen_hexagon.cc b/src/target/llvm/codegen_hexagon.cc index fed2ad5937ee..496c73afa4f5 100644 --- a/src/target/llvm/codegen_hexagon.cc +++ b/src/target/llvm/codegen_hexagon.cc @@ -737,7 +737,7 @@ runtime::Module BuildHexagon(IRModule mod, Target target) { std::vector funcs; std::string entry_func; Map linked_params; - bool could_have_linked_params = target->GetAttr("link-params").value_or(Bool(false)); + bool could_have_linked_params = mod->ShouldLinkParameters(); for (auto kv : mod->functions) { if (could_have_linked_params &&