This is an automated email from the ASF dual-hosted git repository.
tqchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm-tirx.git
The following commit(s) were added to refs/heads/main by this push:
new afbd94270 [FIX][CUDA] Update the module after the loop in LowerIket
(#259)
afbd94270 is described below
commit afbd942701f3e3d1db2500a1cf2a156800333923
Author: Shushi Hong <[email protected]>
AuthorDate: Mon Nov 23 08:23:45 2026 -0500
[FIX][CUDA] Update the module after the loop in LowerIket (#259)
LowerIket called module->Update while iterating module->functions, which
invalidated the iteration: with four functions the pass never returned,
and with five or more it left IKET annotations in most functions. This
collects the stripped functions and updates the module after the loop.
---
src/backend/cuda/transform/lower_iket.cc | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/backend/cuda/transform/lower_iket.cc
b/src/backend/cuda/transform/lower_iket.cc
index ec8792501..0a59b54b3 100644
--- a/src/backend/cuda/transform/lower_iket.cc
+++ b/src/backend/cuda/transform/lower_iket.cc
@@ -1197,6 +1197,9 @@ bool IketEnabled(const IRModule& module) {
IRModule LowerIketImpl(IRModule module) {
if (!IketEnabled(module)) {
+ // Update the module after the loop: updating it while iterating its
function map
+ // invalidates the iteration, which then repeats forever or stops early.
+ std::vector<std::pair<GlobalVar, Function>> stripped_functions;
for (const auto& [global_var, base_function] : module->functions) {
const auto* function_node = base_function.as<FunctionObj>();
if (!function_node ||
function_node->GetAttr(tvm::attr::kDeclaration).value_or(false))
@@ -1221,9 +1224,12 @@ IRModule LowerIketImpl(IRModule module) {
ffi::make_object<RemoveStrippedIketNoOps>()->Mutate(stripped).ValueOrUnchanged(stripped);
if (!function->body.same_as(body)) {
function.CopyOnWrite()->body = body;
- module->Update(global_var, function);
+ stripped_functions.emplace_back(global_var, function);
}
}
+ for (const auto& [global_var, function] : stripped_functions) {
+ module->Update(global_var, function);
+ }
return module;
}