[Mlir-commits] [mlir] [mlir][spirv] Add Pooling, Fourier Transform, and MatMul operations t… (PR #177585)

Jakub Kuderski llvmlistbot at llvm.org
Mon Jan 26 06:13:16 PST 2026


================
@@ -299,6 +362,228 @@ def SPIRV_TosaDepthwiseConv2DOp : SPIRV_TosaOp<"DepthwiseConv2D", 4, [Pure,
 }
 
 
+def SPIRV_TosaFFT2DOp : SPIRV_TosaOp<"FFT2D", 5, [Pure]> {
+  let summary = "Performs FFT2D operation on the input.";
+
+  let description = [{
+    Performs a batched complex 2D Fast Fourier Transform over the input. The
+    complex input values are constructed from the corresponding values in the
+    input_real and input_imag tensors. The resulting values in the output are
+    split into the output_real and output_imag tensors. No normalization is
+    applied on either the forward or inverse versions of the operation.
+
+    References:
+      * https://github.khronos.org/SPIRV-Registry/extended/TOSA.001000.1.html#_fft2d
+      * https://www.mlplatform.org/tosa/tosa_spec_1_0_1.html#_fft2d
+
+    #### Example:
+    ```mlir
+    %0 = spirv.Tosa.FFT2D inverse = true, local_bound = false, %arg0, %arg1 : !spirv.arm.tensor<1x32x32xf32>, !spirv.arm.tensor<1x32x32xf32> -> !spirv.struct<(!spirv.arm.tensor<1x32x32xf32>, !spirv.arm.tensor<1x32x32xf32>)>
+    %1 = spirv.CompositeExtract %0[0 : i32] : !spirv.struct<(!spirv.arm.tensor<1x32x32xf32>, !spirv.arm.tensor<1x32x32xf32>)>
+    %2 = spirv.CompositeExtract %0[1 : i32] : !spirv.struct<(!spirv.arm.tensor<1x32x32xf32>, !spirv.arm.tensor<1x32x32xf32>)>
+    ```
+  }];
+
+  let arguments = (ins
+    SPIRV_BoolConstAttr: $inverse,
+    SPIRV_BoolConstAttr: $local_bound,
+    SPIRV_Float32_TensorArm3D: $input_real,
+    SPIRV_Float32_TensorArm3D: $input_imag
+  );
+
+  let results = (outs
+    SPIRV_Struct_2_Float32_TensorArm3D: $output
+  );
+
+  let assemblyFormat = [{
+    `inverse` `=` $inverse `,`
+    `local_bound` `=` $local_bound `,`
+    $input_real `,`
+    $input_imag
+    attr-dict `:` type(operands) `->` type(results)
+  }];
+
+  let extraClassDeclaration = [{
+    ::mlir::spirv::TensorArmType getInputRealType() {
+      return cast<::mlir::spirv::TensorArmType>(getInputReal().getType());
+    }
+    ::mlir::spirv::TensorArmType getInputImagType() {
+      return cast<::mlir::spirv::TensorArmType>(getInputImag().getType());
+    }
+    ::mlir::spirv::TensorArmType getResultRealType() {
+      auto resultType = cast<StructType>(getType());
+      return cast<::mlir::spirv::TensorArmType>(resultType.getElementType(0));
+    }
+    ::mlir::spirv::TensorArmType getResultImagType() {
+      auto resultType = cast<StructType>(getType());
+      return cast<::mlir::spirv::TensorArmType>(resultType.getElementType(1));
+    }
+  }];
+}
+
+
+def SPIRV_TosaMatMulOp : SPIRV_TosaOp<"MatMul", 6, [Pure,
+  AllElementTypesMatch<["A", "A_zp", "B", "B_zp"]>]> {
+  let summary = "Matrix Multiplication operator.";
+
+  let description = [{
+    Performs two dimensional matrix multiplications.
----------------
kuhar wrote:

I think we should at least say these are zero-points so that we don't over rely on external websites. Other dialects like linalg and torch don't have matmul ops with zero-points.

https://github.com/llvm/llvm-project/pull/177585


More information about the Mlir-commits mailing list