-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deepcopy of state in _copy_state copies the parent sdfg #1443
Comments
Can you verify that it is indeed deep-copying the parent SDFG? In general, when making a clone of an object of some DaCe class, we do deep-copy, but we also describe what deep-copy should do in the class's |
@dace.program
def double_loop(arr: dace.float32[N]):
for i in range(N):
arr[i] *= 2
for i in range(N):
arr[i] *= 2
sdfg = double_loop.to_sdfg()
from dace.transformation.helpers import find_sdfg_control_flow
from dace.sdfg.validation import validate_sdfg
find_sdfg_control_flow(sdfg)
validate_sdfg(sdfg) is enough to trigger the error. |
The bug was indeed in |
This PR fixes #1439 and #1443 by adapting fields and the deepcopy operation for states: 1. Skips derived field `parent` being set if a state is deepcopied on its own 2. Does not add a new field to AST nodes during preprocessing. That parent-pointing field outlives preprocessing and ends up copying the entire original AST for short codeblocks. 3. Does not add a new field to states during state propagation.
dace/dace/transformation/helpers.py
Lines 206 to 208 in 4139ddf
The state is deepcopied and inserted into the sdfg. This results in an expensive copy of the state._parent sdfg, and in potential failures of the state validation (that checks that all states in an sdfg have that sdfg instance as parent).
In general, using deepcopies instead of dedicated methods sounds dangerous.
The text was updated successfully, but these errors were encountered: