Skip to content

Commit

Permalink
feat: hash op arguments (#143)
Browse files Browse the repository at this point in the history
A bit of a hack, we use the json-encoded params to produce a hash.

We could require some hash method in the Hugr definition, but this is a
quick fix so we can do benchmarking.
  • Loading branch information
aborgna-q authored Sep 28, 2023
1 parent d8fce77 commit 7c25d83
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/circuit/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,14 @@ impl HashState {
fn hashable_op(op: &OpType) -> impl Hash {
match op {
OpType::LeafOp(LeafOp::CustomOp(op)) if !op.args().is_empty() => {
panic!("Parametric operation {} cannot be hashed.", op.name())
// TODO: Require hashing for TypeParams?
format!(
"{}[{}]",
op.name(),
serde_json::to_string(op.args()).unwrap()
)
}
_ => op.name(),
_ => op.name().to_string(),
}
}

Expand Down

0 comments on commit 7c25d83

Please sign in to comment.