Skip to content

Commit

Permalink
chore: update dependency to hugr 0.10.1 (#735)
Browse files Browse the repository at this point in the history
use the Some utility in a few places
  • Loading branch information
ss2165 authored Dec 19, 2024
1 parent ed3c0b8 commit 6900c8d
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 50 deletions.
57 changes: 31 additions & 26 deletions Cargo.lock

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

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ pyo3 = "0.19.0"
serde_json = "1.0.111"
cargo_toml = "0.20.4"
thiserror = "2.0.6"
hugr = "0.14.0"
hugr-cli = "0.14.0"
hugr = "0.14.1"
hugr-cli = "0.14.1"
inkwell = "0.5.0"

[patch.crates-io]

# Uncomment these to test the latest dependency version during development
hugr = { git = "https://github.com/CQCL/hugr", rev = "ab94518" }
hugr-cli = { git = "https://github.com/CQCL/hugr", rev = "ab94518" }
hugr-llvm = { git = "https://github.com/CQCL/hugr", rev = "ab94518" }
# hugr = { git = "https://github.com/CQCL/hugr", rev = "ab94518" }
# hugr-cli = { git = "https://github.com/CQCL/hugr", rev = "ab94518" }
# hugr-llvm = { git = "https://github.com/CQCL/hugr", rev = "ab94518" }
2 changes: 1 addition & 1 deletion execute_llvm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "execute_llvm"
version = "0.2.0"
version = "0.2.1"
edition.workspace = true
homepage.workspace = true
repository.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions execute_llvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ fn find_funcdef_node(hugr: impl HugrView, fn_name: &str) -> PyResult<hugr::Node>
}
}

fn guppy_pass(hugr: Hugr) -> Hugr {
let hugr = hugr::algorithms::monomorphize(hugr);
fn guppy_pass(mut hugr: Hugr) -> Hugr {
hugr::algorithms::MonomorphizePass::default().run(&mut hugr).unwrap();
hugr::algorithms::remove_polyfuncs(hugr)
}

Expand Down
6 changes: 3 additions & 3 deletions guppylang/compiler/stmt_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ def _assign_tuple(self, lhs: TupleUnpack, port: Wire) -> None:
starred_ports = (
ports[len(left) : -len(right)] if right else ports[len(left) :]
)
opt_ty = ht.Option(get_element_type(array_ty).to_hugr())
opts = [self.builder.add_op(ops.Tag(1, opt_ty), p) for p in starred_ports]
array = self.builder.add_op(array_new(opt_ty, len(opts)), *opts)
elt = get_element_type(array_ty).to_hugr()
opts = [self.builder.add_op(ops.Some(elt), p) for p in starred_ports]
array = self.builder.add_op(array_new(ht.Option(elt), len(opts)), *opts)
self._assign(starred, array)

@_assign.register
Expand Down
11 changes: 6 additions & 5 deletions guppylang/std/_internal/compiler/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,12 @@ def build_classical_array(self, elems: list[Wire]) -> Wire:

def build_linear_array(self, elems: list[Wire]) -> Wire:
"""Lowers a call to `array.__new__` for linear arrays."""
elem_opt_ty = ht.Option(self.elem_ty)
elem_opts = [
self.builder.add_op(ops.Tag(1, elem_opt_ty), elem) for elem in elems
self.builder.add_op(ops.Some(self.elem_ty), elem) for elem in elems
]
return self.builder.add_op(array_new(elem_opt_ty, len(elems)), *elem_opts)
return self.builder.add_op(
array_new(ht.Option(self.elem_ty), len(elems)), *elem_opts
)

def compile(self, args: list[Wire]) -> list[Wire]:
if self.elem_ty.type_bound() == ht.TypeBound.Any:
Expand Down Expand Up @@ -232,7 +233,7 @@ def build_classical_setitem(
# See https://github.com/CQCL/guppylang/issues/629
elem_opt_ty = ht.Option(self.elem_ty)
idx = self.builder.add_op(convert_itousize(), idx)
elem_opt = self.builder.add_op(ops.Tag(1, elem_opt_ty), elem)
elem_opt = self.builder.add_op(ops.Some(self.elem_ty), elem)
result = self.builder.add_op(
array_set(elem_opt_ty, self.length), array, idx, elem_opt
)
Expand All @@ -246,7 +247,7 @@ def build_linear_setitem(
"""Lowers a call to `array.__setitem__` for linear arrays."""
# Embed the element into an optional
elem_opt_ty = ht.Option(self.elem_ty)
elem = self.builder.add_op(ops.Tag(1, elem_opt_ty), elem)
elem = self.builder.add_op(ops.Some(self.elem_ty), elem)
idx = self.builder.add_op(convert_itousize(), idx)
result = self.builder.add_op(
array_set(elem_opt_ty, self.length), array, idx, elem
Expand Down
6 changes: 3 additions & 3 deletions guppylang/std/_internal/compiler/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def build_linear_setitem(
"""Lowers a call to `array.__setitem__` for linear arrays."""
# Embed the element into an optional
elem_opt_ty = ht.Option(elem_ty)
elem = self.builder.add_op(ops.Tag(1, elem_opt_ty), elem)
elem = self.builder.add_op(ops.Some(elem_ty), elem)
idx = self.builder.add_op(convert_itousize(), idx)
list_wire, result = self.builder.add_op(
list_set(elem_opt_ty), list_wire, idx, elem
Expand Down Expand Up @@ -274,7 +274,7 @@ def build_linear_push(
"""Lowers a call to `list.push` for linear lists."""
# Wrap element into an optional
elem_opt_ty = ht.Option(elem_ty)
elem_opt = self.builder.add_op(ops.Tag(1, elem_opt_ty), elem)
elem_opt = self.builder.add_op(ops.Some(elem_ty), elem)
list_wire = self.builder.add_op(list_push(elem_opt_ty), list_wire, elem_opt)
return CallReturnWires(regular_returns=[], inout_returns=[list_wire])

Expand Down Expand Up @@ -337,6 +337,6 @@ def _list_new_linear(
lst = builder.load(ListVal([], elem_ty=elem_opt_ty))
push_op = list_push(elem_opt_ty)
for elem in args:
elem_opt = builder.add_op(ops.Tag(1, elem_opt_ty), elem)
elem_opt = builder.add_op(ops.Some(elem_type), elem)
lst = builder.add_op(push_op, lst, elem_opt)
return lst
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies = [
"networkx >=3.2.1,<4",
"pydantic >=2.7.0b1,<3",
"typing-extensions >=4.9.0,<5",
"hugr >=0.10.0,<0.11",
"hugr >=0.10.1,<0.11",
"tket2-exts>=0.3.0,<0.4",
]

Expand Down Expand Up @@ -83,7 +83,7 @@ members = ["execute_llvm"]
execute-llvm = { workspace = true }

# Uncomment these to test the latest dependency version during development
hugr = { git = "https://github.com/CQCL/hugr", subdirectory = "hugr-py", rev = "e40b6c7" }
# hugr = { git = "https://github.com/CQCL/hugr", subdirectory = "hugr-py", rev = "e40b6c7" }
# tket2-exts = { git = "https://github.com/CQCL/tket2", subdirectory = "tket2-exts", rev = "eb7cc63"}
# tket2 = { git = "https://github.com/CQCL/tket2", subdirectory = "tket2-py", rev = "eb7cc63"}

Expand Down
10 changes: 7 additions & 3 deletions uv.lock

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

0 comments on commit 6900c8d

Please sign in to comment.