[Mlir-commits] [mlir] 59dd418 - [mlir][tosa] Fix tosa.cast UiToFp32 for tosa-to-linalg
Rob Suderman
llvmlistbot at llvm.org
Thu Oct 14 11:35:09 PDT 2021
Author: Rob Suderman
Date: 2021-10-14T11:34:10-07:00
New Revision: 59dd418e8941434a65fbace26dcd405a88b3775c
URL: https://github.com/llvm/llvm-project/commit/59dd418e8941434a65fbace26dcd405a88b3775c
DIFF: https://github.com/llvm/llvm-project/commit/59dd418e8941434a65fbace26dcd405a88b3775c.diff
LOG: [mlir][tosa] Fix tosa.cast UiToFp32 for tosa-to-linalg
Part of the arith update broke UiToFp32. Fixed the lowering and included a new
test to detect a regression.
Differential Revision: https://reviews.llvm.org/D111772
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 ff0296d7a063c..3d12042960634 100644
--- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
+++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
@@ -567,11 +567,6 @@ createLinalgBodyCalculationForElementwiseOp(Operation *op, ValueRange args,
return rewriter.create<arith::ExtUIOp>(loc, resultTypes, args,
mlir::None);
- // All other si-to-fp conversions should be handled by SIToFP.
- if (arith::SIToFPOp::areCastCompatible(srcTy, dstTy))
- return rewriter.create<arith::SIToFPOp>(loc, resultTypes, args,
- mlir::None);
-
// Unsigned integers need an unrealized cast so that they can be passed
// to UIToFP.
if (srcTy.isUnsignedInteger() && dstTy.isa<FloatType>()) {
@@ -585,6 +580,11 @@ createLinalgBodyCalculationForElementwiseOp(Operation *op, ValueRange args,
unrealizedCast);
}
+ // All other si-to-fp conversions should be handled by SIToFP.
+ if (arith::SIToFPOp::areCastCompatible(srcTy, dstTy))
+ return rewriter.create<arith::SIToFPOp>(loc, resultTypes, args,
+ mlir::None);
+
// Casting to boolean, floats need to only be checked as not-equal to zero.
if (srcTy.isa<FloatType>() && dstTy.isInteger(1)) {
Value zero = rewriter.create<arith::ConstantOp>(
diff --git a/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir b/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir
index 4db36aab197db..ab828b14f6244 100644
--- a/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir
+++ b/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir
@@ -291,6 +291,15 @@ func @test_simple_i16(%arg0: tensor<1xi16>) -> () {
// -----
+// CHECK-LABEL: @test_simple_ui8
+func @test_simple_ui8(%arg0: tensor<1xui8>) -> () {
+ // CHECK: arith.uitofp
+ %0 = "tosa.cast"(%arg0) : (tensor<1xui8>) -> tensor<1xf32>
+ return
+}
+
+// -----
+
// CHECK-LABEL: @test_simple_i32
func @test_simple_i32(%arg0: tensor<1xi32>) -> () {
// CHECK: linalg.generic
More information about the Mlir-commits
mailing list