Skip to content

Commit

Permalink
Preserve tags in rename_iname (#786)
Browse files Browse the repository at this point in the history
* Preserve tags in rename_iname

* Make preserving the tags optional

* Preserve tags by default

* Remove redundant line

* Doc fix, maintain order of pre-existing arguments

* add for_each_kernel decorator

* flake8 fix
  • Loading branch information
nchristensen authored Jun 21, 2023
1 parent ef4f6f1 commit e855c21
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions loopy/transform/iname.py
Original file line number Diff line number Diff line change
Expand Up @@ -2502,8 +2502,23 @@ def does_insn_involve_iname(kernel, insn, *args):
return kernel


def rename_iname(kernel, old_iname, new_iname, existing_ok=False, within=None):
return rename_inames(kernel, [old_iname], new_iname, existing_ok, within)
@for_each_kernel
def rename_iname(kernel, old_iname, new_iname, existing_ok=False,
within=None, preserve_tags=True):
"""
Single iname version of :func:`loopy.rename_inames`.
:arg existing_ok: execute even if *new_iname* already exists
:arg within: a stack match understood by :func:`loopy.match.parse_stack_match`.
:arg preserve_tags: copy the tags on the old iname to the new iname
"""
from itertools import product
from loopy import tag_inames

tags = kernel.inames[old_iname].tags
kernel = rename_inames(kernel, [old_iname], new_iname, existing_ok, within)
if preserve_tags:
kernel = tag_inames(kernel, product([new_iname], tags))
return kernel

# }}}

Expand Down

0 comments on commit e855c21

Please sign in to comment.