Skip to content

Commit

Permalink
[mlir][Linalg] NFC: Refactor fusion on tensors to enable extending
Browse files Browse the repository at this point in the history
it to fusing different kinds of linalg operations on tensors.

The implementation of fusion on tensor was initially planned for just
GenericOps (and maybe IndexedGenericOps). With addition of
linalg.tensor_reshape, and potentially other such non-structured ops,
refactor the existing implementation to allow easier specification of
fusion between different linalg operations on tensors.

Differential Revision: https://reviews.llvm.org/D78463
  • Loading branch information
MaheshRavishankar committed Apr 23, 2020
1 parent 0d9144a commit d27ab5c
Show file tree
Hide file tree
Showing 2 changed files with 201 additions and 175 deletions.
11 changes: 6 additions & 5 deletions mlir/include/mlir/Dialect/Linalg/Utils/Utils.h
Expand Up @@ -19,6 +19,7 @@ namespace mlir {
class AffineExpr;
class AffineMap;
class OperationFolder;
class PatternRewriter;

namespace linalg {
class LinalgDependenceGraph;
Expand Down Expand Up @@ -71,11 +72,11 @@ Optional<FusionInfo> fuseProducerOf(OpBuilder &b, LinalgOp consumer,
const LinalgDependenceGraph &graph,
OperationFolder *folder = nullptr);

/// Fuse linalg operation on tensors, where the result of the producer is used
/// as the operand of the consumer at position `consumerIdx`.
Optional<LinalgOp> fuseTensorOps(OpBuilder &b, LinalgOp producer,
LinalgOp consumer, unsigned consumerIdx,
OperationFolder *folder = nullptr);
/// Fuse linalg operation on tensors, with the producer of the operand at
/// position `consumerIdx` of the consumer.
Operation *fuseTensorOps(PatternRewriter &rewriter, Operation *consumer,
unsigned consumerIdx,
OperationFolder *folder = nullptr);

/// Returns the linearized list of all view dimensions in a linalgOp. Applying
/// the inverse, concatenated loopToOperandRangeMaps to this list allows the
Expand Down

0 comments on commit d27ab5c

Please sign in to comment.