Skip to content

Commit

Permalink
Add tests that catch the fixed behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
ThrudPrimrose committed Nov 28, 2024
1 parent 974e55b commit 1c5d6ef
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions tests/transformations/gpu_transform_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,60 @@ def write_subset_dynamic(A: dace.int32[20, 20], x: dace.int32[20], y: dace.int32
assert np.array_equal(ref, val)


@pytest.mark.parametrize("transient", [False, True])
def test_free_tasklet_and_array(transient):
sdfg = dace.SDFG("assign")

state = sdfg.add_state("main")
arr_name, arr = sdfg.add_array("A", (4,), dace.float32, transient=transient)
an = state.add_access(arr_name)

t = state.add_tasklet("assign", {}, {"_out"}, "_out = 2.0")
state.add_edge(t, "_out", an, None, dace.memlet.Memlet("A[0]"))

sdfg.validate()

sdfg.apply_gpu_transformations(
validate = True,
validate_all = True,
permissive = True,
sequential_innermaps=True,
register_transients=False,
simplify=False
)

sdfg.validate()

@pytest.mark.parametrize("transient", [False, True])
def test_free_tasklet_and_scalar(transient):
sdfg = dace.SDFG("assign")

state = sdfg.add_state("main")
arr_name, arr = sdfg.add_scalar("A", dace.float32, transient=transient)
an = state.add_access(arr_name)

t = state.add_tasklet("assign", {}, {"_out"}, "_out = 2.0")
state.add_edge(t, "_out", an, None, dace.memlet.Memlet("A"))

sdfg.validate()

sdfg.apply_gpu_transformations(
validate = True,
validate_all = True,
permissive = True,
sequential_innermaps=True,
register_transients=False,
simplify=False
)

sdfg.validate()

if __name__ == '__main__':
test_toplevel_transient_lifetime()
test_scalar_to_symbol_in_nested_sdfg()
test_write_subset()
test_write_full()
test_write_subset_dynamic()
for transient in [False, True]:
test_free_tasklet_and_array(transient)
test_free_tasklet_and_array(transient)

0 comments on commit 1c5d6ef

Please sign in to comment.