[Mlir-commits] [mlir] 76dc9a8 - [mlir][tosa] Remove clamping behavior in `tosa.cast` for integer truncation
Rob Suderman
llvmlistbot at llvm.org
Wed Jan 4 15:11:07 PST 2023
Author: mariecwhite
Date: 2023-01-04T15:10:06-08:00
New Revision: 76dc9a853adde45b02252ea7125fa54ae2c16e2c
URL: https://github.com/llvm/llvm-project/commit/76dc9a853adde45b02252ea7125fa54ae2c16e2c
DIFF: https://github.com/llvm/llvm-project/commit/76dc9a853adde45b02252ea7125fa54ae2c16e2c.diff
LOG: [mlir][tosa] Remove clamping behavior in `tosa.cast` for integer truncation
Reviewed By: rsuderman
Differential Revision: https://reviews.llvm.org/D141015
Added:
Modified:
mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
index 22563eaeda20..7e12d1b91dcd 100644
--- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
+++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
@@ -512,20 +512,7 @@ createLinalgBodyCalculationForElementwiseOp(Operation *op, ValueRange args,
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]);
}
}
diff --git a/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir b/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir
index 8406c050075c..864eec8399d7 100644
--- a/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir
+++ b/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir
@@ -400,12 +400,6 @@ func.func @test_simple_i32(%arg0: tensor<1xi32>) -> () {
%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>
More information about the Mlir-commits
mailing list