Inlining of scalar member variables of classes
- Dominant language
- Python
- Stars
- 593
- Forks
- 163
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 60
Description
**Describe the bug**
Scalar member variables of classes get inlined with `@dace.method` calls even if they are changed within the orchestrated call.
**To Reproduce**
Steps to reproduce the behavior:
1. Running
```
import dace
import numpy as np
class Foo:
def __init__(self) -> None:
self.scalar: float = 1
self.variable: float = 2
self.bar(-1)
def bar(self, variable: float):
if variable != self.variable:
self.variable = variable
self.scalar = variable * 10
@dace.method
def mainloop(self, variable, array):
self.bar(variable)
array[:] *= self.scalar
if __name__ == "__main__":
f = Foo()
array = np.ones((10, 10), dtype=np.float32)
variable = 20
f.mainloop(variable, array)
print(array.T)
```
shows that both the `self.scalar` as well as `self.variable` are inlined at post-init time.
Running this code does, without erroring out generate an array of `-10` as outputs.
**Expected behavior**
Even though it is known that this is a limitation to the framework, the naive user would expect a field filled with `200`.
**Screenshots**
Screenshot of inlined scalars in generated code

**Desktop (please complete the following information):**
- OS: ubuntu 19.04
- DaCe Version 0.14
**Additional context**
- There are workarounds for this problem, like using callbacks or using 0-dimensional arrays for this. But the behavior right now is not intuitive.
- We think that it should be possible to detect assignment to scalars or `dace.compiletime` and raise an exception in parsing already
Contributor guide
Assessment
This issue has not been assessed yet.