-
Notifications
You must be signed in to change notification settings - Fork 7
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: Constant-folding of integer and logic operations #1009
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1009 +/- ##
==========================================
+ Coverage 85.71% 86.25% +0.53%
==========================================
Files 79 81 +2
Lines 14639 16848 +2209
Branches 14639 16848 +2209
==========================================
+ Hits 12548 14532 +1984
- Misses 1434 1536 +102
- Partials 657 780 +123
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow huge job!
As I mentioned in many inline comments #1002 will make a few things a little bit nicer.
I think we should pay attention to the coverage report here, which seems to show ~15% of the constant folding missing coverage. I can't seem to view it properly though, so I may be mistaken. In any case, let's make sure we cover all these foldings.
I feel like you could shorten your test cases a lot by writing something like
fn const_fold_test(expected_values: &[Value], reg: &ExtensionRegistry, f: impl FnOnce(&mut DFGBuilder) -> Vec<Wire>) {
let mut builder = todo!();
let out_wires = f(builder);
let mut h = builder.finish_hugr_with_outputs(out_wires, reg).unwrap();
constant_fold_pass(&mut h, reg);
assert_fully_folded(&h, &expected_values);
}
I have not tried this, maybe you would need several? In any case it might reduce the noise a bit. You could also create some(or maybe one is enough?) static ExtensionRegistry
s and reuse them
ifrombool => int_polytype( | ||
0, | ||
type_row![BOOL_T], | ||
vec![int_type(TypeArg::BoundedNat { n: 0 })], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assuming #1002 lands as-is, these can change to int_type(0)
.iter() | ||
.flatten() | ||
.map(|&n| TypeArg::BoundedNat { n }) | ||
.map(|&n| TypeArg::BoundedNat { n: n as u64 }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again assuming #1004 lands, (n as u64).into()
second_width, | ||
}) | ||
let args = ext_op.args(); | ||
let log_widths: Vec<u8> = args.iter().map(|a| get_log_width(a).unwrap()).collect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let log_widths: Vec<u8> = args.iter().map(|a| get_log_width(a).unwrap()).collect(); | |
let log_widths: Vec<u8> = args.iter().map(|a| get_log_width(a)).collect::<Result<_>>()?; |
I think that's right... it's certainly possible to collect into a Result
like this. It's pretty bad to unwrap
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error[E0107]: enum takes 2 generic arguments but 1 generic argument was supplied
--> hugr/src/std_extensions/arithmetic/int_ops.rs:306:83
|
306 | ...t_log_width(a)).collect::<Result<_>>()?;
| ^^^^^^ - supplied 1 generic argument
| |
| expected 2 generic arguments
|
If I change to Result<_, _>
:
error[E0277]: `?` couldn't convert the error to `OpLoadError`
--> hugr/src/std_extensions/arithmetic/int_ops.rs:306:98
|
306 | ...t<_, _>>()?;
| ^ the trait `From<TypeArgError>` is not implemented for `OpLoadError`
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my PR.
/// Initialize a concrete [IntOpType] from a [IntOpDef] which requires one | ||
/// integer width set. | ||
pub fn with_width(self, width: u64) -> IntOpType { | ||
pub fn with_log_width(self, width: u8) -> IntOpType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub fn with_log_width(self, width: u8) -> IntOpType { | |
pub fn with_log_width(self, log_width: u8) -> IntOpType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done,
IntOpType { | ||
def: self, | ||
first_width: width, | ||
second_width: None, | ||
log_widths: vec![width], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log_widths: vec![width], | |
log_widths: vec![log_width], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
IntOpType { | ||
def: self, | ||
first_width, | ||
second_width: Some(second_width), | ||
log_widths: vec![first_width, second_width], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log_widths: vec![first_width, second_width], | |
log_widths: vec![first_log_width, second_log_width], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
.to_extension_op() | ||
.unwrap() | ||
.signature(), | ||
FunctionType::new(vec![int_type(ta(3))], vec![int_type(ta(4))],) | ||
); | ||
assert_eq!( | ||
IntOpDef::iwiden_s | ||
.with_two_widths(3, 3) | ||
.with_two_log_widths(3, 3) | ||
.to_extension_op() | ||
.unwrap() | ||
.signature(), | ||
FunctionType::new(vec![int_type(ta(3))], vec![int_type(ta(3))],) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fn ta
can be removed, pass the u64
straight to int_type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently not:
--> hugr/src/std_extensions/arithmetic/int_ops.rs:382:45
|
382 | FunctionType::new(vec![int_type(3)], vec![int_type(4)],)
| -------- ^ expected `TypeArg`, found integer
| |
| arguments to this function are incorrect
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my PR.
} | ||
|
||
// return q, r s.t. n = qm + r, 0 <= r < m | ||
fn divmod_s(n: i64, m: u64) -> (i64, u64) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs some tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, added.
hugr/src/algorithm/const_fold.rs
Outdated
let expected = Value::true_val(); | ||
assert_fully_folded(&h, &expected); | ||
} | ||
|
||
fn assert_fully_folded(h: &Hugr, expected_value: &Value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
recommend make this pub(crate)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made it public in the test moduile in utils
.
@@ -362,6 +364,1339 @@ mod test { | |||
Ok(()) | |||
} | |||
|
|||
#[test] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all these tests should be moved to a new file src/std_extensions/arithmetic/int_ops/const_fold/test.rs`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have a redundant mod test
inside the new file. See my PR
On further inspection, the missing coverage is all in error-handling, which is fine by me. Nice! |
Thanks @doug-q ! I've adopted your suggestions except for the test code refactoring. While it might reduce the code size, I don't think repetition in test code is actually a bad thing: it makes it easier to understand what a test is doing by looking at a single chunk of code; and it also makes it easier to modify and expand individual tests. (For example, the fact that so many of the tests worked with 32-bit integers is more laziness on my part than something I'd want to bake in.) |
Great, I've no problem with that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome
## 🤖 New release * `hugr`: 0.3.1 -> 0.4.0-alpha.1 (⚠️ API breaking changes) ###⚠️ `hugr` breaking changes ``` --- failure enum_marked_non_exhaustive: enum marked #[non_exhaustive] --- Description: A public enum has been marked #[non_exhaustive]. Pattern-matching on it outside of its crate must now include a wildcard pattern like `_`, or it will fail to compile. ref: https://doc.rust-lang.org/cargo/reference/semver.html#attr-adding-non-exhaustive impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.31.0/src/lints/enum_marked_non_exhaustive.ron Failed in: enum RegionBlocksError in /tmp/.tmpleGpag/hugr/hugr/src/algorithm/nest_cfgs.rs:282 enum EdgeValidationError in /tmp/.tmpleGpag/hugr/hugr/src/ops/validate.rs:213 enum ExtensionDeclarationError in /tmp/.tmpleGpag/hugr/hugr/src/extension/declarative.rs:179 enum InterGraphEdgeError in /tmp/.tmpleGpag/hugr/hugr/src/hugr/validate.rs:748 enum ValidationError in /tmp/.tmpleGpag/hugr/hugr/src/hugr/validate.rs:632 enum ValidationError in /tmp/.tmpleGpag/hugr/hugr/src/hugr/validate.rs:632 enum HUGRSerializationError in /tmp/.tmpleGpag/hugr/hugr/src/hugr/serialize.rs:107 enum InlineDFGError in /tmp/.tmpleGpag/hugr/hugr/src/hugr/rewrite/inline_dfg.rs:15 enum ExtensionError in /tmp/.tmpleGpag/hugr/hugr/src/extension/validate.rs:163 enum IntOpDef in /tmp/.tmpleGpag/hugr/hugr/src/std_extensions/arithmetic/int_ops.rs:51 enum ChildrenValidationError in /tmp/.tmpleGpag/hugr/hugr/src/ops/validate.rs:163 enum SumTypeError in /tmp/.tmpleGpag/hugr/hugr/src/types/check.rs:11 enum ReplaceError in /tmp/.tmpleGpag/hugr/hugr/src/hugr/rewrite/replace.rs:388 enum ConvertOpDef in /tmp/.tmpleGpag/hugr/hugr/src/std_extensions/arithmetic/conversions.rs:30 enum InvalidSubgraph in /tmp/.tmpleGpag/hugr/hugr/src/hugr/views/sibling_subgraph.rs:647 enum TypeArgError in /tmp/.tmpleGpag/hugr/hugr/src/types/type_param.rs:376 enum SumType in /tmp/.tmpleGpag/hugr/hugr/src/types.rs:124 enum ListOp in /tmp/.tmpleGpag/hugr/hugr/src/std_extensions/collections.rs:209 enum SimpleReplacementError in /tmp/.tmpleGpag/hugr/hugr/src/hugr/rewrite/simple_replace.rs:185 enum SimpleReplacementError in /tmp/.tmpleGpag/hugr/hugr/src/hugr/rewrite/simple_replace.rs:185 enum SimpleReplacementError in /tmp/.tmpleGpag/hugr/hugr/src/hugr/rewrite/simple_replace.rs:185 enum CustomCheckFailure in /tmp/.tmpleGpag/hugr/hugr/src/ops/constant.rs:227 enum CustomCheckFailure in /tmp/.tmpleGpag/hugr/hugr/src/ops/constant.rs:227 enum IdentityInsertionError in /tmp/.tmpleGpag/hugr/hugr/src/hugr/rewrite/insert_identity.rs:36 enum RemoveError in /tmp/.tmpleGpag/hugr/hugr/src/hugr/rewrite/consts.rs:18 enum OutlineCfgError in /tmp/.tmpleGpag/hugr/hugr/src/hugr/rewrite/outline_cfg.rs:223 enum NaryLogic in /tmp/.tmpleGpag/hugr/hugr/src/std_extensions/logic.rs:56 enum OpLoadError in /tmp/.tmpleGpag/hugr/hugr/src/extension/simple_op.rs:24 enum ConstTypeError in /tmp/.tmpleGpag/hugr/hugr/src/ops/constant.rs:244 enum ConstTypeError in /tmp/.tmpleGpag/hugr/hugr/src/ops/constant.rs:244 enum InvalidReplacement in /tmp/.tmpleGpag/hugr/hugr/src/hugr/views/sibling_subgraph.rs:629 enum InvalidSubgraphBoundary in /tmp/.tmpleGpag/hugr/hugr/src/hugr/views/sibling_subgraph.rs:665 enum InferExtensionError in /tmp/.tmpleGpag/hugr/hugr/src/extension/infer.rs:68 enum FloatOps in /tmp/.tmpleGpag/hugr/hugr/src/std_extensions/arithmetic/float_ops.rs:25 enum CustomOpError in /tmp/.tmpleGpag/hugr/hugr/src/ops/custom.rs:400 --- failure enum_missing: pub enum removed or renamed --- Description: A publicly-visible enum cannot be imported by its prior path. A `pub use` may have been removed, or the enum itself may have been renamed or removed entirely. ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.31.0/src/lints/enum_missing.ron Failed in: enum hugr::ops::constant::Const, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:22 enum hugr::ops::Const, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:22 --- failure enum_struct_variant_field_added: pub enum struct variant field added --- Description: An enum's exhaustive struct variant has a new field, which has to be included when constructing or matching on this variant. ref: https://doc.rust-lang.org/reference/attributes/type_system.html#the-non_exhaustive-attribute impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.31.0/src/lints/enum_struct_variant_field_added.ron Failed in: field dir of variant HUGRSerializationError::MissingPortOffset in /tmp/.tmpleGpag/hugr/hugr/src/hugr/serialize.rs:120 --- failure enum_variant_added: enum variant added on exhaustive enum --- Description: A publicly-visible enum without #[non_exhaustive] has a new variant. ref: https://doc.rust-lang.org/cargo/reference/semver.html#enum-variant-new impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.31.0/src/lints/enum_variant_added.ron Failed in: variant SignatureError:LoadFunctionIncorrectlyAppliesType in /tmp/.tmpleGpag/hugr/hugr/src/extension.rs:182 variant ExtensionBuildError:ValueExists in /tmp/.tmpleGpag/hugr/hugr/src/extension.rs:405 --- failure inherent_method_missing: pub method removed or renamed --- Description: A publicly-visible method or associated fn is no longer available under its prior name. It may have been renamed or removed entirely. ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.31.0/src/lints/inherent_method_missing.ron Failed in: ConvertOpDef::with_width, previously in file /tmp/.tmppKREXC/hugr/src/std_extensions/arithmetic/conversions.rs:78 IntOpDef::with_width, previously in file /tmp/.tmppKREXC/hugr/src/std_extensions/arithmetic/int_ops.rs:314 IntOpDef::with_two_widths, previously in file /tmp/.tmppKREXC/hugr/src/std_extensions/arithmetic/int_ops.rs:323 Const::const_type, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:124 Const::sum, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:138 Const::tuple, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:153 Const::function, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:164 Const::unit, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:173 Const::unit_sum, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:178 Const::unary_unit_sum, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:183 Const::true_val, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:188 Const::false_val, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:193 Const::from_bool, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:199 Const::extension, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:208 Const::get_custom_value, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:215 Const::const_type, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:124 Const::sum, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:138 Const::tuple, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:153 Const::function, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:164 Const::unit, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:173 Const::unit_sum, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:178 Const::unary_unit_sum, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:183 Const::true_val, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:188 Const::false_val, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:193 Const::from_bool, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:199 Const::extension, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:208 Const::get_custom_value, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:215 --- failure struct_missing: pub struct removed or renamed --- Description: A publicly-visible struct cannot be imported by its prior path. A `pub use` may have been removed, or the struct itself may have been renamed or removed entirely. ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.31.0/src/lints/struct_missing.ron Failed in: struct hugr::std_extensions::arithmetic::int_types::ConstIntS, previously in file /tmp/.tmppKREXC/hugr/src/std_extensions/arithmetic/int_types.rs:83 struct hugr::std_extensions::arithmetic::int_types::ConstIntU, previously in file /tmp/.tmppKREXC/hugr/src/std_extensions/arithmetic/int_types.rs:76 struct hugr::ops::constant::ExtensionConst, previously in file /tmp/.tmppKREXC/hugr/src/ops/constant.rs:64 --- failure trait_missing: pub trait removed or renamed --- Description: A publicly-visible trait cannot be imported by its prior path. A `pub use` may have been removed, or the trait itself may have been renamed or removed entirely. ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.31.0/src/lints/trait_missing.ron Failed in: trait hugr::ops::OpName, previously in file /tmp/.tmppKREXC/hugr/src/ops.rs:307 --- failure trait_removed_supertrait: supertrait removed or renamed --- Description: A supertrait was removed from a trait. Users of the trait can no longer assume it can also be used like its supertrait. ref: https://doc.rust-lang.org/reference/items/traits.html#supertraits impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.31.0/src/lints/trait_removed_supertrait.ron Failed in: supertrait hugr::ops::OpName of trait MakeExtensionOp in file /tmp/.tmpleGpag/hugr/hugr/src/extension/simple_op.rs:87 supertrait hugr::ops::OpName of trait MakeOpDef in file /tmp/.tmpleGpag/hugr/hugr/src/extension/simple_op.rs:45 ``` <details><summary><i><b>Changelog</b></i></summary><p> <blockquote> ## 0.4.0 (2024-05-13) ### Bug Fixes - Serialization round-trips ([#948](#948)) - [**breaking**] Combine `ConstIntU` and `ConstIntS` ([#974](#974)) - Disable serialisation tests when miri is active ([#977](#977)) - [**breaking**] Serialisation schema ([#968](#968)) - Correct constant fold for `fne`. ([#995](#995)) - [**breaking**] Serialisation fixes ([#997](#997)) - [**breaking**] OpDef serialisation ([#1013](#1013)) - NaryLogicOp constant folding ([#1026](#1026)) ### Features - 'Replace' rewrite returns node map ([#929](#929)) - `new` methods for leaf ops ([#940](#940)) - Add `string` type and `print` function to `prelude` ([#942](#942)) - `CustomOp::extension` utility function ([#951](#951)) - [**breaking**] Add `non_exhaustive` to various enums ([#952](#952)) - Encoder metadata in serialized hugr ([#955](#955)) - [**breaking**] Bring back Value ([#967](#967)) - Add LoadFunction node ([#947](#947)) - Add From impls for TypeArg ([#1002](#1002)) - Constant-folding of integer and logic operations ([#1009](#1009)) - [**breaking**] Update serialisation schema, implement `CustomConst` serialisation ([#1005](#1005)) - Merge basic blocks algorithm ([#956](#956)) - [**breaking**] Allow panic operation to have any input and output wires ([#1024](#1024)) ### Refactor - Outline hugr::serialize::test ([#976](#976)) - [**breaking**] Replace SmolStr identifiers with wrapper types. ([#959](#959)) - Separate extension validation from the rest ([#1011](#1011)) - Remove "trait TypeParametrised" ([#1019](#1019)) ### Testing - Add a test of instantiating an extension set ([#939](#939)) - Ignore serialisation tests when using miri ([#975](#975)) - [**breaking**] Test roundtrip serialisation against strict + lax schema ([#982](#982)) - Fix some bad assert_matches ([#1006](#1006)) - Expand test of instantiating extension sets ([#1003](#1003)) - Fix unconnected ports in extension test ([#1010](#1010)) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/MarcoIeni/release-plz/). --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Douglas Wilson <[email protected]>
## 🤖 New release * `hugr`: 0.3.1 -> 0.4.0 (⚠️ API breaking changes) ###⚠️ `hugr` breaking changes ``` --- failure inherent_method_const_removed: pub method is no longer const --- Description: A publicly-visible method or associated fn is no longer `const` and can no longer be used in a `const` context. ref: https://doc.rust-lang.org/reference/const_eval.html impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.31.0/src/lints/inherent_method_const_removed.ron Failed in: ConstF64::new in /tmp/.tmpwo5blB/hugr/hugr/src/std_extensions/arithmetic/float_types.rs:43 --- failure struct_missing: pub struct removed or renamed --- Description: A publicly-visible struct cannot be imported by its prior path. A `pub use` may have been removed, or the struct itself may have been renamed or removed entirely. ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.31.0/src/lints/struct_missing.ron Failed in: struct hugr::ops::constant::ExtensionValue, previously in file /tmp/.tmpq1W6bC/hugr/src/ops/constant.rs:184 ``` <details><summary><i><b>Changelog</b></i></summary><p> <blockquote> ## 0.4.0 (2024-05-20) ### Bug Fixes - Disallow non-finite values for `ConstF64` ([#1075](#1075)) - Serialization round-trips ([#948](#948)) - [**breaking**] Combine `ConstIntU` and `ConstIntS` ([#974](#974)) - Disable serialisation tests when miri is active ([#977](#977)) - [**breaking**] Serialisation schema ([#968](#968)) - Correct constant fold for `fne`. ([#995](#995)) - [**breaking**] Serialisation fixes ([#997](#997)) - [**breaking**] OpDef serialisation ([#1013](#1013)) - NaryLogicOp constant folding ([#1026](#1026)) ### Features - Add verification to constant folding ([#1030](#1030)) - Add `Const::get_custom_value` ([#1037](#1037)) - Add serialization schema for metadata ([#1038](#1038)) - 'Replace' rewrite returns node map ([#929](#929)) - `new` methods for leaf ops ([#940](#940)) - Add `string` type and `print` function to `prelude` ([#942](#942)) - `CustomOp::extension` utility function ([#951](#951)) - [**breaking**] Add `non_exhaustive` to various enums ([#952](#952)) - Encoder metadata in serialized hugr ([#955](#955)) - [**breaking**] Bring back Value ([#967](#967)) - Add LoadFunction node ([#947](#947)) - Add From impls for TypeArg ([#1002](#1002)) - Constant-folding of integer and logic operations ([#1009](#1009)) - [**breaking**] Update serialisation schema, implement `CustomConst` serialisation ([#1005](#1005)) - Merge basic blocks algorithm ([#956](#956)) - [**breaking**] Allow panic operation to have any input and output wires ([#1024](#1024)) ### Refactor - [**breaking**] Rename `crate::ops::constant::ExtensionValue` => `OpaqueValue` ([#1036](#1036)) - Outline hugr::serialize::test ([#976](#976)) - [**breaking**] Replace SmolStr identifiers with wrapper types. ([#959](#959)) - Separate extension validation from the rest ([#1011](#1011)) - Remove "trait TypeParametrised" ([#1019](#1019)) ### Testing - Reorg OutlineCfg/nest_cfgs tests so hugr doesn't depend on algorithm ([#1007](#1007)) - Ignore tests which depend on typetag when cfg(miri) ([#1051](#1051)) - Really ignore tests which depend on typetag when cfg(miri) ([#1058](#1058)) - Proptests for round trip serialisation of `Type`s and `Op`s. ([#981](#981)) - Add a test of instantiating an extension set ([#939](#939)) - Ignore serialisation tests when using miri ([#975](#975)) - [**breaking**] Test roundtrip serialisation against strict + lax schema ([#982](#982)) - Fix some bad assert_matches ([#1006](#1006)) - Expand test of instantiating extension sets ([#1003](#1003)) - Fix unconnected ports in extension test ([#1010](#1010)) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/MarcoIeni/release-plz/). --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Douglas Wilson <[email protected]>
Add constant folders for all integer and logical operations, and add tests. Includes a few small refactors and fixes.
One test (which I'd intended to expand into a larger one involving many operations) is marked "should panic" because of #996 .
Closes #773 .