@@ -2327,6 +2327,7 @@ def rename_inames(kernel, old_inames, new_iname, existing_ok=False,
2327
2327
raise LoopyError (f"iname '{ new_iname } ' conflicts with an existing identifier"
2328
2328
" --cannot rename" )
2329
2329
2330
+ orig_old_inames = old_inames
2330
2331
if not does_exist :
2331
2332
# {{{ rename old_inames[0] -> new_iname
2332
2333
# so that the code below can focus on "merging" inames that already exist
@@ -2404,6 +2405,16 @@ def does_insn_involve_iname(kernel, insn, *args):
2404
2405
smap .map_kernel (kernel , within = does_insn_involve_iname ,
2405
2406
map_tvs = False , map_args = False ))
2406
2407
2408
+ # replace instances where the old inames appear as a param
2409
+ new_domains = []
2410
+ for dom in kernel .domains :
2411
+ for old_iname in orig_old_inames :
2412
+ d = dom .get_var_dict ()
2413
+ if old_iname in d and new_iname not in d :
2414
+ var_type , var_num = d [old_iname ]
2415
+ dom = dom .set_dim_name (var_type , var_num , new_iname )
2416
+ new_domains .append (dom )
2417
+
2407
2418
new_instructions = [insn .copy (within_inames = ((insn .within_inames
2408
2419
- frozenset (old_inames ))
2409
2420
| frozenset ([new_iname ])))
@@ -2412,7 +2423,7 @@ def does_insn_involve_iname(kernel, insn, *args):
2412
2423
else insn
2413
2424
for insn in kernel .instructions ]
2414
2425
2415
- kernel = kernel .copy (instructions = new_instructions )
2426
+ kernel = kernel .copy (instructions = new_instructions , domains = new_domains )
2416
2427
2417
2428
return kernel
2418
2429
0 commit comments