Skip to content

Commit

Permalink
feat: return replaced ops from lowering (#1568)
Browse files Browse the repository at this point in the history
Finishing a todo
drive-by: whitespace trimming in yml
  • Loading branch information
ss2165 authored Oct 9, 2024
1 parent 274a886 commit a725a29
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
enable-cache: true
- name: Install Python
run: uv python install ${{ matrix.python-version }}

- name: Setup dependencies. Fail if the lockfile is outdated.
run: uv sync --locked

Expand Down Expand Up @@ -106,7 +106,7 @@ jobs:
- { py: '3.12', coverage: true }
steps:
- uses: actions/checkout@v4

- name: Set up uv
uses: astral-sh/setup-uv@v3
with:
Expand Down
8 changes: 4 additions & 4 deletions hugr-passes/src/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub enum LowerError {
pub fn lower_ops(
hugr: &mut impl HugrMut,
lowering: impl Fn(&OpType) -> Option<Hugr>,
) -> Result<Vec<Node>, LowerError> {
) -> Result<Vec<(Node, OpType)>, LowerError> {
let replacements = hugr
.nodes()
.filter_map(|node| {
Expand All @@ -69,9 +69,9 @@ pub fn lower_ops(
.map(|(node, replacement)| {
let subcirc = SiblingSubgraph::try_from_nodes([node], hugr)?;
let rw = subcirc.create_simple_replacement(hugr, replacement)?;
// TODO return weights once https://github.com/CQCL/hugr/issues/476 is done.
hugr.apply_rewrite(rw)?;
Ok(node)
let mut repls = hugr.apply_rewrite(rw)?;
debug_assert_eq!(repls.len(), 1);
Ok(repls.remove(0))
})
.collect()
}
Expand Down

0 comments on commit a725a29

Please sign in to comment.