MLIR 24.0.0git
VectorContractBF16ToFMA.cpp
Go to the documentation of this file.
1//===- VectorContractBF16ToFMA.cpp-----------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
17
19#include "mlir/IR/Dominance.h"
21
22#include "mlir/Pass/Pass.h"
24#include "llvm/Support/Casting.h"
25
26using namespace mlir;
27using namespace mlir::vector;
28using namespace mlir::x86;
29
30// Verifies that the LHS and RHS operands of a vector.contract are load or
31// vector.transfer_read operations on a memref source buffer, and checks
32// their bounds, dimensions, offsets, and strides.
33static bool validateVectorContractOperands(Value prodOp, bool isVnni) {
34 Operation *defOp = prodOp.getDefiningOp();
35 if (!defOp)
36 return false;
37
38 if (auto readOp = prodOp.getDefiningOp<mlir::vector::TransferReadOp>()) {
39 if (readOp.hasOutOfBoundsDim())
40 return false;
41
42 // The x86 packed loads read every lane, so they cannot keep a mask. A read
43 // in `vector.mask` never gets here: the operand is then the `vector.mask`
44 // result, which is rejected below as it is not a load.
45 if (readOp.getMask())
46 return false;
47
48 if (!readOp.getPermutationMap().isMinorIdentity())
49 return false;
50 }
51
52 Value srcBuff;
54 llvm::TypeSwitch<Operation *>(defOp).Case<TransferReadOp, LoadOp>(
55 [&](auto readOp) {
56 srcBuff = readOp.getOperand(0);
57 indexVals = SmallVector<OpFoldResult>(readOp.getIndices().begin(),
58 readOp.getIndices().end());
59 });
60
61 if (!srcBuff)
62 return false;
63
64 // Return false, if the source is not a memref type
65 Type srcType = srcBuff.getType();
66 if (!llvm::isa<MemRefType>(srcType))
67 return false;
68
69 // Return false if the two innermost strides of the memref are not contiguous.
70 // The x86.avx.cvt.packed.even/odd.indexed_to_f32 operations require
71 // an eight-element tuple of bf16 values to be contiguous.
72 int dimsToCheck = isVnni ? 2 : 1;
73 if (!cast<mlir::MemRefType>(srcType).areTrailingDimsContiguous(dimsToCheck))
74 return false;
75
76 // Return false if the vnni offset of load or transfer_read is not zero.
77 if (isVnni && getConstantIntValue(indexVals.back()) != 0)
78 return false;
79
80 return true;
81}
82
83// This function retrieves the source operation of the load or transfer
84// reads and creates subviews for the BF16 packed-operations to
85// broadcast or load BF16 elements as F32 packed elements.
86//
87// Example(1) Unit Dim:
88// ```
89// vector.load %arg0[%c0, %c0, %c0]:memref<4x1x2xbf16>,vector<1x1x2xbf16>
90// ```
91// to
92// ```
93// memref.subview %arg0[%c0,%c0,%c1]:memref<4x1x2xbf16> to memref<1x1x1xbf16>
94// memref.subview %arg0[%c0,%c0,%c0]:memref<4x1x2xbf16> to memref<1x1x1xbf16>
95// ```
96//
97// Example(2) Non-unit Dim:
98// ```
99// vector.load %arg1[%c0, %c0, %c0]:memref<1x32x2xbf16>,vector<1x8x2xbf16>
100// ```
101// to
102// ```
103// memref.subview %arg1[%c0,%c0,%c0]:memref<1x32x2xbf16> to memref<1x8x2xbf16>
104// ```
107 ArrayRef<int64_t> nonUnitDimShape, bool isUnitDim,
108 bool isVNNI) {
109
110 Operation *defOp = prodOp.getDefiningOp();
111
112 Value srcBuff;
114 llvm::TypeSwitch<Operation *>(defOp).Case<TransferReadOp, LoadOp>(
115 [&](auto readOp) {
116 srcBuff = readOp.getOperand(0);
117 indexVals = SmallVector<OpFoldResult>(readOp.getIndices().begin(),
118 readOp.getIndices().end());
119 });
120
121 int64_t mnDimSize = 1;
122 unsigned mnDimIdx = 0;
123
124 if (!isUnitDim) {
125 for (auto it : llvm::enumerate(nonUnitDimShape)) {
126 if (it.value() != 1) {
127 mnDimSize = it.value();
128 mnDimIdx = it.index();
129 break;
130 }
131 }
132 }
133
134 auto one = rewriter.getIndexAttr(1);
136
137 if (!isVNNI) {
138 SmallVector<OpFoldResult> strides(indexVals.size(), one);
139 SmallVector<OpFoldResult> sizes(indexVals.size(), one);
140 // Retrive twice the nonUnit dim BF16 element for both even and odd
141 // index elements.
142 if (!isUnitDim)
143 mnDimSize = 2 * mnDimSize;
144 sizes[mnDimIdx] = rewriter.getIndexAttr(mnDimSize);
145 auto subview = memref::SubViewOp::create(rewriter, loc, srcBuff, indexVals,
146 sizes, strides);
147 subviews.push_back(subview);
148 return subviews;
149 }
150
151 int vnniDimSize = isUnitDim ? 1 : 2;
152 auto nonVNNIDimSize = indexVals.size() - 1;
153 // Create the size and stride offsets.
154 SmallVector<OpFoldResult> strides(indexVals.size(), one);
155 SmallVector<OpFoldResult> sizes(nonVNNIDimSize, one);
156
157 sizes.push_back(rewriter.getIndexAttr(vnniDimSize));
158
159 // update the unit/nonUnit Dim size either it is A(LHS) or B(RHS).
160 sizes[mnDimIdx] = rewriter.getIndexAttr(mnDimSize);
161
162 // for unitDim, first broadcast odd element, so index is set to 1.
163 if (isUnitDim)
164 indexVals[indexVals.size() - 1] = rewriter.getIndexAttr(1);
165
166 auto subview = memref::SubViewOp::create(rewriter, loc, srcBuff, indexVals,
167 sizes, strides);
168 subviews.push_back(subview);
169
170 // For unit-dims, two subviews should be created for the odd and even
171 // element in the VNNI tuple (2xbf16) because x86.avx.bcst_to_f32.packed
172 // op loads and broadcast the first BF16 element into packed F32. It
173 // cannot distinguish between even and odd BF16 elements within a
174 // packed pair.
175 //
176 // Example:
177 // memref.subview %arg0[%c0,%c1]:memref<1x2xbf16> to memref<1x1xbf16> // Odd
178 // memref.subview %arg0[%c0,%c0]:memref<1x2xbf16> to memref<1x1xbf16> // Even
179 if (mnDimSize == 1) {
180 indexVals[indexVals.size() - 1] = rewriter.getIndexAttr(0);
181 sizes[indexVals.size() - 1] = rewriter.getIndexAttr(1);
182
183 auto unitDimEvenIdxSubview = memref::SubViewOp::create(
184 rewriter, loc, srcBuff, indexVals, sizes, strides);
185 subviews.push_back(unitDimEvenIdxSubview);
186 }
187
188 return subviews;
189}
190
191// Implements outer product contraction as a sequence of BF16-packed
192// operation even/odd loads and FMA operations.
193//
194// For example (VNNI packed):
195// ```
196// %1 = vector.load from memref (%m1) -> vector<1x1x2xbf16>
197// %2 = vector.load from memref (%m2) -> vector<1x8x2xbf16>
198// return vector.contract %1, %2, %arg1
199// ```
200// to
201// ```
202// %1 = x86.avx.bcst_to_f32.packed %m1[c1] -> vector<8xf32>
203// %2 = x86.avx.cvt.packed.odd.indexed_to_f32 %m2 -> vector<8xf32>
204// %3 = vector.fma %1, %2, %arg1
205// %4 = x86.avx.bcst_to_f32.packed %m1[c0] -> vector<8xf32>
206// %5 = x86.avx.cvt.packed.even.indexed_to_f32 %m2 -> vector<8xf32>
207// return vector.fma %4, %5, %3
208// ```
209//
210// For example (Flat layout):
211// ```
212// %1 = vector.load from memref (%m1) -> vector<1x1xbf16>
213// %2 = vector.load from memref (%m2) -> vector<1x8xbf16>
214// %3 = vector.contract %1, %2, %arg1
215// %4 = vector.load from memref (%m2) -> vector<1x8xbf16>
216// %5 = vector.contract %1, %4, %arg2
217// scf.yield %3, %4
218// ```
219// to
220// ```
221// %1 = x86.avx.bcst_to_f32.packed %m1[c0] -> vector<8xf32>
222// %2 = x86.avx.cvt.packed.even.indexed_to_f32 %m2 -> vector<8xf32>
223// %3 = vector.fma %1, %2, %arg1
224// %4 = x86.avx.cvt.packed.odd.indexed_to_f32 %m2 -> vector<8xf32>
225// %5 = vector.fma %1, %4, %arg2
226// scf.yield %3, %5
228 using AddContractionOpRewritePattern::AddContractionOpRewritePattern;
229
230 LogicalResult
231 matchAndRewriteAddContractOp(vector::ContractionOp contractOp,
232 PatternRewriter &rewriter) const override {
233
234 // TODO: Move this validation to a common utility folder. Planned to
235 // do once (code refactoring), all architecture specific nanokernel
236 // passes are merged into the repo.
237 VectorType lhsTy = contractOp.getLhsType();
238 if (!lhsTy.getElementType().isBF16())
239 return rewriter.notifyMatchFailure(contractOp,
240 "Only BF16 lowering is supported.");
241
242 bool isVnni = isInVnniLayout(contractOp.getOperation(),
243 contractOp.getIndexingMapsArray(),
244 /*blockingFactor=*/2);
245
246 VectorType accTy = dyn_cast<VectorType>(contractOp.getAccType());
247 if (!accTy)
248 return rewriter.notifyMatchFailure(contractOp, "Wrong accmulator type.");
249
250 if (!accTy.getElementType().isF32())
251 return rewriter.notifyMatchFailure(
252 contractOp, "Only F32 acumulation supported for BF16 type.");
253
254 ArrayRef<int64_t> accShape = accTy.getShape();
255 llvm::SmallVector<int64_t> nonUnitDimAcc;
256 llvm::copy_if(accShape, std::back_inserter(nonUnitDimAcc),
257 [](int64_t dim) { return dim != 1; });
258 if (nonUnitDimAcc.size() != 1)
259 return rewriter.notifyMatchFailure(
260 contractOp, "A or B should be a non-unit dim in acc.");
261
262 ArrayRef<int64_t> lhsShape = lhsTy.getShape();
263 llvm::SmallVector<int64_t> nonUnitDimLhs;
264 llvm::copy_if(lhsShape, std::back_inserter(nonUnitDimLhs),
265 [](int64_t dim) { return dim != 1; });
266
267 VectorType rhsTy = contractOp.getRhsType();
268 ArrayRef<int64_t> rhsShape = rhsTy.getShape();
269 llvm::SmallVector<int64_t> nonUnitDimRhs;
270 llvm::copy_if(rhsShape, std::back_inserter(nonUnitDimRhs),
271 [](int64_t dim) { return dim != 1; });
272
273 if (isVnni && (nonUnitDimLhs.size() - 1) > 0 &&
274 (nonUnitDimRhs.size() - 1) > 0)
275 return rewriter.notifyMatchFailure(contractOp,
276 "Excepts unit dimensions for either "
277 "LHS or RHS shape other than VNNI.");
278
279 if (isVnni && (nonUnitDimLhs.size() - 1) != 1 &&
280 (nonUnitDimRhs.size() - 1) != 1)
281 return rewriter.notifyMatchFailure(
282 contractOp,
283 "Excepts a one non-unit A/B dimension for either LHS or RHS shape.");
284
285 if (!isVnni && nonUnitDimLhs.size() > 0 && nonUnitDimRhs.size() > 0)
286 return rewriter.notifyMatchFailure(contractOp,
287 "Excepts unit dimensions for either "
288 "LHS or RHS shape.");
289
290 if (!isVnni && nonUnitDimLhs.size() != 1 && nonUnitDimRhs.size() != 1)
291 return rewriter.notifyMatchFailure(
292 contractOp,
293 "Excepts a one non-unit A/B dimension for either LHS or RHS shape.");
294
295 // Non-unit dimensions should match the vector length of BF16.
296 unsigned int nonUnitDim = nonUnitDimAcc.front();
297 if (nonUnitDim != 4 && nonUnitDim != 8)
298 return rewriter.notifyMatchFailure(
299 contractOp, "BF16 packed load operation expects non-unit (LHR or "
300 "RHS) dim and acc dim of size 4/8.");
301
302 if (!validateVectorContractOperands(contractOp.getLhs(), isVnni) ||
303 !validateVectorContractOperands(contractOp.getRhs(), isVnni)) {
304 return rewriter.notifyMatchFailure(
305 contractOp, "The LHS or RHS is in an invalid format. Either it has "
306 "false in-bounds, a mask, "
307 "a non-identity permutation map, a non-zero VNNI offset, "
308 "a non-memref "
309 "source, or a non-unit VNNI stride");
310 }
311
312 // Lower vector.contract to FMAs with help of BF16 packed ops.
313 auto loc = contractOp.getLoc();
314
315 // create the unit-dimension LHS or RHS subview and the
316 // corresponding non-unit dimension LHS or RHS subview on the other-side.
317 // For example, if LHS has type vector<1x1x2xbf16> and RHS has type
318 // vector<1x8x2xbf16>, we create two subview for the LHS and one subview
319 // for the RHS. In the opposite case (non-unit dimension on the LHS), we
320 // do vice-versa.
321
322 bool rhsHasMultipleNonUnitDims = nonUnitDimRhs.size() > 0;
323 if (isVnni) {
324 rhsHasMultipleNonUnitDims = (nonUnitDimRhs.size() - 1) > 0;
325 }
326
327 // Select which operand is "unit" and which is "non-unit".
328 Value unitSrc =
329 rhsHasMultipleNonUnitDims ? contractOp.getLhs() : contractOp.getRhs();
330 Value nonUnitSrc =
331 rhsHasMultipleNonUnitDims ? contractOp.getRhs() : contractOp.getLhs();
332
333 ArrayRef<int64_t> nonUnitDimShape =
334 rhsHasMultipleNonUnitDims ? rhsShape : lhsShape;
335
336 // Get the pair vector.contract operation. The pair is decided on:
337 // (1) - the unitDim operand Lhs or Rhs should be same,
338 // (2) - the defining source memref should be same for nonUnitDim
339 // operation, (3) - the nonUnit dim offset difference between the
340 // vector.contracts should be 8.
341 vector::ContractionOp pairContractOp;
342 if (!isVnni) {
343 Operation *nextOp = contractOp;
344 while ((nextOp = nextOp->getNextNode())) {
345 auto contOp = dyn_cast<vector::ContractionOp>(nextOp);
346
347 if (!contOp)
348 continue;
349
350 if (validatePairVectorContract(contractOp, contOp,
351 rhsHasMultipleNonUnitDims,
352 nonUnitDimAcc.front())) {
353 pairContractOp = contOp;
354 break;
355 }
356 }
357
358 if (!pairContractOp)
359 return failure();
360
361 // The pair is rewritten too, so its reads need the same checks.
362 if (!validateVectorContractOperands(pairContractOp.getLhs(), isVnni) ||
363 !validateVectorContractOperands(pairContractOp.getRhs(), isVnni))
364 return rewriter.notifyMatchFailure(
365 contractOp, "The LHS or RHS of the pair contract is in an invalid "
366 "format.");
367
368 Operation *accReadOp0 =
369 traceToVectorReadLikeParentOperation(contractOp.getAcc());
370 Operation *accReadOp1 =
371 traceToVectorReadLikeParentOperation(pairContractOp.getAcc());
372
373 // Iterate down to find the users of contact operations until it is store
374 // or transfer_write.
375 Operation *resultWriteOp0 =
376 traceToVectorWriteLikeUserOperation(contractOp.getResult());
377 Operation *resultWriteOp1 =
378 traceToVectorWriteLikeUserOperation(pairContractOp.getResult());
379
380 if (!accReadOp0 || !accReadOp1)
381 return rewriter.notifyMatchFailure(
382 contractOp,
383 "Operand doesn't have load or transfer_read as its parent op");
384
385 if (!resultWriteOp0 || !resultWriteOp1)
386 return rewriter.notifyMatchFailure(
387 contractOp,
388 "The use of contract operations are neither vector.store "
389 "or transfer_write or has multiple users");
390
391 if (contractOp->getBlock() == accReadOp1->getBlock() &&
392 contractOp->isBeforeInBlock(accReadOp1))
393 return rewriter.notifyMatchFailure(
394 contractOp, "The load/read operation of pair contract operation is "
395 "after the contractOp");
396
397 if (pairContractOp->getBlock() == resultWriteOp0->getBlock() &&
398 resultWriteOp0->isBeforeInBlock(pairContractOp)) {
399 return rewriter.notifyMatchFailure(
400 contractOp, "The store/write operation of contract operation is "
401 "before the pair contract operation");
402 }
403 }
404
405 // Build subviews.
406 auto unitDimSubview = getSubviewFromVectorInput(
407 loc, rewriter, unitSrc, nonUnitDimShape, true, isVnni);
408
409 auto nonUnitDimSubview = getSubviewFromVectorInput(
410 loc, rewriter, nonUnitSrc, nonUnitDimShape, false, isVnni);
411
412 auto castAcc = vector::ShapeCastOp::create(
413 rewriter, loc,
414 VectorType::get(nonUnitDimAcc.front(), accTy.getElementType()),
415 contractOp.getAcc());
416 VectorType dstType =
417 VectorType::get(nonUnitDimAcc.front(), rewriter.getF32Type());
418
419 if (!isVnni) {
420
421 // Validate and shuffle the accumulator
422 Operation *accReadOp0 =
423 traceToVectorReadLikeParentOperation(contractOp.getAcc());
424 Operation *accReadOp1 =
425 traceToVectorReadLikeParentOperation(pairContractOp.getAcc());
426
427 if (!isa<arith::ConstantOp>(accReadOp0)) {
428 // Shuffle the accumulators of the contract operations.
429 LogicalResult readShuffle =
430 shuffleAfterReadLikeOp(rewriter, accReadOp0, accReadOp1, contractOp,
431 pairContractOp, nonUnitDim, accTy);
432
433 if (failed(readShuffle))
434 return rewriter.notifyMatchFailure(
435 contractOp, "Accumulator read is not by transfer_read or load");
436 }
437
438 // Shuffle the output of contract operations before its use.
439 LogicalResult writeShuffle = shuffleBeforeWriteLikeOp(
440 rewriter, contractOp.getResult(), pairContractOp.getResult(),
441 nonUnitDim, accTy);
442
443 if (failed(writeShuffle))
444 return rewriter.notifyMatchFailure(
445 contractOp,
446 "Write to accumulator is not by transfer_write or store");
447
448 rewriter.setInsertionPoint(contractOp);
449 castAcc = vector::ShapeCastOp::create(
450 rewriter, loc,
451 VectorType::get(nonUnitDimAcc.front(), accTy.getElementType()),
452 contractOp.getAcc());
453
454 auto loadBcstBF16ElementToF32 = x86::avx::BcstToPackedF32Op::create(
455 rewriter, loc, dstType, unitDimSubview[0]);
456 auto loadEvenIdxElementF32 =
457 x86::avx::CvtPackedEvenIndexedToF32Op::create(rewriter, loc, dstType,
458 nonUnitDimSubview[0]);
459 auto evenIdxFMA =
460 vector::FMAOp::create(rewriter, loc, loadBcstBF16ElementToF32,
461 loadEvenIdxElementF32, castAcc);
462 auto castEvenFma =
463 vector::ShapeCastOp::create(rewriter, loc, accTy, evenIdxFMA);
464 rewriter.replaceOp(contractOp, castEvenFma);
465
466 rewriter.setInsertionPoint(pairContractOp);
467 auto pairContOpLoc = pairContractOp.getLoc();
468 VectorType accTyPairCont =
469 dyn_cast<VectorType>(pairContractOp.getAccType());
470 auto castAccPairCont = vector::ShapeCastOp::create(
471 rewriter, pairContOpLoc,
472 VectorType::get(nonUnitDimAcc.front(),
473 accTyPairCont.getElementType()),
474 pairContractOp.getAcc());
475
476 auto loadOddIdxElementF32 = x86::avx::CvtPackedOddIndexedToF32Op::create(
477 rewriter, pairContOpLoc, dstType, nonUnitDimSubview[0]);
478 auto oddIdxFMA = vector::FMAOp::create(
479 rewriter, pairContOpLoc, loadBcstBF16ElementToF32,
480 loadOddIdxElementF32, castAccPairCont);
481 auto castOddFma = vector::ShapeCastOp::create(rewriter, pairContOpLoc,
482 accTyPairCont, oddIdxFMA);
483 rewriter.replaceOp(pairContractOp, castOddFma);
484
485 return success();
486 }
487
488 // Load, broadcast, and do FMA for odd indexed BF16 elements.
489 auto loadBcstOddIdxElementToF32 = x86::avx::BcstToPackedF32Op::create(
490 rewriter, loc, dstType, unitDimSubview[0]);
491 auto loadOddIdxElementF32 = x86::avx::CvtPackedOddIndexedToF32Op::create(
492 rewriter, loc, dstType, nonUnitDimSubview[0]);
493 auto oddIdxFMA =
494 vector::FMAOp::create(rewriter, loc, loadBcstOddIdxElementToF32,
495 loadOddIdxElementF32, castAcc);
496
497 // Load, broadcast, and do FMA for even indexed BF16 elements.
498 auto loadBcstEvenIdxElementToF32 = x86::avx::BcstToPackedF32Op::create(
499 rewriter, loc, dstType, unitDimSubview[1]);
500 auto loadEvenIdxElementF32 = x86::avx::CvtPackedEvenIndexedToF32Op::create(
501 rewriter, loc, dstType, nonUnitDimSubview[0]);
502 vector::FMAOp fma =
503 vector::FMAOp::create(rewriter, loc, loadBcstEvenIdxElementToF32,
504 loadEvenIdxElementF32, oddIdxFMA);
505
506 auto castFma = vector::ShapeCastOp::create(rewriter, loc, accTy, fma);
507 rewriter.replaceOp(contractOp, castFma);
508 return success();
509 }
510};
511
return success()
static SmallVector< memref::SubViewOp > getSubviewFromVectorInput(Location loc, PatternRewriter &rewriter, Value prodOp, ArrayRef< int64_t > nonUnitDimShape, bool isUnitDim, bool isVNNI)
static bool validateVectorContractOperands(Value prodOp, bool isVnni)
IntegerAttr getIndexAttr(int64_t value)
Definition Builders.cpp:116
FloatType getF32Type()
Definition Builders.cpp:51
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
Definition Location.h:76
void setInsertionPoint(Block *block, Block::iterator insertPoint)
Set the insertion point to the specified location.
Definition Builders.h:401
Operation is the basic unit of execution within MLIR.
Definition Operation.h:87
bool isBeforeInBlock(Operation *other)
Given an operation 'other' that is within the same parent block, return whether the current operation...
Block * getBlock()
Returns the operation block that contains this operation.
Definition Operation.h:230
A special type of RewriterBase that coordinates the application of a rewrite pattern on the current I...
MLIRContext * getContext() const
RewritePatternSet & add(ConstructorArg &&arg, ConstructorArgs &&...args)
Add an instance of each of the pattern types 'Ts' to the pattern list with the given arguments.
virtual void replaceOp(Operation *op, ValueRange newValues)
Replace the results of the given (original) operation with the specified list of values (replacements...
std::enable_if_t<!std::is_convertible< CallbackT, Twine >::value, LogicalResult > notifyMatchFailure(Location loc, CallbackT &&reasonCallback)
Used to notify the listener that the IR failed to be rewritten because of a match failure,...
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Definition Types.h:74
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Definition Value.h:96
Type getType() const
Return the type of this value.
Definition Value.h:105
Operation * getDefiningOp() const
If this value is the result of an operation, return the operation that defines it.
Definition Value.cpp:18
LogicalResult shuffleBeforeWriteLikeOp(PatternRewriter &rewriter, Value contractARes, Value contractBRes, int64_t nonUnitDimAcc, VectorType accTy)
Definition X86Utils.cpp:333
Operation * traceToVectorWriteLikeUserOperation(Value v)
Definition X86Utils.cpp:233
bool isInVnniLayout(Operation *op, llvm::ArrayRef< AffineMap > indexingMaps, std::optional< unsigned > blockingFactor=std::nullopt)
Definition X86Utils.cpp:42
Operation * traceToVectorReadLikeParentOperation(Value v)
Definition X86Utils.cpp:173
LogicalResult shuffleAfterReadLikeOp(PatternRewriter &rewriter, Operation *opA, Operation *opB, vector::ContractionOp contractA, vector::ContractionOp contractB, int64_t nonUnitDimAcc, VectorType accTy)
Definition X86Utils.cpp:283
bool validatePairVectorContract(vector::ContractionOp contractOp, vector::ContractionOp pairContOp, bool rhsHasMultipleNonUnitDims, int64_t nonUnitDimValue)
Definition X86Utils.cpp:391
void populateVectorContractBF16ToFMAPatterns(RewritePatternSet &patterns)
Include the generated interface declarations.
std::optional< int64_t > getConstantIntValue(OpFoldResult ofr)
If ofr is a constant integer or an IntegerAttr, return the integer.
LogicalResult matchAndRewriteAddContractOp(vector::ContractionOp contractOp, PatternRewriter &rewriter) const override
Convenience wrapper for patterns that are only intended for default contractions, i....