Skip to content

Commit

Permalink
Fix removal of if op
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmoses committed Jan 10, 2025
1 parent dce4301 commit 6d568d0
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1942,6 +1942,9 @@ struct IfOpEnzymeOpsRemover
removalBlockExplore(falseBlock, falseMapping, builder, gradients,
pushedCaches);

if (gradients.size() == 0 || pushedCaches.size() == 0)
return success();

Operation *trueTerm = trueBlock->getTerminator();
Operation *falseTerm = falseBlock->getTerminator();

Expand Down Expand Up @@ -2010,6 +2013,8 @@ struct IfOpEnzymeOpsRemover
idx++;
}

ifOp->replaceAllUsesWith(
newIf->getResults().slice(0, ifOp->getNumResults()));
ifOp->erase();

return success();
Expand Down

0 comments on commit 6d568d0

Please sign in to comment.