Memlets propagated incorrectly out of nested SDFGs
- Dominant language
- Python
- Stars
- 593
- Forks
- 163
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 60
Description
If a nested SDFG accesses a data container passed to it not starting from a 0 offset, the outside memlets are propagated incorrectly, leading to incorrect code being generated.
[Edit: It is not actually memlet propagation, but the Python frontend that is at fault here. Propagation works as intended. See the discussion in #1738]
For instance, take the following code:
```Python
N = dace.symbol('N')
M = dace.symbol('M')
@dace.program
def nested_conditional_in_loop_in_map(A: dace.float64[M, N]):
for i in dace.map[0:M]:
for j in range(2, N, 1):
if A[0][0]:
A[i, j] = 1
else:
A[i, j] = 2
A[i, j] = A[i, j] * A[i, j]
```
It is clear that inside the nested SDFG, A is only accessed in the index range `A[:, 2:N-1]`. However, the memlet being propagated to the outside of the nested SDFG inside the map is on the subset `A[i, 0:N-3]`. This leads to the index expression `A[i, j - 2]` being generated in the corresponding C++, consequently producing wrong results.
A failing test was added in https://github.com/spcl/dace/pull/1738.
Contributor guide
Assessment
This issue has not been assessed yet.