Can I extend Linalg.conv to support tensor as input and output

linalg.conv takes only strided memref as input. can I extend linalg.conv to support tensor as well? and also I wanted to know the significance why it supports in strided memref.

The linalg.conv is legacy at this point and will probably be deprecated soon. There are already many versions of convolution that are defined here using the Pythong OpDSL (llvm-project/ at main · llvm/llvm-project · GitHub). This is the source of truth for Linalg ops. From this there is a YAML file generated that is checked into tree, which in-turn is used to generate the Tablegen specification of the linalg ops. So if you need to add an op to Linalg you add an op to the OpDSL file above.

Hope that helps

linalg.conv is legacy and will be deprecated at some point. The yaml named ops do support strides. llvm-project/LinalgNamedStructuredOps.yaml at main · llvm/llvm-project · GitHub

And it works for both tensors and memrefs. Here are more IR examples: llvm-project/named-ops.mlir at main · llvm/llvm-project · GitHub

Note: the ymal conv ops do not have padding attributes, you can create linalg.pad_tensor + linalg.conv to represent a conv op with padding attributes. I’d suggest not to add padding attributes to those ops because it stops many opportunities of Linalg transforms. E.g., we are not able to tile operations if it has padding attributes.

I am trying to add new op to linalg using Pythong OpDSL. I added op definition to and I built iree but I didnt find added op in iree/third_party/llvm-project/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml .How do I generate YAML file using Pythong OpDSL?


The YAML file is machine generated. You have to run the script ( and replace the YAML file with the output. Basically follow the procedure discussed by the basic usage section of Linalg OpDSL - MLIR.