[mlir][tosa] Remove tosa.identityn operator
authorSuraj Sudhir <Suraj.Sudhir@arm.com>
Wed, 12 May 2021 19:39:25 +0000 (12:39 -0700)
committerRob Suderman <rob.suderman@gmail.com>
Wed, 12 May 2021 19:46:22 +0000 (12:46 -0700)
Removes the identityn operator from TOSA MLIR definition.
Removes TosaToLinAlg mappings

Reviewed By: rsuderman

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

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

index cd95f4d..273a71a 100644 (file)
@@ -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.
index 1a9198d..4654b3e 100644 (file)
@@ -1586,28 +1586,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.
 //===----------------------------------------------------------------------===//
index 3718a56..ba5316c 100644 (file)
@@ -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>,
index 4916c70..f0bb4c5 100644 (file)
@@ -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>
 }
 
 // -----
index 3a23f37..6ef3010 100644 (file)
@@ -474,13 +474,6 @@ func @test_identity(%arg0: tensor<13x21x3xi32>) -> 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> {
   %0 = "tosa.cond_if"(%arg2, %arg0, %arg1) ( {