Skip to content

Commit 7559007

Browse files
committed
Removed runtime extension sets.
1 parent db1ffb0 commit 7559007

File tree

126 files changed

+593
-2974
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+593
-2974
lines changed

.github/workflows/ci-rs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ jobs:
108108
- name: Override criterion with the CodSpeed harness
109109
run: cargo add --dev codspeed-criterion-compat --rename criterion --package hugr
110110
- name: Build benchmarks
111-
run: cargo codspeed build --profile bench --features extension_inference,declarative,llvm,llvm-test
111+
run: cargo codspeed build --profile bench --features declarative,llvm,llvm-test
112112
- name: Run benchmarks
113113
uses: CodSpeedHQ/action@v3
114114
with:

.pre-commit-config.yaml

+2-5
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ repos:
7979
# built into a binary build (without using `maturin`)
8080
#
8181
# This feature list should be kept in sync with the `hugr-py/pyproject.toml`
82-
entry: cargo test --workspace --exclude 'hugr-py' --features 'hugr/extension_inference hugr/declarative hugr/model_unstable hugr/llvm hugr/llvm-test hugr/zstd'
82+
entry: cargo test --workspace --exclude 'hugr-py' --features 'hugr/declarative hugr/llvm hugr/llvm-test hugr/zstd'
8383
language: system
8484
files: \.rs$
8585
pass_filenames: false
@@ -100,10 +100,7 @@ repos:
100100
- id: py-test
101101
name: pytest
102102
description: Run python tests
103-
# We need to rebuild `hugr-cli` without the `extension_inference` feature
104-
# to avoid test errors.
105-
# TODO: Remove this once the issue is fixed.
106-
entry: sh -c "cargo build -p hugr-cli && uv run pytest"
103+
entry: sh -c "uv run pytest"
107104
language: system
108105
files: \.py$
109106
pass_filenames: false

hugr-core/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ categories = ["compilers"]
1717
workspace = true
1818

1919
[features]
20-
extension_inference = []
2120
declarative = ["serde_yaml"]
2221
zstd = ["dep:zstd"]
2322

hugr-core/README.md

-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ Please read the [API documentation here][].
1414

1515
## Experimental Features
1616

17-
- `extension_inference`:
18-
Experimental feature which allows automatic inference of which extra extensions
19-
are required at runtime by a HUGR when validating it.
20-
Not enabled by default.
2117
- `declarative`:
2218
Experimental support for declaring extensions in YAML files, support is limited.
2319

hugr-core/src/builder.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
//! let _dfg_handle = {
4343
//! let mut dfg = module_builder.define_function(
4444
//! "main",
45-
//! Signature::new_endo(bool_t()).with_extension_delta(logic::EXTENSION_ID),
45+
//! Signature::new_endo(bool_t()),
4646
//! )?;
4747
//!
4848
//! // Get the wires from the function inputs.
@@ -59,8 +59,7 @@
5959
//! let _circuit_handle = {
6060
//! let mut dfg = module_builder.define_function(
6161
//! "circuit",
62-
//! Signature::new_endo(vec![bool_t(), bool_t()])
63-
//! .with_extension_delta(logic::EXTENSION_ID),
62+
//! Signature::new_endo(vec![bool_t(), bool_t()]),
6463
//! )?;
6564
//! let mut circuit = dfg.as_circuit(dfg.input_wires());
6665
//!
@@ -89,7 +88,7 @@
8988
use thiserror::Error;
9089

9190
use crate::extension::simple_op::OpLoadError;
92-
use crate::extension::{SignatureError, TO_BE_INFERRED};
91+
use crate::extension::SignatureError;
9392
use crate::hugr::ValidationError;
9493
use crate::ops::handle::{BasicBlockID, CfgID, ConditionalID, DfgID, FuncID, TailLoopID};
9594
use crate::ops::{NamedOp, OpType};
@@ -123,16 +122,14 @@ pub use conditional::{CaseBuilder, ConditionalBuilder};
123122
mod circuit;
124123
pub use circuit::{CircuitBuildError, CircuitBuilder};
125124

126-
/// Return a FunctionType with the same input and output types (specified)
127-
/// whose extension delta, when used in a non-FuncDefn container, will be inferred.
125+
/// Return a FunctionType with the same input and output types (specified).
128126
pub fn endo_sig(types: impl Into<TypeRow>) -> Signature {
129-
Signature::new_endo(types).with_extension_delta(TO_BE_INFERRED)
127+
Signature::new_endo(types)
130128
}
131129

132-
/// Return a FunctionType with the specified input and output types
133-
/// whose extension delta, when used in a non-FuncDefn container, will be inferred.
130+
/// Return a FunctionType with the specified input and output types.
134131
pub fn inout_sig(inputs: impl Into<TypeRow>, outputs: impl Into<TypeRow>) -> Signature {
135-
Signature::new(inputs, outputs).with_extension_delta(TO_BE_INFERRED)
132+
Signature::new(inputs, outputs)
136133
}
137134

138135
#[derive(Debug, Clone, PartialEq, Error)]

hugr-core/src/builder/build_traits.rs

+4-78
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::{
2020
types::EdgeKind,
2121
};
2222

23-
use crate::extension::{ExtensionRegistry, ExtensionSet, TO_BE_INFERRED};
23+
use crate::extension::ExtensionRegistry;
2424
use crate::types::{PolyFuncType, Signature, Type, TypeArg, TypeRow};
2525

2626
use itertools::Itertools;
@@ -319,18 +319,14 @@ pub trait Dataflow: Container {
319319
inputs: impl IntoIterator<Item = (Type, Wire)>,
320320
) -> Result<DFGBuilder<&mut Hugr>, BuildError> {
321321
let (types, input_wires): (Vec<Type>, Vec<Wire>) = inputs.into_iter().unzip();
322-
self.dfg_builder(
323-
Signature::new_endo(types).with_extension_delta(TO_BE_INFERRED),
324-
input_wires,
325-
)
322+
self.dfg_builder(Signature::new_endo(types), input_wires)
326323
}
327324

328325
/// Return a builder for a [`crate::ops::CFG`] node,
329326
/// i.e. a nested controlflow subgraph.
330327
/// The `inputs` must be an iterable over pairs of the type of the input and
331328
/// the corresponding wire.
332329
/// The `output_types` are the types of the outputs.
333-
/// The Extension delta will be inferred.
334330
///
335331
/// # Errors
336332
///
@@ -340,27 +336,6 @@ pub trait Dataflow: Container {
340336
&mut self,
341337
inputs: impl IntoIterator<Item = (Type, Wire)>,
342338
output_types: TypeRow,
343-
) -> Result<CFGBuilder<&mut Hugr>, BuildError> {
344-
self.cfg_builder_exts(inputs, output_types, TO_BE_INFERRED)
345-
}
346-
347-
/// Return a builder for a [`crate::ops::CFG`] node,
348-
/// i.e. a nested controlflow subgraph.
349-
/// The `inputs` must be an iterable over pairs of the type of the input and
350-
/// the corresponding wire.
351-
/// The `output_types` are the types of the outputs.
352-
/// `extension_delta` is explicitly specified. Alternatively
353-
/// [cfg_builder](Self::cfg_builder) may be used to infer it.
354-
///
355-
/// # Errors
356-
///
357-
/// This function will return an error if there is an error when building
358-
/// the CFG node.
359-
fn cfg_builder_exts(
360-
&mut self,
361-
inputs: impl IntoIterator<Item = (Type, Wire)>,
362-
output_types: TypeRow,
363-
extension_delta: impl Into<ExtensionSet>,
364339
) -> Result<CFGBuilder<&mut Hugr>, BuildError> {
365340
let (input_types, input_wires): (Vec<Type>, Vec<Wire>) = inputs.into_iter().unzip();
366341

@@ -369,8 +344,7 @@ pub trait Dataflow: Container {
369344
let (cfg_node, _) = add_node_with_wires(
370345
self,
371346
ops::CFG {
372-
signature: Signature::new(inputs.clone(), output_types.clone())
373-
.with_extension_delta(extension_delta),
347+
signature: Signature::new(inputs.clone(), output_types.clone()),
374348
},
375349
input_wires,
376350
)?;
@@ -449,7 +423,6 @@ pub trait Dataflow: Container {
449423
/// The `inputs` must be an iterable over pairs of the type of the input and
450424
/// the corresponding wire.
451425
/// The `output_types` are the types of the outputs.
452-
/// The extension delta will be inferred.
453426
///
454427
/// # Errors
455428
///
@@ -461,27 +434,6 @@ pub trait Dataflow: Container {
461434
just_inputs: impl IntoIterator<Item = (Type, Wire)>,
462435
inputs_outputs: impl IntoIterator<Item = (Type, Wire)>,
463436
just_out_types: TypeRow,
464-
) -> Result<TailLoopBuilder<&mut Hugr>, BuildError> {
465-
self.tail_loop_builder_exts(just_inputs, inputs_outputs, just_out_types, TO_BE_INFERRED)
466-
}
467-
468-
/// Return a builder for a [`crate::ops::TailLoop`] node.
469-
/// The `inputs` must be an iterable over pairs of the type of the input and
470-
/// the corresponding wire.
471-
/// The `output_types` are the types of the outputs.
472-
/// `extension_delta` explicitly specified. Alternatively
473-
/// [tail_loop_builder](Self::tail_loop_builder) may be used to infer it.
474-
///
475-
/// # Errors
476-
///
477-
/// This function will return an error if there is an error when building
478-
/// the [`ops::TailLoop`] node.
479-
fn tail_loop_builder_exts(
480-
&mut self,
481-
just_inputs: impl IntoIterator<Item = (Type, Wire)>,
482-
inputs_outputs: impl IntoIterator<Item = (Type, Wire)>,
483-
just_out_types: TypeRow,
484-
extension_delta: impl Into<ExtensionSet>,
485437
) -> Result<TailLoopBuilder<&mut Hugr>, BuildError> {
486438
let (input_types, mut input_wires): (Vec<Type>, Vec<Wire>) =
487439
just_inputs.into_iter().unzip();
@@ -493,7 +445,6 @@ pub trait Dataflow: Container {
493445
just_inputs: input_types.into(),
494446
just_outputs: just_out_types,
495447
rest: rest_types.into(),
496-
extension_delta: extension_delta.into(),
497448
};
498449
// TODO: Make input extensions a parameter
499450
let (loop_node, _) = add_node_with_wires(self, tail_loop.clone(), input_wires)?;
@@ -507,41 +458,17 @@ pub trait Dataflow: Container {
507458
///
508459
/// The `other_inputs` must be an iterable over pairs of the type of the input and
509460
/// the corresponding wire.
510-
/// The `output_types` are the types of the outputs. Extension delta will be inferred.
511-
///
512-
/// # Errors
513-
///
514-
/// This function will return an error if there is an error when building
515-
/// the Conditional node.
516-
fn conditional_builder(
517-
&mut self,
518-
sum_input: (impl IntoIterator<Item = TypeRow>, Wire),
519-
other_inputs: impl IntoIterator<Item = (Type, Wire)>,
520-
output_types: TypeRow,
521-
) -> Result<ConditionalBuilder<&mut Hugr>, BuildError> {
522-
self.conditional_builder_exts(sum_input, other_inputs, output_types, TO_BE_INFERRED)
523-
}
524-
525-
/// Return a builder for a [`crate::ops::Conditional`] node.
526-
/// `sum_rows` and `sum_wire` define the type of the Sum
527-
/// variants and the wire carrying the Sum respectively.
528-
///
529-
/// The `other_inputs` must be an iterable over pairs of the type of the input and
530-
/// the corresponding wire.
531461
/// The `output_types` are the types of the outputs.
532-
/// `extension_delta` is explicitly specified. Alternatively
533-
/// [conditional_builder](Self::conditional_builder) may be used to infer it.
534462
///
535463
/// # Errors
536464
///
537465
/// This function will return an error if there is an error when building
538466
/// the Conditional node.
539-
fn conditional_builder_exts(
467+
fn conditional_builder(
540468
&mut self,
541469
(sum_rows, sum_wire): (impl IntoIterator<Item = TypeRow>, Wire),
542470
other_inputs: impl IntoIterator<Item = (Type, Wire)>,
543471
output_types: TypeRow,
544-
extension_delta: impl Into<ExtensionSet>,
545472
) -> Result<ConditionalBuilder<&mut Hugr>, BuildError> {
546473
let mut input_wires = vec![sum_wire];
547474
let (input_types, rest_input_wires): (Vec<Type>, Vec<Wire>) =
@@ -558,7 +485,6 @@ pub trait Dataflow: Container {
558485
sum_rows,
559486
other_inputs: inputs,
560487
outputs: output_types,
561-
extension_delta: extension_delta.into(),
562488
},
563489
input_wires,
564490
)?;

0 commit comments

Comments
 (0)