[Mlir-commits] [mlir] e0f3a95 - [mlir][vector] Disallow vector.fma over vectors of integers

Jakub Kuderski llvmlistbot at llvm.org
Fri Jan 13 12:47:03 PST 2023


Author: Jakub Kuderski
Date: 2023-01-13T15:46:01-05:00
New Revision: e0f3a95f9d999b526a9e82bb1a4012fdcb09b364

URL: https://github.com/llvm/llvm-project/commit/e0f3a95f9d999b526a9e82bb1a4012fdcb09b364
DIFF: https://github.com/llvm/llvm-project/commit/e0f3a95f9d999b526a9e82bb1a4012fdcb09b364.diff

LOG: [mlir][vector] Disallow vector.fma over vectors of integers

This is to make `vector.fma` more consistent with the standard
definition of `fma` that is defined only for flaoting point types.

Reviewed By: dcaballe

Differential Revision: https://reviews.llvm.org/D141711

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
    mlir/test/Dialect/Vector/invalid.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
index 8c5d44ab3d31a..abf4f887f971d 100644
--- a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
+++ b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
@@ -630,10 +630,10 @@ def Vector_FMAOp :
        Pure, AllTypesMatch<["lhs", "rhs", "acc", "result"]>,
        DeclareOpInterfaceMethods<VectorUnrollOpInterface, ["getShapeForUnroll"]>
      ] # ElementwiseMappable.traits>,
-    Arguments<(ins AnyVectorOfAnyRank:$lhs,
-                   AnyVectorOfAnyRank:$rhs,
-                   AnyVectorOfAnyRank:$acc)>,
-    Results<(outs AnyVectorOfAnyRank:$result)> {
+    Arguments<(ins VectorOfAnyRankOf<[AnyFloat]>:$lhs,
+                   VectorOfAnyRankOf<[AnyFloat]>:$rhs,
+                   VectorOfAnyRankOf<[AnyFloat]>:$acc)>,
+    Results<(outs VectorOfAnyRankOf<[AnyFloat]>:$result)> {
   let summary = "vector fused multiply-add";
   let description = [{
     Multiply-add expressions operate on n-D vectors and compute a fused

diff  --git a/mlir/test/Dialect/Vector/invalid.mlir b/mlir/test/Dialect/Vector/invalid.mlir
index 3366b1dd6ef02..e0e8ed35c77f4 100644
--- a/mlir/test/Dialect/Vector/invalid.mlir
+++ b/mlir/test/Dialect/Vector/invalid.mlir
@@ -44,6 +44,13 @@ func.func @broadcast_unknown(%arg0: memref<4x8xf32>) {
 
 // -----
 
+func.func @fma_vector_4xi32(%arg0: vector<4xi32>) {
+  // expected-error at +1 {{'vector.fma' op operand #0 must be vector of floating-point value}}
+  %1 = vector.fma %arg0, %arg0, %arg0 : vector<4xi32>
+}
+
+// -----
+
 func.func @shuffle_elt_type_mismatch(%arg0: vector<2xf32>, %arg1: vector<2xi32>) {
   // expected-error at +1 {{'vector.shuffle' op failed to verify that second operand v2 and result have same element type}}
   %1 = vector.shuffle %arg0, %arg1 [0, 1] : vector<2xf32>, vector<2xi32>


        


More information about the Mlir-commits mailing list