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

round-trip serialization fails #949

Closed
doug-q opened this issue Apr 18, 2024 · 4 comments
Closed

round-trip serialization fails #949

doug-q opened this issue Apr 18, 2024 · 4 comments
Assignees

Comments

@doug-q
Copy link
Collaborator

doug-q commented Apr 18, 2024

As evidenced in #948 our serialization is not currently round-tripping as one would expect. There seem to be two flavours of failure:

``` ---- hugr::views::tests::mermaid_string::case_2_cfg stdout ---- thread 'hugr::views::tests::mermaid_string::case_2_cfg' panicked at hugr/src/hugr/serialize.rs:327:34: called `Result::unwrap()` on an `Err` value: Error("Cannot connect an edge without port offset to node Node(1) with operation type DataflowBlock(DataflowBlock { inputs: TypeRow { types: [Type(Extension(CustomType { extension: IdentList(\"prelude\"), id: \"usize\", args: [], bound: Eq }), Eq)] }, other_outputs: TypeRow { types: [] }, sum_rows: [TypeRow { types: [Type(Extension(CustomType { extension: IdentList(\"prelude\"), id: \"usize\", args: [], bound: Eq }), Eq)] }, TypeRow { types: [Type(Extension(CustomType { extension: IdentList(\"prelude\"), id: \"usize\", args: [], bound: Eq }), Eq)] }], extension_delta: ExtensionSet({}) }).", line: 0, column: 0) ```
and
``` ---- ops::constant::test::test_sum stdout ---- thread 'ops::constant::test::test_sum' panicked at hugr/src/hugr/serialize.rs:353:13: assertion `left == right` failed left: Const(Sum { tag: 0, values: [Extension { e: ExtensionConst(CustomTestValue(CustomType { extension: IdentList("prelude"), id: "usize", args: [], bound: Eq })) }, Extension { e: ExtensionConst(CustomSerialized { typ: Type(Extension(CustomType { extension: IdentList("arithmetic.float.types"), id: "float64", args: [], bound: Copyable }), Copyable), value: Number(5.1), extensions: ExtensionSet({IdentList("arithmetic.float.types")}) }) }], sum_type: General { rows: [TypeRow { types: [Type(Extension(CustomType { extension: IdentList("prelude"), id: "usize", args: [], bound: Eq }), Eq), Type(Extension(CustomType { extension: IdentList("arithmetic.float.types"), id: "float64", args: [], bound: Copyable }), Copyable)] }, TypeRow { types: [] }] } }) right: Const(Sum { tag: 0, values: [Extension { e: ExtensionConst(CustomTestValue(CustomType { extension: IdentList("prelude"), id: "usize", args: [], bound: Eq })) }, Extension { e: ExtensionConst(CustomSerialized { typ: Type(Extension(CustomType { extension: IdentList("arithmetic.float.types"), id: "float64", args: [], bound: Copyable }), Copyable), value: Number(5.1), extensions: ExtensionSet({IdentList("arithmetic.float.types")}) }) }], sum_type: General { rows: [TypeRow { types: [Type(Extension(CustomType { extension: IdentList("prelude"), id: "usize", args: [], bound: Eq }), Eq), Type(Extension(CustomType { extension: IdentList("arithmetic.float.types"), id: "float64", args: [], bound: Copyable }), Copyable)] }, TypeRow { types: [] }] } }) ```

I have confirmed that these failures are present back to v0.1

@doug-q
Copy link
Collaborator Author

doug-q commented Apr 18, 2024

The second failure class is caused by missing equals_const for CustomTestValue, I've pushed a fix to #948

@doug-q
Copy link
Collaborator Author

doug-q commented Apr 18, 2024

The first failure is caused by not accounting properly for ControlFlow edges. See OpType::other_port and consider a DataflowBlock with a number of out edges != 1

@aborgna-q
Copy link
Collaborator

aborgna-q commented Apr 18, 2024

I've pushed a fix to #947

I think you meant #948

@doug-q
Copy link
Collaborator Author

doug-q commented May 15, 2024

Fixed by #1005 #968

@doug-q doug-q closed this as completed May 15, 2024
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

No branches or pull requests

2 participants