Skip to content

Commit

Permalink
Test iname duplication for cases with only loop-nest based iname-depe…
Browse files Browse the repository at this point in the history
…ndence
  • Loading branch information
kaushikcfd authored and inducer committed Jul 30, 2024
1 parent 98d5b62 commit f01a86b
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -1704,6 +1704,35 @@ def test_precompute_lets_inner_length1_inames_live():
== parse("(e_inner + e_outer*16) / i_0"))


def test_duplicate_iname_not_read_only_nested(ctx_factory):
# See <https://github.com/inducer/loopy/issues/859>
ctx = ctx_factory()
t_unit = lp.make_kernel(
"{[i, j]: 0<=i,j<10}",
"""
for i
<> acc = 0 {id=init, tags=foo}
for j
acc = acc + A[i, j] * x[i, j] {id=update, tags=foo}
end
y[i] = acc {id=assign, tags=foo}
end
""",
[lp.GlobalArg("A,x,y", shape=lp.auto, dtype=np.float32),
...],
)
ref_t_unit = t_unit

t_unit = lp.duplicate_inames(
t_unit,
inames="i", within="tag:foo", new_inames="irow")
print(t_unit)
assert (t_unit.default_entrypoint.id_to_insn["init"].within_inames
== frozenset({"irow"}))

lp.auto_test_vs_ref(ref_t_unit, ctx, t_unit)


if __name__ == "__main__":
if len(sys.argv) > 1:
exec(sys.argv[1])
Expand Down

0 comments on commit f01a86b

Please sign in to comment.