diff --git a/mlir/lib/Dialect/Tosa/Utils/ConversionUtils.cpp b/mlir/lib/Dialect/Tosa/Utils/ConversionUtils.cpp --- a/mlir/lib/Dialect/Tosa/Utils/ConversionUtils.cpp +++ b/mlir/lib/Dialect/Tosa/Utils/ConversionUtils.cpp @@ -32,8 +32,8 @@ Value mlir::tosa::clampFloatHelper(Location loc, Value arg, arith::ConstantOp min, arith::ConstantOp max, OpBuilder &rewriter) { - Value minValue = rewriter.create(loc, arg, min); - return rewriter.create(loc, minValue, max); + Value minValue = rewriter.create(loc, arg, max); + return rewriter.create(loc, minValue, min); } Value mlir::tosa::clampIntHelper(Location loc, Value arg, arith::ConstantOp min, diff --git a/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir b/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir --- a/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir +++ b/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir @@ -467,8 +467,8 @@ // 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