Skip to content

Commit

Permalink
Patches
Browse files Browse the repository at this point in the history
  • Loading branch information
LPanosTT committed Dec 23, 2024
1 parent f806dde commit a5e1453
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/Dialect/TTIR/Transforms/Fusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,26 @@ class FuseSoftmax : public OpRewritePattern<ttir::DivOp> {

// There may be a broadcast op between the sum op and the div op.
if (!sumOp && dyn_cast_or_null<ttir::BroadcastOp>(rhs.getDefiningOp())) {
auto broadcastOp =
dyn_cast_or_null<ttir::BroadcastOp>(rhs.getDefiningOp());

// Broadcast op should only have one use.
if (!broadcastOp->hasOneUse()) {
return failure();
}

sumOp = dyn_cast_or_null<ttir::SumOp>(
rhs.getDefiningOp()->getOperand(0).getDefiningOp());
broadcastOp->getOperand(0).getDefiningOp());
}
if (!expOp || !sumOp) {
return failure();
}

// Both the exp and sum op should have only one use.
if (!expOp->hasOneUse() != 1 || !sumOp->hasOneUse() != 1) {
return failure();
}

if (sumOp.getInput() != expOp.getResult(0)) {
return failure();
}
Expand Down

0 comments on commit a5e1453

Please sign in to comment.