19 #include "llvm/Support/Debug.h" 
   21 #define DEBUG_TYPE "tensor-swap-slices" 
   27   auto producerOp = dyn_cast<TilingInterface>(producer.
getOwner());
 
   32   if (!llvm::all_of(sliceOp.getMixedStrides(), 
isOneInteger))
 
   35   FailureOr<TilingResult> tiledResult = producerOp.generateResultTileValue(
 
   37       sliceOp.getMixedSizes());
 
   43   llvm::SmallBitVector droppedDims = sliceOp.getDroppedDims();
 
   44   if (droppedDims.any()) {
 
   45     assert(tiledResult->tiledValues.size() == 1 &&
 
   46            "expected only a single tiled result value to replace the extract " 
   52     auto newSliceOp = tensor::ExtractSliceOp::create(
 
   53         builder, sliceOp.getLoc(), sliceOp.
getType(),
 
   54         tiledResult->tiledValues[0], offsets, sliceOp.getMixedSizes(), strides);
 
   55     tiledResult->tiledValues[0] = newSliceOp;
 
   64   if (sliceOps.empty()) {
 
   66         { llvm::dbgs() << 
"expected candidate slices list to be non-empty"; });
 
   69   if (sliceOps.size() != consumerOperands.size()) {
 
   72           << 
"expected as many operands as the number of slices passed";
 
   77       dyn_cast<TilingInterface>(consumerOperands.front()->getOwner());
 
   80   for (
auto *opOperand : consumerOperands.drop_front()) {
 
   81     if (opOperand->getOwner() != consumerOp) {
 
   84             << 
"expected all consumer operands to be from the same operation";
 
   90   auto consumerOperandNums = llvm::map_to_vector(
 
   91       consumerOperands, [](
OpOperand *opOperand) -> 
unsigned {
 
   96   for (
auto sliceOp : sliceOps) {
 
   99     if (!llvm::all_of(sliceOp.getMixedStrides(), 
isOneInteger))
 
  104     allOffsets.emplace_back(std::move(offsets));
 
  105     allSizes.emplace_back(std::move(sizes));
 
  107   FailureOr<TilingResult> tiledResult =
 
  108       consumerOp.getTiledImplementationFromOperandTiles(
 
  109           builder, consumerOperandNums, allOffsets, allSizes);
 
IntegerAttr getIndexAttr(int64_t value)
Ty getType(Args &&...args)
Get or construct an instance of the type Ty with provided arguments.
This class helps build Operations.
This class represents an operand of an operation.
unsigned getOperandNumber()
Return which operand this is in the OpOperand list of the Operation.
This is a value defined by a result of an operation.
Operation * getOwner() const
Returns the operation that owns this result.
unsigned getResultNumber() const
Returns the number of this result.
FailureOr< TilingResult > replaceExtractSliceWithTiledProducer(OpBuilder &builder, tensor::ExtractSliceOp sliceOp, OpResult producerOp)
Method to swap an tensor.extract_slice with its producer when the producer implements the TilingInter...
FailureOr< TilingResult > replaceInsertSlicesWithTiledConsumer(OpBuilder &builder, ArrayRef< tensor::InsertSliceOp > sliceOps, ArrayRef< OpOperand * > consumerOperands)
Method to swap tensor.insert_slices with their consumers when the consumer implements the TilingInter...
Include the generated interface declarations.
bool isOneInteger(OpFoldResult v)
Return true if v is an IntegerAttr with value 1.