Skip to content
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

Interstate assignment to map #1790

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

ThrudPrimrose
Copy link
Collaborator

@ThrudPrimrose ThrudPrimrose commented Nov 21, 2024

Maps simple interstate assignments to map encompassing the whole state.
Will complete after the bug fix on re-declaration of symbols is merge.

The pass only transforms if the assignment is a constant. (and the loops such as i = i + 1 should not be affected)

@ThrudPrimrose ThrudPrimrose added the no-ci Do not run any CI or actions for this PR label Nov 21, 2024
@ThrudPrimrose ThrudPrimrose removed the no-ci Do not run any CI or actions for this PR label Dec 3, 2024
@ThrudPrimrose ThrudPrimrose marked this pull request as ready for review December 3, 2024 09:11
@ThrudPrimrose ThrudPrimrose changed the title [Draft] Interstate assignment to map Interstate assignment to map Dec 3, 2024
@ThrudPrimrose
Copy link
Collaborator Author

I should move this to a transformation. If the assigned symbol's value is used in more than one state, we need to wrap the whole subgraph where this value is necessary in a map and not just one state.

@ThrudPrimrose ThrudPrimrose requested review from tbennun, phschaad and acalotoiu and removed request for tbennun, phschaad and acalotoiu December 16, 2024 11:20
Comment on lines +21 to +25
def _is_simple_assignment(expression_str):
expr = SymExpr(expression_str)
simplified_expr = expr.simplify()
is_constant = simplified_expr.is_number
return is_constant, simplified_expr
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use symbolic.issymbolic()?

Comment on lines +30 to +31
assignments = in_edge.data._assignments
condition = in_edge.data._cond_sympy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't use the internal cached versions, use the methods that we provide.


# Create cutout of the state as an SDFG (should have only one state)
# Create NestedSDFG, add it to the current state
cutout = SDFGCutout.singlestate_cutout(state, *state.nodes())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have utility functions called dace.sdfg.utils.nest_state_subgraph and nest_sdfg_subgraph that are much easier to use and more stable.

@@ -0,0 +1,51 @@
from typing import Dict
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing copyright

sdfg()

if __name__ == "__main__":
test_interstate_assignment()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please run yapf :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants