Open BenWeber42 opened 4 months ago
This is partially a UX issue. a
and b
in r = a + b
(line 15) are considered a
and b
from lines 18 and 19. This happens due to Python's scoping rules and the frontend's preprocessing actively looking for global variables. A quick fix is to either rename the variables or move the program outside the testing method (in another scope). My guess is that preprocessing is not taking into account definitions with <<
and >>,
so a better solution would address that issue.
Ok, thanks!, your proposed work-around fixed the issue.
For my understanding, the issue is that Python's scoping rules and DaCe's scoping rules are different in this case. Particularly in a DaCe tasklet, a << A[0]
, b << B[0]
and r >> R[0]
can declare new variables (i.e., variables a
, b
and r
), whereas in Python they cannot declare new variables. In Python, they only count as variable usages.
a << A[0]
, b << B[0]
and r >> R[0]
, considers them only variable usages of a
, b
and r
.a
, b
and r
are part of the closure of the add_tasklet
methodadd_tasklet
dace program, it uses the closure computed by Python to determine that a
, b
and r
must come from the outside, hence they become parameters of the SDFGPreferably, preprocessing should take into account, that a << A[0]
, b << B[0]
and r >> R[0]
can in fact declare local variables. Thus, a
, b
and r
are not part of the closure and don't become parameters of the SDFG.
When using the explicit dataflow mode of the Python front-end to declare a tasklet with connectors, the body of the tasklet doesn't correctly recognize the variables introduced by memlets.
This example triggers this bug:
The whole test is available here: https://github.com/BenWeber42/dace/blob/tasklet-connector-bug/tests/python_frontend/tasklet_connector_test.py
The generated SDFG contains a tasklet with the code
r = (None + None)
. It seems like the memlet declarations (a << A[0]
andb << B[0]
) are not recognized in the tasklet body (r = a + b
).