spcl / spcl/dace

`InlineSDFG` Removes Some Writes

Open
#2,108 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

I found a bug in `InlineSDFG` (this is the inliner that handles a nested SDFG that has a single state).
The situation is illustrated in the image bellow:

Image

We have a nested SDFG that computes `theta_v` and `exner` (note that `exner` is also an input to the nested SDFG, however, everything is first written to a transient).
The problem is, when I run `InlineSDFG` then for some reason the write to `theta_v` has been removed.
I tried but failed to come up with a reproducer, to debug the transformation.

However, here is a test using the SDFG I was able to get from our pipeline.

```python
sdfg = dace.SDFG.from_file("apply_diffusion_to_theta_and_exner_only_one_level.json")
sdfg.validate()
found_theta_v_writes_before = 0
for state in sdfg.states():
for node in state.data_nodes():
if node.data == "theta_v" and state.in_degree(node) > 0:
found_theta_v_writes_before += 1
assert found_theta_v_writes_before > 0

sdfg.apply_transformations_repeated([InlineSDFG], validate=True, validate_all=True)

found_theta_v_writes_after = 0
for state in sdfg.states():
for node in state.data_nodes():
if node.data == "theta_v" and state.in_degree(node) > 0:
found_theta_v_writes_after += 1
assert found_theta_v_writes_after > 0
```

[apply_diffusion_to_theta_and_exner_only_one_level.json](https://github.com/user-attachments/files/21468414/apply_diffusion_to_theta_and_exner_only_one_level.json)

I was doing my tests using DaCe/main 604393a920969b73c26c83faf03833cf6c1d5838

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.