Skip to content

Commit

Permalink
chore: Bump to hugr-0.7.0 (#469)
Browse files Browse the repository at this point in the history
  • Loading branch information
doug-q authored Jul 11, 2024
1 parent 10639b9 commit 88e9010
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 35 deletions.
21 changes: 11 additions & 10 deletions Cargo.lock

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

7 changes: 3 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ missing_docs = "warn"

[workspace.dependencies]

tket2 = { path = "./tket2" }
hugr = "0.6.1"
hugr-cli = "0.1.2"
hugr-core = "0.3.1"
hugr = "0.7.0"
hugr-cli = "0.1.3"
hugr-core = "0.4.0"
portgraph = "0.12"
pyo3 = "0.21.2"
itertools = "0.13.0"
Expand Down
2 changes: 1 addition & 1 deletion badger-optimiser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ publish = false
[dependencies]
clap = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
tket2 = { workspace = true, features = ["portmatching", "rewrite-tracing"] }
tket2 = { path = "../tket2", features = ["portmatching", "rewrite-tracing"] }
hugr = { workspace = true }
itertools = { workspace = true }
tket-json-rs = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion compile-rewriter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ publish = false

[dependencies]
clap = { workspace = true, features = ["derive"] }
tket2 = { workspace = true, features = ["portmatching"] }
tket2 = { path = "../tket2", features = ["portmatching"] }
hugr = { workspace = true }
itertools = { workspace = true }
9 changes: 1 addition & 8 deletions tket2/src/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use std::iter::Sum;
pub use command::{Command, CommandIterator};
pub use hash::CircuitHash;
use hugr::hugr::views::{DescendantsGraph, ExtractHugr, HierarchyView};
use hugr_core::hugr::internal::HugrMutInternals;
use itertools::Either::{Left, Right};

use hugr::hugr::hugrmut::HugrMut;
Expand Down Expand Up @@ -123,8 +122,6 @@ impl<T: HugrView> Circuit<T> {
}

/// Returns the function type of the circuit.
///
/// Equivalent to [`HugrView::get_function_type`].
#[inline]
pub fn circuit_signature(&self) -> FunctionType {
let op = self.hugr.get_optype(self.parent);
Expand Down Expand Up @@ -317,11 +314,7 @@ impl<T: HugrView> Circuit<T> {
} else {
let view: DescendantsGraph = DescendantsGraph::try_new(&self.hugr, self.parent)
.expect("Circuit parent was not a dataflow container.");
let mut hugr = view.extract_hugr();
// TODO: Remove this once hugr 0.6.0 gets released.
// https://github.com/CQCL/hugr/pull/1239
hugr.set_num_ports(hugr.root(), 0, 0);
hugr.into()
view.extract_hugr().into()
};
extract_dfg::rewrite_into_dfg(&mut circ)?;
Ok(circ)
Expand Down
13 changes: 7 additions & 6 deletions tket2/src/circuit/extract_dfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ pub(super) fn rewrite_into_dfg(circ: &mut Circuit) -> Result<(), CircuitMutError
_ => signature,
};

let dfg = DFG { signature };
circ.hugr.replace_op(circ.parent(), OpType::DFG(dfg))?;
circ.hugr.replace_op(circ.parent(), DFG { signature })?;

Ok(())
}
Expand Down Expand Up @@ -81,10 +80,12 @@ fn remove_cfg_empty_output_tuple(

// Add a new output node.
let new_types = output_sig.input[1..].to_vec();
let new_op = Output {
types: new_types.clone().into(),
};
let new_node = hugr.add_node_after(input_node, new_op);
let new_node = hugr.add_node_after(
input_node,
Output {
types: new_types.clone().into(),
},
);

// Reconnect the outputs.
for (i, (neigh, port)) in input_neighs.into_iter().enumerate() {
Expand Down
11 changes: 6 additions & 5 deletions tket2/src/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ impl MakeOpDef for Tk2Op {
.into()
}

fn extension(&self) -> ExtensionId {
EXTENSION_ID.to_owned()
}

fn post_opdef(&self, def: &mut OpDef) {
def.add_misc(
"commutation",
Expand All @@ -146,7 +150,7 @@ impl MakeOpDef for Tk2Op {
}

fn from_def(op_def: &OpDef) -> Result<Self, hugr::extension::simple_op::OpLoadError> {
try_from_name(op_def.name())
try_from_name(op_def.name(), &EXTENSION_ID)
}
}

Expand Down Expand Up @@ -244,10 +248,7 @@ impl TryFrom<&OpType> for Tk2Op {

match custom_op {
CustomOp::Extension(ext) => Tk2Op::from_extension_op(ext).ok(),
CustomOp::Opaque(opaque) => match opaque.extension() == &EXTENSION_ID {
true => try_from_name(opaque.name()).ok(),
false => None,
},
CustomOp::Opaque(opaque) => try_from_name(opaque.name(), &EXTENSION_ID).ok(),
}
.ok_or_else(|| NotTk2Op { op: op.clone() })
}
Expand Down

0 comments on commit 88e9010

Please sign in to comment.