Skip to content

Commit

Permalink
chore: Bump Hugr version (#77)
Browse files Browse the repository at this point in the history
mark-koch authored Jan 9, 2024
1 parent 9ac76af commit c5be90a
Showing 6 changed files with 63 additions and 31 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ jobs:
with:
command: build
sccache: 'true'
rust-toolchain: '1.75'
working-directory: validator

- name: Install Hugr validator
11 changes: 7 additions & 4 deletions guppy/hugr/hugr.py
Original file line number Diff line number Diff line change
@@ -391,7 +391,10 @@ def add_output(
def add_block(self, parent: Node | None, num_successors: int = 0) -> BlockNode:
"""Adds a `Block` node to the graph."""
node = BlockNode(
idx=self._graph.number_of_nodes(), op=ops.DFB(), parent=parent, meta_data={}
idx=self._graph.number_of_nodes(),
op=ops.DataflowBlock(),
parent=parent,
meta_data={},
)
self._insert_node(node)
for _ in range(num_successors):
@@ -403,7 +406,7 @@ def add_exit(self, output_tys: TypeList, parent: Node) -> CFNode:
outputs = [ty.to_hugr() for ty in output_tys]
node = CFNode(
idx=self._graph.number_of_nodes(),
op=ops.Exit(cfg_outputs=outputs),
op=ops.ExitBlock(cfg_outputs=outputs),
parent=parent,
meta_data={},
)
@@ -702,11 +705,11 @@ def to_raw(self) -> raw.RawHugr:
elif isinstance(n.op, ops.Output):
output_nodes.append(n)
elif (
isinstance(n.op, ops.DFB)
isinstance(n.op, ops.DataflowBlock)
and next(self.in_edges(n.in_port(None)), None) is None
):
entry_nodes.append(n)
elif isinstance(n.op, ops.Exit):
elif isinstance(n.op, ops.ExitBlock):
exit_nodes.append(n)
else:
remaining_nodes.append(n)
21 changes: 6 additions & 15 deletions guppy/hugr/ops.py
Original file line number Diff line number Diff line change
@@ -105,17 +105,11 @@ class Const(BaseOp):
# -----------------------------------------------


class BasicBlock(BaseOp):
"""A basic block in a control flow graph - parent will be a CFG node."""

op: Literal["BasicBlock"] = "BasicBlock"


class DFB(BasicBlock):
class DataflowBlock(BaseOp):
"""A CFG basic block node. The signature is that of the internal Dataflow
graph."""

block: Literal["DFB"] = "DFB"
op: Literal["DataflowBlock"] = "DataflowBlock"
inputs: TypeRow = Field(default_factory=list)
other_outputs: TypeRow = Field(default_factory=list)
tuple_sum_rows: list[TypeRow] = Field(default_factory=list)
@@ -144,17 +138,14 @@ def insert_child_dfg_signature(self, inputs: TypeRow, outputs: TypeRow) -> None:
self.other_outputs = outputs[1:]


class Exit(BasicBlock):
class ExitBlock(BaseOp):
"""The single exit node of the CFG, has no children, stores the types of
the CFG node output."""

block: Literal["Exit"] = "Exit"
op: Literal["ExitBlock"] = "ExitBlock"
cfg_outputs: TypeRow


BasicBlockOp = Annotated[DFB | Exit, Field(discriminator="block")]


# ---------------------------------------------
# --------------- DataflowOp ------------------
# ---------------------------------------------
@@ -515,14 +506,14 @@ class Tag(LeafOp):
OpType = Annotated[
(
Module
| BasicBlock
| Case
| Module
| FuncDefn
| FuncDecl
| Const
| DummyOp
| BasicBlockOp
| DataflowBlock
| ExitBlock
| Conditional
| TailLoop
| CFG
55 changes: 46 additions & 9 deletions validator/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion validator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -10,6 +10,6 @@ crate-type = ["cdylib"]

[dependencies]
pyo3 = "0.19.0"
quantinuum-hugr = { git = "https://github.com/CQCL-DEV/hugr.git", rev = "d00dc3f1d6000349404f01a6bfc6bf94a32b9956" }
quantinuum-hugr = { git = "https://github.com/CQCL/hugr.git", rev = "d07406c13b03a93014ae08a70bb789b25e0b31eb" }
rmp-serde = "1.1.1"
lazy_static = "1.4.0"
4 changes: 2 additions & 2 deletions validator/src/lib.rs
Original file line number Diff line number Diff line change
@@ -10,8 +10,8 @@ lazy_static! {
logic::EXTENSION.to_owned(),
int_types::extension(),
int_ops::EXTENSION.to_owned(),
float_types::extension(),
float_ops::extension()
float_types::EXTENSION.to_owned(),
float_ops::EXTENSION.to_owned(),
])
.unwrap();
}

0 comments on commit c5be90a

Please sign in to comment.