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

fix: Update number of ports for PartialOps, and sanitize orderd edges #1635

Merged
merged 3 commits into from
Nov 6, 2024

Conversation

aborgna-q
Copy link
Collaborator

The number of ports in a PartialOp dataflow node didn't get updated after connecting it.
We didn't see any problem with this because by default the number of output ports is grown when connecting new outputs, so the count ended up being correct.

#1625 found a bug where an UnpackTuple didn't connect its last output, so the serialization though the node had less output ports than it should have, and connected the order edge at an incorrect offset.

As part of this change I added various checks for the order edge index. We use a special -1 offset to identify them, so we should panic when that is seen on invalid places.

  • drive-by: Add a Hugr::has_link method
  • drive-by: Avoid adding duplicated order edges

Closes #1625

@aborgna-q aborgna-q requested a review from a team as a code owner November 5, 2024 16:43
@aborgna-q aborgna-q requested a review from ss2165 November 5, 2024 16:43
# https://github.com/CQCL/hugr/issues/1625
def test_dfg_unpack() -> None:
dfg = Dfg(tys.Tuple(tys.Bool, tys.Bool))
bool1, _unused_bool2 = dfg.add_op(ops.UnpackTuple(), *dfg.inputs())
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Notice that we don't use the node's 2nd output.

@aborgna-q aborgna-q added this pull request to the merge queue Nov 6, 2024
Merged via the queue into main with commit 81a1385 Nov 6, 2024
19 checks passed
@aborgna-q aborgna-q deleted the ab/fix/hugr-build-validation branch November 6, 2024 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect inter-graph edge validation error
2 participants