std::nullopt);
if (srcTy.isa<IntegerType>() && dstTy.isa<IntegerType>() && !bitExtend) {
- auto intMin = rewriter.create<arith::ConstantIntOp>(
- loc,
- APInt::getSignedMinValue(dstTy.getIntOrFloatBitWidth())
- .getSExtValue(),
- srcTy.getIntOrFloatBitWidth());
-
- auto intMax = rewriter.create<arith::ConstantIntOp>(
- loc,
- APInt::getSignedMaxValue(dstTy.getIntOrFloatBitWidth())
- .getSExtValue(),
- srcTy.getIntOrFloatBitWidth());
-
- auto clamped = clampIntHelper(loc, args[0], intMin, intMax, rewriter);
- return rewriter.create<arith::TruncIOp>(loc, dstTy, clamped);
+ return rewriter.create<arith::TruncIOp>(loc, dstTy, args[0]);
}
}
%19 = "tosa.clamp"(%0) {min_int = 1 : i64, max_int = 5 : i64, min_fp = 1.0 : f32, max_fp = 5.0 : f32} : (tensor<1xi32>) -> tensor<1xi32>
// CHECK: linalg.generic
- // CHECK: arith.constant -32768
- // CHECK: arith.constant 32767
- // CHECK: arith.cmpi slt
- // CHECK: select
- // CHECK: arith.cmpi slt
- // CHECK: select
// CHECK: arith.trunci
%20 = "tosa.cast"(%0) : (tensor<1xi32>) -> tensor<1xi16>