MLIR: lib/Dialect/Tensor/Transforms/SwapExtractSliceWithProducerPatterns.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

20

21 using namespace mlir;

22

24 OpBuilder &builder, tensor::ExtractSliceOp sliceOp, OpResult producer) {

25 auto producerOp = dyn_cast(producer.getOwner());

26 if (!producerOp)

27 return failure();

28

29

30 if (!llvm::all_of(sliceOp.getMixedStrides(), isOneInteger))

31 return failure();

32

33 FailureOr tiledResult = producerOp.generateResultTileValue(

34 builder, producer.getResultNumber(), sliceOp.getMixedOffsets(),

35 sliceOp.getMixedSizes());

36 if (failed(tiledResult))

37 return failure();

38

39 return *tiledResult;

40 }

41

43 OpBuilder &builder, OffsetSizeAndStrideOpInterface sliceOp,

45 auto consumerOp = dyn_cast(consumer.getOwner());

46 if (!consumerOp)

47 return failure();

48

49

50 if (!llvm::all_of(sliceOp.getMixedStrides(), isOneInteger))

51 return failure();

52

53 FailureOr tiledResult =

54 consumerOp.getTiledImplementationFromOperandTile(

55 builder, consumer.getOperandNumber(), sliceOp.getMixedOffsets(),

56 sliceOp.getMixedSizes());

57 if (failed(tiledResult))

58 return failure();

59

60 return *tiledResult;

61 }

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.

Operation * getOwner() const

Return the owner of this operand.

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 > replaceInsertSliceWithTiledConsumer(OpBuilder &builder, OffsetSizeAndStrideOpInterface sliceOp, OpOperand &consumerOp)

Method to swap an tensor.insert_slice with its consumer when the consumer implements the TilingInterf...

Include the generated interface declarations.

bool isOneInteger(OpFoldResult v)

Return true if v is an IntegerAttr with value 1.