From: Suraj Sudhir Date: Wed, 12 May 2021 19:39:25 +0000 (-0700) Subject: [mlir][tosa] Remove tosa.identityn operator X-Git-Tag: llvmorg-14-init~6876 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4b014352308f7244b86438fff7c61c632934a1ff;p=platform%2Fupstream%2Fllvm.git [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 --- diff --git a/mlir/docs/Dialects/TOSA.md b/mlir/docs/Dialects/TOSA.md index cd95f4d..273a71a 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 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 - } - - } - - %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 1a9198d..4654b3e 100644 --- a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td +++ b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td @@ -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:$input1 - ); - - let results = (outs - Variadic:$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 3718a56b..ba5316c 100644 --- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp +++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp @@ -2328,7 +2328,6 @@ void mlir::tosa::populateTosaToLinalgOnTensorsConversionPatterns( PointwiseConverter, PointwiseConverter, IdentityNConverter, - IdentityNConverter, ReduceConverter, ReduceConverter, ReduceConverter, diff --git a/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir b/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg.mlir index 4916c70..f0bb4c5 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 3a23f37..6ef3010 100644 --- a/mlir/test/Dialect/Tosa/ops.mlir +++ b/mlir/test/Dialect/Tosa/ops.mlir @@ -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, %arg1: tensor, %arg2: tensor) -> tensor { %0 = "tosa.cond_if"(%arg2, %arg0, %arg1) ( {