Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Validate Extensions using hierarchy, ignore input_extensions, RIP inference #1142

Merged
merged 35 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
8d117e8
WIP start removing NodeType
acl-cqc May 30, 2024
974236b
Revert "WIP start removing NodeType"
acl-cqc May 30, 2024
16c72e5
Drop validate_with_extension_closure...may want to revert eventually
acl-cqc May 30, 2024
759af86
Rm extension/validate.rs (ExtensionValidator), just check child.is_su…
acl-cqc May 30, 2024
07c09cd
Fix DataflowBlock::inner_signature (fixes 2*cfg tests in infer.rs)
acl-cqc May 30, 2024
08bb5a5
Fix tail_loop tests by adding extension_delta to TailLoop and impl Da…
acl-cqc May 30, 2024
d4e92d8
Fix/regenerate schema for TailLoop
acl-cqc May 30, 2024
968cc15
Fix constant.rs test_sum
acl-cqc May 30, 2024
e744527
Fix prelude.rs tests
acl-cqc May 30, 2024
7aa06b1
Fix constant.rs test
acl-cqc May 30, 2024
fcd10c1
Fix merge_bbs tests
acl-cqc May 30, 2024
664112f
Calculate delta in const_fold
acl-cqc May 30, 2024
fffacf9
const_fold/tests.rs via helper functions
acl-cqc May 30, 2024
3367490
const_fold/test.rs: drop first param to helper
acl-cqc May 30, 2024
8a9628f
Generalize parent_io_mismatch to cover Case, DFG and FuncDefn
acl-cqc May 31, 2024
a6e6459
Drop funcdefn_signature_mismatch(,2) tests
acl-cqc May 31, 2024
abe27fb
Don't call infer_extensions; drop broken tests
acl-cqc May 31, 2024
87b80d3
Rm infer.rs, infer/test.rs, infer_extensions, instantiate, etc. (keep…
acl-cqc May 31, 2024
5715ea1
Bonus (BREAKING): remove io_extensions()
acl-cqc May 31, 2024
d605c5b
Reinstate ExtensionError but as a struct
acl-cqc May 31, 2024
e691dea
And keep infer_extensions around as a No-op
acl-cqc May 31, 2024
4b61ff0
Test for CFG, BB
acl-cqc May 31, 2024
19e64a9
Be more explicit in ModuleRoot check
acl-cqc May 31, 2024
63a8a87
Tweak message
acl-cqc Jun 7, 2024
39fc4fe
Add assert message
acl-cqc Jun 7, 2024
00f152a
Conditional test
acl-cqc Jun 7, 2024
ae55091
Add TailLoop test
acl-cqc Jun 7, 2024
bcd23df
Combine BasicBlock/TailLoop tests
acl-cqc Jun 7, 2024
0f37a8f
Move cfg_children_restrictions out of extension_tests
acl-cqc Jun 7, 2024
53d2b88
...and inline singly-used add_block_children
acl-cqc Jun 7, 2024
bcec7cd
Merge remote-tracking branch 'origin/main' into extension_hierarchy
acl-cqc Jun 7, 2024
7e1cb4a
Add new test of too-many-connections in cfg
acl-cqc Jun 7, 2024
f256960
fix broken doclink
acl-cqc Jun 7, 2024
1bf1c14
clippy
acl-cqc Jun 7, 2024
546ced4
Try to fix 1.75 test
acl-cqc Jun 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions hugr-core/src/builder/build_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ pub trait Dataflow: Container {
just_inputs: impl IntoIterator<Item = (Type, Wire)>,
inputs_outputs: impl IntoIterator<Item = (Type, Wire)>,
just_out_types: TypeRow,
extension_delta: ExtensionSet,
) -> Result<TailLoopBuilder<&mut Hugr>, BuildError> {
let (input_types, mut input_wires): (Vec<Type>, Vec<Wire>) =
just_inputs.into_iter().unzip();
Expand All @@ -440,6 +441,7 @@ pub trait Dataflow: Container {
just_inputs: input_types.into(),
just_outputs: just_out_types,
rest: rest_types.into(),
extension_delta,
};
// TODO: Make input extensions a parameter
let (loop_node, _) = add_node_with_wires(self, tail_loop.clone(), input_wires)?;
Expand Down
17 changes: 12 additions & 5 deletions hugr-core/src/builder/tail_loop.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::extension::ExtensionSet;
use crate::ops;

use crate::hugr::{views::HugrView, NodeType};
Expand Down Expand Up @@ -74,11 +75,13 @@ impl TailLoopBuilder<Hugr> {
just_inputs: impl Into<TypeRow>,
inputs_outputs: impl Into<TypeRow>,
just_outputs: impl Into<TypeRow>,
extension_delta: ExtensionSet,
) -> Result<Self, BuildError> {
let tail_loop = ops::TailLoop {
just_inputs: just_inputs.into(),
just_outputs: just_outputs.into(),
rest: inputs_outputs.into(),
extension_delta,
};
// TODO: Allow input extensions to be specified
let base = Hugr::new(NodeType::new_open(tail_loop.clone()));
Expand All @@ -97,7 +100,6 @@ mod test {
DataflowSubContainer, HugrBuilder, ModuleBuilder,
},
extension::prelude::{ConstUsize, PRELUDE_ID, USIZE_T},
extension::ExtensionSet,
hugr::ValidationError,
ops::Value,
type_row,
Expand All @@ -107,7 +109,8 @@ mod test {
#[test]
fn basic_loop() -> Result<(), BuildError> {
let build_result: Result<Hugr, ValidationError> = {
let mut loop_b = TailLoopBuilder::new(vec![], vec![BIT], vec![USIZE_T])?;
let mut loop_b =
TailLoopBuilder::new(vec![], vec![BIT], vec![USIZE_T], PRELUDE_ID.into())?;
let [i1] = loop_b.input_wires_arr();
let const_wire = loop_b.add_load_value(ConstUsize::new(1));

Expand Down Expand Up @@ -141,8 +144,12 @@ mod test {
)?
.outputs_arr();
let loop_id = {
let mut loop_b =
fbuild.tail_loop_builder(vec![(BIT, b1)], vec![], type_row![NAT])?;
let mut loop_b = fbuild.tail_loop_builder(
vec![(BIT, b1)],
vec![],
type_row![NAT],
PRELUDE_ID.into(),
)?;
let signature = loop_b.loop_signature()?.clone();
let const_val = Value::true_val();
let const_wire = loop_b.add_load_const(Value::true_val());
Expand All @@ -161,7 +168,7 @@ mod test {
([type_row![], type_row![]], const_wire),
vec![(BIT, b1)],
output_row,
ExtensionSet::new(),
PRELUDE_ID.into(),
)?;

let mut branch_0 = conditional_b.case_builder(0)?;
Expand Down
7 changes: 0 additions & 7 deletions hugr-core/src/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ use crate::types::type_param::{TypeArg, TypeArgError, TypeParam};
use crate::types::{check_typevar_decl, CustomType, Substitution, TypeBound, TypeName};
use crate::types::{FunctionType, TypeNameRef};

#[allow(dead_code)]
mod infer;
#[cfg(feature = "extension_inference")]
pub use infer::infer_extensions;
pub use infer::{ExtensionSolution, InferExtensionError};

mod op_def;
pub use op_def::{
CustomSignatureFunc, CustomValidator, LowerFunc, OpDef, SignatureFromArgs, SignatureFunc,
Expand All @@ -35,7 +29,6 @@ pub use type_def::{TypeDef, TypeDefBound};
mod const_fold;
pub mod prelude;
pub mod simple_op;
pub mod validate;
pub use const_fold::{ConstFold, ConstFoldResult, Folder};
pub use prelude::{PRELUDE, PRELUDE_REGISTRY};

Expand Down
Loading