Memlet WCR propagation bug
- Dominant language
- Python
- Stars
- 593
- Forks
- 163
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 60
Description
**Describe the bug**
WCR edges are not propagated correctly. As a side effect, applying greedy fusion to an erroneous graph results in a graph that gives incorrect results.
**To Reproduce**
```
import numpy as np
import dace
def test_greedy_fuse_bug():
N = 3
dtype = np.float32
np.random.seed(42)
# Create input.
graph = (scipy.sparse.random(N, N, density=0.5, format='csr')
+ scipy.sparse.eye(N, format='csr'))
graph.data = np.ones_like(graph.data)
_, col = graph.indptr, graph.indices
col = np.copy(col)
num_entries = col.shape[0]
out_e = np.random.rand(num_entries).astype(dtype=dtype)
@dace.program
def gat(columns, e):
softmax_sum = np.zeros((N,), dtype=dtype)
for j in dace.map[0:num_entries]:
colj = columns[j]
e[j] = np.exp(e[j])
softmax_sum[colj] += e[j]
for j in dace.map[0:num_entries]:
colj = columns[j]
e[j] = e[j] / softmax_sum[colj]
sdfg = gat.to_sdfg(columns=col, e=out_e)
greedy_fuse(sdfg, device=dace.dtypes.DeviceType.CPU, validate_all=True)
sdfg(columns=col, e=out_e)
expected_e = np.zeros((num_entries,), dtype=dtype)
gat.f(columns=col, e=expected_e)
check_equal(expected_e, out_e, 'attention_weights')
```
See the highlighted edge:

Contributor guide
Assessment
This issue has not been assessed yet.