spcl / spcl/dace

Memlet WCR propagation bug

Open
#1,276 1 comment 0 reactions 0 assignees View on GitHub
frontend
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:
![image](https://github.com/spcl/dace/assets/12202811/785b191d-45db-4574-bebd-2bd862073aae)

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.