Closed
Description
PR #2957 describes a discrepancy between the linalg dialect re-implemented in xdsl and the upstream linalg dialect.
Specifically, linalg named ops are printed correctly in the default pretty printing mode, but the generic printing mode should also print a hidden region.
The above PR #2957 makes the xdsl-opt generic print for AddOp, SubOp, and MulOp, which previously was:
xdsl-opt --print-op-generic tests/filecheck/mlir-conversion/with-mlir/dialects/linalg/ops.mlir
[...]
%sum = "linalg.add"(%2, %2, %3) <{"operandSegmentSizes" = array<i32: 2, 1>}> : (tensor<2x3xf32>, tensor<2x3xf32>, tensor<2x3xf32>) -> tensor<2x3xf32>
... match the mlir-opt generic print:
mlir-opt --mlir-print-op-generic tests/filecheck/mlir-conversion/with-mlir/dialects/linalg/ops.mlir
[...]
%2 = "linalg.add"(%1#0, %1#0, %1#1) <{operandSegmentSizes = array<i32: 2, 1>}> ({
^bb0(%arg0: f32, %arg1: f32, %arg2: f32):
%21 = "arith.addf"(%arg0, %arg1) <{fastmath = #arith.fastmath<none>}> : (f32, f32) -> f32
"linalg.yield"(%21) : (f32) -> ()
}) : (tensor<2x3xf32>, tensor<2x3xf32>, tensor<2x3xf32>) -> tensor<2x3xf32>
Help is wanted in checking if the generic print differs for the following ops between xdsl-opt and mlir-opt, and to fix this in the code:
- FillOp
- TransposeOp
- MatmulOp
- PoolingNchwMaxOp
- Conv2DNchwFchwOp
- BroadcastOp
- Is there a non-manual way to verify MLIR compatibility (e.g. in tests/filecheck/mlir-conversion/with-mlir/dialects/linalg/ops.mlir) ?
The NamedOpBase
class provides standard printing/parsing methods for the common ins
/outs
+variadic syntax employed by linalg named ops, and may be re-used for any of these ops.