[Mlir-commits] [mlir] d94ee70 - [mlir][TOSA]Add optional attributes to TOSA custom op

Rob Suderman llvmlistbot at llvm.org
Tue Nov 1 15:23:07 PDT 2022


Author: Eric Kunze
Date: 2022-11-01T15:10:05-07:00
New Revision: d94ee70f4f01e4d9eec49e02eff57a5655618401

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

LOG: [mlir][TOSA]Add optional attributes to TOSA custom op

The implementation_attrs attr allows passing of backend specific
attributes to TOSA custom ops.

Also adds a config option to avoid namespace collisions on the
identifier.

Reviewed By: rsuderman

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
index fc8b44e7cccde..93178288dfc1b 100644
--- a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
+++ b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td
@@ -1793,10 +1793,26 @@ def Tosa_CustomOp : Tosa_Op<"custom"> {
     that are not expressed in the existing TOSA operations. These operators are
     not expected to be portable across TOSA implementations. The input and
     output signatures must be expressed in the corresponding TOSA node.
+
+    `identifier` is a string that tells the backend which custom operator is being
+    called.
+
+    `config` is a string identifier which can help avoid name collisions on the
+    identifier field.
+
+    `implementation_attrs` is a string which is a backend and identifier specific
+    set of attributes to the custom operator.
+
+    `inputs` is the set of tensor inputs to the custom operator.
+
+    `outputs is the list of tensors returned by the operator. The number of operators
+    is backend specific.
   }];
 
   let arguments = (ins
     StrAttr:$identifier,
+    StrAttr:$config,
+    StrAttr:$implementation_attrs,
     Variadic<Tosa_Tensor>:$inputs
   );
 

diff  --git a/mlir/test/Dialect/Tosa/ops.mlir b/mlir/test/Dialect/Tosa/ops.mlir
index 7894b07a8ef42..ac7bf49a2b81b 100644
--- a/mlir/test/Dialect/Tosa/ops.mlir
+++ b/mlir/test/Dialect/Tosa/ops.mlir
@@ -529,3 +529,10 @@ func.func @test_while_loop(%arg0: tensor<10xi32>, %arg1: tensor<i32>) {
   }) : (tensor<i32>, tensor<i32>, tensor<10xi32>) -> (tensor<i32>, tensor<i32>, tensor<10xi32>)
   return
 }
+
+// -----
+// CHECK-LABEL: custom
+func.func @test_custom(%arg0: tensor<10xi32>) -> tensor<10xi32> {
+  %0 = "tosa.custom"(%arg0) {identifier="custom_test", config="tosa_mlir_test", implementation_attrs=""} : (tensor<10xi32>) -> (tensor<10xi32>)
+  return %0 : tensor<10xi32>
+}


        


More information about the Mlir-commits mailing list