Skip to content

Commit

Permalink
address minor review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ss2165 committed Jan 3, 2024
1 parent 2c6abc6 commit 905ef01
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/algorithm/const_fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub fn fold_const(op: &OpType, consts: &[(IncomingPort, Const)]) -> ConstFoldRes
}));
}
}
None // could panic
panic!("This op always takes a Tuple input.");
}

LeafOp::Tag { tag, variants } => out_row([Const::new(
Expand Down Expand Up @@ -99,7 +99,8 @@ fn const_graph(consts: Vec<Const>, reg: &ExtensionRegistry) -> Hugr {
/// [`SimpleReplacement`] replaces an operation with constants that result from
/// evaluating it, the extension registry `reg` is used to validate the
/// replacement HUGR. The vector of [`RemoveConstIgnore`] refer to the
/// LoadConstant nodes that could be removed.
/// LoadConstant nodes that could be removed - they are not automatically
/// removed as they may be used by other operations.
pub fn find_consts<'a, 'r: 'a>(
hugr: &'a impl HugrView,
candidate_nodes: impl IntoIterator<Item = Node> + 'a,
Expand Down
1 change: 1 addition & 0 deletions src/extension/op_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ pub struct OpDef {
#[serde(flatten)]
lower_funcs: Vec<LowerFunc>,

/// Operations can optionally implement [`ConstFold`] to implement constant folding.
#[serde(skip)]
constant_folder: Box<dyn ConstFold>,
}
Expand Down
4 changes: 2 additions & 2 deletions src/std_extensions/arithmetic/float_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::{
Extension,
};
use lazy_static::lazy_static;
mod fold;
mod const_fold;
/// The extension identifier.
pub const EXTENSION_ID: ExtensionId = ExtensionId::new_unchecked("arithmetic.float");

Expand Down Expand Up @@ -84,7 +84,7 @@ impl MakeOpDef for FloatOps {
}

fn post_opdef(&self, def: &mut OpDef) {
fold::set_fold(self, def)
const_fold::set_fold(self, def)
}
}

Expand Down

0 comments on commit 905ef01

Please sign in to comment.