@@ -808,6 +808,7 @@ class MaxPool2dConverter : public OpConversionPattern<tosa::MaxPool2dOp> {
808
808
dilationAttr);
809
809
810
810
rewriter.setInsertionPointAfter (op);
811
+ auto nanMode = op.getNanMode ();
811
812
rewriter.replaceOp (op, resultOp);
812
813
813
814
// NaN propagation has no meaning for non floating point types.
@@ -821,11 +822,10 @@ class MaxPool2dConverter : public OpConversionPattern<tosa::MaxPool2dOp> {
821
822
// we've already produced a named op we will just take its body and modify
822
823
// it to include the appropriate checks. If the current value is NaN the
823
824
// old value of pool will be taken otherwise we use the result.
824
- if (const auto nanMode = op. getNanMode (); nanMode == " IGNORE" ) {
825
+ if (nanMode == " IGNORE" ) {
825
826
auto genericOp = rewriter.create <linalg::GenericOp>(
826
- op->getLoc (), resultOp.getType (0 ), resultOp.getInputs (),
827
- resultOp.getOutputs (), resultOp.getIndexingMapsArray (),
828
- resultOp.getIteratorTypesArray (),
827
+ loc, resultOp.getType (0 ), resultOp.getInputs (), resultOp.getOutputs (),
828
+ resultOp.getIndexingMapsArray (), resultOp.getIteratorTypesArray (),
829
829
[&](OpBuilder &opBuilder, Location loc, ValueRange blockArgs) {
830
830
IRMapping map;
831
831
auto oldBlock = resultOp.getRegion ().begin ();
@@ -834,10 +834,10 @@ class MaxPool2dConverter : public OpConversionPattern<tosa::MaxPool2dOp> {
834
834
map.map (oldArgs, blockArgs);
835
835
auto *newOp = opBuilder.clone (oldMaxOp, map);
836
836
Value isNaN = opBuilder.create <arith::CmpFOp>(
837
- op-> getLoc () , arith::CmpFPredicate::UNO, blockArgs.front (),
837
+ loc , arith::CmpFPredicate::UNO, blockArgs.front (),
838
838
blockArgs.front ());
839
839
auto selectOp = opBuilder.create <arith::SelectOp>(
840
- op-> getLoc () , isNaN, blockArgs.back (), newOp->getResult (0 ));
840
+ loc , isNaN, blockArgs.back (), newOp->getResult (0 ));
841
841
opBuilder.create <linalg::YieldOp>(loc, selectOp.getResult ());
842
842
});
843
843
rewriter.replaceOp (resultOp, genericOp);
0 commit comments