[Mlir-commits] [mlir] 4bdc9d9 - [mlir][tosa] Add TOSA f64 type support for const op

Jacques Pienaar llvmlistbot at llvm.org
Mon Mar 27 18:59:08 PDT 2023


Author: AmosLewis
Date: 2023-03-27T18:49:44-07:00
New Revision: 4bdc9d9b2d95add1e9511553d4c555b1770c1f16

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

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

[mlir][tosa] Add TOSA f64 type support for const op

Reviewed By: eric-k256, jpienaar

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

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
    mlir/include/mlir/Dialect/Tosa/IR/TosaTypesBase.td
    mlir/test/Dialect/Tosa/constant_folding.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
index b6127f1ffa3cf..33741c00d8495 100644
--- a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
+++ b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
@@ -1746,11 +1746,11 @@ def Tosa_CastOp: Tosa_Op<"cast", [Pure,
   }];
 
   let arguments = (ins
-    Tosa_Tensor_Cast:$input
+    Tosa_Tensor_Plus_F64:$input
   );
 
   let results = (outs
-    Tosa_Tensor_Cast:$output
+    Tosa_Tensor_Plus_F64:$output
   );
 
   let hasFolder = 1;
@@ -1821,7 +1821,7 @@ def Tosa_ConstOp : Tosa_Op<"const", [ConstantLike, Pure,
   );
 
   let results = (outs
-    Tosa_Tensor:$output
+    Tosa_Tensor_Plus_F64:$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 d3eeac92a4ee2..4e8aef11c67e3 100644
--- a/mlir/include/mlir/Dialect/Tosa/IR/TosaTypesBase.td
+++ b/mlir/include/mlir/Dialect/Tosa/IR/TosaTypesBase.td
@@ -95,9 +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">;
+// Add F64 type support just for tosa::CastOp and tosa::ConstOp
+def Tosa_AnyNumber_Plus_F64 : AnyTypeOf<[Tosa_Int, Tosa_QuantizedInt, Tosa_Float, F64],
+                               "number_plus_f64">;
 
 //===----------------------------------------------------------------------===//
 // Tensor types
@@ -108,7 +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]>;
+def Tosa_Tensor_Plus_F64 : TensorOf<[Tosa_AnyNumber_Plus_F64]>;
 // Must be ranked but no further constraints
 def Tosa_RankedTensor : RankedTensorOf<[Tosa_AnyNumber]>;
 

diff  --git a/mlir/test/Dialect/Tosa/constant_folding.mlir b/mlir/test/Dialect/Tosa/constant_folding.mlir
index 259b2eaf0bd13..529125db34208 100644
--- a/mlir/test/Dialect/Tosa/constant_folding.mlir
+++ b/mlir/test/Dialect/Tosa/constant_folding.mlir
@@ -7,6 +7,13 @@ func.func @test_const(%arg0 : index) -> tensor<4xi32> {
   return %0 : tensor<4xi32>
 }
 
+// CHECK-LABEL: func @test_const_i64
+func.func @test_const_i64(%arg0 : index) -> tensor<4xi64> {
+  // CHECK: "tosa.const"
+  %0 = "tosa.const"() {value = dense<[3, 0, 1, 2]> : tensor<4xi64>} : () -> tensor<4xi64>
+  return %0 : tensor<4xi64>
+}
+
 // CHECK-LABEL: func @try_fold_equal_with_unranked_tensor
 func.func @try_fold_equal_with_unranked_tensor(%arg0: tensor<4xi32>, %arg1: tensor<i32>) {
   // CHECK: "tosa.equal"


        


More information about the Mlir-commits mailing list