[f2dace] Simplify (prob. Symbol Propagation) bug/incompatability with Structs
- Dominant language
- Python
- Stars
- 593
- Forks
- 163
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 60
Description
I need structs to generate the issue, so to reproduce:
Symbol propagation creates unused symbols when the value of a Scalar is read from a struct. (The bug does not persist if I apply flattening before - and ensure all structs are read in a library node before)
I do not have time right now to find the exact location where Simplify is incompatible.
To reproduce, you need: `f2dace/staging`: `ebbe4fd701ae2c359194d846a2c91b23cb603d49`
`icon-artifacts`: 650f87d8b4425d0ed08dd15105305cb97b53f62a
To get error, run in `icon-artifacts` repo:
```
cd repo
python propagate_ifs.py
```
then the script with the following code:
```
import dace
from dace.transformation.interstate import (
ContinueToCondition,
)
from dace.transformation.passes import (
SymbolPropagation,
)
from utils import *
import dace
from dace import config, data as dt, dtypes, Memlet, symbolic
from dace.sdfg import SDFG, nodes, graph as gr
# Load SDFG
sdfg_names = [
"velocity_no_nproma_if_prop_lvn_only_0_istep_1.sdfgz",
]
resulting_sdfgs = []
for sdfg_name in sdfg_names:
sdfg = dace.SDFG.from_file(sdfg_name)
sdfg.name = sdfg_name.split(".")[0]
sdfg.validate()
build_loc = sdfg.build_folder
sdfg_name = sdfg.name
# Needed to remove partial view towers (it is illegal and should not happen, but it happens)
clean_bad_views(sdfg)
sdfg.apply_transformations_repeated(ContinueToCondition) # To RM continue blocks - this could made into a nice transformation (living in Main)
sdfg.save("cpu_continue_to_cond.sdfgz", compress=True)
sdfg.simplify()
sdfg.save("cpu_simplified1.sdfgz", compress=True)
SymbolPropagation().apply_pass(sdfg, {}) # Like ConstProp can be made into a transformation
sdfg.save("cpu_symbol_prop.sdfgz", compress=True)
sdfg.compile()
sdfg.simplify()
sdfg.save("cpu_simplified2.sdfgz", compress=True)
sdfg.compile() # Crashes here
```
this one works fine:
```
import dace
from dace.transformation.interstate import (
ContinueToCondition,
)
from dace.transformation.passes import (
SymbolPropagation,
)
from dace.transformation.passes.struct_to_container_group import StructToContainerGroups
from utils import *
import dace
from dace import config, data as dt, dtypes, Memlet, symbolic
from dace.sdfg import SDFG, nodes, graph as gr
# Load SDFG
sdfg_names = [
"velocity_no_nproma_if_prop_lvn_only_0_istep_1.sdfgz",
]
resulting_sdfgs = []
for sdfg_name in sdfg_names:
sdfg = dace.SDFG.from_file(sdfg_name)
sdfg.name = sdfg_name.split(".")[0]
sdfg.validate()
build_loc = sdfg.build_folder
sdfg_name = sdfg.name
# Needed to remove partial view towers (it is illegal and should not happen, but it happens)
clean_bad_views(sdfg)
sdfg.apply_transformations_repeated(ContinueToCondition) # To RM continue blocks - this could made into a nice transformation (living in Main)
sdfg.save("cpu_continue_to_cond.sdfgz", compress=True)
StructToContainerGroups(
validate=False,
save_steps=False,
verbose=verbose,
simplify=False,
interface_with_struct_copy=True,
interface_to_gpu=False,
clean_trivial_views=True,
shallow_copy=False,
shallow_copy_to_gpu=False
).apply_pass(sdfg, {}) # Flattening pass
sdfg.simplify()
sdfg.save("cpu_simplified1.sdfgz", compress=True)
SymbolPropagation().apply_pass(sdfg, {}) # Like ConstProp can be made into a transformation
sdfg.save("cpu_symbol_prop.sdfgz", compress=True)
sdfg.compile()
sdfg.simplify()
sdfg.save("cpu_simplified2.sdfgz", compress=True)
sdfg.compile() # Crashes here
sdfg.save("final.sdfgz", compress=True)
```
Contributor guide
Assessment
This issue has not been assessed yet.