-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat: MakeTuple->UnpackTuple elision pass #2012
base: main
Are you sure you want to change the base?
Conversation
b3dc6a5
to
bad40dc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Mostly wondering about edge cases with order and inter-graph edges?
Btw, it would be nice to have the opposite UnpackTuple -> MakeTuple
elison as well since Guppy sometimes emits those when dealing with structs. Happy for this to be a follow-up though
let mut nodes = unpack_nodes; | ||
nodes.push(pack_node); | ||
let subcirc = SiblingSubgraph::try_from_nodes_with_checker(nodes, hugr, checker).unwrap(); | ||
let subcirc_signature = subcirc.signature(hugr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
afaik this will panic if there are order edges?
|
||
let mut nodes = unpack_nodes; | ||
nodes.push(pack_node); | ||
let subcirc = SiblingSubgraph::try_from_nodes_with_checker(nodes, hugr, checker).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this unwrap
safe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the make-unpack is an inter-graph edge?
Imports the
MakeTuple -> UnpackTuple
elimination pass from tket2.This removes tuple unpacks consuming the output of a
MakeTuple
, and deletes the packing operation when possible.This pass does not remove the reverse case,
Unpack->MakeTuple
. Should it be added here? We should avoid producing overlapping rewrites if doing that (the simplePack->Unpack->Pack
case is easy, but multiports can make things interesting).Requires #2011
Closes #1810