From a1c04aa8ead191f5125347868dc802f2d1141bab Mon Sep 17 00:00:00 2001 From: Ruihang Lai Date: Sat, 24 Dec 2022 16:04:10 -0500 Subject: [PATCH] [Fix] Misc fixes from #32, #42, #48, #54 (#57) * [FIX][Pass] concurrent modification in RemoveUnusedVars (#32) * [Pass] Fix concurrent modification in RemoveUnusedVars When running RemoveUnusedVars (i.e. remove_all_unused), in some cases the map users will raise Concurrent modification error. This commit fixed it by changing the logic to "iterate the map first and update it later". * change the algorithm by store keys first * Add an ICHECK before getting map value * change the information of the ICHECK * fix find include path (#42) Co-authored-by: Hongyi Jin * [BUG] ExternFunc is not considered in attach_global_symbol.cc (#48) * [Cherry-Pick] Minor fix for TaskScheduler and VerifyGPUCode (#54) * [Fix] Task scheduler error prompt upon build/run failure (#13601) * [Fix] Use proper target in VerifyGPUCode (#13548) Previously, the VerifyGPUCode post-processor uses hardcoded target `Target("cuda")` for applying pass LowerIntrin. This is a bit problematic since the actual target can be other GPU target (e.g., Metal). Therefore, this PR changes the hardcoded target to be the actual target. Co-authored-by: Chaosfan Co-authored-by: Hongyi Jin <3231950289@qq.com> Co-authored-by: Hongyi Jin Co-authored-by: Bohan Hou <32121147+spectrometerHBH@users.noreply.github.com> --- python/tvm/_ffi/libinfo.py | 8 +++++--- src/relax/transform/attach_global_symbol.cc | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/python/tvm/_ffi/libinfo.py b/python/tvm/_ffi/libinfo.py index fdd888a470..b27d4247fd 100644 --- a/python/tvm/_ffi/libinfo.py +++ b/python/tvm/_ffi/libinfo.py @@ -165,9 +165,11 @@ def find_include_path(name=None, search_path=None, optional=False): include_path : list(string) List of all found paths to header files. """ - ffi_dir = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) - source_dir = os.path.join(ffi_dir, "..", "..", "..") - + if os.environ.get("TVM_HOME", None): + source_dir = os.environ["TVM_HOME"] + else: + ffi_dir = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) + source_dir = os.path.join(ffi_dir, "..", "..", "..") third_party_dir = os.path.join(source_dir, "3rdparty") header_path = [] diff --git a/src/relax/transform/attach_global_symbol.cc b/src/relax/transform/attach_global_symbol.cc index be779e97bc..cd771c607d 100644 --- a/src/relax/transform/attach_global_symbol.cc +++ b/src/relax/transform/attach_global_symbol.cc @@ -39,6 +39,8 @@ class GlobalSymbolAttacher { func = WithAttr(GetRef(prim_func), "global_symbol", p.first->name_hint); } else if (auto* relax_func = func.as()) { func = WithAttr(GetRef(relax_func), "global_symbol", p.first->name_hint); + } else if (auto* extern_func = func.as()) { + func = WithAttr(GetRef(extern_func), "global_symbol", p.first->name_hint); } else { LOG(FATAL) << "Unsupported function type: " << func->GetTypeKey(); throw;