[Mlir-commits] [mlir] 4b01435 - [mlir][tosa] Remove tosa.identityn operator

Rob Suderman llvmlistbot at llvm.org
Wed May 12 12:47:07 PDT 2021


Author: Suraj Sudhir
Date: 2021-05-12T12:46:22-07:00
New Revision: 4b014352308f7244b86438fff7c61c632934a1ff

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

LOG: [mlir][tosa] Remove tosa.identityn operator

Removes the identityn operator from TOSA MLIR definition.
Removes TosaToLinAlg mappings

Reviewed By: rsuderman

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

Added: 
    

Modified: 
    mlir/docs/Dialects/TOSA.md
    mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
    mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
    mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir
    mlir/test/Dialect/Tosa/ops.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/docs/Dialects/TOSA.md b/mlir/docs/Dialects/TOSA.md
index cd95f4da69cd2..273a71aeed200 100644
--- a/mlir/docs/Dialects/TOSA.md
+++ b/mlir/docs/Dialects/TOSA.md
@@ -61,41 +61,6 @@ The general basis of selection of the operator set that constitutes TOSA is
 described in the TOSA specification document  under Section 1.3 Operator
 Selection. Explanation of the thinking behind some operators is listed here:
 
-### IDENTITYN
-
-tosa.IDENTITYN is used to form a list of Operator results during
-lowering of operations such as tf.Split from a sequence of tosa.SLICE
-ops.  If there are alternate ways to express this lowering without the
-tosa.IDENTITYN op, the tosa.IDENTITYN op could be removed from TOSA.
-
-```
-Value lower_split_op(Value %value, size_t axis, size_t
-num_split) { Value %output[]
-
-    size_t slice_size = %value.shape[axis] / num_split
-
-    for (int i = 0; i < num_split; i++) {
-        vector <size_t> begin_vals, size_vals
-
-        for (int j = 0; j < %value.rank; j++) {
-            if (j == axis) {
-               begin_vals.push_back(slice_size * i)
-               size_vals.push_back(slice_size)
-            } else {
-               begin_vals.push_back(0)
-               size_vals.push_bac(%value.shape[j])
-            }
-
-            %output[i] = tosa.SLICE(%value) {start=begin_vals, size=size_vals} (tensor<%value.type>) -> tensor<size_vals, %value.dtype>
-        }
-
-    }
-
-    %output_list = tosa.IDENTITYN(%output) (tensor<%output:*.type>) -> tensor<%output_list:*.type>
-    return %output_list
-}
-```
-
 ### COND\_IF and WHILE\_LOOP
 
 Several neural networks express conditional control flow at the tensor level.

diff  --git a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
index 1a9198d0fef2c..4654b3e0c9a5f 100644
--- a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
+++ b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
@@ -1585,28 +1585,6 @@ def Tosa_IdentityOp: Tosa_Op<"identity", [NoSideEffect]> {
   );
 }
 
-//===----------------------------------------------------------------------===//
-// Operator: identityn
-//===----------------------------------------------------------------------===//
-//===----------------------------------------------------------------------===//
-// Further described in docs/Rationale/RationaleTOSADialect.md .
-//===----------------------------------------------------------------------===//
-def Tosa_IdentityNOp: Tosa_Op<"identityn", [NoSideEffect]> {
-  let summary = "IdentityN operator";
-  let description = [{
-    Returns a list of tensors with the same shape, type, and contents as the
-    input list of tensors.
-  }];
-
-  let arguments = (ins
-    Variadic<Tosa_TensorUpto6D>:$input1
-  );
-
-  let results = (outs
-     Variadic<Tosa_TensorUpto6D>:$output
-  );
-}
-
 //===----------------------------------------------------------------------===//
 // TOSA Spec Section 2.14
 // Operator Class: Custom Operators.

diff  --git a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
index 3718a56b38f02..ba5316ce4167e 100644
--- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
+++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
@@ -2328,7 +2328,6 @@ void mlir::tosa::populateTosaToLinalgOnTensorsConversionPatterns(
       PointwiseConverter<tosa::ReluNOp>,
       PointwiseConverter<tosa::SigmoidOp>,
       IdentityNConverter<tosa::IdentityOp>,
-      IdentityNConverter<tosa::IdentityNOp>,
       ReduceConverter<tosa::ReduceAllOp>,
       ReduceConverter<tosa::ReduceAnyOp>,
       ReduceConverter<tosa::ReduceMinOp>,

diff  --git a/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir b/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir
index 4916c703ef8c5..f0bb4c5cc8833 100644
--- a/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir
+++ b/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir
@@ -482,10 +482,8 @@ func @test_identity(%arg0: tensor<1xf32>, %arg1: tensor<1xi32>) -> (tensor<1xf32
   %0 = "tosa.identity"(%arg0) : (tensor<1xf32>) -> tensor<1xf32>
   %1 = "tosa.identity"(%arg1) : (tensor<1xi32>) -> tensor<1xi32>
 
-  %2:2 = "tosa.identityn"(%0, %1) : (tensor<1xf32>, tensor<1xi32>) -> (tensor<1xf32>, tensor<1xi32>)
-
   // CHECK: return %arg0, %arg1
-  return %2#0, %2#1 : tensor<1xf32>, tensor<1xi32>
+  return %0, %1 : tensor<1xf32>, tensor<1xi32>
 }
 
 // -----

diff  --git a/mlir/test/Dialect/Tosa/ops.mlir b/mlir/test/Dialect/Tosa/ops.mlir
index 3a23f3798bb57..6ef301081bb56 100644
--- a/mlir/test/Dialect/Tosa/ops.mlir
+++ b/mlir/test/Dialect/Tosa/ops.mlir
@@ -473,13 +473,6 @@ func @test_identity(%arg0: tensor<13x21x3xi32>) -> tensor<13x21x3xi32> {
   return %0 : tensor<13x21x3xi32>
 }
 
-// -----
-// CHECK-LABEL: identityn
-func @test_identityn(%arg0: tensor<1xi32>, %arg1: tensor<1xi32>) -> tensor<1xi32> {
-  %0:2 = "tosa.identityn"(%arg0, %arg1) : (tensor<1xi32>, tensor<1xi32>) -> (tensor<1xi32>, tensor<1xi32>)
-  return %0#0 : tensor<1xi32>
-}
-
 // -----
 // CHECK-LABEL: cond_if
 func @test_cond_if(%arg0: tensor<f32>, %arg1: tensor<f32>, %arg2: tensor<i1>) -> tensor<f32> {


        


More information about the Mlir-commits mailing list