spcl / spcl/dace

Influence of Unused Transient on the Signature

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

As far as I can tell the recent [fix to `LoopToMap`](https://github.com/spcl/dace/pull/2349) introduced a change in behaviour.
The PR also modified how `SDFG::_used_symbols_internal()` works and in my opinion changed it in a non desirable way.

Consider the following script:
```python=
import dace
import pytest

def _make_sdfg_with_unused_transient(create_unused_transient: bool) -> dace.SDFG:
sdfg = dace.SDFG("unused_transient")
state = sdfg.add_state()

for name in "ab":
sdfg.add_array(
name,
shape=(10,),
dtype=dace.float64,
transient=False,
)

sdfg.add_symbol("x_shape", dace.int32)
if create_unused_transient:
sdfg.add_array(
"x",
shape=("x_shape",),
dtype=dace.float32,
transient=True,
)

state.add_mapped_tasklet(
"map",
map_ranges={"__i": "0:10"},
inputs={"__in": dace.Memlet("a[__i]")},
code="__out = __in + 1.90",
outputs={"__out": dace.Memlet("b[__i]")},
external_edges=True,
)

return sdfg

if __name__ == "__main__":
create_unused_transient = True
sdfg: dace.SDFG = _make_sdfg_with_unused_transient(create_unused_transient)

print(f"Free Symbols: {sdfg.free_symbols}")
print(f"arglist(): {sdfg.arglist()}")
print(f"signature_arglist(): {sdfg.signature_arglist()}")
print(f"signature_init_arglist(): {sdfg.init_signature()}")
```

As you can see depending on `create_unused_transient` the SDFG may or may not contain data descriptor with name `x`, that when it is present is not used.
Furthermore, the array has a symbolic size of `x_shape`, that symbol, however, is always present.
If you run that script using DaCe `2.0.0a3`, then `x_shape` will _not_ be part of the signature.

But if you use current `main` (`a6717b608f497190205d`) then `x_shape` will part of the signature if `create_unused_transient` is `True`.
However, if `create_unused_transient` is `False` then it will not be present.
It is important to notice that even if `x_shape` is present in the signature it is not used, i.e. the array is not allocated.

My question now is what is the correct behaviour?
In my opinion `x_shape` should not be part of the signature and this is an unintended side effect.

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.