[Mlir-commits] [mlir] [mlir][spirv] Add 6 Element Binary operators to TOSA Ext Inst Set (PR #179627)
Davide Grohmann
llvmlistbot at llvm.org
Mon Feb 23 07:01:33 PST 2026
================
@@ -863,4 +876,229 @@ def SPIRV_TosaTanhOp : SPIRV_TosaOpWithResult<"Tanh", 13, [Pure,
}
+def SPIRV_TosaAddOp : SPIRV_TosaElementwiseBinaryOp<"Add", 14, [Pure,
+ AllElementTypesMatch<["input1", "input2", "output"]>,
+ AllRanksMatch<["input1", "input2"]>]> {
+ let summary = "Addition operator.";
+
+ let description = [{
+ Elementwise Addition of input1 and input2. Axis of size 1 will be broadcast,
+ as necessary. Rank of input tensors must match.
+
+ References:
+ * https://github.khronos.org/SPIRV-Registry/extended/TOSA.001000.1.html#_add
+ * https://www.mlplatform.org/tosa/tosa_spec_1_0_1.html#_add
+
+ #### Example:
+ ```mlir
+ %0 = spirv.Tosa.Add %arg0, %arg1 : !spirv.arm.tensor<4x7x3x10xi32>, !spirv.arm.tensor<4x7x3x1xi32> -> !spirv.arm.tensor<4x7x3x10xi32>
+ %0 = spirv.Tosa.Add %arg0, %arg1 : !spirv.arm.tensor<26x37x18xf16>, !spirv.arm.tensor<1x37x18xf16> -> !spirv.arm.tensor<26x37x18xf16>
+ ```
+ }];
+
+ let arguments = (ins
+ SPIRV_TosaNumerical_TensorArm: $input1,
+ SPIRV_TosaNumerical_TensorArm: $input2
+ );
+
+ let results = (outs
+ SPIRV_TosaNumerical_TensorArm: $output
+ );
+
+ let assemblyFormat = [{
+ $input1 `,`
+ $input2
----------------
davidegrohmann wrote:
I do not mind the little extra verbosity, I find easier to have one input per line.
https://github.com/llvm/llvm-project/pull/179627
More information about the Mlir-commits
mailing list