spcl / spcl/dace

Missing validation for memlet symbolic subset expression

Open
#1,418 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
593
Forks
163
Avg merge
2d 23h
Merged PRs (30d)
60

Description

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:

```python
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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.