[Mlir-commits] [mlir] [mlir] Add helper to check elementwise-mappable ops with tensors and scalars (PR #154872)

Adam Siemieniuk llvmlistbot at llvm.org
Fri Aug 22 09:56:52 PDT 2025


================
@@ -19,6 +19,53 @@ func.func @addf_rank0(%arg0: tensor<f32>, %arg1: tensor<f32>) -> tensor<f32> {
   return %0 : tensor<f32>
 }
 
+// Test a binary elementwise op with a tensor and a scalar operand.
+// CHECK-LABEL: func @addf_tensor_plus_scalar_rank1
+//  CHECK-SAME:   %[[T:[0-9a-zA-Z]*]]: tensor<?xf32>, %[[S:[0-9a-zA-Z]*]]: f32
+func.func @addf_tensor_plus_scalar_rank1(%t: tensor<?xf32>, %s: f32) -> tensor<?xf32> {
----------------
adam-smnk wrote:

After a bit of digging, I've found there's this test op that should also work with this conversion pass:
```mlir
func.func @test(%arg0: f32, %arg1: tensor<?x?xf32>) {
  %0 = "test.elementwise_mappable"(%arg0, %arg1) : (f32, tensor<?x?xf32>) -> tensor<?x?xf32>
  return
}
```

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


More information about the Mlir-commits mailing list