-
Notifications
You must be signed in to change notification settings - Fork 137
Description
Describe the bug
While running the following code:
import numpy as np
import dace
def sub_fn(x) -> dace.float32[3]:
STATIC_DATA = {
1: 1.06,
2: 0.98,
3: 99.7,
}
stuff = []
for i in x:
stuff.append(STATIC_DATA[i])
stuff = np.array(stuff)
print(x)
return stuff
@dace.program
def run(x):
stuff: dace.float32[3] = sub_fn(x)
return stuff
if __name__ == "__main__":
ret = run([1, 2, 3])
print(ret)
the output is the following:
[4607452634777659638 4607002274814922588 4636716180731382989]
[ 1.06 0.98 99.7 ]
While the final return value is correct, the argument x
has been corrupted after being read.
Expected behavior
I'm new to dace
, so I might be doing something wrong here. However, I'd expect x
to not be corrupted as such, since it doesn't make any sense at the Python level.
One thing that I find odd is that dace
won't run this code if it's all in the same function because of the dictionary (TypeError: unhashable type: 'collections.OrderedDict'
). I imagine that dictionaries can't be used with dace
and that subfunctions are just currently not checked? What is the best way to handle complex programs that require this type of branching?
Desktop (please complete the following information):
- OS: Linux Mint 22.1
- Python: 3.12.3
- dace: 1.0.2