Skip to content

Commit

Permalink
add under reduce join
Browse files Browse the repository at this point in the history
  • Loading branch information
kaikalii committed Nov 25, 2024
1 parent 98f81c1 commit 359f1a7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/compile/invert/under.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ static UNDER_PATTERNS: &[&dyn UnderPattern] = &[
(PopUnd(1), UndoDeshape(None)),
),
&DeshapeSubPat,
&ReduceJoinPat,
&MaybeVal((
Rerank,
(Over, Shape, Over, PushUnd(2), Rerank),
Expand Down Expand Up @@ -692,6 +693,20 @@ under!(
}
);

under!(ReduceJoinPat, input, _, _, _, Reduce, span, [f], {
let Node::Prim(Join, _) = f.node else {
return generic();
};
let before = Node::from_iter([
Prim(Dup, span),
Prim(Shape, span),
PushUnder(1, span),
Mod(Reduce, eco_vec![f.clone()], span),
]);
let after = Node::from_iter([PopUnder(1, span), ImplPrim(UndoDeshape(Some(-1)), span)]);
Ok((input, before, after))
});

#[derive(Debug)]
struct Trivial;
impl UnderPattern for Trivial {
Expand Down

0 comments on commit 359f1a7

Please sign in to comment.