spcl / spcl/dace

Conditional `if array is None` behavior

Open
#1,209 12 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
593
Forks
163
Avg merge
2d 23h
Merged PRs (30d)
60

Description

**Bug**
Some pattern involving array switch on conditional and function broke after 0.14. I haven't tracked down exactly when, but 0.14.2 is broken.
This has been first identified in the larger Pace model - the NASA fork.

While trying to reproduce the actual error, I encounter a slightly different one. So let start here, but be aware they might be more.

**Reproducer**
```python
import dace
import numpy as np

def a_function(array, scalar: np.float32, optional_array=None):
if optional_array:
tmp_array = optional_array
else:
tmp_array = array

tmp_array[:] = scalar

@dace.program
def a_program(array, scalar: np.float32, optional_array):
a_function(array, scalar)
a_function(array, scalar, optional_array)

arr = np.ones((4), dtype=np.float32)
opt_arr = np.ones((4), dtype=np.float32)
s = np.float32(3.0)

a_program(arr, s, opt_arr)

assert (arr == s).all()
assert (opt_arr == s).all()
```

**Expected behavior**
0.14: assert are fine, code works as intent (both arrays are init)
0.14.2: callback is triggered for no reason then conditional fails to parse

**Notes**
There's no identified workaround for this apart code duplication which would be significant and a risk to maintenance on our side. Therefore this regression blocks us from updating DaCe.

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.