MLIR 24.0.0git
VectorContractToPackedTypeDotProduct.cpp
Go to the documentation of this file.
1//===- VectorContractToPackedTypeDotProduct.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
25using namespace mlir;
26using namespace mlir::vector;
27using namespace mlir::x86;
28
29namespace {
30
31// Returns true if the A or B matrix vector is packed (shuffled) to
32// VNNI layout, already.
33static bool isNonUnitDimOperandShuffled(Value nonUnitDimOperand) {
34 if (Operation *defOp = nonUnitDimOperand.getDefiningOp()) {
35 if (isa<vector::ShuffleOp>(defOp))
36 return true;
37
38 if (isa<vector::ShapeCastOp>(defOp)) {
39 Operation *defOpShpCst = defOp->getOperand(0).getDefiningOp();
40 if (isa<vector::ShuffleOp>(defOpShpCst))
41 return true;
42 }
43 }
44
45 return false;
46}
47
48static void rewriteUses(mlir::Value oldVal, mlir::Value newVal,
49 mlir::Operation *targetContract,
50 mlir::PatternRewriter &rewriter) {
51 for (mlir::OpOperand &use : llvm::make_early_inc_range(oldVal.getUses())) {
52 mlir::Operation *user = use.getOwner();
53 if (mlir::isa<mlir::vector::ContractionOp>(user) ||
54 mlir::isa<mlir::scf::ForOp>(user)) {
55 rewriter.modifyOpInPlace(user, [&]() { use.set(newVal); });
56 }
57 }
58}
59
60// Function to convert the flat layout A or B matrix vector<32xbf16>
61// into VNNI packed layout using the vpunpack operations
62static void packNonUnitDimOperandToVNNI(mlir::PatternRewriter &rewriter,
63 mlir::Operation *opA,
64 mlir::Operation *opB,
65 mlir::vector::ContractionOp contractA,
66 mlir::vector::ContractionOp contractB,
67 int64_t nonUnitDimAcc,
68 mlir::VectorType Ty) {
69
70 bool opABeforeopB = opA->isBeforeInBlock(opB);
71
72 if (opABeforeopB)
73 rewriter.moveOpAfter(opB, opA);
74 else
75 rewriter.moveOpAfter(opA, opB);
76
77 mlir::Operation *insertAfter = opABeforeopB ? opB : opA;
78
79 rewriter.setInsertionPointAfter(insertAfter);
80 mlir::Location loc = insertAfter->getLoc();
81
82 auto elemTy = Ty.getElementType();
83 auto flatTy = mlir::VectorType::get(nonUnitDimAcc, elemTy);
84
85 if (elemTy.isSignlessInteger(8))
86 flatTy = mlir::VectorType::get({2, nonUnitDimAcc / 2}, elemTy);
87
88 Value srcBuff;
89 SmallVector<Value> indexVals;
90
91 llvm::TypeSwitch<Operation *>(opA).Case<TransferReadOp, LoadOp>(
92 [&](auto readOp) {
93 srcBuff = readOp.getOperand(0);
94
95 auto indices = readOp.getIndices();
96 indexVals.reserve(indices.size());
97
98 llvm::transform(
99 indices, std::back_inserter(indexVals), [&](OpFoldResult ofr) {
100 return mlir::getValueOrCreateConstantIndexOp(rewriter, loc, ofr);
101 });
102 });
103
104 int64_t srcRank = (dyn_cast<ShapedType>(srcBuff.getType())).getRank();
105 Value padding = ub::PoisonOp::create(rewriter, loc, elemTy);
106 auto map = AffineMap::getMinorIdentityMap(srcRank, flatTy.getRank(),
107 rewriter.getContext());
108 SmallVector<bool> inBounds(flatTy.getRank(), true);
109
110 Value vec1 = vector::TransferReadOp::create(
111 rewriter, loc, flatTy, srcBuff, indexVals, padding, map, inBounds);
112
113 if (elemTy.isSignlessInteger(8))
114 vec1 = vector::ShapeCastOp::create(
115 rewriter, loc, VectorType::get(nonUnitDimAcc, elemTy), vec1);
116
117 unsigned int offset = 1;
118 if (elemTy.isSignlessInteger(8))
119 offset = 2;
120
121 Value cOffset = arith::ConstantIndexOp::create(rewriter, loc, offset);
122 auto nextIndx =
123 arith::AddIOp::create(rewriter, loc, rewriter.getIndexType(), cOffset,
124 indexVals[indexVals.size() - 2]);
125 indexVals[indexVals.size() - 2] = nextIndx;
126
127 Value vec2 = vector::TransferReadOp::create(
128 rewriter, loc, flatTy, srcBuff, indexVals, padding, map, inBounds);
129
130 if (elemTy.isSignlessInteger(8))
131 vec2 = vector::ShapeCastOp::create(
132 rewriter, loc, VectorType::get(nonUnitDimAcc, elemTy), vec2);
133
134 flatTy = mlir::VectorType::get(nonUnitDimAcc, elemTy);
135
136 static constexpr int64_t maskLo_bf16[] = {
137 0, 32, 1, 33, 2, 34, 3, 35, 8, 40, 9, 41, 10, 42, 11, 43,
138 16, 48, 17, 49, 18, 50, 19, 51, 24, 56, 25, 57, 26, 58, 27, 59};
139 static constexpr int64_t maskHi_bf16[] = {
140 4, 36, 5, 37, 6, 38, 7, 39, 12, 44, 13, 45, 14, 46, 15, 47,
141 20, 52, 21, 53, 22, 54, 23, 55, 28, 60, 29, 61, 30, 62, 31, 63};
142
143 static constexpr int64_t maskLo_int8_avx2[] = {
144 0, 16, 32, 48, 1, 17, 33, 49, 2, 18, 34, 50, 3, 19, 35, 51,
145 8, 24, 40, 56, 9, 25, 41, 57, 10, 26, 42, 58, 11, 27, 43, 59};
146 static constexpr int64_t maskHi_int8_avx2[] = {
147 4, 20, 36, 52, 5, 21, 37, 53, 6, 22, 38, 54, 7, 23, 39, 55,
148 12, 28, 44, 60, 13, 29, 45, 61, 14, 30, 46, 62, 15, 31, 47, 63};
149
150 static constexpr int64_t maskLo_int8_avx10[] = {
151 0, 32, 64, 96, 1, 33, 65, 97, 2, 34, 66, 98, 3, 35, 67, 99,
152 8, 40, 72, 104, 9, 41, 73, 105, 10, 42, 74, 106, 11, 43, 75, 107,
153 16, 48, 80, 112, 17, 49, 81, 113, 18, 50, 82, 114, 19, 51, 83, 115,
154 24, 56, 88, 120, 25, 57, 89, 121, 26, 58, 90, 122, 27, 59, 91, 123};
155 static constexpr int64_t maskHi_int8_avx10[] = {
156 4, 36, 68, 100, 5, 37, 69, 101, 6, 38, 70, 102, 7, 39, 71, 103,
157 12, 44, 76, 108, 13, 45, 77, 109, 14, 46, 78, 110, 15, 47, 79, 111,
158 20, 52, 84, 116, 21, 53, 85, 117, 22, 54, 86, 118, 23, 55, 87, 119,
159 28, 60, 92, 124, 29, 61, 93, 125, 30, 62, 94, 126, 31, 63, 95, 127};
160
161 mlir::DenseI64ArrayAttr maskLo = rewriter.getDenseI64ArrayAttr(maskLo_bf16);
162 mlir::DenseI64ArrayAttr maskHi = rewriter.getDenseI64ArrayAttr(maskHi_bf16);
163
164 if (elemTy.isSignlessInteger(8)) {
165 maskLo = rewriter.getDenseI64ArrayAttr(maskLo_int8_avx10);
166 maskHi = rewriter.getDenseI64ArrayAttr(maskHi_int8_avx10);
167
168 if (nonUnitDimAcc == 32) {
169 maskLo = rewriter.getDenseI64ArrayAttr(maskLo_int8_avx2);
170 maskHi = rewriter.getDenseI64ArrayAttr(maskHi_int8_avx2);
171 }
172 }
173
174 auto shuffleLo = mlir::vector::ShuffleOp::create(rewriter, loc, flatTy, vec1,
175 vec2, maskLo);
176 auto shuffleHi = mlir::vector::ShuffleOp::create(rewriter, loc, flatTy, vec1,
177 vec2, maskHi);
178
179 auto newA = mlir::vector::ShapeCastOp::create(rewriter, loc, Ty, shuffleLo);
180 auto newB = mlir::vector::ShapeCastOp::create(rewriter, loc, Ty, shuffleHi);
181
182 rewriteUses(opA->getResult(0), newA.getResult(), contractA, rewriter);
183 rewriteUses(opB->getResult(0), newB.getResult(), contractB, rewriter);
184}
185
186// Implements packed type outer product contraction as a sequence
187// of broadcast and packed dot-product operations.
188//
189// For example - for bf16 type (VNNI):
190// ```
191// vector.contract <1x1x2xbf16>, <1x16x2xbf16> into <1x16xf32>
192// ```
193// to
194// ```
195// vector.broadcast %lhs to <32xbf16>
196// x86.avx512.dot vector<32xbf16> -> vector<16xf32>
197// ```
198//
199// For example - for bf16 type (Flat layout):
200// ```
201// %1 = vector.load -> <2x16xbf16>
202// %2 = vector.load -> <2x16xbf16>
203// vector.contract <1x2xbf16>, %1 into <1x16xf32>
204// vector.contract <1x2xbf16>, %2 into <1x16xf32>
205// ```
206// to
207// ```
208// %1 = vector.load -> <2x16xbf16>
209// %2 = vector.load -> <2x16xbf16>
210// %3 = vector.shuffle %1, %2 [0, 32, 1, ... 27, 59]
211// %4 = vector.shuffle %1, %2 [4, 36, 5, ... 31, 63]
212// vector.broadcast %lhs to <32xbf16>
213// x86.avx512.dot vector<32xbf16>, %3 -> vector<16xf32>
214// vector.broadcast %lhs to <32xbf16>
215// x86.avx512.dot vector<32xbf16>, %3 -> vector<16xf32>
216// ```
217struct VectorContractToPackedTypeDotProduct
219 using Base::Base;
220
221 LogicalResult
222 matchAndRewriteAddContractOp(vector::ContractionOp contractOp,
223 PatternRewriter &rewriter) const override {
224
225 VectorType lhsTy = contractOp.getLhsType();
226 if (!lhsTy.getElementType().isBF16() &&
227 !lhsTy.getElementType().isSignlessInteger(8))
228 return rewriter.notifyMatchFailure(
229 contractOp, "Only BF16/Int8 lowering is supported.");
230
231 unsigned int blockingFactor = lhsTy.getElementType().isBF16() ? 2 : 4;
232 bool isVnni =
233 isInVnniLayout(contractOp.getOperation(),
234 contractOp.getIndexingMapsArray(), blockingFactor);
235
236 VectorType accTy = dyn_cast<VectorType>(contractOp.getAccType());
237 if (!accTy)
238 return rewriter.notifyMatchFailure(contractOp, "Wrong accmulator type.");
239
240 ArrayRef<int64_t> accShape = accTy.getShape();
241 llvm::SmallVector<int64_t> nonUnitDimAcc;
242 llvm::copy_if(accShape, std::back_inserter(nonUnitDimAcc),
243 [](int64_t dim) { return dim != 1; });
244 if (nonUnitDimAcc.size() != 1)
245 return rewriter.notifyMatchFailure(
246 contractOp, "A or B should be a non-unit dim in acc.");
247
248 int64_t nonUnitDimValue = nonUnitDimAcc.front();
249 // Non-unit dimensions should match the vector length of BF16 or Int8
250 // dot-product.
251 if (lhsTy.getElementType().isBF16() && nonUnitDimValue != 4 &&
252 nonUnitDimValue != 8 && nonUnitDimValue != 16)
253 return rewriter.notifyMatchFailure(
254 contractOp, "BF16 dot-product operation expects non-unit (LHR or "
255 "RHS) dim and acc dim of size 4/8/16.");
256
257 if (lhsTy.getElementType().isSignlessInteger(8) && nonUnitDimValue != 4 &&
258 nonUnitDimValue != 8 && nonUnitDimValue != 16 &&
259 nonUnitDimAcc.front() == nonUnitDimValue)
260 return rewriter.notifyMatchFailure(
261 contractOp, "Int8 dot-product operation expects non-unit (LHR or "
262 "RHS) dim and acc dim of size 4/8/16.");
263
264 ArrayRef<int64_t> lhsShape = lhsTy.getShape();
265 llvm::SmallVector<int64_t> nonUnitDimLhs;
266 llvm::copy_if(lhsShape, std::back_inserter(nonUnitDimLhs),
267 [](int64_t dim) { return dim != 1; });
268
269 VectorType rhsTy = contractOp.getRhsType();
270 ArrayRef<int64_t> rhsShape = rhsTy.getShape();
271 llvm::SmallVector<int64_t> nonUnitDimRhs;
272 llvm::copy_if(rhsShape, std::back_inserter(nonUnitDimRhs),
273 [](int64_t dim) { return dim != 1; });
274
275 if ((nonUnitDimLhs.size() - 1) > 0 && (nonUnitDimRhs.size() - 1) > 0)
276 return rewriter.notifyMatchFailure(contractOp,
277 "Excepts unit dimensions for either "
278 "LHS or RHS shape.");
279
280 if ((nonUnitDimLhs.size() - 1) != 1 && (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 bool rhsHasMultipleNonUnitDims = (nonUnitDimRhs.size() - 1) > 0;
286 int64_t extraFlatDim = rhsHasMultipleNonUnitDims ? nonUnitDimLhs.front()
287 : nonUnitDimRhs.front();
288
289 if (!isVnni && (extraFlatDim != blockingFactor))
290 return rewriter.notifyMatchFailure(
291 contractOp, "The K or reduction dim for flat layout should be 2/4.");
292
293 if ((lhsTy.getElementType().isBF16() && !accTy.getElementType().isF32()) ||
294 (lhsTy.getElementType().isSignlessInteger(8) &&
295 !accTy.getElementType().isSignlessInteger(32)))
296 return rewriter.notifyMatchFailure(contractOp,
297 "Only F32 for BF16 or Int32 for Int8 "
298 "accumulation type is supported.");
299
300 Value unitDimOperand =
301 rhsHasMultipleNonUnitDims ? contractOp.getLhs() : contractOp.getRhs();
302 Value nonUnitDimOperand =
303 rhsHasMultipleNonUnitDims ? contractOp.getRhs() : contractOp.getLhs();
304
305 // If the A or B matrix vector of the contact operation is not packed, then
306 // find it's pair contract operation and pack (shuffle) them to VNNI packed.
307 if (!isVnni) {
308 vector::ContractionOp pairContractOp;
309 Operation *nextOp = contractOp;
310 while ((nextOp = nextOp->getNextNode())) {
311 auto contOp = dyn_cast<vector::ContractionOp>(nextOp);
312
313 if (!contOp)
314 continue;
315
316 if (validatePairVectorContract(contractOp, contOp,
317 rhsHasMultipleNonUnitDims,
318 nonUnitDimValue)) {
319 pairContractOp = contOp;
320 break;
321 }
322 }
323
324 // If the accumulators are shuffled we get nullptr else the
325 // transfer_load or store operations.
326 Operation *accWrite =
327 traceToVectorWriteLikeUserOperation(contractOp.getResult());
328
329 if (!pairContractOp &&
330 (!isNonUnitDimOperandShuffled(nonUnitDimOperand) || accWrite))
331 return rewriter.notifyMatchFailure(contractOp,
332 "Could not find a contract pair");
333
334 // Validate and shuffle the accumulator
335 if (accWrite) {
336 // Trace back to the load or transfer_read operations of the contract
337 // accumulators.
338 Operation *accReadOp0 =
339 traceToVectorReadLikeParentOperation(contractOp.getAcc());
340 Operation *accReadOp1 =
341 traceToVectorReadLikeParentOperation(pairContractOp.getAcc());
342
343 // Iterate down to find the users of contact operations until it is
344 // store or transfer_write.
345 Operation *resultWriteOp0 =
346 traceToVectorWriteLikeUserOperation(contractOp.getResult());
347 Operation *resultWriteOp1 =
348 traceToVectorWriteLikeUserOperation(pairContractOp.getResult());
349
350 if (!accReadOp0 || !accReadOp1)
351 return rewriter.notifyMatchFailure(
352 contractOp, "Operands doesn't have load or transfer_read or "
353 "dense constant attribute as its parent op");
354
355 if (!resultWriteOp0 || !resultWriteOp1)
356 return rewriter.notifyMatchFailure(
357 contractOp,
358 "The use of contract operations are neither vector.store "
359 "or transfer_write or has multiple users.");
360
361 if (contractOp->getBlock() == accReadOp1->getBlock() &&
362 contractOp->isBeforeInBlock(accReadOp1))
363 return rewriter.notifyMatchFailure(
364 contractOp,
365 "The load/read operation of pair contract operation is "
366 "after the contractOp");
367
368 if (pairContractOp->getBlock() == resultWriteOp0->getBlock() &&
369 resultWriteOp0->isBeforeInBlock(pairContractOp))
370 return rewriter.notifyMatchFailure(
371 contractOp, "The store/write operation of contract operation is "
372 "before the pair contract operation");
373
374 if (!isa<arith::ConstantOp>(accReadOp0)) {
375 // Shuffle the accumulators of the contract operations.
376 LogicalResult readShuffle = shuffleAfterReadLikeOp(
377 rewriter, accReadOp0, accReadOp1, contractOp, pairContractOp,
378 nonUnitDimValue, accTy);
379
380 if (failed(readShuffle))
381 return rewriter.notifyMatchFailure(
382 contractOp, "Accumulator read is not by transfer_read or load");
383 }
384
385 // Shuffle the output of contract operations before it's use.
386 LogicalResult writeShuffle = shuffleBeforeWriteLikeOp(
387 rewriter, contractOp.getResult(), pairContractOp.getResult(),
388 nonUnitDimValue, accTy);
389
390 if (failed(writeShuffle))
391 return rewriter.notifyMatchFailure(
392 contractOp,
393 "Write to accumulator is not by transfer_write or store");
394 }
395
396 if (!isNonUnitDimOperandShuffled(nonUnitDimOperand)) {
397 Value nonUnitDimOperandPairContract = rhsHasMultipleNonUnitDims
398 ? pairContractOp.getRhs()
399 : pairContractOp.getLhs();
400
401 // Get the non-packed A or B matrix's vector<32xbf16> elements.
402 Operation *nonUnitDimReadOp =
403 traceToVectorReadLikeParentOperation(nonUnitDimOperand);
404 Operation *nonUnitDimReadOpPairContract =
405 traceToVectorReadLikeParentOperation(nonUnitDimOperandPairContract);
406
407 if (!nonUnitDimReadOp || !nonUnitDimReadOpPairContract)
408 return rewriter.notifyMatchFailure(
409 contractOp, "Could not find a valid contract pair");
410
411 VectorType nonUnitDimTy = rhsHasMultipleNonUnitDims
412 ? contractOp.getRhsType()
413 : contractOp.getLhsType();
414
415 packNonUnitDimOperandToVNNI(
416 rewriter, nonUnitDimReadOp, nonUnitDimReadOpPairContract,
417 contractOp, pairContractOp, blockingFactor * nonUnitDimValue,
418 nonUnitDimTy);
419
420 nonUnitDimOperand = rhsHasMultipleNonUnitDims ? contractOp.getRhs()
421 : contractOp.getLhs();
422 }
423 }
424
425 rewriter.setInsertionPoint(contractOp);
426 auto loc = contractOp.getLoc();
427 auto castAcc = vector::ShapeCastOp::create(
428 rewriter, loc,
429 VectorType::get(nonUnitDimAcc.front(), accTy.getElementType()),
430 contractOp.getAcc());
431
432 VectorType nonUnitDimTy = rhsHasMultipleNonUnitDims
433 ? contractOp.getRhsType()
434 : contractOp.getLhsType();
435 VectorType unitDimTy = rhsHasMultipleNonUnitDims ? contractOp.getLhsType()
436 : contractOp.getRhsType();
437
438 Value dp;
439
440 auto castNonUnitDim = vector::ShapeCastOp::create(
441 rewriter, loc,
442 VectorType::get(blockingFactor * nonUnitDimValue,
443 nonUnitDimTy.getElementType()),
444 nonUnitDimOperand);
445
446 auto castUnitDim = vector::ShapeCastOp::create(
447 rewriter, loc,
448 VectorType::get(blockingFactor, unitDimTy.getElementType()),
449 unitDimOperand);
450 auto bitcastUnitDim = vector::BitCastOp::create(
451 rewriter, loc, VectorType::get({1}, rewriter.getIntegerType(32)),
452 castUnitDim);
453 auto broadcastUnitDim = vector::BroadcastOp::create(
454 rewriter, loc,
455 VectorType::get({nonUnitDimValue}, rewriter.getIntegerType(32)),
456 bitcastUnitDim);
457 auto bitcastUnitDimPkType = vector::BitCastOp::create(
458 rewriter, loc, castNonUnitDim.getResult().getType(), broadcastUnitDim);
459
460 if (lhsTy.getElementType().isBF16()) {
461 dp = x86::avx512::DotBF16Op::create(
462 rewriter, loc,
463 VectorType::get(nonUnitDimValue, rewriter.getF32Type()), castAcc,
464 bitcastUnitDimPkType, castNonUnitDim);
465 }
466
467 if (lhsTy.getElementType().isSignlessInteger(8)) {
468 if (nonUnitDimAcc.front() == 16) {
469 dp = x86::avx10::AVX10DotInt8Op::create(
470 rewriter, loc,
471 VectorType::get(nonUnitDimValue, rewriter.getIntegerType(32)),
472 castAcc, bitcastUnitDimPkType, castNonUnitDim);
473 } else {
474 dp = x86::avx::DotInt8Op::create(
475 rewriter, loc,
476 VectorType::get(nonUnitDimValue, rewriter.getIntegerType(32)),
477 castAcc, bitcastUnitDimPkType, castNonUnitDim);
478 }
479 }
480
481 if (!dp)
482 return failure();
483
484 auto castDp = vector::ShapeCastOp::create(rewriter, loc, accTy, dp);
485 rewriter.replaceOp(contractOp, castDp);
486 return success();
487 }
488};
489} // namespace
490
492 RewritePatternSet &patterns) {
493 patterns.add<VectorContractToPackedTypeDotProduct>(patterns.getContext());
494}
return success()
static AffineMap getMinorIdentityMap(unsigned dims, unsigned results, MLIRContext *context)
Returns an identity affine map (d0, ..., dn) -> (dp, ..., dn) on the most minor dimensions.
FloatType getF32Type()
Definition Builders.cpp:51
DenseI64ArrayAttr getDenseI64ArrayAttr(ArrayRef< int64_t > values)
Definition Builders.cpp:175
IntegerType getIntegerType(unsigned width)
Definition Builders.cpp:75
MLIRContext * getContext() const
Definition Builders.h:56
IndexType getIndexType()
Definition Builders.cpp:59
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
void setInsertionPointAfter(Operation *op)
Sets the insertion point to the node after the specified operation, which will cause subsequent inser...
Definition Builders.h:415
This class represents a single result from folding an operation.
This class represents an operand of an operation.
Definition Value.h:256
Operation is the basic unit of execution within MLIR.
Definition Operation.h:87
Value getOperand(unsigned idx)
Definition Operation.h:377
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
OpResult getResult(unsigned idx)
Get the 'idx'th result of this operation.
Definition Operation.h:434
Location getLoc()
The source location the operation was defined or derived from.
Definition Operation.h:240
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,...
void modifyOpInPlace(Operation *root, CallableT &&callable)
This method is a utility wrapper around an in-place modification of an operation.
void moveOpAfter(Operation *op, Operation *existingOp)
Unlink this operation from its current block and insert it right after existingOp which may be in the...
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Definition Value.h:96
use_range getUses() const
Returns a range of all uses, which is useful for iterating over all uses.
Definition Value.h:188
Operation * getDefiningOp() const
If this value is the result of an operation, return the operation that defines it.
Definition Value.cpp:18
static ConstantIndexOp create(OpBuilder &builder, Location location, int64_t value)
Definition ArithOps.cpp:436
detail::InFlightRemark failed(Location loc, RemarkOpts opts)
Report an optimization remark that failed.
Definition Remarks.h:886
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
void populateVectorContractToPackedTypeDotProductPatterns(RewritePatternSet &patterns)
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
Include the generated interface declarations.
detail::DenseArrayAttrImpl< int64_t > DenseI64ArrayAttr
Value getValueOrCreateConstantIndexOp(OpBuilder &b, Location loc, OpFoldResult ofr)
Converts an OpFoldResult to a Value.
Definition Utils.cpp:114
Convenience wrapper for patterns that are only intended for default contractions, i....