15 using namespace affine;
21 const llvm::SmallBitVector &droppedProducerDims,
28 combinedOffsets.resize(producerOffsets.size());
29 combinedSizes.resize(producerOffsets.size());
30 combinedStrides.resize(producerOffsets.size());
35 unsigned consumerPos = 0;
36 for (
auto i : llvm::seq<unsigned>(0, producerOffsets.size())) {
37 if (droppedProducerDims.test(i)) {
39 combinedOffsets[i] = producerOffsets[i];
40 combinedSizes[i] = producerSizes[i];
41 combinedStrides[i] = producerStrides[i];
48 builder, loc, s0 * s1 + s2,
49 {consumerOffsets[consumerPos], producerStrides[i], producerOffsets[i]});
50 combinedSizes[i] = consumerSizes[consumerPos];
54 builder, loc, s0 * s1,
55 {consumerStrides[consumerPos], producerStrides[i]});
64 OffsetSizeAndStrideOpInterface consumer,
65 const llvm::SmallBitVector &droppedProducerDims,
76 builder, loc, producerOffsets, producerSizes, producerStrides,
77 droppedProducerDims, consumerOffsets, consumerSizes, consumerStrides,
78 combinedOffsets, combinedSizes, combinedStrides);
85 const llvm::SmallBitVector &rankReducedDims,
91 int64_t indicesDim = 0;
93 for (
auto dim : llvm::seq<int64_t>(0, mixedSourceOffsets.size())) {
95 (rankReducedDims.test(dim)) ? zero : consumerIndices[indicesDim++];
96 indices.push_back(ofr);
99 resolvedIndices.resize(indices.size());
100 resolvedIndices.clear();
101 for (
auto [offset, index, stride] :
102 llvm::zip_equal(mixedSourceOffsets, indices, mixedSourceStrides)) {
107 {offset, index, stride});
108 resolvedIndices.push_back(
115 const llvm::SmallBitVector &rankReducedSourceDims,
118 int64_t srcRank = sourceSizes.size();
119 for (int64_t srcDim = 0; srcDim < srcRank; ++srcDim) {
120 if (rankReducedSourceDims[srcDim]) {
121 resolvedSizes.push_back(sourceSizes[srcDim]);
124 resolvedSizes.push_back(destSizes[dim++]);
Base type for affine expression.
static AffineMap get(MLIRContext *context)
Returns a zero result affine map with no dimensions or symbols: () -> ().
IntegerAttr getIndexAttr(int64_t value)
MLIRContext * getContext() const
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
This class helps build Operations.
This class represents a single result from folding an operation.
This class coordinates the application of a rewrite on a set of IR, providing a way for clients to tr...
void resolveSizesIntoOpWithSizes(ArrayRef< OpFoldResult > sourceSizes, ArrayRef< OpFoldResult > destSizes, const llvm::SmallBitVector &rankReducedSourceDims, SmallVectorImpl< OpFoldResult > &resolvedSizes)
Given sourceSizes, destSizes and information about which dimensions are dropped by the source: rankRe...
void resolveIndicesIntoOpWithOffsetsAndStrides(RewriterBase &rewriter, Location loc, ArrayRef< OpFoldResult > mixedSourceOffsets, ArrayRef< OpFoldResult > mixedSourceStrides, const llvm::SmallBitVector &rankReducedDims, ArrayRef< OpFoldResult > consumerIndices, SmallVectorImpl< Value > &resolvedIndices)
Given the 'consumerIndices' of a load/store operation operating on an op with offsets and strides,...
OpFoldResult makeComposedFoldedAffineApply(OpBuilder &b, Location loc, AffineMap map, ArrayRef< OpFoldResult > operands)
Constructs an AffineApplyOp that applies map to operands after composing the map with the maps of any...
LogicalResult mergeOffsetsSizesAndStrides(OpBuilder &builder, Location loc, ArrayRef< OpFoldResult > producerOffsets, ArrayRef< OpFoldResult > producerSizes, ArrayRef< OpFoldResult > producerStrides, const llvm::SmallBitVector &droppedProducerDims, ArrayRef< OpFoldResult > consumerOffsets, ArrayRef< OpFoldResult > consumerSizes, ArrayRef< OpFoldResult > consumerStrides, SmallVector< OpFoldResult > &combinedOffsets, SmallVector< OpFoldResult > &combinedSizes, SmallVector< OpFoldResult > &combinedStrides)
Fills the combinedOffsets, combinedSizes and combinedStrides to use when combining a producer slice i...
Include the generated interface declarations.
void bindSymbols(MLIRContext *ctx, AffineExprTy &...exprs)
Bind a list of AffineExpr references to SymbolExpr at positions: [0 .
Value getValueOrCreateConstantIndexOp(OpBuilder &b, Location loc, OpFoldResult ofr)
Converts an OpFoldResult to a Value.