[Mlir-commits] [mlir] [mlir][Vector] Support mixed mode vector.contract lowering (PR #117753)

Jakub Kuderski llvmlistbot at llvm.org
Tue Dec 3 07:58:00 PST 2024


================
@@ -80,6 +80,28 @@ static AffineMap adjustMap(AffineMap map, int64_t index,
   return AffineMap::get(map.getNumDims() - 1, 0, results, ctx);
 }
 
+static Value promoteToElementType(Location loc, RewriterBase &rewriter, Value v,
+                                  Type dstElementType) {
+  Type elementType = getElementTypeOrSelf(v.getType());
+  if (elementType == dstElementType)
+    return v;
+
+  // vector.contract only allows extension on operands.
+  assert(elementType.getIntOrFloatBitWidth() <=
+             dstElementType.getIntOrFloatBitWidth() &&
+         "vector.contract does not allow truncation of operands");
+
+  Type promotedType = dstElementType;
+  if (auto vecType = dyn_cast<VectorType>(v.getType()))
+    promotedType = vecType.clone(promotedType);
+
+  if (isa<FloatType>(dstElementType))
+    return rewriter.create<arith::ExtFOp>(loc, promotedType, v);
+  // For integer types, vector.contract only supports signless integer types
----------------
kuhar wrote:

nit: I'd add a new line before this comment

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


More information about the Mlir-commits mailing list