Skip to content

Commit

Permalink
mul(a,a) -> square(a)
Browse files Browse the repository at this point in the history
  • Loading branch information
kali committed Apr 12, 2024
1 parent 60ad0c8 commit eebb56e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/src/ops/math/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@ fn declutter_mul(
model: &TypedModel,
node: &TypedNode,
) -> TractResult<Option<TypedModelPatch>> {
if node.inputs[0] == node.inputs[1] {
return Ok(Some(TypedModelPatch::replace_single_op(model, node, &node.inputs[0..1], square())?))
}
if let Some(p) = declutter_neutral(model, node, 1, true).context("decluttering neutral")? {
return Ok(Some(p));
}
Expand Down

0 comments on commit eebb56e

Please sign in to comment.