spcl / dace

DaCe - Data Centric Parallel Programming

Home Page:http://dace.is/fast

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing validation for memlet symbolic subset expression

BenWeber42 opened this issue · comments

Currently, validation does not check whether the symbolic subset expressions of memlets don't contain array accesses. Such a case is invalid and should throw a validation error. See this testcase:

def test_memlet_subset_validation_bug():
    sdfg = dace.SDFG("test")

    sdfg.add_array("A", shape=(5, ), dtype=dace.int32)
    sdfg.add_array("B", shape=(5, ), dtype=dace.int32)
    sdfg.add_array("indirection", shape=(5, ), dtype=dace.int32)

    state = sdfg.add_state("start", is_start_state=True)
    access_A = state.add_access("A")
    access_B = state.add_access("B")
    memlet = state.add_edge(access_A, "A", access_B, None, dace.Memlet("A[0]"))

    # This is invalid SDFG as we are not allowed to use other arrays as subset expressions!
    memlet.data.subset = subsets.Range([("indirection[0]", "indirection[0]", "1")])

    # FIXME: we don't seem to have an appropriate type for memlet errors?
    with pytest.raises(Exception):
        sdfg.validate()

    # This must also work if the array is doesn't exist
    memlet.data.subset = subsets.Range([("undeclared_array[0]", "undeclared_array[0]", "1")])

    # FIXME: we don't seem to have an appropriate type for memlet errors?
    with pytest.raises(Exception):
        sdfg.validate()

The full testcase is available here: https://github.com/BenWeber42/dace/blob/060d873a7609633752b6f3bf3f7687b1b6d51506/tests/memlet_subset_validation_bug_test.py