}
if (arith::FPToSIOp::areCastCompatible(srcTy, dstTy)) {
- auto zero = rewriter.create<arith::ConstantOp>(
- loc, rewriter.getF32FloatAttr(0.0f));
- auto half = rewriter.create<arith::ConstantOp>(
- loc, rewriter.getF32FloatAttr(0.5f));
-
auto intMin = rewriter.create<arith::ConstantOp>(
loc, rewriter.getF32FloatAttr(
APInt::getSignedMinValue(dstTy.getIntOrFloatBitWidth())
APInt::getSignedMaxValue(dstTy.getIntOrFloatBitWidth())
.getSExtValue()));
- auto added = rewriter.create<arith::AddFOp>(loc, args[0], half);
- auto subbed = rewriter.create<arith::SubFOp>(loc, args[0], half);
- auto negative = rewriter.create<arith::CmpFOp>(
- loc, arith::CmpFPredicate::OLT, args[0], zero);
- auto rounded =
- rewriter.create<arith::SelectOp>(loc, negative, subbed, added);
+ auto rounded = rewriter.create<math::RoundEvenOp>(loc, args[0]);
auto clamped = clampFloatHelper(loc, rounded, intMin, intMax, rewriter);
%19 = "tosa.sigmoid"(%0) : (tensor<1xf32>) -> tensor<1xf32>
// CHECK: linalg.generic
- // CHECK: arith.constant 0.000000e+00
- // CHECK: arith.constant 5.000000e-01
// CHECK: arith.constant -2.14748365E+9
// CHECK: arith.constant 2.14748365E+9
- // CHECK: arith.addf
- // CHECK: arith.subf
- // CHECK: arith.cmpf olt
- // CHECK: select
+ // CHECK: math.roundeven
// CHECK: arith.minf
// CHECK: arith.maxf
// CHECK: arith.fptosi