Skip to content

Commit

Permalink
[new] Infer extension requirements (#330)
Browse files Browse the repository at this point in the history
Add a module `extension::infer`, which given a Hugr attempts to infer
the resource requirements where they are left open.

Addresses #425

---------

Co-authored-by: Seyon Sivarajah <[email protected]>
  • Loading branch information
croyzor and ss2165 authored Aug 25, 2023
1 parent 2013622 commit 95c0b56
Show file tree
Hide file tree
Showing 6 changed files with 1,057 additions and 36 deletions.
5 changes: 3 additions & 2 deletions src/builder/dataflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ impl DFGBuilder<Hugr> {
}

impl HugrBuilder for DFGBuilder<Hugr> {
fn finish_hugr(self) -> Result<Hugr, ValidationError> {
self.base.validate()?;
fn finish_hugr(mut self) -> Result<Hugr, ValidationError> {
let closure = self.base.infer_extensions()?;
self.base.validate_with_extension_closure(closure)?;
Ok(self.base)
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ use crate::types::type_param::{check_type_arg, TypeArgError};
use crate::types::type_param::{TypeArg, TypeParam};
use crate::types::CustomType;

mod infer;
pub use infer::{infer_extensions, ExtensionSolution, InferExtensionError};

mod op_def;
pub use op_def::{CustomSignatureFunc, OpDef};
mod type_def;
Expand Down
Loading

0 comments on commit 95c0b56

Please sign in to comment.