[Mlir-commits] [mlir] [mlir][linalg] Align `elementwise` builder to do type-conversion of input to result type (PR #190566)
Renato Golin
llvmlistbot at llvm.org
Sat Apr 25 02:11:57 PDT 2026
================
@@ -163,3 +163,27 @@ func.func @ternary(%A : tensor<32x16xi1>, %B: tensor<8x16x32xf32>, %C : tensor<8
outs(%D: tensor<8x16x32xf32>) -> tensor<8x16x32xf32>
return %r : tensor<8x16x32xf32>
}
+// -----
+// CHECK-DAG: #[[IDENTITY:.+]] = affine_map<(d0, d1, d2) -> (d0, d1, d2)>
+//
+// CHECK: @unary_upcast_exp(%[[A:.+]]: tensor<8x16x32xf16>, %[[B:.+]]: tensor<8x16x32xf32>)
+// CHECK: linalg.generic
+// CHECK-SAME: indexing_maps = [#[[IDENTITY]], #[[IDENTITY]]]
+// CHECK-SAME: iterator_types = ["parallel", "parallel", "parallel"]
+//
+// CHECK-SAME: ins(%[[A]]
+// CHECK-SAME: outs(%[[B]]
+//
+// CHECK: ^{{.*}}(%[[IN:.+]]: f16, %[[OUT:.+]]: f32)
+// CHECK: %[[EXT:.+]] = arith.extf %[[IN]] : f16 to f32
+// CHECK: %[[EXP:.+]] = math.exp %[[EXT]] : f32
+// CHECK: linalg.yield %[[EXP]] : f32
+//
+func.func @unary_upcast_exp(%A : tensor<8x16x32xf16>, %B : tensor<8x16x32xf32>) -> tensor<8x16x32xf32> {
----------------
rengolin wrote:
Please add a test for upcast and downcast, unary and binary, and a negative test for ternary on both up/down cases.
https://github.com/llvm/llvm-project/pull/190566
More information about the Mlir-commits
mailing list