Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
937cd14
Add TypeTransformer and (Sum/Function)Type(Arg/Row)::transform
acl-cqc Mar 11, 2025
815536b
trait Transformable to common up all the 'let mut any_change = false'…
acl-cqc Mar 12, 2025
cc1e8f2
Transformable v2: implement for [E], works without iter_mut/etc. in a…
acl-cqc Mar 12, 2025
4888184
first test, fix CustomType bound caching
acl-cqc Mar 17, 2025
7002e4d
Second test, fix SumType caching
acl-cqc Mar 17, 2025
6cc7cea
Make clippy happy
acl-cqc Mar 17, 2025
d43784b
Add HugrMut::optype_mut (v2, allow mutating root if RootHandle == Node)
acl-cqc Mar 11, 2025
422c496
WIP add hugr-passes/src/lower_types.rs (w/ change_node, subst_ty)
acl-cqc Mar 5, 2025
76ed391
Add def_arc
acl-cqc Mar 11, 2025
ed5b5dd
change_node, change_type, and the rest
acl-cqc Mar 10, 2025
adcbbf6
Use TypeTransformer framework, removing most type_stuff from lower_ty…
acl-cqc Mar 11, 2025
d84ae4e
Add a load of copy/discard lowering stuff, OpReplacement
acl-cqc Mar 12, 2025
bfa52cf
OpHashWrapper
acl-cqc Mar 12, 2025
b373571
Parametrized type support
acl-cqc Mar 17, 2025
a8e613a
remove copy_discard stuff
acl-cqc Mar 17, 2025
24ed15c
Assume less in OpReplacement::replace
acl-cqc Mar 17, 2025
9153fcf
parametrized ops
acl-cqc Mar 17, 2025
a89879c
Comments, renaming, use const_fn
acl-cqc Mar 17, 2025
c78d88a
Comment const_fn TODO
acl-cqc Mar 17, 2025
bf6a9a4
Test panics on unexpected argument - simpler, better
acl-cqc Mar 18, 2025
5ecd9e6
test functiontype
acl-cqc Mar 18, 2025
d9a6d29
clippy that new test
acl-cqc Mar 18, 2025
83e798e
Merge remote-tracking branch 'origin/main' into acl/type_transform
acl-cqc Mar 18, 2025
84fe82d
WIP setup for test
acl-cqc Mar 18, 2025
6168353
First test
acl-cqc Mar 18, 2025
fcb85a2
read only makes sense for Copyables
acl-cqc Mar 18, 2025
0f9aa17
Extend test to Calls of polyfunc; comments, monomorphize first
acl-cqc Mar 18, 2025
74c6775
no, instantiate the calls with types being lowered
acl-cqc Mar 18, 2025
00fd284
Consts: HashMap keyed by either, add lower_ methods. Test TailLoop an…
acl-cqc Mar 18, 2025
9f02acf
clippy, turn off type-complexity
acl-cqc Mar 18, 2025
a0ac6d6
Actual Error for check_sig, add setter method
acl-cqc Mar 19, 2025
6ac9efc
docs
acl-cqc Mar 19, 2025
044ff32
Test variable, boundednat; use list_type
acl-cqc Mar 19, 2025
b539e2f
Yet Another ValidationLevel interface
acl-cqc Mar 19, 2025
2c7e035
Merge remote-tracking branch 'origin/main' into acl/type_transform
acl-cqc Mar 19, 2025
6b190a6
Merge branch 'acl/type_transform' into acl/lower_types
acl-cqc Mar 19, 2025
bd24d1a
clippy
acl-cqc Mar 19, 2025
a5d8b65
doclinxs
acl-cqc Mar 19, 2025
6b1438c
pub re-export
acl-cqc Mar 19, 2025
d1036bc
fix const_loop for extensions
acl-cqc Mar 19, 2025
d19dc5a
fix other test for extensions, but turn off extension validation afte…
acl-cqc Mar 19, 2025
d0fddde
Add another test of Conditional + Case
acl-cqc Mar 21, 2025
3494887
common up read_op
acl-cqc Mar 21, 2025
ffdcaf2
test tidies
acl-cqc Mar 21, 2025
6f8f43c
No need to validate, run() does it for us
acl-cqc Mar 21, 2025
e3da259
check_sig: use Option::unzip to tuple-ize
acl-cqc Mar 21, 2025
28f2470
Move private utility classes below the pub ones; add comments
acl-cqc Mar 21, 2025
bef90b0
Comments - all callbacks return Option
acl-cqc Mar 24, 2025
85df7ff
test: Rename lower_types to lowerer
acl-cqc Mar 25, 2025
507f027
Extend loop_const test
acl-cqc Mar 25, 2025
bae0ebe
Add copy/dup linearization stuff
acl-cqc Mar 25, 2025
8fa79bd
do_copy_chain => insert_copy_discard
acl-cqc Mar 21, 2025
6a186a5
Move insert_copy_discard into Linearizer
acl-cqc Mar 25, 2025
6d8a89b
Add LinearizeError
acl-cqc Mar 21, 2025
3f0f1e6
pass Linearizer to callbacks
acl-cqc Mar 21, 2025
974a25b
comments
acl-cqc Mar 24, 2025
2bbf663
first test, don't linearize root node outputs, reject nonlocal edges
acl-cqc Mar 21, 2025
290a8ae
copy_fn/discard_fn return Result
acl-cqc Mar 23, 2025
19b1442
linearize takes &TypeDef not TypeDef
acl-cqc Mar 23, 2025
269f0f1
OpReplacement::add(&self, ...) -> add_hugr(self, ...)
acl-cqc Mar 24, 2025
f6a1af5
Drop an else-continue
acl-cqc Mar 25, 2025
ac9adac
Add OpReplacement::add for builder
acl-cqc Mar 24, 2025
65eaf52
Handle Sum Types in copy_op/discard_op
acl-cqc Mar 25, 2025
354a89c
drop redundant allow-missing_docs
acl-cqc Mar 25, 2025
1b31631
Refactor test code, fix --all-features
acl-cqc Mar 23, 2025
d5cbd58
Test copying+discarding an option of two elements
acl-cqc Mar 25, 2025
63bdd3b
tidy imports
acl-cqc Mar 25, 2025
1ac3728
Combine lower_consts(_parametric) with lower_(parametric_)type
acl-cqc Mar 25, 2025
e768814
Test sig checking
acl-cqc Mar 25, 2025
506570b
No, remove sig checking
acl-cqc Mar 25, 2025
0958e2a
Test funky partial replace
acl-cqc Mar 25, 2025
74cfdb1
common up just_elem_type
acl-cqc Mar 25, 2025
dc79c93
comment spacing
acl-cqc Mar 25, 2025
63d24b0
RIP SignatureMismatch
acl-cqc Mar 25, 2025
ba63fbe
Reinstate separate lower_consts/lower_consts_parametric
acl-cqc Mar 26, 2025
2c7bb80
Remove the boxes
acl-cqc Mar 26, 2025
08d3227
drop comment re. validation_level
acl-cqc Mar 26, 2025
dedc3d5
rename module lower_types -> replace_types
acl-cqc Mar 26, 2025
9993467
rename LowerTypes=>ReplaceTypes, ChangeTypeError => ReplaceTypesError
acl-cqc Mar 26, 2025
cc81d87
rename methods, parametric => parametrized
acl-cqc Mar 26, 2025
74c6492
doc notes
acl-cqc Mar 26, 2025
18316de
comment/doc updates
acl-cqc Mar 26, 2025
520e414
fmt
acl-cqc Mar 26, 2025
0814bf2
callbacks for Const take &ReplaceTypes
acl-cqc Mar 26, 2025
0a82fef
Replace that break 'changed block with a match, + map_or_else to avoi…
acl-cqc Mar 26, 2025
94c0ff3
Add Type::as_extension
acl-cqc Mar 26, 2025
e9ff81c
wip
acl-cqc Mar 26, 2025
cf6451f
add list_const handler, use in test
acl-cqc Mar 26, 2025
9a355d5
Clarify replace_consts_parametrized callback
acl-cqc Mar 26, 2025
ec2d0ba
const callbacks report errors via Result
acl-cqc Mar 26, 2025
c9d7033
fmt+fix
acl-cqc Mar 26, 2025
812ac89
comment tweaks
acl-cqc Mar 26, 2025
ae7bd6e
Merge remote-tracking branch 'origin/main' into acl/lower_types
acl-cqc Mar 26, 2025
e0937ee
docs
acl-cqc Mar 26, 2025
36df03c
and some more - warn on missing_docs except ReplaceTypesError
acl-cqc Mar 26, 2025
71f8c0b
Merge remote-tracking branch 'origin/main' into acl/lower_types
acl-cqc Mar 26, 2025
dc0c7dd
Merge branch 'acl/lower_types' into acl/lower_types_linearize
acl-cqc Mar 26, 2025
31ba4e0
docs, make pub, more errors
acl-cqc Mar 26, 2025
86c73ed
Test copyable element inside Sum - breaks test
acl-cqc Mar 26, 2025
92d7a51
Error on copyable; handle copyable elements of sums - fixes
acl-cqc Mar 26, 2025
582b9f1
register errors with type; panic on function as already ruled out
acl-cqc Mar 26, 2025
95da97d
more docs - no overriding copy/discard of non-extension types
acl-cqc Mar 26, 2025
c7e56e6
pub discard_op
acl-cqc Mar 27, 2025
a1e63de
rm Boxes
acl-cqc Mar 28, 2025
7634e92
Only allow copy/discard funcs for *Custom*Type's
acl-cqc Mar 28, 2025
0cd31e0
single callback taking num_outports != 1
acl-cqc Mar 28, 2025
65b8993
In insert_copy_discard, a discard really is a 0-way copy
acl-cqc Mar 28, 2025
198f990
renaming
acl-cqc Mar 28, 2025
517cd0d
Generalize test 2,3,4 copies
acl-cqc Mar 28, 2025
272f024
Simplify test w/binary copy to just option type, add more complex w/ …
acl-cqc Mar 28, 2025
e74b12b
combine the two test extensions
acl-cqc Mar 28, 2025
34bd90d
tweaks
acl-cqc Mar 28, 2025
a2cba09
filter
acl-cqc Mar 28, 2025
3084004
so that
acl-cqc Mar 28, 2025
cec9162
insert_copy_discard takes Wire, no Type
acl-cqc Mar 28, 2025
bf74996
Rename OpReplacement -> NodeTemplate
acl-cqc Mar 28, 2025
221bf7d
fix dataflowparent doclink
acl-cqc Mar 28, 2025
f6312bc
Remove linearize() proxy methods, add linearizer() getter - docs a mess
acl-cqc Mar 30, 2025
5fe25c0
docs+notes
acl-cqc Mar 30, 2025
edd2126
fix lists in docs
acl-cqc Mar 30, 2025
5ea9763
Add Linearizer trait, rename to DelegatingLinearizer
acl-cqc Mar 31, 2025
cc4fd68
Pass &dyn Linearizer - requires making object-safe
acl-cqc Mar 31, 2025
8a1ff0c
No - revert - instead pass ref to new CallbackHandler struct
acl-cqc Mar 31, 2025
d5e4ac3
Add LinearizeError::WrongSignature
acl-cqc Apr 1, 2025
b259426
Remove NeedDiscard, rename NeedCopy
acl-cqc Apr 1, 2025
a14fafa
test, also check sig for register(CustTy, NodeTempl*2)
acl-cqc Apr 1, 2025
a4686d3
lint
doug-q Apr 2, 2025
1abf1b4
docs
doug-q Apr 2, 2025
7e3efcc
Rename register(=>_simple,_parametric=>_callback), docs
acl-cqc Apr 2, 2025
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
Prev Previous commit
Next Next commit
rm Boxes
  • Loading branch information
acl-cqc committed Mar 28, 2025
commit a1e63de1ee1d42f4dcc3794e3bbab20db0b2e34c
4 changes: 2 additions & 2 deletions hugr-passes/src/replace_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ impl ReplaceTypes {
pub fn linearize_parametric(
&mut self,
src: &TypeDef,
copy_fn: Box<dyn Fn(&[TypeArg], &Linearizer) -> Result<OpReplacement, LinearizeError>>,
discard_fn: Box<dyn Fn(&[TypeArg], &Linearizer) -> Result<OpReplacement, LinearizeError>>,
copy_fn: impl Fn(&[TypeArg], &Linearizer) -> Result<OpReplacement, LinearizeError> + 'static,
discard_fn: impl Fn(&[TypeArg], &Linearizer) -> Result<OpReplacement, LinearizeError> + 'static,
) {
self.linearize.register_parametric(src, copy_fn, discard_fn)
}
Expand Down
6 changes: 3 additions & 3 deletions hugr-passes/src/replace_types/linearize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ impl Linearizer {
pub fn register_parametric(
Copy link
Contributor Author

@acl-cqc acl-cqc Mar 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So perhaps that this one takes a callback, supporting arbitrary N, whereas register has only 0-ary discard and 2-ary copy, might be the bigger difference; both can be used for monomorphic types. It might be better to rename, thus

  • this one to register_callback or register_with_callback or even just register?
  • register maybe to register_binary / register_2way / register_(dup/copy)_discard / register_simple ??

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like register_simple/register_callback best, but do not feel strongly about it..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM, done

&mut self,
src: &TypeDef,
copy_fn: Box<dyn Fn(&[TypeArg], &Linearizer) -> Result<OpReplacement, LinearizeError>>,
discard_fn: Box<dyn Fn(&[TypeArg], &Linearizer) -> Result<OpReplacement, LinearizeError>>,
copy_fn: impl Fn(&[TypeArg], &Linearizer) -> Result<OpReplacement, LinearizeError> + 'static,
discard_fn: impl Fn(&[TypeArg], &Linearizer) -> Result<OpReplacement, LinearizeError> + 'static,
) {
// We could look for `src`s TypeDefBound being explicit Copyable, otherwise
// it depends on the arguments. Since there is no method to get the TypeDefBound
// from a TypeDef, leaving this for now.
self.copy_discard_parametric
.insert(src.into(), (Arc::from(copy_fn), Arc::from(discard_fn)));
.insert(src.into(), (Arc::new(copy_fn), Arc::new(discard_fn)));
}

/// Insert copy or discard operations (as appropriate) enough to wire `src_port` of `src_node`
Expand Down
Loading