@@ -3790,33 +3790,33 @@ struct BroadcastToReshape final
3790
3790
else {
3791
3791
rewriter.replaceOpWithNewOp<stablehlo::ReshapeOp>(op, op.getType(),
3792
3792
op.getOperand());
3793
- auto NT = op.getType();
3794
- stablehlo::ReshapeOp reshaped = nullptr;
3795
- for (auto u : op.getOperand().getUsers()) {
3796
- auto re = dyn_cast<stablehlo::ReshapeOp>(u);
3797
- if (!re)
3798
- continue;
3799
- if (re.getType() != NT)
3800
- continue;
3801
- reshaped = re;
3802
- break;
3803
- }
3804
- if (!reshaped) {
3805
- rewriter.replaceOpWithNewOp<stablehlo::ReshapeOp>(op, op.getType(),
3806
- op.getOperand());
3807
- } else {
3808
- if (reshaped->getBlock() == op->getBlock()) {
3809
- if (op->isBeforeInBlock(reshaped)) {
3810
- rewriter.modifyOpInPlace(reshaped,
3811
- [&]() { reshaped->moveBefore(op); });
3812
- }
3813
- rewriter.replaceOp(op, reshaped);
3814
- } else {
3793
+ auto NT = op.getType();
3794
+ stablehlo::ReshapeOp reshaped = nullptr;
3795
+ for (auto u : op.getOperand().getUsers()) {
3796
+ auto re = dyn_cast<stablehlo::ReshapeOp>(u);
3797
+ if (!re)
3798
+ continue;
3799
+ if (re.getType() != NT)
3800
+ continue;
3801
+ reshaped = re;
3802
+ break;
3803
+ }
3804
+ if (!reshaped) {
3815
3805
rewriter.replaceOpWithNewOp<stablehlo::ReshapeOp>(op, op.getType(),
3816
3806
op.getOperand());
3807
+ } else {
3808
+ if (reshaped->getBlock() == op->getBlock()) {
3809
+ if (op->isBeforeInBlock(reshaped)) {
3810
+ rewriter.modifyOpInPlace(reshaped,
3811
+ [&]() { reshaped->moveBefore(op); });
3812
+ }
3813
+ rewriter.replaceOp(op, reshaped);
3814
+ } else {
3815
+ rewriter.replaceOpWithNewOp<stablehlo::ReshapeOp>(op, op.getType(),
3816
+ op.getOperand());
3817
+ }
3817
3818
}
3818
3819
}
3819
- }
3820
3820
return success();
3821
3821
}
3822
3822
};
0 commit comments