[Mlir-commits] [mlir] a2dcd99 - [mlir][tosa] Add TOSA f64 type support for cast op

Jacques Pienaar llvmlistbot at llvm.org
Fri Feb 10 12:12:58 PST 2023


Author: AmosLewis
Date: 2023-02-10T12:12:51-08:00
New Revision: a2dcd994a7f8cc33640f58105276b78acf3483e5

URL: https://github.com/llvm/llvm-project/commit/a2dcd994a7f8cc33640f58105276b78acf3483e5
DIFF: https://github.com/llvm/llvm-project/commit/a2dcd994a7f8cc33640f58105276b78acf3483e5.diff

LOG: [mlir][tosa] Add TOSA f64 type support for cast op

Add TOSA f64 type support for cast op

Reviewed By: eric-k256

Differential Revision: https://reviews.llvm.org/D142599

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
    mlir/include/mlir/Dialect/Tosa/IR/TosaTypesBase.td
    mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
index f9221662b1d7e..fc4cf7d82174c 100644
--- a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
+++ b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
@@ -1705,14 +1705,16 @@ def Tosa_CastOp: Tosa_Op<"cast", [Pure,
         float to signed 16      float   int16
         signed 8 to float       int8    float
         signed 16 to float      int16   float
+        float 32 to float 64    float32 float64
+        float 64 to float 32    float64 float32
   }];
 
   let arguments = (ins
-    Tosa_Tensor:$input
+    Tosa_Tensor_Cast:$input
   );
 
   let results = (outs
-    Tosa_Tensor:$output
+    Tosa_Tensor_Cast:$output
   );
 
   let hasFolder = 1;

diff  --git a/mlir/include/mlir/Dialect/Tosa/IR/TosaTypesBase.td b/mlir/include/mlir/Dialect/Tosa/IR/TosaTypesBase.td
index 3c9094e6aaef7..d3eeac92a4ee2 100644
--- a/mlir/include/mlir/Dialect/Tosa/IR/TosaTypesBase.td
+++ b/mlir/include/mlir/Dialect/Tosa/IR/TosaTypesBase.td
@@ -95,6 +95,9 @@ def Tosa_Float : AnyTypeOf<[
 //===----------------------------------------------------------------------===//
 def Tosa_AnyNumber : AnyTypeOf<[Tosa_Int, Tosa_QuantizedInt, Tosa_Float],
                                "number">;
+// Add F64 type support for just for tosa::CastOp
+def Tosa_AnyNumber_Cast : AnyTypeOf<[Tosa_Int, Tosa_QuantizedInt, Tosa_Float, F64],
+                               "number_cast">;
 
 //===----------------------------------------------------------------------===//
 // Tensor types
@@ -105,6 +108,7 @@ def Tosa_Int32Or64Tensor : TensorOf<[Tosa_Int32Or64]>;
 
 // Either ranked or unranked tensor of TOSA supported element types.
 def Tosa_Tensor : TensorOf<[Tosa_AnyNumber]>;
+def Tosa_Tensor_Cast : TensorOf<[Tosa_AnyNumber_Cast]>;
 // Must be ranked but no further constraints
 def Tosa_RankedTensor : RankedTensorOf<[Tosa_AnyNumber]>;
 

diff  --git a/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp b/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp
index 9517cbf8703cb..896f81e75daab 100644
--- a/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp
+++ b/mlir/lib/Dialect/Tosa/Transforms/TosaValidation.cpp
@@ -58,6 +58,9 @@ void TosaValidation::runOnOperation() {
           getElementTypeOrSelf(operand).isa<FloatType>()) {
         return signalPassFailure();
       }
+      if (getElementTypeOrSelf(operand).isF64()) {
+        return signalPassFailure();
+      }
     }
   });
 }


        


More information about the Mlir-commits mailing list