• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//===-- Passes.td - Linalg pass definition file ------------*- tablegen -*-===//
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
9#ifndef MLIR_DIALECT_LINALG_PASSES
10#define MLIR_DIALECT_LINALG_PASSES
11
12include "mlir/Pass/PassBase.td"
13
14def ConvertElementwiseToLinalg : FunctionPass<"convert-elementwise-to-linalg"> {
15  let summary = "Convert ElementwiseMappable ops to linalg";
16  let description = [{
17    Convert ops with the `ElementwiseMappable` trait to linalg parallel loops.
18
19    This pass only converts ops that operate on ranked tensors.
20  }];
21  let constructor = "mlir::createConvertElementwiseToLinalgPass()";
22  let dependentDialects = ["linalg::LinalgDialect"];
23}
24
25def LinalgFoldUnitExtentDims : FunctionPass<"linalg-fold-unit-extent-dims"> {
26  let summary = "Remove unit-extent dimension in Linalg ops on tensors";
27  let constructor = "mlir::createLinalgFoldUnitExtentDimsPass()";
28  let options = [
29    Option<"foldOneTripLoopsOnly", "fold-one-trip-loops-only", "bool",
30            /*default=*/"false",
31	    "Only folds the one-trip loops from Linalg ops on tensors "
32	    "(for testing purposes only)">
33  ];
34  let dependentDialects = ["linalg::LinalgDialect"];
35}
36
37def LinalgFusionOfTensorOps : Pass<"linalg-fusion-for-tensor-ops"> {
38  let summary = "Fuse operations on RankedTensorType in linalg dialect";
39  let constructor = "mlir::createLinalgFusionOfTensorOpsPass()";
40  let dependentDialects = ["linalg::LinalgDialect", "AffineDialect"];
41}
42
43def LinalgFoldReshapeOpsByLinearization :
44  Pass<"linalg-fold-reshape-ops-by-linearization"> {
45  let summary = "Fold TensorReshapeOps with generic/indexed generic ops by "
46                "linearization";
47  let constructor = "mlir::createFoldReshapeOpsByLinearizationPass()";
48  let dependentDialects = ["AffineDialect"];
49}
50
51def LinalgLowerToAffineLoops : FunctionPass<"convert-linalg-to-affine-loops"> {
52  let summary = "Lower the operations from the linalg dialect into affine "
53                "loops";
54  let constructor = "mlir::createConvertLinalgToAffineLoopsPass()";
55  let dependentDialects = ["linalg::LinalgDialect", "AffineDialect"];
56}
57
58def LinalgLowerToLoops : FunctionPass<"convert-linalg-to-loops"> {
59  let summary = "Lower the operations from the linalg dialect into loops";
60  let constructor = "mlir::createConvertLinalgToLoopsPass()";
61  let dependentDialects = ["linalg::LinalgDialect", "scf::SCFDialect", "AffineDialect"];
62}
63
64def LinalgBufferize : Pass<"linalg-bufferize", "FuncOp"> {
65  let summary = "Bufferize the linalg dialect";
66  let constructor = "mlir::createLinalgBufferizePass()";
67  let dependentDialects = ["linalg::LinalgDialect", "AffineDialect"];
68}
69
70def LinalgLowerToParallelLoops
71    : FunctionPass<"convert-linalg-to-parallel-loops"> {
72  let summary = "Lower the operations from the linalg dialect into parallel "
73                "loops";
74  let constructor = "mlir::createConvertLinalgToParallelLoopsPass()";
75  let dependentDialects = ["AffineDialect", "linalg::LinalgDialect", "scf::SCFDialect"];
76}
77
78def LinalgPromotion : FunctionPass<"linalg-promote-subviews"> {
79  let summary = "Promote subview ops to local buffers";
80  let constructor = "mlir::createLinalgPromotionPass()";
81  let options = [
82    Option<"dynamicBuffers", "test-promote-dynamic", "bool",
83           /*default=*/"false", "Test generation of dynamic promoted buffers">,
84    Option<"useAlloca", "test-use-alloca", "bool",
85           /*default=*/"false", "Test generation of alloca'ed buffers.">
86  ];
87  let dependentDialects = ["linalg::LinalgDialect"];
88}
89
90def LinalgTiling : FunctionPass<"linalg-tile"> {
91  let summary = "Tile operations in the linalg dialect";
92  let constructor = "mlir::createLinalgTilingPass()";
93  let dependentDialects = [
94    "AffineDialect", "linalg::LinalgDialect", "scf::SCFDialect"
95  ];
96  let options = [
97    ListOption<"tileSizes", "linalg-tile-sizes", "int64_t",
98               "Test generation of dynamic promoted buffers",
99               "llvm::cl::ZeroOrMore, llvm::cl::MiscFlags::CommaSeparated">
100  ];
101}
102
103def LinalgTilingToParallelLoops
104    : FunctionPass<"linalg-tile-to-parallel-loops"> {
105  let summary = "Tile operations in the linalg dialect to parallel loops";
106  let constructor = "mlir::createLinalgTilingToParallelLoopsPass()";
107  let options = [
108    ListOption<"tileSizes", "linalg-tile-sizes", "int64_t",
109               "Test generation of dynamic promoted buffers",
110               "llvm::cl::ZeroOrMore, llvm::cl::MiscFlags::CommaSeparated">
111  ];
112  let dependentDialects = ["AffineDialect", "linalg::LinalgDialect", "scf::SCFDialect"];
113}
114
115def LinalgGeneralization : FunctionPass<"linalg-generalize-named-ops"> {
116  let summary = "Convert named ops into generic ops";
117  let constructor = "mlir::createLinalgGeneralizationPass()";
118  let dependentDialects = ["linalg::LinalgDialect"];
119}
120
121#endif // MLIR_DIALECT_LINALG_PASSES
122