diff options
author | Eric Kunze <eric.kunze@arm.com> | 2022-11-02 01:09:56 +0300 |
---|---|---|
committer | Rob Suderman <suderman@google.com> | 2022-11-02 01:10:05 +0300 |
commit | d94ee70f4f01e4d9eec49e02eff57a5655618401 (patch) | |
tree | f276f62a920158a2ba7cbf06866eb475d8ea4ee8 /mlir | |
parent | d71a8ad3460f1a04686f7087a44c1fef64311239 (diff) |
[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
Diffstat (limited to 'mlir')
-rw-r--r-- | mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td | 16 | ||||
-rw-r--r-- | mlir/test/Dialect/Tosa/ops.mlir | 7 |
2 files changed, 23 insertions, 0 deletions
diff --git a/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td b/mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td index fc8b44e7cccd..93178288dfc1 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 7894b07a8ef4..ac7bf49a2b81 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> +} |