[Mlir-commits] [mlir] [mlir][spirv] Add Conv operations for TOSA Extended Instruction Set (001000.1) (PR #176908)
Davide Grohmann
llvmlistbot at llvm.org
Wed Jan 21 06:15:04 PST 2026
================
@@ -83,4 +83,254 @@ def SPIRV_TosaArgMaxOp : SPIRV_TosaOp<"ArgMax", 0, [Pure]> {
}];
}
+
+def SPIRV_TosaConv2DOp : SPIRV_TosaOp<"Conv2D", 2, [Pure]> {
+ let summary = "2D Convolution operator.";
+
+ let description = [{
+ Performs a 2D convolution over the given tensor input, using the weight
+ tensor. Implementations may choose to skip calculation of multiplies in
+ the padding area.
+
+ References:
+ * https://github.khronos.org/SPIRV-Registry/extended/TOSA.001000.1.html#_conv2d
+ * https://www.mlplatform.org/tosa/tosa_spec_1_0_1.html#_conv2d
+
+ #### Example:
+ ```mlir
+ %7 = spirv.Tosa.Conv2D pad = dense<[1, 0, 0, 0]> : !spirv.arm.tensor<4xi32>, stride = dense<[1, 2]> : !spirv.arm.tensor<2xi32>, dilation = dense<[7, 1]> : !spirv.arm.tensor<2xi32>, acc_type = <INT32>, local_bound = false, %arg0, %arg1, %arg2, %5, %6 : !spirv.arm.tensor<1x65535x3x1xi8>, !spirv.arm.tensor<7x1x1x1xi8>, !spirv.arm.tensor<1xi32>, !spirv.arm.tensor<1xi8>, !spirv.arm.tensor<1xi8> -> !spirv.arm.tensor<1x65536x2x7xi32>
+ %7 = spirv.Tosa.Conv2D pad = dense<0> : !spirv.arm.tensor<4xi32>, stride = dense<1> : !spirv.arm.tensor<2xi32>, dilation = dense<1> : !spirv.arm.tensor<2xi32>, acc_type = <FP16>, local_bound = true, %arg0, %arg1, %arg2, %5, %6 : !spirv.arm.tensor<1x34x18x27xf16>, !spirv.arm.tensor<11x1x1x27xf16>, !spirv.arm.tensor<11xf16>, !spirv.arm.tensor<1xf16>, !spirv.arm.tensor<1xf16> -> !spirv.arm.tensor<1x34x18x11xf16>
+ ```
+ }];
+
+ let arguments = (ins
+ SPIRV_Int32_1DTensorArmOfLength4Attr: $pad,
+ SPIRV_Int32_1DTensorArmOfLength2Attr: $stride,
+ SPIRV_Int32_1DTensorArmOfLength2Attr: $dilation,
----------------
davidegrohmann wrote:
I am not sure how to do this. Maybe I have not a good knoweledge.
I had a look at the linked use cases, those use I64ArrayAttr which are not exactly the same as we use here. Whilst the types here are based on ElementsAttr where the ShapedType is mandated to be a TensorARM type (so the serializer/deserializer can do the correct work when generating/parsing SPIR-V modules).
I see no obvious way to remove the type by keeping using ElementsAttr based types.
https://github.com/llvm/llvm-project/pull/176908
More information about the Mlir-commits
mailing list