diff --git a/loopy/kernel/array.py b/loopy/kernel/array.py index 97bc02dfd..b6ed5518d 100644 --- a/loopy/kernel/array.py +++ b/loopy/kernel/array.py @@ -892,6 +892,11 @@ def __init__(self, name, dtype=None, shape=None, dim_tags=None, offset=0, tags=tags, **kwargs) + # Without this __hash__ is set to None because this class overrides __eq__. + # Source: https://docs.python.org/3/reference/datamodel.html#object.__hash__ + def __hash__(self): + return super().__hash__() + def __eq__(self, other): from loopy.symbolic import ( is_tuple_of_expressions_equal as istoee, diff --git a/loopy/transform/iname.py b/loopy/transform/iname.py index e61b85be3..e55bad50c 100644 --- a/loopy/transform/iname.py +++ b/loopy/transform/iname.py @@ -935,7 +935,8 @@ def duplicate_inames(kernel, inames, within, new_inames=None, suffix=None, within=within) def _does_access_old_inames(kernel, insn, *args): - return bool(frozenset(inames) & insn.dependency_names()) + return bool(frozenset(inames) & (insn.dependency_names() + | insn.reduction_inames())) kernel = rule_mapping_context.finish_kernel( indup.map_kernel(kernel, within=_does_access_old_inames, diff --git a/test/test_transform.py b/test/test_transform.py index 27f55c760..3915ce161 100644 --- a/test/test_transform.py +++ b/test/test_transform.py @@ -1324,6 +1324,19 @@ def test_precompute_does_not_lead_to_dep_cycle(ctx_factory): lp.auto_test_vs_ref(knl, ctx, ref_knl) +def test_rename_inames_redn(): + t_unit = lp.make_kernel( + "{[i, j0, j1]: 0<=i, j0, j1<10}", + """ + y0[i] = sum(j0, sum([j1], 2*A[i, j0, j1])) + """) + + t_unit = lp.rename_iname(t_unit, "j1", "ifused") + + assert "j1" not in t_unit.default_entrypoint.all_inames() + assert "ifused" in t_unit.default_entrypoint.all_inames() + + if __name__ == "__main__": if len(sys.argv) > 1: exec(sys.argv[1])