[mlir][tosa] Fix clamp float lowering

min and max were mixed up after switching to using float min/max

Differential Revision: https://reviews.llvm.org/D131923
This commit is contained in:
Thomas Raoux 2022-08-15 21:59:54 +00:00
parent 73f0ca806e
commit 444b4fda17
2 changed files with 4 additions and 4 deletions

View File

@ -32,8 +32,8 @@ mlir::tosa::condenseValues(const SmallVector<Value> &values) {
Value mlir::tosa::clampFloatHelper(Location loc, Value arg,
arith::ConstantOp min, arith::ConstantOp max,
OpBuilder &rewriter) {
Value minValue = rewriter.create<arith::MinFOp>(loc, arg, min);
return rewriter.create<arith::MaxFOp>(loc, minValue, max);
Value minValue = rewriter.create<arith::MinFOp>(loc, arg, max);
return rewriter.create<arith::MaxFOp>(loc, minValue, min);
}
Value mlir::tosa::clampIntHelper(Location loc, Value arg, arith::ConstantOp min,

View File

@ -467,8 +467,8 @@ func.func @test_clamp_f16(%arg0: tensor<1xf16>) -> () {
// CHECK: ^bb0(%[[ARG1:.+]]: f16,
// CHECK-DAG: %[[C0:.+]] = arith.constant 0.0
// CHECK-DAG: %[[C6:.+]] = arith.constant 6.0
// CHECK-DAG: %[[MIN:.+]] = arith.minf %[[ARG1]], %[[C0]]
// CHECK-DAG: %[[MAX:.+]] = arith.maxf %[[MIN]], %[[C6]]
// CHECK-DAG: %[[MIN:.+]] = arith.minf %[[ARG1]], %[[C6]]
// CHECK-DAG: %[[MAX:.+]] = arith.maxf %[[MIN]], %[[C0]]
%0 = "tosa.clamp"(%arg0) {min_int = 0 : i64, max_int = 0 : i64, min_fp = 0.0 : f32, max_fp = 6.0 : f32} : (tensor<1xf16>) -> tensor<1xf16>
return