[Mlir-commits] [mlir] [MLIR][Linalg] Harden parsing Linalg named ops (PR #145337)
Andrzej WarzyĆski
llvmlistbot at llvm.org
Tue Jun 24 04:26:20 PDT 2025
================
@@ -1874,3 +1874,13 @@ func.func @reduce_non_operation_name(%arg0: tensor<4xf32>, %arg1: tensor<f32>) -
%arg0: tensor<4xf32>) outs(%arg1: tensor<f32>) dimensions = [0]
return %0 : tensor<f32>
}
+
+// -----
+
+module {
+ func.func @add_dynamic(%arg0: memref<3x4x5xf32>, %arg1 : memref< 3x4x5xi32>, %arg2: memref<3x4x5xf32>, %arg3: memref<3x4x5xf32>) attributes {arm_streaming} {
+ linalg.add ins(%arg0, %arg1 : memref<3x4x5xf32>, memref< 3x4x5xi32>) outs(%arg2 : memref<3x4x5xf32>)
+ // expected-error @below {{Cannot build binary Linalg operation: expects allComplex, allFloatingPoint, or allInteger, got 'f32' and 'i32'}}
+ return
+ }
+}
----------------
banach-space wrote:
1. Missing new-line charachter.
2. Would you mind adding a block comment to separate this from other Ops? See e.g. [this comment](https://github.com/banach-space/llvm-project/blob/c62abf4d15500182b66e5957f945f790f5d8ad72/mlir/test/Dialect/Linalg/invalid.mlir#L1799-L1801)? (there's one missing for `linalg.reduce` as well).
I also suggest reducing this test (e.g. by removing the attribute, using rank-1 types, etc). This way its clearer what makes this "unique".
```suggestion
// -----
module {
func.func @add_mixed_types(%in_f32: memref<3xf32>, %in_i32 : memref< 3xi32>, %out_f32: memref<3xf32>, %arg3: memref<3xf32>) {
linalg.add ins(%in_f32, %in_i32 : memref<3xf32>, memref< 3xi32>) outs(%out_f32 : memref<3xf32>)
// expected-error @below {{Cannot build binary Linalg operation: expects allComplex, allFloatingPoint, or allInteger, got 'f32' and 'i32'}}
return
}
}
```
https://github.com/llvm/llvm-project/pull/145337
More information about the Mlir-commits
mailing list