jasonfan commited on
Commit
64126b1
·
verified ·
1 Parent(s): 99c70c0

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/DeviceMappingAttributes.cpp.inc +8 -0
  2. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/DeviceMappingAttributes.h.inc +19 -0
  3. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/DeviceMappingInterface.h +22 -0
  4. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/SCF.h +112 -0
  5. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/SCFOps.cpp.inc +0 -0
  6. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/SCFOps.h.inc +1885 -0
  7. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/SCFOpsDialect.cpp.inc +25 -0
  8. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/SCFOpsDialect.h.inc +26 -0
  9. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/ValueBoundsOpInterfaceImpl.h +20 -0
  10. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/BufferDeallocationOpInterfaceImpl.h +22 -0
  11. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.h +20 -0
  12. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/Passes.h +75 -0
  13. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/Passes.h.inc +1304 -0
  14. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/Patterns.h +85 -0
  15. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/TileUsingInterface.h +246 -0
  16. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/Transforms.h +172 -0
  17. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Utils/AffineCanonicalizationUtils.h +85 -0
  18. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Utils/Utils.h +167 -0
  19. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/Analysis/ShapeMappingAnalysis.h +60 -0
  20. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/Shape.h +56 -0
  21. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeCanonicalization.inc +384 -0
  22. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.cpp.inc +0 -0
  23. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.h.inc +0 -0
  24. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOpsDialect.cpp.inc +27 -0
  25. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOpsDialect.h.inc +45 -0
  26. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOpsTypes.cpp.inc +113 -0
  27. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOpsTypes.h.inc +63 -0
  28. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/Transforms/BufferizableOpInterfaceImpl.h +20 -0
  29. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/Transforms/Passes.h +71 -0
  30. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/Transforms/Passes.h.inc +520 -0
  31. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/Enums.h +451 -0
  32. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensor.h +197 -0
  33. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.cpp.inc +386 -0
  34. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.h.inc +238 -0
  35. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrEnums.cpp.inc +81 -0
  36. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrEnums.h.inc +177 -0
  37. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.cpp.inc +0 -0
  38. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.h.inc +0 -0
  39. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOpsDialect.cpp.inc +23 -0
  40. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOpsDialect.h.inc +41 -0
  41. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorStorageLayout.h +183 -0
  42. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorType.h +325 -0
  43. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorTypes.cpp.inc +141 -0
  44. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorTypes.h.inc +43 -0
  45. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Transforms/BufferizableOpInterfaceImpl.h +20 -0
  46. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.capi.cpp.inc +96 -0
  47. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.capi.h.inc +72 -0
  48. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.h +253 -0
  49. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.h.inc +1758 -0
  50. miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Utils/Merger.h +744 -0
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/DeviceMappingAttributes.cpp.inc ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2
+ |* *|
3
+ |* AttrDef Definitions *|
4
+ |* *|
5
+ |* Automatically generated file, do not edit! *|
6
+ |* *|
7
+ \*===----------------------------------------------------------------------===*/
8
+
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/DeviceMappingAttributes.h.inc ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2
+ |* *|
3
+ |* AttrDef Declarations *|
4
+ |* *|
5
+ |* Automatically generated file, do not edit! *|
6
+ |* *|
7
+ \*===----------------------------------------------------------------------===*/
8
+
9
+ #ifdef GET_ATTRDEF_CLASSES
10
+ #undef GET_ATTRDEF_CLASSES
11
+
12
+
13
+ namespace mlir {
14
+ class AsmParser;
15
+ class AsmPrinter;
16
+ } // namespace mlir
17
+
18
+ #endif // GET_ATTRDEF_CLASSES
19
+
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/DeviceMappingInterface.h ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //===- DeviceMappingInterface.h - -------------------------------*- C++ -*-===//
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
+ // This file contains the definitions of the device mapping interface defined in
10
+ // `DeviceMappingInterface.td`.
11
+ //
12
+ //===----------------------------------------------------------------------===//
13
+
14
+ #ifndef MLIR_DEVICEMAPPINGINTERFACE_H
15
+ #define MLIR_DEVICEMAPPINGINTERFACE_H
16
+
17
+ #include "mlir/IR/OpDefinition.h"
18
+
19
+ /// Include the generated interface declarations.
20
+ #include "mlir/Dialect/SCF/IR/DeviceMappingAttrInterface.h.inc"
21
+
22
+ #endif // MLIR_DEVICEMAPPINGINTERFACE_H
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/SCF.h ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //===- SCFOps.h - Structured Control Flow -----------------------*- C++ -*-===//
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
+ // This file defines structured control flow operations.
10
+ //
11
+ //===----------------------------------------------------------------------===//
12
+
13
+ #ifndef MLIR_DIALECT_SCF_SCF_H
14
+ #define MLIR_DIALECT_SCF_SCF_H
15
+
16
+ #include "mlir/Dialect/Arith/Utils/Utils.h"
17
+ #include "mlir/Dialect/SCF/IR/DeviceMappingInterface.h"
18
+ #include "mlir/IR/Builders.h"
19
+ #include "mlir/IR/BuiltinTypes.h"
20
+ #include "mlir/IR/RegionKindInterface.h"
21
+ #include "mlir/Interfaces/ControlFlowInterfaces.h"
22
+ #include "mlir/Interfaces/DestinationStyleOpInterface.h"
23
+ #include "mlir/Interfaces/InferTypeOpInterface.h"
24
+ #include "mlir/Interfaces/LoopLikeInterface.h"
25
+ #include "mlir/Interfaces/ParallelCombiningOpInterface.h"
26
+ #include "mlir/Interfaces/SideEffectInterfaces.h"
27
+ #include "mlir/Interfaces/ViewLikeInterface.h"
28
+
29
+ namespace mlir {
30
+ namespace scf {
31
+ void buildTerminatedBody(OpBuilder &builder, Location loc);
32
+ } // namespace scf
33
+ } // namespace mlir
34
+
35
+ #include "mlir/Dialect/SCF/IR/SCFOpsDialect.h.inc"
36
+
37
+ #define GET_OP_CLASSES
38
+ #include "mlir/Dialect/SCF/IR/SCFOps.h.inc"
39
+
40
+ namespace mlir {
41
+ namespace scf {
42
+
43
+ // Insert `loop.yield` at the end of the only region's only block if it
44
+ // does not have a terminator already. If a new `loop.yield` is inserted,
45
+ // the location is specified by `loc`. If the region is empty, insert a new
46
+ // block first.
47
+ void ensureLoopTerminator(Region &region, Builder &builder, Location loc);
48
+
49
+ /// Returns the loop parent of an induction variable. If the provided value is
50
+ /// not an induction variable, then return nullptr.
51
+ ForOp getForInductionVarOwner(Value val);
52
+
53
+ /// Returns the parallel loop parent of an induction variable. If the provided
54
+ /// value is not an induction variable, then return nullptr.
55
+ ParallelOp getParallelForInductionVarOwner(Value val);
56
+
57
+ /// Returns the ForallOp parent of an thread index variable.
58
+ /// If the provided value is not a thread index variable, then return nullptr.
59
+ ForallOp getForallOpThreadIndexOwner(Value val);
60
+
61
+ /// Return true if ops a and b (or their ancestors) are in mutually exclusive
62
+ /// regions/blocks of an IfOp.
63
+ // TODO: Consider moving this functionality to RegionBranchOpInterface.
64
+ bool insideMutuallyExclusiveBranches(Operation *a, Operation *b);
65
+
66
+ /// Promotes the loop body of a scf::ForallOp to its containing block.
67
+ void promote(RewriterBase &rewriter, scf::ForallOp forallOp);
68
+
69
+ /// An owning vector of values, handy to return from functions.
70
+ using ValueVector = SmallVector<Value>;
71
+ using LoopVector = SmallVector<scf::ForOp>;
72
+ struct LoopNest {
73
+ LoopVector loops;
74
+ ValueVector results;
75
+ };
76
+
77
+ /// Creates a perfect nest of "for" loops, i.e. all loops but the innermost
78
+ /// contain only another loop and a terminator. The lower, upper bounds and
79
+ /// steps are provided as `lbs`, `ubs` and `steps`, which are expected to be of
80
+ /// the same size. `iterArgs` points to the initial values of the loop iteration
81
+ /// arguments, which will be forwarded through the nest to the innermost loop.
82
+ /// The body of the loop is populated using `bodyBuilder`, which accepts an
83
+ /// ordered list of induction variables of all loops, followed by a list of
84
+ /// iteration arguments of the innermost loop, in the same order as provided to
85
+ /// `iterArgs`. This function is expected to return as many values as
86
+ /// `iterArgs`, of the same type and in the same order, that will be treated as
87
+ /// yielded from the loop body and forwarded back through the loop nest. If the
88
+ /// function is not provided, the loop nest is not expected to have iteration
89
+ /// arguments, the body of the innermost loop will be left empty, containing
90
+ /// only the zero-operand terminator. Returns the LoopNest containing the list
91
+ /// of perfectly nest scf::ForOp build during the call.
92
+ /// If bound arrays are empty, the body builder will be called
93
+ /// once to construct the IR outside of the loop with an empty list of induction
94
+ /// variables.
95
+ LoopNest buildLoopNest(
96
+ OpBuilder &builder, Location loc, ValueRange lbs, ValueRange ubs,
97
+ ValueRange steps, ValueRange iterArgs,
98
+ function_ref<ValueVector(OpBuilder &, Location, ValueRange, ValueRange)>
99
+ bodyBuilder = nullptr);
100
+
101
+ /// A convenience version for building loop nests without iteration arguments
102
+ /// (like for reductions). Does not take the initial value of reductions or
103
+ /// expect the body building functions to return their current value.
104
+ /// The built nested scf::For are captured in `capturedLoops` when non-null.
105
+ LoopNest buildLoopNest(OpBuilder &builder, Location loc, ValueRange lbs,
106
+ ValueRange ubs, ValueRange steps,
107
+ function_ref<void(OpBuilder &, Location, ValueRange)>
108
+ bodyBuilder = nullptr);
109
+
110
+ } // namespace scf
111
+ } // namespace mlir
112
+ #endif // MLIR_DIALECT_SCF_SCF_H
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/SCFOps.cpp.inc ADDED
The diff for this file is too large to render. See raw diff
 
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/SCFOps.h.inc ADDED
@@ -0,0 +1,1885 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2
+ |* *|
3
+ |* Op Declarations *|
4
+ |* *|
5
+ |* Automatically generated file, do not edit! *|
6
+ |* From: SCFOps.td *|
7
+ |* *|
8
+ \*===----------------------------------------------------------------------===*/
9
+
10
+ #if defined(GET_OP_CLASSES) || defined(GET_OP_FWD_DEFINES)
11
+ #undef GET_OP_FWD_DEFINES
12
+ namespace mlir {
13
+ namespace scf {
14
+ class ConditionOp;
15
+ } // namespace scf
16
+ } // namespace mlir
17
+ namespace mlir {
18
+ namespace scf {
19
+ class ExecuteRegionOp;
20
+ } // namespace scf
21
+ } // namespace mlir
22
+ namespace mlir {
23
+ namespace scf {
24
+ class ForOp;
25
+ } // namespace scf
26
+ } // namespace mlir
27
+ namespace mlir {
28
+ namespace scf {
29
+ class ForallOp;
30
+ } // namespace scf
31
+ } // namespace mlir
32
+ namespace mlir {
33
+ namespace scf {
34
+ class IfOp;
35
+ } // namespace scf
36
+ } // namespace mlir
37
+ namespace mlir {
38
+ namespace scf {
39
+ class InParallelOp;
40
+ } // namespace scf
41
+ } // namespace mlir
42
+ namespace mlir {
43
+ namespace scf {
44
+ class IndexSwitchOp;
45
+ } // namespace scf
46
+ } // namespace mlir
47
+ namespace mlir {
48
+ namespace scf {
49
+ class ParallelOp;
50
+ } // namespace scf
51
+ } // namespace mlir
52
+ namespace mlir {
53
+ namespace scf {
54
+ class ReduceOp;
55
+ } // namespace scf
56
+ } // namespace mlir
57
+ namespace mlir {
58
+ namespace scf {
59
+ class ReduceReturnOp;
60
+ } // namespace scf
61
+ } // namespace mlir
62
+ namespace mlir {
63
+ namespace scf {
64
+ class WhileOp;
65
+ } // namespace scf
66
+ } // namespace mlir
67
+ namespace mlir {
68
+ namespace scf {
69
+ class YieldOp;
70
+ } // namespace scf
71
+ } // namespace mlir
72
+ #endif
73
+
74
+ #ifdef GET_OP_CLASSES
75
+ #undef GET_OP_CLASSES
76
+
77
+
78
+ //===----------------------------------------------------------------------===//
79
+ // Local Utility Method Definitions
80
+ //===----------------------------------------------------------------------===//
81
+
82
+ namespace mlir {
83
+ namespace scf {
84
+
85
+ //===----------------------------------------------------------------------===//
86
+ // ::mlir::scf::ConditionOp declarations
87
+ //===----------------------------------------------------------------------===//
88
+
89
+ namespace detail {
90
+ class ConditionOpGenericAdaptorBase {
91
+ public:
92
+ protected:
93
+ ::mlir::DictionaryAttr odsAttrs;
94
+ ::std::optional<::mlir::OperationName> odsOpName;
95
+ ::mlir::RegionRange odsRegions;
96
+ public:
97
+ ConditionOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {});
98
+
99
+ ConditionOpGenericAdaptorBase(ConditionOp op);
100
+
101
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize);
102
+ ::mlir::DictionaryAttr getAttributes();
103
+ };
104
+ } // namespace detail
105
+ template <typename RangeT>
106
+ class ConditionOpGenericAdaptor : public detail::ConditionOpGenericAdaptorBase {
107
+ using ValueT = ::llvm::detail::ValueOfRange<RangeT>;
108
+ using Base = detail::ConditionOpGenericAdaptorBase;
109
+ public:
110
+ ConditionOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {}
111
+
112
+ ConditionOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ConditionOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {}
113
+
114
+ template <typename LateInst = ConditionOp, typename = std::enable_if_t<std::is_same_v<LateInst, ConditionOp>>>
115
+ ConditionOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {}
116
+
117
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index) {
118
+ return Base::getODSOperandIndexAndLength(index, odsOperands.size());
119
+ }
120
+
121
+ RangeT getODSOperands(unsigned index) {
122
+ auto valueRange = getODSOperandIndexAndLength(index);
123
+ return {std::next(odsOperands.begin(), valueRange.first),
124
+ std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
125
+ }
126
+
127
+ ValueT getCondition() {
128
+ return (*getODSOperands(0).begin());
129
+ }
130
+
131
+ RangeT getArgs() {
132
+ return getODSOperands(1);
133
+ }
134
+
135
+ RangeT getOperands() {
136
+ return odsOperands;
137
+ }
138
+
139
+ private:
140
+ RangeT odsOperands;
141
+ };
142
+ class ConditionOpAdaptor : public ConditionOpGenericAdaptor<::mlir::ValueRange> {
143
+ public:
144
+ using ConditionOpGenericAdaptor::ConditionOpGenericAdaptor;
145
+ ConditionOpAdaptor(ConditionOp op);
146
+
147
+ ::mlir::LogicalResult verify(::mlir::Location loc);
148
+ };
149
+ class ConditionOp : public ::mlir::Op<ConditionOp, ::mlir::OpTrait::ZeroRegions, ::mlir::OpTrait::ZeroResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<1>::Impl, ::mlir::OpTrait::HasParent<WhileOp>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::RegionBranchTerminatorOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::IsTerminator> {
150
+ public:
151
+ using Op::Op;
152
+ using Op::print;
153
+ using Adaptor = ConditionOpAdaptor;
154
+ template <typename RangeT>
155
+ using GenericAdaptor = ConditionOpGenericAdaptor<RangeT>;
156
+ using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>;
157
+ static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() {
158
+ return {};
159
+ }
160
+
161
+ static constexpr ::llvm::StringLiteral getOperationName() {
162
+ return ::llvm::StringLiteral("scf.condition");
163
+ }
164
+
165
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index);
166
+ ::mlir::Operation::operand_range getODSOperands(unsigned index);
167
+ ::mlir::TypedValue<::mlir::IntegerType> getCondition();
168
+ ::mlir::Operation::operand_range getArgs();
169
+ ::mlir::OpOperand &getConditionMutable();
170
+ ::mlir::MutableOperandRange getArgsMutable();
171
+ std::pair<unsigned, unsigned> getODSResultIndexAndLength(unsigned index);
172
+ ::mlir::Operation::result_range getODSResults(unsigned index);
173
+ static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value condition, ::mlir::ValueRange args);
174
+ static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value condition, ::mlir::ValueRange args);
175
+ static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {});
176
+ ::mlir::LogicalResult verifyInvariantsImpl();
177
+ ::mlir::LogicalResult verifyInvariants();
178
+ ::mlir::MutableOperandRange getMutableSuccessorOperands(::mlir::RegionBranchPoint point);
179
+ void getSuccessorRegions(::llvm::ArrayRef<::mlir::Attribute> operands, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> &regions);
180
+ static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result);
181
+ void print(::mlir::OpAsmPrinter &_odsPrinter);
182
+ void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects);
183
+ public:
184
+ };
185
+ } // namespace scf
186
+ } // namespace mlir
187
+ MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::ConditionOp)
188
+
189
+ namespace mlir {
190
+ namespace scf {
191
+
192
+ //===----------------------------------------------------------------------===//
193
+ // ::mlir::scf::ExecuteRegionOp declarations
194
+ //===----------------------------------------------------------------------===//
195
+
196
+ namespace detail {
197
+ class ExecuteRegionOpGenericAdaptorBase {
198
+ public:
199
+ protected:
200
+ ::mlir::DictionaryAttr odsAttrs;
201
+ ::std::optional<::mlir::OperationName> odsOpName;
202
+ ::mlir::RegionRange odsRegions;
203
+ public:
204
+ ExecuteRegionOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {});
205
+
206
+ ExecuteRegionOpGenericAdaptorBase(ExecuteRegionOp op);
207
+
208
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize);
209
+ ::mlir::DictionaryAttr getAttributes();
210
+ ::mlir::Region &getRegion();
211
+ ::mlir::RegionRange getRegions();
212
+ };
213
+ } // namespace detail
214
+ template <typename RangeT>
215
+ class ExecuteRegionOpGenericAdaptor : public detail::ExecuteRegionOpGenericAdaptorBase {
216
+ using ValueT = ::llvm::detail::ValueOfRange<RangeT>;
217
+ using Base = detail::ExecuteRegionOpGenericAdaptorBase;
218
+ public:
219
+ ExecuteRegionOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {}
220
+
221
+ ExecuteRegionOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ExecuteRegionOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {}
222
+
223
+ template <typename LateInst = ExecuteRegionOp, typename = std::enable_if_t<std::is_same_v<LateInst, ExecuteRegionOp>>>
224
+ ExecuteRegionOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {}
225
+
226
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index) {
227
+ return Base::getODSOperandIndexAndLength(index, odsOperands.size());
228
+ }
229
+
230
+ RangeT getODSOperands(unsigned index) {
231
+ auto valueRange = getODSOperandIndexAndLength(index);
232
+ return {std::next(odsOperands.begin(), valueRange.first),
233
+ std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
234
+ }
235
+
236
+ RangeT getOperands() {
237
+ return odsOperands;
238
+ }
239
+
240
+ private:
241
+ RangeT odsOperands;
242
+ };
243
+ class ExecuteRegionOpAdaptor : public ExecuteRegionOpGenericAdaptor<::mlir::ValueRange> {
244
+ public:
245
+ using ExecuteRegionOpGenericAdaptor::ExecuteRegionOpGenericAdaptor;
246
+ ExecuteRegionOpAdaptor(ExecuteRegionOp op);
247
+
248
+ ::mlir::LogicalResult verify(::mlir::Location loc);
249
+ };
250
+ class ExecuteRegionOp : public ::mlir::Op<ExecuteRegionOp, ::mlir::OpTrait::OneRegion, ::mlir::OpTrait::VariadicResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::ZeroOperands, ::mlir::OpTrait::OpInvariants, ::mlir::RegionBranchOpInterface::Trait> {
251
+ public:
252
+ using Op::Op;
253
+ using Op::print;
254
+ using Adaptor = ExecuteRegionOpAdaptor;
255
+ template <typename RangeT>
256
+ using GenericAdaptor = ExecuteRegionOpGenericAdaptor<RangeT>;
257
+ using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>;
258
+ static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() {
259
+ return {};
260
+ }
261
+
262
+ static constexpr ::llvm::StringLiteral getOperationName() {
263
+ return ::llvm::StringLiteral("scf.execute_region");
264
+ }
265
+
266
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index);
267
+ ::mlir::Operation::operand_range getODSOperands(unsigned index);
268
+ std::pair<unsigned, unsigned> getODSResultIndexAndLength(unsigned index);
269
+ ::mlir::Operation::result_range getODSResults(unsigned index);
270
+ ::mlir::Region &getRegion();
271
+ static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultType0);
272
+ static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {});
273
+ static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result);
274
+ void print(::mlir::OpAsmPrinter &p);
275
+ ::mlir::LogicalResult verifyInvariantsImpl();
276
+ ::mlir::LogicalResult verifyInvariants();
277
+ ::mlir::LogicalResult verify();
278
+ static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context);
279
+ void getSuccessorRegions(::mlir::RegionBranchPoint point, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> &regions);
280
+ public:
281
+ };
282
+ } // namespace scf
283
+ } // namespace mlir
284
+ MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::ExecuteRegionOp)
285
+
286
+ namespace mlir {
287
+ namespace scf {
288
+
289
+ //===----------------------------------------------------------------------===//
290
+ // ::mlir::scf::ForOp declarations
291
+ //===----------------------------------------------------------------------===//
292
+
293
+ namespace detail {
294
+ class ForOpGenericAdaptorBase {
295
+ public:
296
+ protected:
297
+ ::mlir::DictionaryAttr odsAttrs;
298
+ ::std::optional<::mlir::OperationName> odsOpName;
299
+ ::mlir::RegionRange odsRegions;
300
+ public:
301
+ ForOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {});
302
+
303
+ ForOpGenericAdaptorBase(ForOp op);
304
+
305
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize);
306
+ ::mlir::DictionaryAttr getAttributes();
307
+ ::mlir::Region &getRegion();
308
+ ::mlir::RegionRange getRegions();
309
+ };
310
+ } // namespace detail
311
+ template <typename RangeT>
312
+ class ForOpGenericAdaptor : public detail::ForOpGenericAdaptorBase {
313
+ using ValueT = ::llvm::detail::ValueOfRange<RangeT>;
314
+ using Base = detail::ForOpGenericAdaptorBase;
315
+ public:
316
+ ForOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {}
317
+
318
+ ForOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ForOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {}
319
+
320
+ template <typename LateInst = ForOp, typename = std::enable_if_t<std::is_same_v<LateInst, ForOp>>>
321
+ ForOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {}
322
+
323
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index) {
324
+ return Base::getODSOperandIndexAndLength(index, odsOperands.size());
325
+ }
326
+
327
+ RangeT getODSOperands(unsigned index) {
328
+ auto valueRange = getODSOperandIndexAndLength(index);
329
+ return {std::next(odsOperands.begin(), valueRange.first),
330
+ std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
331
+ }
332
+
333
+ ValueT getLowerBound() {
334
+ return (*getODSOperands(0).begin());
335
+ }
336
+
337
+ ValueT getUpperBound() {
338
+ return (*getODSOperands(1).begin());
339
+ }
340
+
341
+ ValueT getStep() {
342
+ return (*getODSOperands(2).begin());
343
+ }
344
+
345
+ RangeT getInitArgs() {
346
+ return getODSOperands(3);
347
+ }
348
+
349
+ RangeT getOperands() {
350
+ return odsOperands;
351
+ }
352
+
353
+ private:
354
+ RangeT odsOperands;
355
+ };
356
+ class ForOpAdaptor : public ForOpGenericAdaptor<::mlir::ValueRange> {
357
+ public:
358
+ using ForOpGenericAdaptor::ForOpGenericAdaptor;
359
+ ForOpAdaptor(ForOp op);
360
+
361
+ ::mlir::LogicalResult verify(::mlir::Location loc);
362
+ };
363
+ class ForOp : public ::mlir::Op<ForOp, ::mlir::OpTrait::OneRegion, ::mlir::OpTrait::VariadicResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::AtLeastNOperands<3>::Impl, ::mlir::OpTrait::SingleBlock, ::mlir::OpTrait::SingleBlockImplicitTerminator<scf::YieldOp>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::OpTrait::AutomaticAllocationScope, ::mlir::LoopLikeOpInterface::Trait, ::mlir::ConditionallySpeculatable::Trait, ::mlir::RegionBranchOpInterface::Trait, ::mlir::OpTrait::HasRecursiveMemoryEffects> {
364
+ public:
365
+ using Op::Op;
366
+ using Op::print;
367
+ using Adaptor = ForOpAdaptor;
368
+ template <typename RangeT>
369
+ using GenericAdaptor = ForOpGenericAdaptor<RangeT>;
370
+ using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>;
371
+ static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() {
372
+ return {};
373
+ }
374
+
375
+ static constexpr ::llvm::StringLiteral getOperationName() {
376
+ return ::llvm::StringLiteral("scf.for");
377
+ }
378
+
379
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index);
380
+ ::mlir::Operation::operand_range getODSOperands(unsigned index);
381
+ ::mlir::Value getLowerBound();
382
+ ::mlir::Value getUpperBound();
383
+ ::mlir::Value getStep();
384
+ ::mlir::Operation::operand_range getInitArgs();
385
+ ::mlir::OpOperand &getLowerBoundMutable();
386
+ ::mlir::OpOperand &getUpperBoundMutable();
387
+ ::mlir::OpOperand &getStepMutable();
388
+ ::mlir::MutableOperandRange getInitArgsMutable();
389
+ std::pair<unsigned, unsigned> getODSResultIndexAndLength(unsigned index);
390
+ ::mlir::Operation::result_range getODSResults(unsigned index);
391
+ ::mlir::Operation::result_range getResults();
392
+ ::mlir::Region &getRegion();
393
+ static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value lowerBound, Value upperBound, Value step, ValueRange iterArgs = std::nullopt, function_ref<void(OpBuilder &, Location, Value, ValueRange)> odsArg4 = nullptr);
394
+ static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result);
395
+ void print(::mlir::OpAsmPrinter &p);
396
+ ::mlir::LogicalResult verifyInvariantsImpl();
397
+ ::mlir::LogicalResult verifyInvariants();
398
+ ::mlir::LogicalResult verify();
399
+ ::mlir::LogicalResult verifyRegions();
400
+ static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context);
401
+ ::llvm::SmallVector<::mlir::Region *> getLoopRegions();
402
+ ::mlir::LogicalResult promoteIfSingleIteration(::mlir::RewriterBase &rewriter);
403
+ ::std::optional<::mlir::Value> getSingleInductionVar();
404
+ ::std::optional<::mlir::OpFoldResult> getSingleLowerBound();
405
+ ::std::optional<::mlir::OpFoldResult> getSingleStep();
406
+ ::std::optional<::mlir::OpFoldResult> getSingleUpperBound();
407
+ ::mlir::OperandRange getInits();
408
+ ::mlir::FailureOr<::mlir::LoopLikeOpInterface> replaceWithAdditionalYields(::mlir::RewriterBase &rewriter, ::mlir::ValueRange newInitOperands, bool replaceInitOperandUsesInLoop, const ::mlir::NewYieldValuesFn &newYieldValuesFn);
409
+ ::mlir::OperandRange getEntrySuccessorOperands(::mlir::RegionBranchPoint point);
410
+ void getSuccessorRegions(::mlir::RegionBranchPoint point, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> &regions);
411
+ public:
412
+ using BodyBuilderFn =
413
+ function_ref<void(OpBuilder &, Location, Value, ValueRange)>;
414
+
415
+ Value getInductionVar() { return getBody()->getArgument(0); }
416
+ Block::BlockArgListType getRegionIterArgs() {
417
+ return getBody()->getArguments().drop_front(getNumInductionVars());
418
+ }
419
+ /// Return the `index`-th region iteration argument.
420
+ BlockArgument getRegionIterArg(unsigned index) {
421
+ assert(index < getNumRegionIterArgs() &&
422
+ "expected an index less than the number of region iter args");
423
+ return getBody()->getArguments().drop_front(getNumInductionVars())[index];
424
+ }
425
+
426
+ void setLowerBound(Value bound) { getOperation()->setOperand(0, bound); }
427
+ void setUpperBound(Value bound) { getOperation()->setOperand(1, bound); }
428
+ void setStep(Value step) { getOperation()->setOperand(2, step); }
429
+
430
+ /// Number of induction variables, always 1 for scf::ForOp.
431
+ unsigned getNumInductionVars() { return 1; }
432
+ /// Number of region arguments for loop-carried values
433
+ unsigned getNumRegionIterArgs() {
434
+ return getBody()->getNumArguments() - getNumInductionVars();
435
+ }
436
+ /// Number of operands controlling the loop: lb, ub, step
437
+ unsigned getNumControlOperands() { return 3; }
438
+
439
+ /// Get the region iter arg that corresponds to an OpOperand.
440
+ /// This helper prevents internal op implementation detail leakage to
441
+ /// clients by hiding the operand / block argument mapping.
442
+ BlockArgument getRegionIterArgForOpOperand(OpOperand &opOperand) {
443
+ assert(opOperand.getOperandNumber() >= getNumControlOperands() &&
444
+ "expected an iter args operand");
445
+ assert(opOperand.getOwner() == getOperation() &&
446
+ "opOperand does not belong to this scf::ForOp operation");
447
+ return getRegionIterArgs()[
448
+ opOperand.getOperandNumber() - getNumControlOperands()];
449
+ }
450
+ /// Get the OpOperand& that corresponds to a region iter arg.
451
+ /// This helper prevents internal op implementation detail leakage to
452
+ /// clients by hiding the operand / block argument mapping.
453
+ OpOperand &getOpOperandForRegionIterArg(BlockArgument bbArg) {
454
+ assert(bbArg.getArgNumber() >= getNumInductionVars() &&
455
+ "expected a bbArg that is not an induction variable");
456
+ assert(bbArg.getOwner()->getParentOp() == getOperation() &&
457
+ "bbArg does not belong to the scf::ForOp body");
458
+ return getOperation()->getOpOperand(
459
+ getNumControlOperands() + bbArg.getArgNumber() - getNumInductionVars());
460
+ }
461
+ /// Get the OpResult that corresponds to an OpOperand.
462
+ /// Assert that opOperand is an iterArg.
463
+ /// This helper prevents internal op implementation detail leakage to
464
+ /// clients by hiding the operand / block argument mapping.
465
+ OpResult getResultForOpOperand(OpOperand &opOperand) {
466
+ assert(opOperand.getOperandNumber() >= getNumControlOperands() &&
467
+ "expected an iter args operand");
468
+ assert(opOperand.getOwner() == getOperation() &&
469
+ "opOperand does not belong to this scf::ForOp operation");
470
+ return getOperation()->getResult(
471
+ opOperand.getOperandNumber() - getNumControlOperands());
472
+ }
473
+ /// Get the OpOperand& that corresponds to an OpResultOpOperand.
474
+ /// This helper prevents internal op implementation detail leakage to
475
+ /// clients by hiding the operand / block argument mapping.
476
+ OpOperand &getOpOperandForResult(OpResult opResult) {
477
+ assert(opResult.getDefiningOp() == getOperation() &&
478
+ "opResult does not belong to the scf::ForOp operation");
479
+ return getOperation()->getOpOperand(
480
+ getNumControlOperands() + opResult.getResultNumber());
481
+ }
482
+
483
+ /// Returns the step as an `APInt` if it is constant.
484
+ std::optional<APInt> getConstantStep();
485
+
486
+ /// Interface method for ConditionallySpeculatable.
487
+ Speculation::Speculatability getSpeculatability();
488
+ };
489
+ } // namespace scf
490
+ } // namespace mlir
491
+ MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::ForOp)
492
+
493
+ namespace mlir {
494
+ namespace scf {
495
+
496
+ //===----------------------------------------------------------------------===//
497
+ // ::mlir::scf::ForallOp declarations
498
+ //===----------------------------------------------------------------------===//
499
+
500
+ namespace detail {
501
+ class ForallOpGenericAdaptorBase {
502
+ public:
503
+ struct Properties {
504
+ using mappingTy = ::mlir::ArrayAttr;
505
+ mappingTy mapping;
506
+
507
+ auto getMapping() {
508
+ auto &propStorage = this->mapping;
509
+ return ::llvm::dyn_cast_or_null<::mlir::ArrayAttr>(propStorage);
510
+ }
511
+ void setMapping(const ::mlir::ArrayAttr &propValue) {
512
+ this->mapping = propValue;
513
+ }
514
+ using staticLowerBoundTy = ::mlir::DenseI64ArrayAttr;
515
+ staticLowerBoundTy staticLowerBound;
516
+
517
+ auto getStaticLowerBound() {
518
+ auto &propStorage = this->staticLowerBound;
519
+ return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage);
520
+ }
521
+ void setStaticLowerBound(const ::mlir::DenseI64ArrayAttr &propValue) {
522
+ this->staticLowerBound = propValue;
523
+ }
524
+ using staticStepTy = ::mlir::DenseI64ArrayAttr;
525
+ staticStepTy staticStep;
526
+
527
+ auto getStaticStep() {
528
+ auto &propStorage = this->staticStep;
529
+ return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage);
530
+ }
531
+ void setStaticStep(const ::mlir::DenseI64ArrayAttr &propValue) {
532
+ this->staticStep = propValue;
533
+ }
534
+ using staticUpperBoundTy = ::mlir::DenseI64ArrayAttr;
535
+ staticUpperBoundTy staticUpperBound;
536
+
537
+ auto getStaticUpperBound() {
538
+ auto &propStorage = this->staticUpperBound;
539
+ return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage);
540
+ }
541
+ void setStaticUpperBound(const ::mlir::DenseI64ArrayAttr &propValue) {
542
+ this->staticUpperBound = propValue;
543
+ }
544
+ using operandSegmentSizesTy = std::array<int32_t, 4>;
545
+ operandSegmentSizesTy operandSegmentSizes;
546
+ ::llvm::ArrayRef<int32_t> getOperandSegmentSizes() {
547
+ auto &propStorage = this->operandSegmentSizes;
548
+ return propStorage;
549
+ }
550
+ void setOperandSegmentSizes(const ::llvm::ArrayRef<int32_t> &propValue) {
551
+ auto &propStorage = this->operandSegmentSizes;
552
+ ::llvm::copy(propValue, propStorage.begin());
553
+ }
554
+ bool operator==(const Properties &rhs) const {
555
+ return
556
+ rhs.mapping == this->mapping &&
557
+ rhs.staticLowerBound == this->staticLowerBound &&
558
+ rhs.staticStep == this->staticStep &&
559
+ rhs.staticUpperBound == this->staticUpperBound &&
560
+ rhs.operandSegmentSizes == this->operandSegmentSizes &&
561
+ true;
562
+ }
563
+ bool operator!=(const Properties &rhs) const {
564
+ return !(*this == rhs);
565
+ }
566
+ };
567
+ protected:
568
+ ::mlir::DictionaryAttr odsAttrs;
569
+ ::std::optional<::mlir::OperationName> odsOpName;
570
+ Properties properties;
571
+ ::mlir::RegionRange odsRegions;
572
+ public:
573
+ ForallOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties = {}, ::mlir::RegionRange regions = {});
574
+
575
+ ForallOpGenericAdaptorBase(ForallOp op);
576
+
577
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize);
578
+ const Properties &getProperties() {
579
+ return properties;
580
+ }
581
+
582
+ ::mlir::DictionaryAttr getAttributes();
583
+ ::mlir::DenseI64ArrayAttr getStaticLowerBoundAttr();
584
+ ::llvm::ArrayRef<int64_t> getStaticLowerBound();
585
+ ::mlir::DenseI64ArrayAttr getStaticUpperBoundAttr();
586
+ ::llvm::ArrayRef<int64_t> getStaticUpperBound();
587
+ ::mlir::DenseI64ArrayAttr getStaticStepAttr();
588
+ ::llvm::ArrayRef<int64_t> getStaticStep();
589
+ ::mlir::ArrayAttr getMappingAttr();
590
+ ::std::optional< ::mlir::ArrayAttr > getMapping();
591
+ ::mlir::Region &getRegion();
592
+ ::mlir::RegionRange getRegions();
593
+ };
594
+ } // namespace detail
595
+ template <typename RangeT>
596
+ class ForallOpGenericAdaptor : public detail::ForallOpGenericAdaptorBase {
597
+ using ValueT = ::llvm::detail::ValueOfRange<RangeT>;
598
+ using Base = detail::ForallOpGenericAdaptorBase;
599
+ public:
600
+ ForallOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {}
601
+
602
+ ForallOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ForallOpGenericAdaptor(values, attrs, (properties ? *properties.as<Properties *>() : Properties{}), regions) {}
603
+
604
+ template <typename LateInst = ForallOp, typename = std::enable_if_t<std::is_same_v<LateInst, ForallOp>>>
605
+ ForallOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {}
606
+
607
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index) {
608
+ return Base::getODSOperandIndexAndLength(index, odsOperands.size());
609
+ }
610
+
611
+ RangeT getODSOperands(unsigned index) {
612
+ auto valueRange = getODSOperandIndexAndLength(index);
613
+ return {std::next(odsOperands.begin(), valueRange.first),
614
+ std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
615
+ }
616
+
617
+ RangeT getDynamicLowerBound() {
618
+ return getODSOperands(0);
619
+ }
620
+
621
+ RangeT getDynamicUpperBound() {
622
+ return getODSOperands(1);
623
+ }
624
+
625
+ RangeT getDynamicStep() {
626
+ return getODSOperands(2);
627
+ }
628
+
629
+ RangeT getOutputs() {
630
+ return getODSOperands(3);
631
+ }
632
+
633
+ RangeT getOperands() {
634
+ return odsOperands;
635
+ }
636
+
637
+ private:
638
+ RangeT odsOperands;
639
+ };
640
+ class ForallOpAdaptor : public ForallOpGenericAdaptor<::mlir::ValueRange> {
641
+ public:
642
+ using ForallOpGenericAdaptor::ForallOpGenericAdaptor;
643
+ ForallOpAdaptor(ForallOp op);
644
+
645
+ ::mlir::LogicalResult verify(::mlir::Location loc);
646
+ };
647
+ class ForallOp : public ::mlir::Op<ForallOp, ::mlir::OpTrait::OneRegion, ::mlir::OpTrait::VariadicResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::AttrSizedOperandSegments, ::mlir::OpTrait::SingleBlock, ::mlir::OpTrait::SingleBlockImplicitTerminator<scf::InParallelOp>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpTrait::AutomaticAllocationScope, ::mlir::LoopLikeOpInterface::Trait, ::mlir::OpTrait::HasRecursiveMemoryEffects, ::mlir::RegionBranchOpInterface::Trait, ::mlir::DestinationStyleOpInterface::Trait> {
648
+ public:
649
+ using Op::Op;
650
+ using Op::print;
651
+ using Adaptor = ForallOpAdaptor;
652
+ template <typename RangeT>
653
+ using GenericAdaptor = ForallOpGenericAdaptor<RangeT>;
654
+ using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>;
655
+ using Properties = FoldAdaptor::Properties;
656
+ static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() {
657
+ static ::llvm::StringRef attrNames[] = {::llvm::StringRef("mapping"), ::llvm::StringRef("staticLowerBound"), ::llvm::StringRef("staticStep"), ::llvm::StringRef("staticUpperBound"), ::llvm::StringRef("operandSegmentSizes")};
658
+ return ::llvm::ArrayRef(attrNames);
659
+ }
660
+
661
+ ::mlir::StringAttr getMappingAttrName() {
662
+ return getAttributeNameForIndex(0);
663
+ }
664
+
665
+ static ::mlir::StringAttr getMappingAttrName(::mlir::OperationName name) {
666
+ return getAttributeNameForIndex(name, 0);
667
+ }
668
+
669
+ ::mlir::StringAttr getStaticLowerBoundAttrName() {
670
+ return getAttributeNameForIndex(1);
671
+ }
672
+
673
+ static ::mlir::StringAttr getStaticLowerBoundAttrName(::mlir::OperationName name) {
674
+ return getAttributeNameForIndex(name, 1);
675
+ }
676
+
677
+ ::mlir::StringAttr getStaticStepAttrName() {
678
+ return getAttributeNameForIndex(2);
679
+ }
680
+
681
+ static ::mlir::StringAttr getStaticStepAttrName(::mlir::OperationName name) {
682
+ return getAttributeNameForIndex(name, 2);
683
+ }
684
+
685
+ ::mlir::StringAttr getStaticUpperBoundAttrName() {
686
+ return getAttributeNameForIndex(3);
687
+ }
688
+
689
+ static ::mlir::StringAttr getStaticUpperBoundAttrName(::mlir::OperationName name) {
690
+ return getAttributeNameForIndex(name, 3);
691
+ }
692
+
693
+ ::mlir::StringAttr getOperandSegmentSizesAttrName() {
694
+ return (*this)->getName().getAttributeNames().back();
695
+ }
696
+
697
+ static ::mlir::StringAttr getOperandSegmentSizesAttrName(::mlir::OperationName name) {
698
+ return name.getAttributeNames().back();
699
+ }
700
+
701
+ static constexpr ::llvm::StringLiteral getOperationName() {
702
+ return ::llvm::StringLiteral("scf.forall");
703
+ }
704
+
705
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index);
706
+ ::mlir::Operation::operand_range getODSOperands(unsigned index);
707
+ ::mlir::Operation::operand_range getDynamicLowerBound();
708
+ ::mlir::Operation::operand_range getDynamicUpperBound();
709
+ ::mlir::Operation::operand_range getDynamicStep();
710
+ ::mlir::Operation::operand_range getOutputs();
711
+ ::mlir::MutableOperandRange getDynamicLowerBoundMutable();
712
+ ::mlir::MutableOperandRange getDynamicUpperBoundMutable();
713
+ ::mlir::MutableOperandRange getDynamicStepMutable();
714
+ ::mlir::MutableOperandRange getOutputsMutable();
715
+ std::pair<unsigned, unsigned> getODSResultIndexAndLength(unsigned index);
716
+ ::mlir::Operation::result_range getODSResults(unsigned index);
717
+ ::mlir::Operation::result_range getResults();
718
+ ::mlir::Region &getRegion();
719
+ static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError);
720
+ static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop);
721
+ static llvm::hash_code computePropertiesHash(const Properties &prop);
722
+ static std::optional<mlir::Attribute> getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name);
723
+ static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value);
724
+ static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs);
725
+ static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError);
726
+ static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state);
727
+ void writeProperties(::mlir::DialectBytecodeWriter &writer);
728
+ ::mlir::DenseI64ArrayAttr getStaticLowerBoundAttr();
729
+ ::llvm::ArrayRef<int64_t> getStaticLowerBound();
730
+ ::mlir::DenseI64ArrayAttr getStaticUpperBoundAttr();
731
+ ::llvm::ArrayRef<int64_t> getStaticUpperBound();
732
+ ::mlir::DenseI64ArrayAttr getStaticStepAttr();
733
+ ::llvm::ArrayRef<int64_t> getStaticStep();
734
+ ::mlir::ArrayAttr getMappingAttr();
735
+ ::std::optional< ::mlir::ArrayAttr > getMapping();
736
+ void setStaticLowerBoundAttr(::mlir::DenseI64ArrayAttr attr);
737
+ void setStaticLowerBound(::llvm::ArrayRef<int64_t> attrValue);
738
+ void setStaticUpperBoundAttr(::mlir::DenseI64ArrayAttr attr);
739
+ void setStaticUpperBound(::llvm::ArrayRef<int64_t> attrValue);
740
+ void setStaticStepAttr(::mlir::DenseI64ArrayAttr attr);
741
+ void setStaticStep(::llvm::ArrayRef<int64_t> attrValue);
742
+ void setMappingAttr(::mlir::ArrayAttr attr);
743
+ ::mlir::Attribute removeMappingAttr();
744
+ static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ArrayRef<OpFoldResult> lbs, ArrayRef<OpFoldResult> ubs, ArrayRef<OpFoldResult> steps, ValueRange outputs, std::optional<ArrayAttr> mapping, function_ref<void(OpBuilder &, Location, ValueRange)> bodyBuilderFn = nullptr);
745
+ static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ArrayRef<OpFoldResult> ubs, ValueRange outputs, std::optional<ArrayAttr> mapping, function_ref<void(OpBuilder &, Location, ValueRange)> bodyBuilderFn = nullptr);
746
+ static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result);
747
+ void print(::mlir::OpAsmPrinter &p);
748
+ ::mlir::LogicalResult verifyInvariantsImpl();
749
+ ::mlir::LogicalResult verifyInvariants();
750
+ ::mlir::LogicalResult verify();
751
+ static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context);
752
+ ::llvm::SmallVector<::mlir::Region *> getLoopRegions();
753
+ ::mlir::LogicalResult promoteIfSingleIteration(::mlir::RewriterBase &rewriter);
754
+ void getSuccessorRegions(::mlir::RegionBranchPoint point, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> &regions);
755
+ private:
756
+ ::mlir::StringAttr getAttributeNameForIndex(unsigned index) {
757
+ return getAttributeNameForIndex((*this)->getName(), index);
758
+ }
759
+
760
+ static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) {
761
+ assert(index < 4 && "invalid attribute index");
762
+ assert(name.getStringRef() == getOperationName() && "invalid operation name");
763
+ return name.getAttributeNames()[index];
764
+ }
765
+
766
+ public:
767
+ // Get lower bounds as OpFoldResult.
768
+ SmallVector<OpFoldResult> getMixedLowerBound() {
769
+ Builder b(getOperation()->getContext());
770
+ return getMixedValues(getStaticLowerBound(), getDynamicLowerBound(), b);
771
+ }
772
+
773
+ // Get upper bounds as OpFoldResult.
774
+ SmallVector<OpFoldResult> getMixedUpperBound() {
775
+ Builder b(getOperation()->getContext());
776
+ return getMixedValues(getStaticUpperBound(), getDynamicUpperBound(), b);
777
+ }
778
+
779
+ // Get steps as OpFoldResult.
780
+ SmallVector<OpFoldResult> getMixedStep() {
781
+ Builder b(getOperation()->getContext());
782
+ return getMixedValues(getStaticStep(), getDynamicStep(), b);
783
+ }
784
+
785
+ /// Get lower bounds as values.
786
+ SmallVector<Value> getLowerBound(OpBuilder &b) {
787
+ return getValueOrCreateConstantIndexOp(b, getLoc(), getMixedLowerBound());
788
+ }
789
+
790
+ /// Get upper bounds as values.
791
+ SmallVector<Value> getUpperBound(OpBuilder &b) {
792
+ return getValueOrCreateConstantIndexOp(b, getLoc(), getMixedUpperBound());
793
+ }
794
+
795
+ /// Get steps as values.
796
+ SmallVector<Value> getStep(OpBuilder &b) {
797
+ return getValueOrCreateConstantIndexOp(b, getLoc(), getMixedStep());
798
+ }
799
+
800
+ int64_t getRank() { return getStaticLowerBound().size(); }
801
+
802
+ /// Number of operands controlling the loop: lbs, ubs, steps
803
+ unsigned getNumControlOperands() { return 3 * getRank(); }
804
+
805
+ /// Number of dynamic operands controlling the loop: lbs, ubs, steps
806
+ unsigned getNumDynamicControlOperands() {
807
+ return getODSOperandIndexAndLength(3).first;
808
+ }
809
+
810
+ OpResult getTiedOpResult(OpOperand *opOperand) {
811
+ assert(opOperand->getOperandNumber() >= getNumDynamicControlOperands() &&
812
+ "invalid operand");
813
+ return getOperation()->getOpResult(
814
+ opOperand->getOperandNumber() - getNumDynamicControlOperands());
815
+ }
816
+
817
+ /// Return the num_threads operand that is tied to the given thread id
818
+ /// block argument.
819
+ OpOperand *getTiedOpOperand(BlockArgument bbArg) {
820
+ assert(bbArg.getArgNumber() >= getRank() && "invalid bbArg");
821
+
822
+ return &getOperation()->getOpOperand(getNumDynamicControlOperands() +
823
+ bbArg.getArgNumber() - getRank());
824
+ }
825
+
826
+ /// Return the shared_outs operand that is tied to the given OpResult.
827
+ OpOperand *getTiedOpOperand(OpResult opResult) {
828
+ assert(opResult.getDefiningOp() == getOperation() && "invalid OpResult");
829
+ return &getOperation()->getOpOperand(getNumDynamicControlOperands() +
830
+ opResult.getResultNumber());
831
+ }
832
+
833
+ BlockArgument getTiedBlockArgument(OpOperand *opOperand) {
834
+ assert(opOperand->getOperandNumber() >= getNumDynamicControlOperands() &&
835
+ "invalid operand");
836
+
837
+ return getBody()->getArgument(opOperand->getOperandNumber() -
838
+ getNumDynamicControlOperands() + getRank());
839
+ }
840
+
841
+ ArrayRef<BlockArgument> getOutputBlockArguments() {
842
+ return getBody()->getArguments().drop_front(getRank());
843
+ }
844
+
845
+ ::mlir::ValueRange getInductionVars() {
846
+ return getBody()->getArguments().take_front(getRank());
847
+ }
848
+
849
+ ::mlir::Value getInductionVar(int64_t idx) {
850
+ return getInductionVars()[idx];
851
+ }
852
+
853
+ ::mlir::Block::BlockArgListType getRegionOutArgs() {
854
+ return getBody()->getArguments().drop_front(getRank());
855
+ }
856
+
857
+ /// Checks if the lbs are zeros and steps are ones.
858
+ bool isNormalized();
859
+
860
+ // The ensureTerminator method generated by SingleBlockImplicitTerminator is
861
+ // unaware of the fact that our terminator also needs a region to be
862
+ // well-formed. We override it here to ensure that we do the right thing.
863
+ static void ensureTerminator(Region & region, OpBuilder & builder,
864
+ Location loc);
865
+
866
+ InParallelOp getTerminator();
867
+
868
+ // Declare the shared_outs as inits/outs to DestinationStyleOpInterface.
869
+ MutableOperandRange getDpsInitsMutable() { return getOutputsMutable(); }
870
+ };
871
+ } // namespace scf
872
+ } // namespace mlir
873
+ MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::ForallOp)
874
+
875
+ namespace mlir {
876
+ namespace scf {
877
+
878
+ //===----------------------------------------------------------------------===//
879
+ // ::mlir::scf::IfOp declarations
880
+ //===----------------------------------------------------------------------===//
881
+
882
+ namespace detail {
883
+ class IfOpGenericAdaptorBase {
884
+ public:
885
+ protected:
886
+ ::mlir::DictionaryAttr odsAttrs;
887
+ ::std::optional<::mlir::OperationName> odsOpName;
888
+ ::mlir::RegionRange odsRegions;
889
+ public:
890
+ IfOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {});
891
+
892
+ IfOpGenericAdaptorBase(IfOp op);
893
+
894
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize);
895
+ ::mlir::DictionaryAttr getAttributes();
896
+ ::mlir::Region &getThenRegion();
897
+ ::mlir::Region &getElseRegion();
898
+ ::mlir::RegionRange getRegions();
899
+ };
900
+ } // namespace detail
901
+ template <typename RangeT>
902
+ class IfOpGenericAdaptor : public detail::IfOpGenericAdaptorBase {
903
+ using ValueT = ::llvm::detail::ValueOfRange<RangeT>;
904
+ using Base = detail::IfOpGenericAdaptorBase;
905
+ public:
906
+ IfOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {}
907
+
908
+ IfOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : IfOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {}
909
+
910
+ template <typename LateInst = IfOp, typename = std::enable_if_t<std::is_same_v<LateInst, IfOp>>>
911
+ IfOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {}
912
+
913
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index) {
914
+ return Base::getODSOperandIndexAndLength(index, odsOperands.size());
915
+ }
916
+
917
+ RangeT getODSOperands(unsigned index) {
918
+ auto valueRange = getODSOperandIndexAndLength(index);
919
+ return {std::next(odsOperands.begin(), valueRange.first),
920
+ std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
921
+ }
922
+
923
+ ValueT getCondition() {
924
+ return (*getODSOperands(0).begin());
925
+ }
926
+
927
+ RangeT getOperands() {
928
+ return odsOperands;
929
+ }
930
+
931
+ private:
932
+ RangeT odsOperands;
933
+ };
934
+ class IfOpAdaptor : public IfOpGenericAdaptor<::mlir::ValueRange> {
935
+ public:
936
+ using IfOpGenericAdaptor::IfOpGenericAdaptor;
937
+ IfOpAdaptor(IfOp op);
938
+
939
+ ::mlir::LogicalResult verify(::mlir::Location loc);
940
+ };
941
+ class IfOp : public ::mlir::Op<IfOp, ::mlir::OpTrait::NRegions<2>::Impl, ::mlir::OpTrait::VariadicResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::SingleBlock, ::mlir::OpTrait::SingleBlockImplicitTerminator<scf::YieldOp>::Impl, ::mlir::OpTrait::NoRegionArguments, ::mlir::OpTrait::OpInvariants, ::mlir::RegionBranchOpInterface::Trait, ::mlir::InferTypeOpInterface::Trait, ::mlir::OpTrait::InferTypeOpAdaptor, ::mlir::OpTrait::HasRecursiveMemoryEffects> {
942
+ public:
943
+ using Op::Op;
944
+ using Op::print;
945
+ using Adaptor = IfOpAdaptor;
946
+ template <typename RangeT>
947
+ using GenericAdaptor = IfOpGenericAdaptor<RangeT>;
948
+ using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>;
949
+ static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() {
950
+ return {};
951
+ }
952
+
953
+ static constexpr ::llvm::StringLiteral getOperationName() {
954
+ return ::llvm::StringLiteral("scf.if");
955
+ }
956
+
957
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index);
958
+ ::mlir::Operation::operand_range getODSOperands(unsigned index);
959
+ ::mlir::TypedValue<::mlir::IntegerType> getCondition();
960
+ ::mlir::OpOperand &getConditionMutable();
961
+ std::pair<unsigned, unsigned> getODSResultIndexAndLength(unsigned index);
962
+ ::mlir::Operation::result_range getODSResults(unsigned index);
963
+ ::mlir::Operation::result_range getResults();
964
+ ::mlir::Region &getThenRegion();
965
+ ::mlir::Region &getElseRegion();
966
+ static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, TypeRange resultTypes, Value cond);
967
+ static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, TypeRange resultTypes, Value cond, bool addThenBlock, bool addElseBlock);
968
+ static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value cond, bool withElseRegion);
969
+ static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, TypeRange resultTypes, Value cond, bool withElseRegion);
970
+ static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value cond, function_ref<void(OpBuilder &, Location)> thenBuilder = buildTerminatedBody, function_ref<void(OpBuilder &, Location)> elseBuilder = nullptr);
971
+ static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result);
972
+ void print(::mlir::OpAsmPrinter &p);
973
+ ::mlir::LogicalResult verifyInvariantsImpl();
974
+ ::mlir::LogicalResult verifyInvariants();
975
+ ::mlir::LogicalResult verify();
976
+ static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context);
977
+ ::mlir::LogicalResult fold(FoldAdaptor adaptor, ::llvm::SmallVectorImpl<::mlir::OpFoldResult> &results);
978
+ void getEntrySuccessorRegions(::llvm::ArrayRef<::mlir::Attribute> operands, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> &regions);
979
+ void getSuccessorRegions(::mlir::RegionBranchPoint point, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> &regions);
980
+ void getRegionInvocationBounds(::llvm::ArrayRef<::mlir::Attribute> operands, ::llvm::SmallVectorImpl<::mlir::InvocationBounds> &invocationBounds);
981
+ static ::mlir::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes);
982
+ public:
983
+ static ::mlir::LogicalResult
984
+ inferReturnTypes(::mlir::MLIRContext *context,
985
+ std::optional<::mlir::Location> location,
986
+ Adaptor adaptor,
987
+ ::llvm::SmallVectorImpl<::mlir::Type> &inferredReturnTypes);
988
+
989
+
990
+ OpBuilder getThenBodyBuilder(OpBuilder::Listener *listener = nullptr) {
991
+ Block* body = getBody(0);
992
+ return getResults().empty() ? OpBuilder::atBlockTerminator(body, listener)
993
+ : OpBuilder::atBlockEnd(body, listener);
994
+ }
995
+ OpBuilder getElseBodyBuilder(OpBuilder::Listener *listener = nullptr) {
996
+ Block* body = getBody(1);
997
+ return getResults().empty() ? OpBuilder::atBlockTerminator(body, listener)
998
+ : OpBuilder::atBlockEnd(body, listener);
999
+ }
1000
+ Block* thenBlock();
1001
+ YieldOp thenYield();
1002
+ Block* elseBlock();
1003
+ YieldOp elseYield();
1004
+ };
1005
+ } // namespace scf
1006
+ } // namespace mlir
1007
+ MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::IfOp)
1008
+
1009
+ namespace mlir {
1010
+ namespace scf {
1011
+
1012
+ //===----------------------------------------------------------------------===//
1013
+ // ::mlir::scf::InParallelOp declarations
1014
+ //===----------------------------------------------------------------------===//
1015
+
1016
+ namespace detail {
1017
+ class InParallelOpGenericAdaptorBase {
1018
+ public:
1019
+ protected:
1020
+ ::mlir::DictionaryAttr odsAttrs;
1021
+ ::std::optional<::mlir::OperationName> odsOpName;
1022
+ ::mlir::RegionRange odsRegions;
1023
+ public:
1024
+ InParallelOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {});
1025
+
1026
+ InParallelOpGenericAdaptorBase(InParallelOp op);
1027
+
1028
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize);
1029
+ ::mlir::DictionaryAttr getAttributes();
1030
+ ::mlir::Region &getRegion();
1031
+ ::mlir::RegionRange getRegions();
1032
+ };
1033
+ } // namespace detail
1034
+ template <typename RangeT>
1035
+ class InParallelOpGenericAdaptor : public detail::InParallelOpGenericAdaptorBase {
1036
+ using ValueT = ::llvm::detail::ValueOfRange<RangeT>;
1037
+ using Base = detail::InParallelOpGenericAdaptorBase;
1038
+ public:
1039
+ InParallelOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {}
1040
+
1041
+ InParallelOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : InParallelOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {}
1042
+
1043
+ template <typename LateInst = InParallelOp, typename = std::enable_if_t<std::is_same_v<LateInst, InParallelOp>>>
1044
+ InParallelOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {}
1045
+
1046
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index) {
1047
+ return Base::getODSOperandIndexAndLength(index, odsOperands.size());
1048
+ }
1049
+
1050
+ RangeT getODSOperands(unsigned index) {
1051
+ auto valueRange = getODSOperandIndexAndLength(index);
1052
+ return {std::next(odsOperands.begin(), valueRange.first),
1053
+ std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
1054
+ }
1055
+
1056
+ RangeT getOperands() {
1057
+ return odsOperands;
1058
+ }
1059
+
1060
+ private:
1061
+ RangeT odsOperands;
1062
+ };
1063
+ class InParallelOpAdaptor : public InParallelOpGenericAdaptor<::mlir::ValueRange> {
1064
+ public:
1065
+ using InParallelOpGenericAdaptor::InParallelOpGenericAdaptor;
1066
+ InParallelOpAdaptor(InParallelOp op);
1067
+
1068
+ ::mlir::LogicalResult verify(::mlir::Location loc);
1069
+ };
1070
+ class InParallelOp : public ::mlir::Op<InParallelOp, ::mlir::OpTrait::OneRegion, ::mlir::OpTrait::ZeroResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::ZeroOperands, ::mlir::OpTrait::HasParent<ForallOp>::Impl, ::mlir::OpTrait::NoTerminator, ::mlir::OpTrait::SingleBlock, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::IsTerminator, ::mlir::ParallelCombiningOpInterface::Trait, ::mlir::RegionKindInterface::Trait, ::mlir::OpTrait::HasOnlyGraphRegion> {
1071
+ public:
1072
+ using Op::Op;
1073
+ using Op::print;
1074
+ using Adaptor = InParallelOpAdaptor;
1075
+ template <typename RangeT>
1076
+ using GenericAdaptor = InParallelOpGenericAdaptor<RangeT>;
1077
+ using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>;
1078
+ static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() {
1079
+ return {};
1080
+ }
1081
+
1082
+ static constexpr ::llvm::StringLiteral getOperationName() {
1083
+ return ::llvm::StringLiteral("scf.forall.in_parallel");
1084
+ }
1085
+
1086
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index);
1087
+ ::mlir::Operation::operand_range getODSOperands(unsigned index);
1088
+ std::pair<unsigned, unsigned> getODSResultIndexAndLength(unsigned index);
1089
+ ::mlir::Operation::result_range getODSResults(unsigned index);
1090
+ ::mlir::Region &getRegion();
1091
+ static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState);
1092
+ static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result);
1093
+ void print(::mlir::OpAsmPrinter &p);
1094
+ ::mlir::LogicalResult verifyInvariantsImpl();
1095
+ ::mlir::LogicalResult verifyInvariants();
1096
+ ::mlir::LogicalResult verify();
1097
+ void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects);
1098
+ public:
1099
+ ::llvm::SmallVector<::mlir::BlockArgument> getDests();
1100
+ ::llvm::iterator_range<::mlir::Block::iterator> getYieldingOps();
1101
+ ::mlir::OpResult getParentResult(int64_t idx);
1102
+ };
1103
+ } // namespace scf
1104
+ } // namespace mlir
1105
+ MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::InParallelOp)
1106
+
1107
+ namespace mlir {
1108
+ namespace scf {
1109
+
1110
+ //===----------------------------------------------------------------------===//
1111
+ // ::mlir::scf::IndexSwitchOp declarations
1112
+ //===----------------------------------------------------------------------===//
1113
+
1114
+ namespace detail {
1115
+ class IndexSwitchOpGenericAdaptorBase {
1116
+ public:
1117
+ struct Properties {
1118
+ using casesTy = ::mlir::DenseI64ArrayAttr;
1119
+ casesTy cases;
1120
+
1121
+ auto getCases() {
1122
+ auto &propStorage = this->cases;
1123
+ return ::llvm::cast<::mlir::DenseI64ArrayAttr>(propStorage);
1124
+ }
1125
+ void setCases(const ::mlir::DenseI64ArrayAttr &propValue) {
1126
+ this->cases = propValue;
1127
+ }
1128
+ bool operator==(const Properties &rhs) const {
1129
+ return
1130
+ rhs.cases == this->cases &&
1131
+ true;
1132
+ }
1133
+ bool operator!=(const Properties &rhs) const {
1134
+ return !(*this == rhs);
1135
+ }
1136
+ };
1137
+ protected:
1138
+ ::mlir::DictionaryAttr odsAttrs;
1139
+ ::std::optional<::mlir::OperationName> odsOpName;
1140
+ Properties properties;
1141
+ ::mlir::RegionRange odsRegions;
1142
+ public:
1143
+ IndexSwitchOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {});
1144
+
1145
+ IndexSwitchOpGenericAdaptorBase(IndexSwitchOp op);
1146
+
1147
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize);
1148
+ const Properties &getProperties() {
1149
+ return properties;
1150
+ }
1151
+
1152
+ ::mlir::DictionaryAttr getAttributes();
1153
+ ::mlir::DenseI64ArrayAttr getCasesAttr();
1154
+ ::llvm::ArrayRef<int64_t> getCases();
1155
+ ::mlir::Region &getDefaultRegion();
1156
+ ::mlir::RegionRange getCaseRegions();
1157
+ ::mlir::RegionRange getRegions();
1158
+ };
1159
+ } // namespace detail
1160
+ template <typename RangeT>
1161
+ class IndexSwitchOpGenericAdaptor : public detail::IndexSwitchOpGenericAdaptorBase {
1162
+ using ValueT = ::llvm::detail::ValueOfRange<RangeT>;
1163
+ using Base = detail::IndexSwitchOpGenericAdaptorBase;
1164
+ public:
1165
+ IndexSwitchOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {}
1166
+
1167
+ IndexSwitchOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : IndexSwitchOpGenericAdaptor(values, attrs, (properties ? *properties.as<Properties *>() : Properties{}), regions) {}
1168
+
1169
+ template <typename LateInst = IndexSwitchOp, typename = std::enable_if_t<std::is_same_v<LateInst, IndexSwitchOp>>>
1170
+ IndexSwitchOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {}
1171
+
1172
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index) {
1173
+ return Base::getODSOperandIndexAndLength(index, odsOperands.size());
1174
+ }
1175
+
1176
+ RangeT getODSOperands(unsigned index) {
1177
+ auto valueRange = getODSOperandIndexAndLength(index);
1178
+ return {std::next(odsOperands.begin(), valueRange.first),
1179
+ std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
1180
+ }
1181
+
1182
+ ValueT getArg() {
1183
+ return (*getODSOperands(0).begin());
1184
+ }
1185
+
1186
+ RangeT getOperands() {
1187
+ return odsOperands;
1188
+ }
1189
+
1190
+ private:
1191
+ RangeT odsOperands;
1192
+ };
1193
+ class IndexSwitchOpAdaptor : public IndexSwitchOpGenericAdaptor<::mlir::ValueRange> {
1194
+ public:
1195
+ using IndexSwitchOpGenericAdaptor::IndexSwitchOpGenericAdaptor;
1196
+ IndexSwitchOpAdaptor(IndexSwitchOp op);
1197
+
1198
+ ::mlir::LogicalResult verify(::mlir::Location loc);
1199
+ };
1200
+ class IndexSwitchOp : public ::mlir::Op<IndexSwitchOp, ::mlir::OpTrait::AtLeastNRegions<1>::Impl, ::mlir::OpTrait::VariadicResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::SingleBlock, ::mlir::OpTrait::SingleBlockImplicitTerminator<scf::YieldOp>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpTrait::HasRecursiveMemoryEffects, ::mlir::RegionBranchOpInterface::Trait> {
1201
+ public:
1202
+ using Op::Op;
1203
+ using Op::print;
1204
+ using Adaptor = IndexSwitchOpAdaptor;
1205
+ template <typename RangeT>
1206
+ using GenericAdaptor = IndexSwitchOpGenericAdaptor<RangeT>;
1207
+ using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>;
1208
+ using Properties = FoldAdaptor::Properties;
1209
+ static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() {
1210
+ static ::llvm::StringRef attrNames[] = {::llvm::StringRef("cases")};
1211
+ return ::llvm::ArrayRef(attrNames);
1212
+ }
1213
+
1214
+ ::mlir::StringAttr getCasesAttrName() {
1215
+ return getAttributeNameForIndex(0);
1216
+ }
1217
+
1218
+ static ::mlir::StringAttr getCasesAttrName(::mlir::OperationName name) {
1219
+ return getAttributeNameForIndex(name, 0);
1220
+ }
1221
+
1222
+ static constexpr ::llvm::StringLiteral getOperationName() {
1223
+ return ::llvm::StringLiteral("scf.index_switch");
1224
+ }
1225
+
1226
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index);
1227
+ ::mlir::Operation::operand_range getODSOperands(unsigned index);
1228
+ ::mlir::TypedValue<::mlir::IndexType> getArg();
1229
+ ::mlir::OpOperand &getArgMutable();
1230
+ std::pair<unsigned, unsigned> getODSResultIndexAndLength(unsigned index);
1231
+ ::mlir::Operation::result_range getODSResults(unsigned index);
1232
+ ::mlir::Operation::result_range getResults();
1233
+ ::mlir::Region &getDefaultRegion();
1234
+ ::mlir::MutableArrayRef<::mlir::Region> getCaseRegions();
1235
+ static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError);
1236
+ static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop);
1237
+ static llvm::hash_code computePropertiesHash(const Properties &prop);
1238
+ static std::optional<mlir::Attribute> getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name);
1239
+ static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value);
1240
+ static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs);
1241
+ static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError);
1242
+ static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state);
1243
+ void writeProperties(::mlir::DialectBytecodeWriter &writer);
1244
+ ::mlir::DenseI64ArrayAttr getCasesAttr();
1245
+ ::llvm::ArrayRef<int64_t> getCases();
1246
+ void setCasesAttr(::mlir::DenseI64ArrayAttr attr);
1247
+ void setCases(::llvm::ArrayRef<int64_t> attrValue);
1248
+ static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::Value arg, ::mlir::DenseI64ArrayAttr cases, unsigned caseRegionsCount);
1249
+ static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange results, ::mlir::Value arg, ::llvm::ArrayRef<int64_t> cases, unsigned caseRegionsCount);
1250
+ static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes, unsigned numRegions);
1251
+ ::mlir::LogicalResult verifyInvariantsImpl();
1252
+ ::mlir::LogicalResult verifyInvariants();
1253
+ ::mlir::LogicalResult verify();
1254
+ void getEntrySuccessorRegions(::llvm::ArrayRef<::mlir::Attribute> operands, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> &regions);
1255
+ void getSuccessorRegions(::mlir::RegionBranchPoint point, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> &regions);
1256
+ void getRegionInvocationBounds(::llvm::ArrayRef<::mlir::Attribute> operands, ::llvm::SmallVectorImpl<::mlir::InvocationBounds> &invocationBounds);
1257
+ static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result);
1258
+ void print(::mlir::OpAsmPrinter &_odsPrinter);
1259
+ private:
1260
+ ::mlir::StringAttr getAttributeNameForIndex(unsigned index) {
1261
+ return getAttributeNameForIndex((*this)->getName(), index);
1262
+ }
1263
+
1264
+ static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) {
1265
+ assert(index < 1 && "invalid attribute index");
1266
+ assert(name.getStringRef() == getOperationName() && "invalid operation name");
1267
+ return name.getAttributeNames()[index];
1268
+ }
1269
+
1270
+ public:
1271
+ /// Get the number of cases.
1272
+ unsigned getNumCases();
1273
+
1274
+ /// Get the default region body.
1275
+ Block &getDefaultBlock();
1276
+
1277
+ /// Get the body of a case region.
1278
+ Block &getCaseBlock(unsigned idx);
1279
+ };
1280
+ } // namespace scf
1281
+ } // namespace mlir
1282
+ MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::IndexSwitchOp)
1283
+
1284
+ namespace mlir {
1285
+ namespace scf {
1286
+
1287
+ //===----------------------------------------------------------------------===//
1288
+ // ::mlir::scf::ParallelOp declarations
1289
+ //===----------------------------------------------------------------------===//
1290
+
1291
+ namespace detail {
1292
+ class ParallelOpGenericAdaptorBase {
1293
+ public:
1294
+ struct Properties {
1295
+ using operandSegmentSizesTy = std::array<int32_t, 4>;
1296
+ operandSegmentSizesTy operandSegmentSizes;
1297
+ ::llvm::ArrayRef<int32_t> getOperandSegmentSizes() {
1298
+ auto &propStorage = this->operandSegmentSizes;
1299
+ return propStorage;
1300
+ }
1301
+ void setOperandSegmentSizes(const ::llvm::ArrayRef<int32_t> &propValue) {
1302
+ auto &propStorage = this->operandSegmentSizes;
1303
+ ::llvm::copy(propValue, propStorage.begin());
1304
+ }
1305
+ bool operator==(const Properties &rhs) const {
1306
+ return
1307
+ rhs.operandSegmentSizes == this->operandSegmentSizes &&
1308
+ true;
1309
+ }
1310
+ bool operator!=(const Properties &rhs) const {
1311
+ return !(*this == rhs);
1312
+ }
1313
+ };
1314
+ protected:
1315
+ ::mlir::DictionaryAttr odsAttrs;
1316
+ ::std::optional<::mlir::OperationName> odsOpName;
1317
+ Properties properties;
1318
+ ::mlir::RegionRange odsRegions;
1319
+ public:
1320
+ ParallelOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties = {}, ::mlir::RegionRange regions = {});
1321
+
1322
+ ParallelOpGenericAdaptorBase(ParallelOp op);
1323
+
1324
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize);
1325
+ const Properties &getProperties() {
1326
+ return properties;
1327
+ }
1328
+
1329
+ ::mlir::DictionaryAttr getAttributes();
1330
+ ::mlir::Region &getRegion();
1331
+ ::mlir::RegionRange getRegions();
1332
+ };
1333
+ } // namespace detail
1334
+ template <typename RangeT>
1335
+ class ParallelOpGenericAdaptor : public detail::ParallelOpGenericAdaptorBase {
1336
+ using ValueT = ::llvm::detail::ValueOfRange<RangeT>;
1337
+ using Base = detail::ParallelOpGenericAdaptorBase;
1338
+ public:
1339
+ ParallelOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {}
1340
+
1341
+ ParallelOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ParallelOpGenericAdaptor(values, attrs, (properties ? *properties.as<Properties *>() : Properties{}), regions) {}
1342
+
1343
+ template <typename LateInst = ParallelOp, typename = std::enable_if_t<std::is_same_v<LateInst, ParallelOp>>>
1344
+ ParallelOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {}
1345
+
1346
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index) {
1347
+ return Base::getODSOperandIndexAndLength(index, odsOperands.size());
1348
+ }
1349
+
1350
+ RangeT getODSOperands(unsigned index) {
1351
+ auto valueRange = getODSOperandIndexAndLength(index);
1352
+ return {std::next(odsOperands.begin(), valueRange.first),
1353
+ std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
1354
+ }
1355
+
1356
+ RangeT getLowerBound() {
1357
+ return getODSOperands(0);
1358
+ }
1359
+
1360
+ RangeT getUpperBound() {
1361
+ return getODSOperands(1);
1362
+ }
1363
+
1364
+ RangeT getStep() {
1365
+ return getODSOperands(2);
1366
+ }
1367
+
1368
+ RangeT getInitVals() {
1369
+ return getODSOperands(3);
1370
+ }
1371
+
1372
+ RangeT getOperands() {
1373
+ return odsOperands;
1374
+ }
1375
+
1376
+ private:
1377
+ RangeT odsOperands;
1378
+ };
1379
+ class ParallelOpAdaptor : public ParallelOpGenericAdaptor<::mlir::ValueRange> {
1380
+ public:
1381
+ using ParallelOpGenericAdaptor::ParallelOpGenericAdaptor;
1382
+ ParallelOpAdaptor(ParallelOp op);
1383
+
1384
+ ::mlir::LogicalResult verify(::mlir::Location loc);
1385
+ };
1386
+ class ParallelOp : public ::mlir::Op<ParallelOp, ::mlir::OpTrait::OneRegion, ::mlir::OpTrait::VariadicResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::AttrSizedOperandSegments, ::mlir::OpTrait::SingleBlock, ::mlir::OpTrait::SingleBlockImplicitTerminator<scf::YieldOp>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::BytecodeOpInterface::Trait, ::mlir::OpTrait::AutomaticAllocationScope, ::mlir::LoopLikeOpInterface::Trait, ::mlir::OpTrait::HasRecursiveMemoryEffects, ::mlir::RegionBranchOpInterface::Trait> {
1387
+ public:
1388
+ using Op::Op;
1389
+ using Op::print;
1390
+ using Adaptor = ParallelOpAdaptor;
1391
+ template <typename RangeT>
1392
+ using GenericAdaptor = ParallelOpGenericAdaptor<RangeT>;
1393
+ using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>;
1394
+ using Properties = FoldAdaptor::Properties;
1395
+ static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() {
1396
+ static ::llvm::StringRef attrNames[] = {::llvm::StringRef("operandSegmentSizes")};
1397
+ return ::llvm::ArrayRef(attrNames);
1398
+ }
1399
+
1400
+ ::mlir::StringAttr getOperandSegmentSizesAttrName() {
1401
+ return (*this)->getName().getAttributeNames().back();
1402
+ }
1403
+
1404
+ static ::mlir::StringAttr getOperandSegmentSizesAttrName(::mlir::OperationName name) {
1405
+ return name.getAttributeNames().back();
1406
+ }
1407
+
1408
+ static constexpr ::llvm::StringLiteral getOperationName() {
1409
+ return ::llvm::StringLiteral("scf.parallel");
1410
+ }
1411
+
1412
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index);
1413
+ ::mlir::Operation::operand_range getODSOperands(unsigned index);
1414
+ ::mlir::Operation::operand_range getLowerBound();
1415
+ ::mlir::Operation::operand_range getUpperBound();
1416
+ ::mlir::Operation::operand_range getStep();
1417
+ ::mlir::Operation::operand_range getInitVals();
1418
+ ::mlir::MutableOperandRange getLowerBoundMutable();
1419
+ ::mlir::MutableOperandRange getUpperBoundMutable();
1420
+ ::mlir::MutableOperandRange getStepMutable();
1421
+ ::mlir::MutableOperandRange getInitValsMutable();
1422
+ std::pair<unsigned, unsigned> getODSResultIndexAndLength(unsigned index);
1423
+ ::mlir::Operation::result_range getODSResults(unsigned index);
1424
+ ::mlir::Operation::result_range getResults();
1425
+ ::mlir::Region &getRegion();
1426
+ static ::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError);
1427
+ static ::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop);
1428
+ static llvm::hash_code computePropertiesHash(const Properties &prop);
1429
+ static std::optional<mlir::Attribute> getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name);
1430
+ static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value);
1431
+ static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs);
1432
+ static ::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError);
1433
+ static ::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state);
1434
+ void writeProperties(::mlir::DialectBytecodeWriter &writer);
1435
+ static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ValueRange lowerBounds, ValueRange upperBounds, ValueRange steps, ValueRange initVals, function_ref<void (OpBuilder &, Location, ValueRange, ValueRange)> bodyBuilderFn = nullptr);
1436
+ static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ValueRange lowerBounds, ValueRange upperBounds, ValueRange steps, function_ref<void (OpBuilder &, Location, ValueRange)> bodyBuilderFn = nullptr);
1437
+ static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result);
1438
+ void print(::mlir::OpAsmPrinter &p);
1439
+ ::mlir::LogicalResult verifyInvariantsImpl();
1440
+ ::mlir::LogicalResult verifyInvariants();
1441
+ ::mlir::LogicalResult verify();
1442
+ static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context);
1443
+ ::llvm::SmallVector<::mlir::Region *> getLoopRegions();
1444
+ void getSuccessorRegions(::mlir::RegionBranchPoint point, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> &regions);
1445
+ private:
1446
+ ::mlir::StringAttr getAttributeNameForIndex(unsigned index) {
1447
+ return getAttributeNameForIndex((*this)->getName(), index);
1448
+ }
1449
+
1450
+ static ::mlir::StringAttr getAttributeNameForIndex(::mlir::OperationName name, unsigned index) {
1451
+ return {};
1452
+ }
1453
+
1454
+ public:
1455
+ ValueRange getInductionVars() {
1456
+ return getBody()->getArguments();
1457
+ }
1458
+ unsigned getNumLoops() { return getStep().size(); }
1459
+ unsigned getNumReductions() { return getInitVals().size(); }
1460
+ };
1461
+ } // namespace scf
1462
+ } // namespace mlir
1463
+ MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::ParallelOp)
1464
+
1465
+ namespace mlir {
1466
+ namespace scf {
1467
+
1468
+ //===----------------------------------------------------------------------===//
1469
+ // ::mlir::scf::ReduceOp declarations
1470
+ //===----------------------------------------------------------------------===//
1471
+
1472
+ namespace detail {
1473
+ class ReduceOpGenericAdaptorBase {
1474
+ public:
1475
+ protected:
1476
+ ::mlir::DictionaryAttr odsAttrs;
1477
+ ::std::optional<::mlir::OperationName> odsOpName;
1478
+ ::mlir::RegionRange odsRegions;
1479
+ public:
1480
+ ReduceOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {});
1481
+
1482
+ ReduceOpGenericAdaptorBase(ReduceOp op);
1483
+
1484
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize);
1485
+ ::mlir::DictionaryAttr getAttributes();
1486
+ ::mlir::Region &getReductionOperator();
1487
+ ::mlir::RegionRange getRegions();
1488
+ };
1489
+ } // namespace detail
1490
+ template <typename RangeT>
1491
+ class ReduceOpGenericAdaptor : public detail::ReduceOpGenericAdaptorBase {
1492
+ using ValueT = ::llvm::detail::ValueOfRange<RangeT>;
1493
+ using Base = detail::ReduceOpGenericAdaptorBase;
1494
+ public:
1495
+ ReduceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {}
1496
+
1497
+ ReduceOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ReduceOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {}
1498
+
1499
+ template <typename LateInst = ReduceOp, typename = std::enable_if_t<std::is_same_v<LateInst, ReduceOp>>>
1500
+ ReduceOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {}
1501
+
1502
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index) {
1503
+ return Base::getODSOperandIndexAndLength(index, odsOperands.size());
1504
+ }
1505
+
1506
+ RangeT getODSOperands(unsigned index) {
1507
+ auto valueRange = getODSOperandIndexAndLength(index);
1508
+ return {std::next(odsOperands.begin(), valueRange.first),
1509
+ std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
1510
+ }
1511
+
1512
+ ValueT getOperand() {
1513
+ return (*getODSOperands(0).begin());
1514
+ }
1515
+
1516
+ RangeT getOperands() {
1517
+ return odsOperands;
1518
+ }
1519
+
1520
+ private:
1521
+ RangeT odsOperands;
1522
+ };
1523
+ class ReduceOpAdaptor : public ReduceOpGenericAdaptor<::mlir::ValueRange> {
1524
+ public:
1525
+ using ReduceOpGenericAdaptor::ReduceOpGenericAdaptor;
1526
+ ReduceOpAdaptor(ReduceOp op);
1527
+
1528
+ ::mlir::LogicalResult verify(::mlir::Location loc);
1529
+ };
1530
+ class ReduceOp : public ::mlir::Op<ReduceOp, ::mlir::OpTrait::OneRegion, ::mlir::OpTrait::ZeroResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::HasParent<ParallelOp>::Impl, ::mlir::OpTrait::OpInvariants> {
1531
+ public:
1532
+ using Op::Op;
1533
+ using Op::print;
1534
+ using Adaptor = ReduceOpAdaptor;
1535
+ template <typename RangeT>
1536
+ using GenericAdaptor = ReduceOpGenericAdaptor<RangeT>;
1537
+ using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>;
1538
+ static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() {
1539
+ return {};
1540
+ }
1541
+
1542
+ static constexpr ::llvm::StringLiteral getOperationName() {
1543
+ return ::llvm::StringLiteral("scf.reduce");
1544
+ }
1545
+
1546
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index);
1547
+ ::mlir::Operation::operand_range getODSOperands(unsigned index);
1548
+ ::mlir::Value getOperand();
1549
+ ::mlir::OpOperand &getOperandMutable();
1550
+ std::pair<unsigned, unsigned> getODSResultIndexAndLength(unsigned index);
1551
+ ::mlir::Operation::result_range getODSResults(unsigned index);
1552
+ ::mlir::Region &getReductionOperator();
1553
+ static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value operand, function_ref<void (OpBuilder &, Location, Value, Value)> bodyBuilderFn = nullptr);
1554
+ static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result);
1555
+ void print(::mlir::OpAsmPrinter &p);
1556
+ ::mlir::LogicalResult verifyInvariantsImpl();
1557
+ ::mlir::LogicalResult verifyInvariants();
1558
+ ::mlir::LogicalResult verifyRegions();
1559
+ public:
1560
+ };
1561
+ } // namespace scf
1562
+ } // namespace mlir
1563
+ MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::ReduceOp)
1564
+
1565
+ namespace mlir {
1566
+ namespace scf {
1567
+
1568
+ //===----------------------------------------------------------------------===//
1569
+ // ::mlir::scf::ReduceReturnOp declarations
1570
+ //===----------------------------------------------------------------------===//
1571
+
1572
+ namespace detail {
1573
+ class ReduceReturnOpGenericAdaptorBase {
1574
+ public:
1575
+ protected:
1576
+ ::mlir::DictionaryAttr odsAttrs;
1577
+ ::std::optional<::mlir::OperationName> odsOpName;
1578
+ ::mlir::RegionRange odsRegions;
1579
+ public:
1580
+ ReduceReturnOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {});
1581
+
1582
+ ReduceReturnOpGenericAdaptorBase(ReduceReturnOp op);
1583
+
1584
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize);
1585
+ ::mlir::DictionaryAttr getAttributes();
1586
+ };
1587
+ } // namespace detail
1588
+ template <typename RangeT>
1589
+ class ReduceReturnOpGenericAdaptor : public detail::ReduceReturnOpGenericAdaptorBase {
1590
+ using ValueT = ::llvm::detail::ValueOfRange<RangeT>;
1591
+ using Base = detail::ReduceReturnOpGenericAdaptorBase;
1592
+ public:
1593
+ ReduceReturnOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {}
1594
+
1595
+ ReduceReturnOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : ReduceReturnOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {}
1596
+
1597
+ template <typename LateInst = ReduceReturnOp, typename = std::enable_if_t<std::is_same_v<LateInst, ReduceReturnOp>>>
1598
+ ReduceReturnOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {}
1599
+
1600
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index) {
1601
+ return Base::getODSOperandIndexAndLength(index, odsOperands.size());
1602
+ }
1603
+
1604
+ RangeT getODSOperands(unsigned index) {
1605
+ auto valueRange = getODSOperandIndexAndLength(index);
1606
+ return {std::next(odsOperands.begin(), valueRange.first),
1607
+ std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
1608
+ }
1609
+
1610
+ ValueT getResult() {
1611
+ return (*getODSOperands(0).begin());
1612
+ }
1613
+
1614
+ RangeT getOperands() {
1615
+ return odsOperands;
1616
+ }
1617
+
1618
+ private:
1619
+ RangeT odsOperands;
1620
+ };
1621
+ class ReduceReturnOpAdaptor : public ReduceReturnOpGenericAdaptor<::mlir::ValueRange> {
1622
+ public:
1623
+ using ReduceReturnOpGenericAdaptor::ReduceReturnOpGenericAdaptor;
1624
+ ReduceReturnOpAdaptor(ReduceReturnOp op);
1625
+
1626
+ ::mlir::LogicalResult verify(::mlir::Location loc);
1627
+ };
1628
+ class ReduceReturnOp : public ::mlir::Op<ReduceReturnOp, ::mlir::OpTrait::ZeroRegions, ::mlir::OpTrait::ZeroResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::OneOperand, ::mlir::OpTrait::HasParent<ReduceOp>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpTrait::IsTerminator> {
1629
+ public:
1630
+ using Op::Op;
1631
+ using Op::print;
1632
+ using Adaptor = ReduceReturnOpAdaptor;
1633
+ template <typename RangeT>
1634
+ using GenericAdaptor = ReduceReturnOpGenericAdaptor<RangeT>;
1635
+ using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>;
1636
+ static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() {
1637
+ return {};
1638
+ }
1639
+
1640
+ static constexpr ::llvm::StringLiteral getOperationName() {
1641
+ return ::llvm::StringLiteral("scf.reduce.return");
1642
+ }
1643
+
1644
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index);
1645
+ ::mlir::Operation::operand_range getODSOperands(unsigned index);
1646
+ ::mlir::Value getResult();
1647
+ ::mlir::OpOperand &getResultMutable();
1648
+ std::pair<unsigned, unsigned> getODSResultIndexAndLength(unsigned index);
1649
+ ::mlir::Operation::result_range getODSResults(unsigned index);
1650
+ static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value result);
1651
+ static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value result);
1652
+ static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {});
1653
+ ::mlir::LogicalResult verifyInvariantsImpl();
1654
+ ::mlir::LogicalResult verifyInvariants();
1655
+ ::mlir::LogicalResult verify();
1656
+ static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result);
1657
+ void print(::mlir::OpAsmPrinter &_odsPrinter);
1658
+ void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects);
1659
+ public:
1660
+ };
1661
+ } // namespace scf
1662
+ } // namespace mlir
1663
+ MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::ReduceReturnOp)
1664
+
1665
+ namespace mlir {
1666
+ namespace scf {
1667
+
1668
+ //===----------------------------------------------------------------------===//
1669
+ // ::mlir::scf::WhileOp declarations
1670
+ //===----------------------------------------------------------------------===//
1671
+
1672
+ namespace detail {
1673
+ class WhileOpGenericAdaptorBase {
1674
+ public:
1675
+ protected:
1676
+ ::mlir::DictionaryAttr odsAttrs;
1677
+ ::std::optional<::mlir::OperationName> odsOpName;
1678
+ ::mlir::RegionRange odsRegions;
1679
+ public:
1680
+ WhileOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {});
1681
+
1682
+ WhileOpGenericAdaptorBase(WhileOp op);
1683
+
1684
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize);
1685
+ ::mlir::DictionaryAttr getAttributes();
1686
+ ::mlir::Region &getBefore();
1687
+ ::mlir::Region &getAfter();
1688
+ ::mlir::RegionRange getRegions();
1689
+ };
1690
+ } // namespace detail
1691
+ template <typename RangeT>
1692
+ class WhileOpGenericAdaptor : public detail::WhileOpGenericAdaptorBase {
1693
+ using ValueT = ::llvm::detail::ValueOfRange<RangeT>;
1694
+ using Base = detail::WhileOpGenericAdaptorBase;
1695
+ public:
1696
+ WhileOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {}
1697
+
1698
+ WhileOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : WhileOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {}
1699
+
1700
+ template <typename LateInst = WhileOp, typename = std::enable_if_t<std::is_same_v<LateInst, WhileOp>>>
1701
+ WhileOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {}
1702
+
1703
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index) {
1704
+ return Base::getODSOperandIndexAndLength(index, odsOperands.size());
1705
+ }
1706
+
1707
+ RangeT getODSOperands(unsigned index) {
1708
+ auto valueRange = getODSOperandIndexAndLength(index);
1709
+ return {std::next(odsOperands.begin(), valueRange.first),
1710
+ std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
1711
+ }
1712
+
1713
+ RangeT getInits() {
1714
+ return getODSOperands(0);
1715
+ }
1716
+
1717
+ RangeT getOperands() {
1718
+ return odsOperands;
1719
+ }
1720
+
1721
+ private:
1722
+ RangeT odsOperands;
1723
+ };
1724
+ class WhileOpAdaptor : public WhileOpGenericAdaptor<::mlir::ValueRange> {
1725
+ public:
1726
+ using WhileOpGenericAdaptor::WhileOpGenericAdaptor;
1727
+ WhileOpAdaptor(WhileOp op);
1728
+
1729
+ ::mlir::LogicalResult verify(::mlir::Location loc);
1730
+ };
1731
+ class WhileOp : public ::mlir::Op<WhileOp, ::mlir::OpTrait::NRegions<2>::Impl, ::mlir::OpTrait::VariadicResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::SingleBlock, ::mlir::OpTrait::OpInvariants, ::mlir::RegionBranchOpInterface::Trait, ::mlir::LoopLikeOpInterface::Trait, ::mlir::OpTrait::HasRecursiveMemoryEffects> {
1732
+ public:
1733
+ using Op::Op;
1734
+ using Op::print;
1735
+ using Adaptor = WhileOpAdaptor;
1736
+ template <typename RangeT>
1737
+ using GenericAdaptor = WhileOpGenericAdaptor<RangeT>;
1738
+ using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>;
1739
+ static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() {
1740
+ return {};
1741
+ }
1742
+
1743
+ static constexpr ::llvm::StringLiteral getOperationName() {
1744
+ return ::llvm::StringLiteral("scf.while");
1745
+ }
1746
+
1747
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index);
1748
+ ::mlir::Operation::operand_range getODSOperands(unsigned index);
1749
+ ::mlir::Operation::operand_range getInits();
1750
+ ::mlir::MutableOperandRange getInitsMutable();
1751
+ std::pair<unsigned, unsigned> getODSResultIndexAndLength(unsigned index);
1752
+ ::mlir::Operation::result_range getODSResults(unsigned index);
1753
+ ::mlir::Operation::result_range getResults();
1754
+ ::mlir::Region &getBefore();
1755
+ ::mlir::Region &getAfter();
1756
+ static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, TypeRange resultTypes, ValueRange operands, function_ref<void(OpBuilder &, Location, ValueRange)> beforeBuilder, function_ref<void(OpBuilder &, Location, ValueRange)> afterBuilder);
1757
+ static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {});
1758
+ static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result);
1759
+ void print(::mlir::OpAsmPrinter &p);
1760
+ ::mlir::LogicalResult verifyInvariantsImpl();
1761
+ ::mlir::LogicalResult verifyInvariants();
1762
+ ::mlir::LogicalResult verify();
1763
+ static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context);
1764
+ ::mlir::OperandRange getEntrySuccessorOperands(::mlir::RegionBranchPoint point);
1765
+ void getSuccessorRegions(::mlir::RegionBranchPoint point, ::llvm::SmallVectorImpl<::mlir::RegionSuccessor> &regions);
1766
+ ::llvm::SmallVector<::mlir::Region *> getLoopRegions();
1767
+ ::mlir::Block::BlockArgListType getRegionIterArgs();
1768
+ public:
1769
+ using BodyBuilderFn =
1770
+ function_ref<void(OpBuilder &, Location, ValueRange)>;
1771
+
1772
+ ConditionOp getConditionOp();
1773
+ YieldOp getYieldOp();
1774
+ Block::BlockArgListType getBeforeArguments();
1775
+ Block::BlockArgListType getAfterArguments();
1776
+ Block *getBeforeBody() { return &getBefore().front(); }
1777
+ Block *getAfterBody() { return &getAfter().front(); }
1778
+ };
1779
+ } // namespace scf
1780
+ } // namespace mlir
1781
+ MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::WhileOp)
1782
+
1783
+ namespace mlir {
1784
+ namespace scf {
1785
+
1786
+ //===----------------------------------------------------------------------===//
1787
+ // ::mlir::scf::YieldOp declarations
1788
+ //===----------------------------------------------------------------------===//
1789
+
1790
+ namespace detail {
1791
+ class YieldOpGenericAdaptorBase {
1792
+ public:
1793
+ protected:
1794
+ ::mlir::DictionaryAttr odsAttrs;
1795
+ ::std::optional<::mlir::OperationName> odsOpName;
1796
+ ::mlir::RegionRange odsRegions;
1797
+ public:
1798
+ YieldOpGenericAdaptorBase(::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {});
1799
+
1800
+ YieldOpGenericAdaptorBase(YieldOp op);
1801
+
1802
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize);
1803
+ ::mlir::DictionaryAttr getAttributes();
1804
+ };
1805
+ } // namespace detail
1806
+ template <typename RangeT>
1807
+ class YieldOpGenericAdaptor : public detail::YieldOpGenericAdaptorBase {
1808
+ using ValueT = ::llvm::detail::ValueOfRange<RangeT>;
1809
+ using Base = detail::YieldOpGenericAdaptorBase;
1810
+ public:
1811
+ YieldOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = nullptr, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {}
1812
+
1813
+ YieldOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : YieldOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {}
1814
+
1815
+ template <typename LateInst = YieldOp, typename = std::enable_if_t<std::is_same_v<LateInst, YieldOp>>>
1816
+ YieldOpGenericAdaptor(RangeT values, LateInst op) : Base(op), odsOperands(values) {}
1817
+
1818
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index) {
1819
+ return Base::getODSOperandIndexAndLength(index, odsOperands.size());
1820
+ }
1821
+
1822
+ RangeT getODSOperands(unsigned index) {
1823
+ auto valueRange = getODSOperandIndexAndLength(index);
1824
+ return {std::next(odsOperands.begin(), valueRange.first),
1825
+ std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
1826
+ }
1827
+
1828
+ RangeT getResults() {
1829
+ return getODSOperands(0);
1830
+ }
1831
+
1832
+ RangeT getOperands() {
1833
+ return odsOperands;
1834
+ }
1835
+
1836
+ private:
1837
+ RangeT odsOperands;
1838
+ };
1839
+ class YieldOpAdaptor : public YieldOpGenericAdaptor<::mlir::ValueRange> {
1840
+ public:
1841
+ using YieldOpGenericAdaptor::YieldOpGenericAdaptor;
1842
+ YieldOpAdaptor(YieldOp op);
1843
+
1844
+ ::mlir::LogicalResult verify(::mlir::Location loc);
1845
+ };
1846
+ class YieldOp : public ::mlir::Op<YieldOp, ::mlir::OpTrait::ZeroRegions, ::mlir::OpTrait::ZeroResults, ::mlir::OpTrait::ZeroSuccessors, ::mlir::OpTrait::VariadicOperands, ::mlir::OpTrait::HasParent<ExecuteRegionOp, ForOp, IfOp, IndexSwitchOp, ParallelOp, WhileOp>::Impl, ::mlir::OpTrait::OpInvariants, ::mlir::ConditionallySpeculatable::Trait, ::mlir::OpTrait::AlwaysSpeculatableImplTrait, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::RegionBranchTerminatorOpInterface::Trait, ::mlir::OpTrait::ReturnLike, ::mlir::OpTrait::IsTerminator> {
1847
+ public:
1848
+ using Op::Op;
1849
+ using Op::print;
1850
+ using Adaptor = YieldOpAdaptor;
1851
+ template <typename RangeT>
1852
+ using GenericAdaptor = YieldOpGenericAdaptor<RangeT>;
1853
+ using FoldAdaptor = GenericAdaptor<::llvm::ArrayRef<::mlir::Attribute>>;
1854
+ static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() {
1855
+ return {};
1856
+ }
1857
+
1858
+ static constexpr ::llvm::StringLiteral getOperationName() {
1859
+ return ::llvm::StringLiteral("scf.yield");
1860
+ }
1861
+
1862
+ std::pair<unsigned, unsigned> getODSOperandIndexAndLength(unsigned index);
1863
+ ::mlir::Operation::operand_range getODSOperands(unsigned index);
1864
+ ::mlir::Operation::operand_range getResults();
1865
+ ::mlir::MutableOperandRange getResultsMutable();
1866
+ std::pair<unsigned, unsigned> getODSResultIndexAndLength(unsigned index);
1867
+ ::mlir::Operation::result_range getODSResults(unsigned index);
1868
+ static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState);
1869
+ static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange results);
1870
+ static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {});
1871
+ ::mlir::LogicalResult verifyInvariantsImpl();
1872
+ ::mlir::LogicalResult verifyInvariants();
1873
+ ::mlir::MutableOperandRange getMutableSuccessorOperands(::mlir::RegionBranchPoint point);
1874
+ static ::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result);
1875
+ void print(::mlir::OpAsmPrinter &_odsPrinter);
1876
+ void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects);
1877
+ public:
1878
+ };
1879
+ } // namespace scf
1880
+ } // namespace mlir
1881
+ MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::YieldOp)
1882
+
1883
+
1884
+ #endif // GET_OP_CLASSES
1885
+
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/SCFOpsDialect.cpp.inc ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2
+ |* *|
3
+ |* Dialect Definitions *|
4
+ |* *|
5
+ |* Automatically generated file, do not edit! *|
6
+ |* From: SCFOps.td *|
7
+ |* *|
8
+ \*===----------------------------------------------------------------------===*/
9
+
10
+ MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::scf::SCFDialect)
11
+ namespace mlir {
12
+ namespace scf {
13
+
14
+ SCFDialect::SCFDialect(::mlir::MLIRContext *context)
15
+ : ::mlir::Dialect(getDialectNamespace(), context, ::mlir::TypeID::get<SCFDialect>()) {
16
+
17
+ getContext()->loadDialect<arith::ArithDialect>();
18
+
19
+ initialize();
20
+ }
21
+
22
+ SCFDialect::~SCFDialect() = default;
23
+
24
+ } // namespace scf
25
+ } // namespace mlir
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/SCFOpsDialect.h.inc ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2
+ |* *|
3
+ |* Dialect Declarations *|
4
+ |* *|
5
+ |* Automatically generated file, do not edit! *|
6
+ |* From: SCFOps.td *|
7
+ |* *|
8
+ \*===----------------------------------------------------------------------===*/
9
+
10
+ namespace mlir {
11
+ namespace scf {
12
+
13
+ class SCFDialect : public ::mlir::Dialect {
14
+ explicit SCFDialect(::mlir::MLIRContext *context);
15
+
16
+ void initialize();
17
+ friend class ::mlir::MLIRContext;
18
+ public:
19
+ ~SCFDialect() override;
20
+ static constexpr ::llvm::StringLiteral getDialectNamespace() {
21
+ return ::llvm::StringLiteral("scf");
22
+ }
23
+ };
24
+ } // namespace scf
25
+ } // namespace mlir
26
+ MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::scf::SCFDialect)
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/IR/ValueBoundsOpInterfaceImpl.h ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //===- ValueBoundsOpInterfaceImpl.h - Impl. of ValueBoundsOpInterface -----===//
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_SCF_IR_VALUEBOUNDSOPINTERFACEIMPL_H
10
+ #define MLIR_DIALECT_SCF_IR_VALUEBOUNDSOPINTERFACEIMPL_H
11
+
12
+ namespace mlir {
13
+ class DialectRegistry;
14
+
15
+ namespace scf {
16
+ void registerValueBoundsOpInterfaceExternalModels(DialectRegistry &registry);
17
+ } // namespace scf
18
+ } // namespace mlir
19
+
20
+ #endif // MLIR_DIALECT_SCF_IR_VALUEBOUNDSOPINTERFACEIMPL_H
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/BufferDeallocationOpInterfaceImpl.h ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //===- BufferDeallocationOpInterfaceImpl.h ----------------------*- C++ -*-===//
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_SCF_TRANSFORMS_BUFFERDEALLOCATIONOPINTERFACEIMPL_H
10
+ #define MLIR_DIALECT_SCF_TRANSFORMS_BUFFERDEALLOCATIONOPINTERFACEIMPL_H
11
+
12
+ namespace mlir {
13
+
14
+ class DialectRegistry;
15
+
16
+ namespace scf {
17
+ void registerBufferDeallocationOpInterfaceExternalModels(
18
+ DialectRegistry &registry);
19
+ } // namespace scf
20
+ } // namespace mlir
21
+
22
+ #endif // MLIR_DIALECT_SCF_TRANSFORMS_BUFFERDEALLOCATIONOPINTERFACEIMPL_H
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.h ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //===- BufferizableOpInterfaceImpl.h - Impl. of BufferizableOpInterface ---===//
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_SCF_TRANSFORMS_BUFFERIZABLEOPINTERFACEIMPL_H
10
+ #define MLIR_DIALECT_SCF_TRANSFORMS_BUFFERIZABLEOPINTERFACEIMPL_H
11
+
12
+ namespace mlir {
13
+ class DialectRegistry;
14
+
15
+ namespace scf {
16
+ void registerBufferizableOpInterfaceExternalModels(DialectRegistry &registry);
17
+ } // namespace scf
18
+ } // namespace mlir
19
+
20
+ #endif // MLIR_DIALECT_SCF_BUFFERIZABLEOPINTERFACEIMPL_H
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/Passes.h ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //===- Passes.h - Pass Entrypoints ------------------------------*- C++ -*-===//
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
+ // This header file defines prototypes that expose pass constructors.
10
+ //
11
+ //===----------------------------------------------------------------------===//
12
+
13
+ #ifndef MLIR_DIALECT_SCF_TRANSFORMS_PASSES_H_
14
+ #define MLIR_DIALECT_SCF_TRANSFORMS_PASSES_H_
15
+
16
+ #include "mlir/Pass/Pass.h"
17
+
18
+ namespace mlir {
19
+
20
+ #define GEN_PASS_DECL
21
+ #include "mlir/Dialect/SCF/Transforms/Passes.h.inc"
22
+
23
+ /// Creates a pass that bufferizes the SCF dialect.
24
+ std::unique_ptr<Pass> createSCFBufferizePass();
25
+
26
+ /// Creates a pass that specializes for loop for unrolling and
27
+ /// vectorization.
28
+ std::unique_ptr<Pass> createForLoopSpecializationPass();
29
+
30
+ /// Creates a pass that peels for loops at their upper bounds for
31
+ /// better vectorization.
32
+ std::unique_ptr<Pass> createForLoopPeelingPass();
33
+
34
+ /// Creates a pass that canonicalizes affine.min and affine.max operations
35
+ /// inside of scf.for loops with known lower and upper bounds.
36
+ std::unique_ptr<Pass> createSCFForLoopCanonicalizationPass();
37
+
38
+ /// Creates a pass that transforms a single ParallelLoop over N induction
39
+ /// variables into another ParallelLoop over less than N induction variables.
40
+ std::unique_ptr<Pass> createTestSCFParallelLoopCollapsingPass();
41
+
42
+ /// Creates a loop fusion pass which fuses parallel loops.
43
+ std::unique_ptr<Pass> createParallelLoopFusionPass();
44
+
45
+ /// Creates a pass that specializes parallel loop for unrolling and
46
+ /// vectorization.
47
+ std::unique_ptr<Pass> createParallelLoopSpecializationPass();
48
+
49
+ /// Creates a pass which tiles innermost parallel loops.
50
+ /// If noMinMaxBounds, the upper bound of the inner loop will
51
+ /// be a same value among different outter loop iterations, and
52
+ /// an additional inbound check will be emitted inside the internal
53
+ /// loops.
54
+ std::unique_ptr<Pass>
55
+ createParallelLoopTilingPass(llvm::ArrayRef<int64_t> tileSize = {},
56
+ bool noMinMaxBounds = false);
57
+
58
+ /// Creates a pass which folds arith ops on induction variable into
59
+ /// loop range.
60
+ std::unique_ptr<Pass> createForLoopRangeFoldingPass();
61
+
62
+ // Creates a pass which lowers for loops into while loops.
63
+ std::unique_ptr<Pass> createForToWhileLoopPass();
64
+
65
+ //===----------------------------------------------------------------------===//
66
+ // Registration
67
+ //===----------------------------------------------------------------------===//
68
+
69
+ /// Generate the code for registering passes.
70
+ #define GEN_PASS_REGISTRATION
71
+ #include "mlir/Dialect/SCF/Transforms/Passes.h.inc"
72
+
73
+ } // namespace mlir
74
+
75
+ #endif // MLIR_DIALECT_SCF_TRANSFORMS_PASSES_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/Passes.h.inc ADDED
@@ -0,0 +1,1304 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Autogenerated by mlir-tblgen; don't manually edit */
2
+
3
+ #ifdef GEN_PASS_DECL
4
+ // Generate declarations for all passes.
5
+ #define GEN_PASS_DECL_SCFBUFFERIZE
6
+ #define GEN_PASS_DECL_SCFFORLOOPCANONICALIZATION
7
+ #define GEN_PASS_DECL_SCFFORLOOPPEELING
8
+ #define GEN_PASS_DECL_SCFFORLOOPRANGEFOLDING
9
+ #define GEN_PASS_DECL_SCFFORLOOPSPECIALIZATION
10
+ #define GEN_PASS_DECL_SCFFORTOWHILELOOP
11
+ #define GEN_PASS_DECL_SCFPARALLELLOOPFUSION
12
+ #define GEN_PASS_DECL_SCFPARALLELLOOPSPECIALIZATION
13
+ #define GEN_PASS_DECL_SCFPARALLELLOOPTILING
14
+ #define GEN_PASS_DECL_TESTSCFPARALLELLOOPCOLLAPSING
15
+ #undef GEN_PASS_DECL
16
+ #endif // GEN_PASS_DECL
17
+
18
+ //===----------------------------------------------------------------------===//
19
+ // SCFBufferize
20
+ //===----------------------------------------------------------------------===//
21
+ #ifdef GEN_PASS_DECL_SCFBUFFERIZE
22
+ #undef GEN_PASS_DECL_SCFBUFFERIZE
23
+ #endif // GEN_PASS_DECL_SCFBUFFERIZE
24
+ #ifdef GEN_PASS_DEF_SCFBUFFERIZE
25
+ namespace impl {
26
+
27
+ template <typename DerivedT>
28
+ class SCFBufferizeBase : public ::mlir::OperationPass<> {
29
+ public:
30
+ using Base = SCFBufferizeBase;
31
+
32
+ SCFBufferizeBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {}
33
+ SCFBufferizeBase(const SCFBufferizeBase &other) : ::mlir::OperationPass<>(other) {}
34
+
35
+ /// Returns the command-line argument attached to this pass.
36
+ static constexpr ::llvm::StringLiteral getArgumentName() {
37
+ return ::llvm::StringLiteral("scf-bufferize");
38
+ }
39
+ ::llvm::StringRef getArgument() const override { return "scf-bufferize"; }
40
+
41
+ ::llvm::StringRef getDescription() const override { return "Bufferize the scf dialect."; }
42
+
43
+ /// Returns the derived pass name.
44
+ static constexpr ::llvm::StringLiteral getPassName() {
45
+ return ::llvm::StringLiteral("SCFBufferize");
46
+ }
47
+ ::llvm::StringRef getName() const override { return "SCFBufferize"; }
48
+
49
+ /// Support isa/dyn_cast functionality for the derived pass class.
50
+ static bool classof(const ::mlir::Pass *pass) {
51
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
52
+ }
53
+
54
+ /// A clone method to create a copy of this pass.
55
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
56
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
57
+ }
58
+
59
+ /// Return the dialect that must be loaded in the context before this pass.
60
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
61
+
62
+ registry.insert<bufferization::BufferizationDialect>();
63
+
64
+ registry.insert<memref::MemRefDialect>();
65
+
66
+ }
67
+
68
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
69
+ /// instantiation because Pass classes should only be visible by the current
70
+ /// library.
71
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFBufferizeBase<DerivedT>)
72
+
73
+ protected:
74
+ private:
75
+ };
76
+ } // namespace impl
77
+ #undef GEN_PASS_DEF_SCFBUFFERIZE
78
+ #endif // GEN_PASS_DEF_SCFBUFFERIZE
79
+
80
+ //===----------------------------------------------------------------------===//
81
+ // SCFForLoopCanonicalization
82
+ //===----------------------------------------------------------------------===//
83
+ #ifdef GEN_PASS_DECL_SCFFORLOOPCANONICALIZATION
84
+ #undef GEN_PASS_DECL_SCFFORLOOPCANONICALIZATION
85
+ #endif // GEN_PASS_DECL_SCFFORLOOPCANONICALIZATION
86
+ #ifdef GEN_PASS_DEF_SCFFORLOOPCANONICALIZATION
87
+ namespace impl {
88
+
89
+ template <typename DerivedT>
90
+ class SCFForLoopCanonicalizationBase : public ::mlir::OperationPass<> {
91
+ public:
92
+ using Base = SCFForLoopCanonicalizationBase;
93
+
94
+ SCFForLoopCanonicalizationBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {}
95
+ SCFForLoopCanonicalizationBase(const SCFForLoopCanonicalizationBase &other) : ::mlir::OperationPass<>(other) {}
96
+
97
+ /// Returns the command-line argument attached to this pass.
98
+ static constexpr ::llvm::StringLiteral getArgumentName() {
99
+ return ::llvm::StringLiteral("scf-for-loop-canonicalization");
100
+ }
101
+ ::llvm::StringRef getArgument() const override { return "scf-for-loop-canonicalization"; }
102
+
103
+ ::llvm::StringRef getDescription() const override { return "Canonicalize operations within scf.for loop bodies"; }
104
+
105
+ /// Returns the derived pass name.
106
+ static constexpr ::llvm::StringLiteral getPassName() {
107
+ return ::llvm::StringLiteral("SCFForLoopCanonicalization");
108
+ }
109
+ ::llvm::StringRef getName() const override { return "SCFForLoopCanonicalization"; }
110
+
111
+ /// Support isa/dyn_cast functionality for the derived pass class.
112
+ static bool classof(const ::mlir::Pass *pass) {
113
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
114
+ }
115
+
116
+ /// A clone method to create a copy of this pass.
117
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
118
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
119
+ }
120
+
121
+ /// Return the dialect that must be loaded in the context before this pass.
122
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
123
+
124
+ registry.insert<affine::AffineDialect>();
125
+
126
+ registry.insert<tensor::TensorDialect>();
127
+
128
+ registry.insert<memref::MemRefDialect>();
129
+
130
+ }
131
+
132
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
133
+ /// instantiation because Pass classes should only be visible by the current
134
+ /// library.
135
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFForLoopCanonicalizationBase<DerivedT>)
136
+
137
+ protected:
138
+ private:
139
+ };
140
+ } // namespace impl
141
+ #undef GEN_PASS_DEF_SCFFORLOOPCANONICALIZATION
142
+ #endif // GEN_PASS_DEF_SCFFORLOOPCANONICALIZATION
143
+
144
+ //===----------------------------------------------------------------------===//
145
+ // SCFForLoopPeeling
146
+ //===----------------------------------------------------------------------===//
147
+ #ifdef GEN_PASS_DECL_SCFFORLOOPPEELING
148
+ struct SCFForLoopPeelingOptions {
149
+ bool skipPartial = true;
150
+ };
151
+ #undef GEN_PASS_DECL_SCFFORLOOPPEELING
152
+ #endif // GEN_PASS_DECL_SCFFORLOOPPEELING
153
+ #ifdef GEN_PASS_DEF_SCFFORLOOPPEELING
154
+ namespace impl {
155
+
156
+ template <typename DerivedT>
157
+ class SCFForLoopPeelingBase : public ::mlir::OperationPass<> {
158
+ public:
159
+ using Base = SCFForLoopPeelingBase;
160
+
161
+ SCFForLoopPeelingBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {}
162
+ SCFForLoopPeelingBase(const SCFForLoopPeelingBase &other) : ::mlir::OperationPass<>(other) {}
163
+
164
+ /// Returns the command-line argument attached to this pass.
165
+ static constexpr ::llvm::StringLiteral getArgumentName() {
166
+ return ::llvm::StringLiteral("scf-for-loop-peeling");
167
+ }
168
+ ::llvm::StringRef getArgument() const override { return "scf-for-loop-peeling"; }
169
+
170
+ ::llvm::StringRef getDescription() const override { return "Peel `for` loops at their upper bounds."; }
171
+
172
+ /// Returns the derived pass name.
173
+ static constexpr ::llvm::StringLiteral getPassName() {
174
+ return ::llvm::StringLiteral("SCFForLoopPeeling");
175
+ }
176
+ ::llvm::StringRef getName() const override { return "SCFForLoopPeeling"; }
177
+
178
+ /// Support isa/dyn_cast functionality for the derived pass class.
179
+ static bool classof(const ::mlir::Pass *pass) {
180
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
181
+ }
182
+
183
+ /// A clone method to create a copy of this pass.
184
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
185
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
186
+ }
187
+
188
+ /// Return the dialect that must be loaded in the context before this pass.
189
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
190
+
191
+ registry.insert<affine::AffineDialect>();
192
+
193
+ }
194
+
195
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
196
+ /// instantiation because Pass classes should only be visible by the current
197
+ /// library.
198
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFForLoopPeelingBase<DerivedT>)
199
+
200
+ SCFForLoopPeelingBase(const SCFForLoopPeelingOptions &options) : SCFForLoopPeelingBase() {
201
+ skipPartial = options.skipPartial;
202
+ }
203
+ protected:
204
+ ::mlir::Pass::Option<bool> skipPartial{*this, "skip-partial", ::llvm::cl::desc("Do not peel loops inside of the last, partial iteration of another already peeled loop."), ::llvm::cl::init(true)};
205
+ private:
206
+ };
207
+ } // namespace impl
208
+ #undef GEN_PASS_DEF_SCFFORLOOPPEELING
209
+ #endif // GEN_PASS_DEF_SCFFORLOOPPEELING
210
+
211
+ //===----------------------------------------------------------------------===//
212
+ // SCFForLoopRangeFolding
213
+ //===----------------------------------------------------------------------===//
214
+ #ifdef GEN_PASS_DECL_SCFFORLOOPRANGEFOLDING
215
+ #undef GEN_PASS_DECL_SCFFORLOOPRANGEFOLDING
216
+ #endif // GEN_PASS_DECL_SCFFORLOOPRANGEFOLDING
217
+ #ifdef GEN_PASS_DEF_SCFFORLOOPRANGEFOLDING
218
+ namespace impl {
219
+
220
+ template <typename DerivedT>
221
+ class SCFForLoopRangeFoldingBase : public ::mlir::OperationPass<> {
222
+ public:
223
+ using Base = SCFForLoopRangeFoldingBase;
224
+
225
+ SCFForLoopRangeFoldingBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {}
226
+ SCFForLoopRangeFoldingBase(const SCFForLoopRangeFoldingBase &other) : ::mlir::OperationPass<>(other) {}
227
+
228
+ /// Returns the command-line argument attached to this pass.
229
+ static constexpr ::llvm::StringLiteral getArgumentName() {
230
+ return ::llvm::StringLiteral("scf-for-loop-range-folding");
231
+ }
232
+ ::llvm::StringRef getArgument() const override { return "scf-for-loop-range-folding"; }
233
+
234
+ ::llvm::StringRef getDescription() const override { return "Fold add/mul ops into loop range"; }
235
+
236
+ /// Returns the derived pass name.
237
+ static constexpr ::llvm::StringLiteral getPassName() {
238
+ return ::llvm::StringLiteral("SCFForLoopRangeFolding");
239
+ }
240
+ ::llvm::StringRef getName() const override { return "SCFForLoopRangeFolding"; }
241
+
242
+ /// Support isa/dyn_cast functionality for the derived pass class.
243
+ static bool classof(const ::mlir::Pass *pass) {
244
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
245
+ }
246
+
247
+ /// A clone method to create a copy of this pass.
248
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
249
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
250
+ }
251
+
252
+ /// Return the dialect that must be loaded in the context before this pass.
253
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
254
+
255
+ }
256
+
257
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
258
+ /// instantiation because Pass classes should only be visible by the current
259
+ /// library.
260
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFForLoopRangeFoldingBase<DerivedT>)
261
+
262
+ protected:
263
+ private:
264
+ };
265
+ } // namespace impl
266
+ #undef GEN_PASS_DEF_SCFFORLOOPRANGEFOLDING
267
+ #endif // GEN_PASS_DEF_SCFFORLOOPRANGEFOLDING
268
+
269
+ //===----------------------------------------------------------------------===//
270
+ // SCFForLoopSpecialization
271
+ //===----------------------------------------------------------------------===//
272
+ #ifdef GEN_PASS_DECL_SCFFORLOOPSPECIALIZATION
273
+ #undef GEN_PASS_DECL_SCFFORLOOPSPECIALIZATION
274
+ #endif // GEN_PASS_DECL_SCFFORLOOPSPECIALIZATION
275
+ #ifdef GEN_PASS_DEF_SCFFORLOOPSPECIALIZATION
276
+ namespace impl {
277
+
278
+ template <typename DerivedT>
279
+ class SCFForLoopSpecializationBase : public ::mlir::OperationPass<> {
280
+ public:
281
+ using Base = SCFForLoopSpecializationBase;
282
+
283
+ SCFForLoopSpecializationBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {}
284
+ SCFForLoopSpecializationBase(const SCFForLoopSpecializationBase &other) : ::mlir::OperationPass<>(other) {}
285
+
286
+ /// Returns the command-line argument attached to this pass.
287
+ static constexpr ::llvm::StringLiteral getArgumentName() {
288
+ return ::llvm::StringLiteral("scf-for-loop-specialization");
289
+ }
290
+ ::llvm::StringRef getArgument() const override { return "scf-for-loop-specialization"; }
291
+
292
+ ::llvm::StringRef getDescription() const override { return "Specialize `for` loops for vectorization"; }
293
+
294
+ /// Returns the derived pass name.
295
+ static constexpr ::llvm::StringLiteral getPassName() {
296
+ return ::llvm::StringLiteral("SCFForLoopSpecialization");
297
+ }
298
+ ::llvm::StringRef getName() const override { return "SCFForLoopSpecialization"; }
299
+
300
+ /// Support isa/dyn_cast functionality for the derived pass class.
301
+ static bool classof(const ::mlir::Pass *pass) {
302
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
303
+ }
304
+
305
+ /// A clone method to create a copy of this pass.
306
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
307
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
308
+ }
309
+
310
+ /// Return the dialect that must be loaded in the context before this pass.
311
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
312
+
313
+ }
314
+
315
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
316
+ /// instantiation because Pass classes should only be visible by the current
317
+ /// library.
318
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFForLoopSpecializationBase<DerivedT>)
319
+
320
+ protected:
321
+ private:
322
+ };
323
+ } // namespace impl
324
+ #undef GEN_PASS_DEF_SCFFORLOOPSPECIALIZATION
325
+ #endif // GEN_PASS_DEF_SCFFORLOOPSPECIALIZATION
326
+
327
+ //===----------------------------------------------------------------------===//
328
+ // SCFForToWhileLoop
329
+ //===----------------------------------------------------------------------===//
330
+ #ifdef GEN_PASS_DECL_SCFFORTOWHILELOOP
331
+ #undef GEN_PASS_DECL_SCFFORTOWHILELOOP
332
+ #endif // GEN_PASS_DECL_SCFFORTOWHILELOOP
333
+ #ifdef GEN_PASS_DEF_SCFFORTOWHILELOOP
334
+ namespace impl {
335
+
336
+ template <typename DerivedT>
337
+ class SCFForToWhileLoopBase : public ::mlir::OperationPass<> {
338
+ public:
339
+ using Base = SCFForToWhileLoopBase;
340
+
341
+ SCFForToWhileLoopBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {}
342
+ SCFForToWhileLoopBase(const SCFForToWhileLoopBase &other) : ::mlir::OperationPass<>(other) {}
343
+
344
+ /// Returns the command-line argument attached to this pass.
345
+ static constexpr ::llvm::StringLiteral getArgumentName() {
346
+ return ::llvm::StringLiteral("scf-for-to-while");
347
+ }
348
+ ::llvm::StringRef getArgument() const override { return "scf-for-to-while"; }
349
+
350
+ ::llvm::StringRef getDescription() const override { return "Convert SCF for loops to SCF while loops"; }
351
+
352
+ /// Returns the derived pass name.
353
+ static constexpr ::llvm::StringLiteral getPassName() {
354
+ return ::llvm::StringLiteral("SCFForToWhileLoop");
355
+ }
356
+ ::llvm::StringRef getName() const override { return "SCFForToWhileLoop"; }
357
+
358
+ /// Support isa/dyn_cast functionality for the derived pass class.
359
+ static bool classof(const ::mlir::Pass *pass) {
360
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
361
+ }
362
+
363
+ /// A clone method to create a copy of this pass.
364
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
365
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
366
+ }
367
+
368
+ /// Return the dialect that must be loaded in the context before this pass.
369
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
370
+
371
+ }
372
+
373
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
374
+ /// instantiation because Pass classes should only be visible by the current
375
+ /// library.
376
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFForToWhileLoopBase<DerivedT>)
377
+
378
+ protected:
379
+ private:
380
+ };
381
+ } // namespace impl
382
+ #undef GEN_PASS_DEF_SCFFORTOWHILELOOP
383
+ #endif // GEN_PASS_DEF_SCFFORTOWHILELOOP
384
+
385
+ //===----------------------------------------------------------------------===//
386
+ // SCFParallelLoopFusion
387
+ //===----------------------------------------------------------------------===//
388
+ #ifdef GEN_PASS_DECL_SCFPARALLELLOOPFUSION
389
+ #undef GEN_PASS_DECL_SCFPARALLELLOOPFUSION
390
+ #endif // GEN_PASS_DECL_SCFPARALLELLOOPFUSION
391
+ #ifdef GEN_PASS_DEF_SCFPARALLELLOOPFUSION
392
+ namespace impl {
393
+
394
+ template <typename DerivedT>
395
+ class SCFParallelLoopFusionBase : public ::mlir::OperationPass<> {
396
+ public:
397
+ using Base = SCFParallelLoopFusionBase;
398
+
399
+ SCFParallelLoopFusionBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {}
400
+ SCFParallelLoopFusionBase(const SCFParallelLoopFusionBase &other) : ::mlir::OperationPass<>(other) {}
401
+
402
+ /// Returns the command-line argument attached to this pass.
403
+ static constexpr ::llvm::StringLiteral getArgumentName() {
404
+ return ::llvm::StringLiteral("scf-parallel-loop-fusion");
405
+ }
406
+ ::llvm::StringRef getArgument() const override { return "scf-parallel-loop-fusion"; }
407
+
408
+ ::llvm::StringRef getDescription() const override { return "Fuse adjacent parallel loops"; }
409
+
410
+ /// Returns the derived pass name.
411
+ static constexpr ::llvm::StringLiteral getPassName() {
412
+ return ::llvm::StringLiteral("SCFParallelLoopFusion");
413
+ }
414
+ ::llvm::StringRef getName() const override { return "SCFParallelLoopFusion"; }
415
+
416
+ /// Support isa/dyn_cast functionality for the derived pass class.
417
+ static bool classof(const ::mlir::Pass *pass) {
418
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
419
+ }
420
+
421
+ /// A clone method to create a copy of this pass.
422
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
423
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
424
+ }
425
+
426
+ /// Return the dialect that must be loaded in the context before this pass.
427
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
428
+
429
+ }
430
+
431
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
432
+ /// instantiation because Pass classes should only be visible by the current
433
+ /// library.
434
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFParallelLoopFusionBase<DerivedT>)
435
+
436
+ protected:
437
+ private:
438
+ };
439
+ } // namespace impl
440
+ #undef GEN_PASS_DEF_SCFPARALLELLOOPFUSION
441
+ #endif // GEN_PASS_DEF_SCFPARALLELLOOPFUSION
442
+
443
+ //===----------------------------------------------------------------------===//
444
+ // SCFParallelLoopSpecialization
445
+ //===----------------------------------------------------------------------===//
446
+ #ifdef GEN_PASS_DECL_SCFPARALLELLOOPSPECIALIZATION
447
+ #undef GEN_PASS_DECL_SCFPARALLELLOOPSPECIALIZATION
448
+ #endif // GEN_PASS_DECL_SCFPARALLELLOOPSPECIALIZATION
449
+ #ifdef GEN_PASS_DEF_SCFPARALLELLOOPSPECIALIZATION
450
+ namespace impl {
451
+
452
+ template <typename DerivedT>
453
+ class SCFParallelLoopSpecializationBase : public ::mlir::OperationPass<> {
454
+ public:
455
+ using Base = SCFParallelLoopSpecializationBase;
456
+
457
+ SCFParallelLoopSpecializationBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {}
458
+ SCFParallelLoopSpecializationBase(const SCFParallelLoopSpecializationBase &other) : ::mlir::OperationPass<>(other) {}
459
+
460
+ /// Returns the command-line argument attached to this pass.
461
+ static constexpr ::llvm::StringLiteral getArgumentName() {
462
+ return ::llvm::StringLiteral("scf-parallel-loop-specialization");
463
+ }
464
+ ::llvm::StringRef getArgument() const override { return "scf-parallel-loop-specialization"; }
465
+
466
+ ::llvm::StringRef getDescription() const override { return "Specialize parallel loops for vectorization"; }
467
+
468
+ /// Returns the derived pass name.
469
+ static constexpr ::llvm::StringLiteral getPassName() {
470
+ return ::llvm::StringLiteral("SCFParallelLoopSpecialization");
471
+ }
472
+ ::llvm::StringRef getName() const override { return "SCFParallelLoopSpecialization"; }
473
+
474
+ /// Support isa/dyn_cast functionality for the derived pass class.
475
+ static bool classof(const ::mlir::Pass *pass) {
476
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
477
+ }
478
+
479
+ /// A clone method to create a copy of this pass.
480
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
481
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
482
+ }
483
+
484
+ /// Return the dialect that must be loaded in the context before this pass.
485
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
486
+
487
+ }
488
+
489
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
490
+ /// instantiation because Pass classes should only be visible by the current
491
+ /// library.
492
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFParallelLoopSpecializationBase<DerivedT>)
493
+
494
+ protected:
495
+ private:
496
+ };
497
+ } // namespace impl
498
+ #undef GEN_PASS_DEF_SCFPARALLELLOOPSPECIALIZATION
499
+ #endif // GEN_PASS_DEF_SCFPARALLELLOOPSPECIALIZATION
500
+
501
+ //===----------------------------------------------------------------------===//
502
+ // SCFParallelLoopTiling
503
+ //===----------------------------------------------------------------------===//
504
+ #ifdef GEN_PASS_DECL_SCFPARALLELLOOPTILING
505
+ struct SCFParallelLoopTilingOptions {
506
+ ::llvm::ArrayRef<int64_t> tileSizes;
507
+ bool noMinMaxBounds = false;
508
+ };
509
+ #undef GEN_PASS_DECL_SCFPARALLELLOOPTILING
510
+ #endif // GEN_PASS_DECL_SCFPARALLELLOOPTILING
511
+ #ifdef GEN_PASS_DEF_SCFPARALLELLOOPTILING
512
+ namespace impl {
513
+
514
+ template <typename DerivedT>
515
+ class SCFParallelLoopTilingBase : public ::mlir::OperationPass<> {
516
+ public:
517
+ using Base = SCFParallelLoopTilingBase;
518
+
519
+ SCFParallelLoopTilingBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {}
520
+ SCFParallelLoopTilingBase(const SCFParallelLoopTilingBase &other) : ::mlir::OperationPass<>(other) {}
521
+
522
+ /// Returns the command-line argument attached to this pass.
523
+ static constexpr ::llvm::StringLiteral getArgumentName() {
524
+ return ::llvm::StringLiteral("scf-parallel-loop-tiling");
525
+ }
526
+ ::llvm::StringRef getArgument() const override { return "scf-parallel-loop-tiling"; }
527
+
528
+ ::llvm::StringRef getDescription() const override { return "Tile parallel loops"; }
529
+
530
+ /// Returns the derived pass name.
531
+ static constexpr ::llvm::StringLiteral getPassName() {
532
+ return ::llvm::StringLiteral("SCFParallelLoopTiling");
533
+ }
534
+ ::llvm::StringRef getName() const override { return "SCFParallelLoopTiling"; }
535
+
536
+ /// Support isa/dyn_cast functionality for the derived pass class.
537
+ static bool classof(const ::mlir::Pass *pass) {
538
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
539
+ }
540
+
541
+ /// A clone method to create a copy of this pass.
542
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
543
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
544
+ }
545
+
546
+ /// Return the dialect that must be loaded in the context before this pass.
547
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
548
+
549
+ registry.insert<affine::AffineDialect>();
550
+
551
+ }
552
+
553
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
554
+ /// instantiation because Pass classes should only be visible by the current
555
+ /// library.
556
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFParallelLoopTilingBase<DerivedT>)
557
+
558
+ SCFParallelLoopTilingBase(const SCFParallelLoopTilingOptions &options) : SCFParallelLoopTilingBase() {
559
+ tileSizes = options.tileSizes;
560
+ noMinMaxBounds = options.noMinMaxBounds;
561
+ }
562
+ protected:
563
+ ::mlir::Pass::ListOption<int64_t> tileSizes{*this, "parallel-loop-tile-sizes", ::llvm::cl::desc("Factors to tile parallel loops by")};
564
+ ::mlir::Pass::Option<bool> noMinMaxBounds{*this, "no-min-max-bounds", ::llvm::cl::desc("Perform tiling with fixed upper bound with inbound check inside the internal loops"), ::llvm::cl::init(false)};
565
+ private:
566
+ };
567
+ } // namespace impl
568
+ #undef GEN_PASS_DEF_SCFPARALLELLOOPTILING
569
+ #endif // GEN_PASS_DEF_SCFPARALLELLOOPTILING
570
+
571
+ //===----------------------------------------------------------------------===//
572
+ // TestSCFParallelLoopCollapsing
573
+ //===----------------------------------------------------------------------===//
574
+ #ifdef GEN_PASS_DECL_TESTSCFPARALLELLOOPCOLLAPSING
575
+ struct TestSCFParallelLoopCollapsingOptions {
576
+ ::llvm::ArrayRef<unsigned> clCollapsedIndices0;
577
+ ::llvm::ArrayRef<unsigned> clCollapsedIndices1;
578
+ ::llvm::ArrayRef<unsigned> clCollapsedIndices2;
579
+ };
580
+ #undef GEN_PASS_DECL_TESTSCFPARALLELLOOPCOLLAPSING
581
+ #endif // GEN_PASS_DECL_TESTSCFPARALLELLOOPCOLLAPSING
582
+ #ifdef GEN_PASS_DEF_TESTSCFPARALLELLOOPCOLLAPSING
583
+ namespace impl {
584
+
585
+ template <typename DerivedT>
586
+ class TestSCFParallelLoopCollapsingBase : public ::mlir::OperationPass<> {
587
+ public:
588
+ using Base = TestSCFParallelLoopCollapsingBase;
589
+
590
+ TestSCFParallelLoopCollapsingBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {}
591
+ TestSCFParallelLoopCollapsingBase(const TestSCFParallelLoopCollapsingBase &other) : ::mlir::OperationPass<>(other) {}
592
+
593
+ /// Returns the command-line argument attached to this pass.
594
+ static constexpr ::llvm::StringLiteral getArgumentName() {
595
+ return ::llvm::StringLiteral("test-scf-parallel-loop-collapsing");
596
+ }
597
+ ::llvm::StringRef getArgument() const override { return "test-scf-parallel-loop-collapsing"; }
598
+
599
+ ::llvm::StringRef getDescription() const override { return "Test parallel loops collapsing transformation"; }
600
+
601
+ /// Returns the derived pass name.
602
+ static constexpr ::llvm::StringLiteral getPassName() {
603
+ return ::llvm::StringLiteral("TestSCFParallelLoopCollapsing");
604
+ }
605
+ ::llvm::StringRef getName() const override { return "TestSCFParallelLoopCollapsing"; }
606
+
607
+ /// Support isa/dyn_cast functionality for the derived pass class.
608
+ static bool classof(const ::mlir::Pass *pass) {
609
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
610
+ }
611
+
612
+ /// A clone method to create a copy of this pass.
613
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
614
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
615
+ }
616
+
617
+ /// Return the dialect that must be loaded in the context before this pass.
618
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
619
+
620
+ }
621
+
622
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
623
+ /// instantiation because Pass classes should only be visible by the current
624
+ /// library.
625
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestSCFParallelLoopCollapsingBase<DerivedT>)
626
+
627
+ TestSCFParallelLoopCollapsingBase(const TestSCFParallelLoopCollapsingOptions &options) : TestSCFParallelLoopCollapsingBase() {
628
+ clCollapsedIndices0 = options.clCollapsedIndices0;
629
+ clCollapsedIndices1 = options.clCollapsedIndices1;
630
+ clCollapsedIndices2 = options.clCollapsedIndices2;
631
+ }
632
+ protected:
633
+ ::mlir::Pass::ListOption<unsigned> clCollapsedIndices0{*this, "collapsed-indices-0", ::llvm::cl::desc("Which loop indices to combine 0th loop index")};
634
+ ::mlir::Pass::ListOption<unsigned> clCollapsedIndices1{*this, "collapsed-indices-1", ::llvm::cl::desc("Which loop indices to combine into the position 1 loop index")};
635
+ ::mlir::Pass::ListOption<unsigned> clCollapsedIndices2{*this, "collapsed-indices-2", ::llvm::cl::desc("Which loop indices to combine into the position 2 loop index")};
636
+ private:
637
+ };
638
+ } // namespace impl
639
+ #undef GEN_PASS_DEF_TESTSCFPARALLELLOOPCOLLAPSING
640
+ #endif // GEN_PASS_DEF_TESTSCFPARALLELLOOPCOLLAPSING
641
+ #ifdef GEN_PASS_REGISTRATION
642
+
643
+ //===----------------------------------------------------------------------===//
644
+ // SCFBufferize Registration
645
+ //===----------------------------------------------------------------------===//
646
+
647
+ inline void registerSCFBufferize() {
648
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
649
+ return mlir::createSCFBufferizePass();
650
+ });
651
+ }
652
+
653
+ // Old registration code, kept for temporary backwards compatibility.
654
+ inline void registerSCFBufferizePass() {
655
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
656
+ return mlir::createSCFBufferizePass();
657
+ });
658
+ }
659
+
660
+ //===----------------------------------------------------------------------===//
661
+ // SCFForLoopCanonicalization Registration
662
+ //===----------------------------------------------------------------------===//
663
+
664
+ inline void registerSCFForLoopCanonicalization() {
665
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
666
+ return mlir::createSCFForLoopCanonicalizationPass();
667
+ });
668
+ }
669
+
670
+ // Old registration code, kept for temporary backwards compatibility.
671
+ inline void registerSCFForLoopCanonicalizationPass() {
672
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
673
+ return mlir::createSCFForLoopCanonicalizationPass();
674
+ });
675
+ }
676
+
677
+ //===----------------------------------------------------------------------===//
678
+ // SCFForLoopPeeling Registration
679
+ //===----------------------------------------------------------------------===//
680
+
681
+ inline void registerSCFForLoopPeeling() {
682
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
683
+ return mlir::createForLoopPeelingPass();
684
+ });
685
+ }
686
+
687
+ // Old registration code, kept for temporary backwards compatibility.
688
+ inline void registerSCFForLoopPeelingPass() {
689
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
690
+ return mlir::createForLoopPeelingPass();
691
+ });
692
+ }
693
+
694
+ //===----------------------------------------------------------------------===//
695
+ // SCFForLoopRangeFolding Registration
696
+ //===----------------------------------------------------------------------===//
697
+
698
+ inline void registerSCFForLoopRangeFolding() {
699
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
700
+ return mlir::createForLoopRangeFoldingPass();
701
+ });
702
+ }
703
+
704
+ // Old registration code, kept for temporary backwards compatibility.
705
+ inline void registerSCFForLoopRangeFoldingPass() {
706
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
707
+ return mlir::createForLoopRangeFoldingPass();
708
+ });
709
+ }
710
+
711
+ //===----------------------------------------------------------------------===//
712
+ // SCFForLoopSpecialization Registration
713
+ //===----------------------------------------------------------------------===//
714
+
715
+ inline void registerSCFForLoopSpecialization() {
716
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
717
+ return mlir::createForLoopSpecializationPass();
718
+ });
719
+ }
720
+
721
+ // Old registration code, kept for temporary backwards compatibility.
722
+ inline void registerSCFForLoopSpecializationPass() {
723
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
724
+ return mlir::createForLoopSpecializationPass();
725
+ });
726
+ }
727
+
728
+ //===----------------------------------------------------------------------===//
729
+ // SCFForToWhileLoop Registration
730
+ //===----------------------------------------------------------------------===//
731
+
732
+ inline void registerSCFForToWhileLoop() {
733
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
734
+ return mlir::createForToWhileLoopPass();
735
+ });
736
+ }
737
+
738
+ // Old registration code, kept for temporary backwards compatibility.
739
+ inline void registerSCFForToWhileLoopPass() {
740
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
741
+ return mlir::createForToWhileLoopPass();
742
+ });
743
+ }
744
+
745
+ //===----------------------------------------------------------------------===//
746
+ // SCFParallelLoopFusion Registration
747
+ //===----------------------------------------------------------------------===//
748
+
749
+ inline void registerSCFParallelLoopFusion() {
750
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
751
+ return mlir::createParallelLoopFusionPass();
752
+ });
753
+ }
754
+
755
+ // Old registration code, kept for temporary backwards compatibility.
756
+ inline void registerSCFParallelLoopFusionPass() {
757
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
758
+ return mlir::createParallelLoopFusionPass();
759
+ });
760
+ }
761
+
762
+ //===----------------------------------------------------------------------===//
763
+ // SCFParallelLoopSpecialization Registration
764
+ //===----------------------------------------------------------------------===//
765
+
766
+ inline void registerSCFParallelLoopSpecialization() {
767
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
768
+ return mlir::createParallelLoopSpecializationPass();
769
+ });
770
+ }
771
+
772
+ // Old registration code, kept for temporary backwards compatibility.
773
+ inline void registerSCFParallelLoopSpecializationPass() {
774
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
775
+ return mlir::createParallelLoopSpecializationPass();
776
+ });
777
+ }
778
+
779
+ //===----------------------------------------------------------------------===//
780
+ // SCFParallelLoopTiling Registration
781
+ //===----------------------------------------------------------------------===//
782
+
783
+ inline void registerSCFParallelLoopTiling() {
784
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
785
+ return mlir::createParallelLoopTilingPass();
786
+ });
787
+ }
788
+
789
+ // Old registration code, kept for temporary backwards compatibility.
790
+ inline void registerSCFParallelLoopTilingPass() {
791
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
792
+ return mlir::createParallelLoopTilingPass();
793
+ });
794
+ }
795
+
796
+ //===----------------------------------------------------------------------===//
797
+ // TestSCFParallelLoopCollapsing Registration
798
+ //===----------------------------------------------------------------------===//
799
+
800
+ inline void registerTestSCFParallelLoopCollapsing() {
801
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
802
+ return mlir::createTestSCFParallelLoopCollapsingPass();
803
+ });
804
+ }
805
+
806
+ // Old registration code, kept for temporary backwards compatibility.
807
+ inline void registerTestSCFParallelLoopCollapsingPass() {
808
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
809
+ return mlir::createTestSCFParallelLoopCollapsingPass();
810
+ });
811
+ }
812
+
813
+ //===----------------------------------------------------------------------===//
814
+ // SCF Registration
815
+ //===----------------------------------------------------------------------===//
816
+
817
+ inline void registerSCFPasses() {
818
+ registerSCFBufferize();
819
+ registerSCFForLoopCanonicalization();
820
+ registerSCFForLoopPeeling();
821
+ registerSCFForLoopRangeFolding();
822
+ registerSCFForLoopSpecialization();
823
+ registerSCFForToWhileLoop();
824
+ registerSCFParallelLoopFusion();
825
+ registerSCFParallelLoopSpecialization();
826
+ registerSCFParallelLoopTiling();
827
+ registerTestSCFParallelLoopCollapsing();
828
+ }
829
+ #undef GEN_PASS_REGISTRATION
830
+ #endif // GEN_PASS_REGISTRATION
831
+ // Deprecated. Please use the new per-pass macros.
832
+ #ifdef GEN_PASS_CLASSES
833
+
834
+ template <typename DerivedT>
835
+ class SCFBufferizeBase : public ::mlir::OperationPass<> {
836
+ public:
837
+ using Base = SCFBufferizeBase;
838
+
839
+ SCFBufferizeBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {}
840
+ SCFBufferizeBase(const SCFBufferizeBase &other) : ::mlir::OperationPass<>(other) {}
841
+
842
+ /// Returns the command-line argument attached to this pass.
843
+ static constexpr ::llvm::StringLiteral getArgumentName() {
844
+ return ::llvm::StringLiteral("scf-bufferize");
845
+ }
846
+ ::llvm::StringRef getArgument() const override { return "scf-bufferize"; }
847
+
848
+ ::llvm::StringRef getDescription() const override { return "Bufferize the scf dialect."; }
849
+
850
+ /// Returns the derived pass name.
851
+ static constexpr ::llvm::StringLiteral getPassName() {
852
+ return ::llvm::StringLiteral("SCFBufferize");
853
+ }
854
+ ::llvm::StringRef getName() const override { return "SCFBufferize"; }
855
+
856
+ /// Support isa/dyn_cast functionality for the derived pass class.
857
+ static bool classof(const ::mlir::Pass *pass) {
858
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
859
+ }
860
+
861
+ /// A clone method to create a copy of this pass.
862
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
863
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
864
+ }
865
+
866
+ /// Return the dialect that must be loaded in the context before this pass.
867
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
868
+
869
+ registry.insert<bufferization::BufferizationDialect>();
870
+
871
+ registry.insert<memref::MemRefDialect>();
872
+
873
+ }
874
+
875
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
876
+ /// instantiation because Pass classes should only be visible by the current
877
+ /// library.
878
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFBufferizeBase<DerivedT>)
879
+
880
+ protected:
881
+ };
882
+
883
+ template <typename DerivedT>
884
+ class SCFForLoopCanonicalizationBase : public ::mlir::OperationPass<> {
885
+ public:
886
+ using Base = SCFForLoopCanonicalizationBase;
887
+
888
+ SCFForLoopCanonicalizationBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {}
889
+ SCFForLoopCanonicalizationBase(const SCFForLoopCanonicalizationBase &other) : ::mlir::OperationPass<>(other) {}
890
+
891
+ /// Returns the command-line argument attached to this pass.
892
+ static constexpr ::llvm::StringLiteral getArgumentName() {
893
+ return ::llvm::StringLiteral("scf-for-loop-canonicalization");
894
+ }
895
+ ::llvm::StringRef getArgument() const override { return "scf-for-loop-canonicalization"; }
896
+
897
+ ::llvm::StringRef getDescription() const override { return "Canonicalize operations within scf.for loop bodies"; }
898
+
899
+ /// Returns the derived pass name.
900
+ static constexpr ::llvm::StringLiteral getPassName() {
901
+ return ::llvm::StringLiteral("SCFForLoopCanonicalization");
902
+ }
903
+ ::llvm::StringRef getName() const override { return "SCFForLoopCanonicalization"; }
904
+
905
+ /// Support isa/dyn_cast functionality for the derived pass class.
906
+ static bool classof(const ::mlir::Pass *pass) {
907
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
908
+ }
909
+
910
+ /// A clone method to create a copy of this pass.
911
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
912
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
913
+ }
914
+
915
+ /// Return the dialect that must be loaded in the context before this pass.
916
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
917
+
918
+ registry.insert<affine::AffineDialect>();
919
+
920
+ registry.insert<tensor::TensorDialect>();
921
+
922
+ registry.insert<memref::MemRefDialect>();
923
+
924
+ }
925
+
926
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
927
+ /// instantiation because Pass classes should only be visible by the current
928
+ /// library.
929
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFForLoopCanonicalizationBase<DerivedT>)
930
+
931
+ protected:
932
+ };
933
+
934
+ template <typename DerivedT>
935
+ class SCFForLoopPeelingBase : public ::mlir::OperationPass<> {
936
+ public:
937
+ using Base = SCFForLoopPeelingBase;
938
+
939
+ SCFForLoopPeelingBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {}
940
+ SCFForLoopPeelingBase(const SCFForLoopPeelingBase &other) : ::mlir::OperationPass<>(other) {}
941
+
942
+ /// Returns the command-line argument attached to this pass.
943
+ static constexpr ::llvm::StringLiteral getArgumentName() {
944
+ return ::llvm::StringLiteral("scf-for-loop-peeling");
945
+ }
946
+ ::llvm::StringRef getArgument() const override { return "scf-for-loop-peeling"; }
947
+
948
+ ::llvm::StringRef getDescription() const override { return "Peel `for` loops at their upper bounds."; }
949
+
950
+ /// Returns the derived pass name.
951
+ static constexpr ::llvm::StringLiteral getPassName() {
952
+ return ::llvm::StringLiteral("SCFForLoopPeeling");
953
+ }
954
+ ::llvm::StringRef getName() const override { return "SCFForLoopPeeling"; }
955
+
956
+ /// Support isa/dyn_cast functionality for the derived pass class.
957
+ static bool classof(const ::mlir::Pass *pass) {
958
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
959
+ }
960
+
961
+ /// A clone method to create a copy of this pass.
962
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
963
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
964
+ }
965
+
966
+ /// Return the dialect that must be loaded in the context before this pass.
967
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
968
+
969
+ registry.insert<affine::AffineDialect>();
970
+
971
+ }
972
+
973
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
974
+ /// instantiation because Pass classes should only be visible by the current
975
+ /// library.
976
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFForLoopPeelingBase<DerivedT>)
977
+
978
+ protected:
979
+ ::mlir::Pass::Option<bool> skipPartial{*this, "skip-partial", ::llvm::cl::desc("Do not peel loops inside of the last, partial iteration of another already peeled loop."), ::llvm::cl::init(true)};
980
+ };
981
+
982
+ template <typename DerivedT>
983
+ class SCFForLoopRangeFoldingBase : public ::mlir::OperationPass<> {
984
+ public:
985
+ using Base = SCFForLoopRangeFoldingBase;
986
+
987
+ SCFForLoopRangeFoldingBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {}
988
+ SCFForLoopRangeFoldingBase(const SCFForLoopRangeFoldingBase &other) : ::mlir::OperationPass<>(other) {}
989
+
990
+ /// Returns the command-line argument attached to this pass.
991
+ static constexpr ::llvm::StringLiteral getArgumentName() {
992
+ return ::llvm::StringLiteral("scf-for-loop-range-folding");
993
+ }
994
+ ::llvm::StringRef getArgument() const override { return "scf-for-loop-range-folding"; }
995
+
996
+ ::llvm::StringRef getDescription() const override { return "Fold add/mul ops into loop range"; }
997
+
998
+ /// Returns the derived pass name.
999
+ static constexpr ::llvm::StringLiteral getPassName() {
1000
+ return ::llvm::StringLiteral("SCFForLoopRangeFolding");
1001
+ }
1002
+ ::llvm::StringRef getName() const override { return "SCFForLoopRangeFolding"; }
1003
+
1004
+ /// Support isa/dyn_cast functionality for the derived pass class.
1005
+ static bool classof(const ::mlir::Pass *pass) {
1006
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
1007
+ }
1008
+
1009
+ /// A clone method to create a copy of this pass.
1010
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
1011
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
1012
+ }
1013
+
1014
+ /// Return the dialect that must be loaded in the context before this pass.
1015
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
1016
+
1017
+ }
1018
+
1019
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
1020
+ /// instantiation because Pass classes should only be visible by the current
1021
+ /// library.
1022
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFForLoopRangeFoldingBase<DerivedT>)
1023
+
1024
+ protected:
1025
+ };
1026
+
1027
+ template <typename DerivedT>
1028
+ class SCFForLoopSpecializationBase : public ::mlir::OperationPass<> {
1029
+ public:
1030
+ using Base = SCFForLoopSpecializationBase;
1031
+
1032
+ SCFForLoopSpecializationBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {}
1033
+ SCFForLoopSpecializationBase(const SCFForLoopSpecializationBase &other) : ::mlir::OperationPass<>(other) {}
1034
+
1035
+ /// Returns the command-line argument attached to this pass.
1036
+ static constexpr ::llvm::StringLiteral getArgumentName() {
1037
+ return ::llvm::StringLiteral("scf-for-loop-specialization");
1038
+ }
1039
+ ::llvm::StringRef getArgument() const override { return "scf-for-loop-specialization"; }
1040
+
1041
+ ::llvm::StringRef getDescription() const override { return "Specialize `for` loops for vectorization"; }
1042
+
1043
+ /// Returns the derived pass name.
1044
+ static constexpr ::llvm::StringLiteral getPassName() {
1045
+ return ::llvm::StringLiteral("SCFForLoopSpecialization");
1046
+ }
1047
+ ::llvm::StringRef getName() const override { return "SCFForLoopSpecialization"; }
1048
+
1049
+ /// Support isa/dyn_cast functionality for the derived pass class.
1050
+ static bool classof(const ::mlir::Pass *pass) {
1051
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
1052
+ }
1053
+
1054
+ /// A clone method to create a copy of this pass.
1055
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
1056
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
1057
+ }
1058
+
1059
+ /// Return the dialect that must be loaded in the context before this pass.
1060
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
1061
+
1062
+ }
1063
+
1064
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
1065
+ /// instantiation because Pass classes should only be visible by the current
1066
+ /// library.
1067
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFForLoopSpecializationBase<DerivedT>)
1068
+
1069
+ protected:
1070
+ };
1071
+
1072
+ template <typename DerivedT>
1073
+ class SCFForToWhileLoopBase : public ::mlir::OperationPass<> {
1074
+ public:
1075
+ using Base = SCFForToWhileLoopBase;
1076
+
1077
+ SCFForToWhileLoopBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {}
1078
+ SCFForToWhileLoopBase(const SCFForToWhileLoopBase &other) : ::mlir::OperationPass<>(other) {}
1079
+
1080
+ /// Returns the command-line argument attached to this pass.
1081
+ static constexpr ::llvm::StringLiteral getArgumentName() {
1082
+ return ::llvm::StringLiteral("scf-for-to-while");
1083
+ }
1084
+ ::llvm::StringRef getArgument() const override { return "scf-for-to-while"; }
1085
+
1086
+ ::llvm::StringRef getDescription() const override { return "Convert SCF for loops to SCF while loops"; }
1087
+
1088
+ /// Returns the derived pass name.
1089
+ static constexpr ::llvm::StringLiteral getPassName() {
1090
+ return ::llvm::StringLiteral("SCFForToWhileLoop");
1091
+ }
1092
+ ::llvm::StringRef getName() const override { return "SCFForToWhileLoop"; }
1093
+
1094
+ /// Support isa/dyn_cast functionality for the derived pass class.
1095
+ static bool classof(const ::mlir::Pass *pass) {
1096
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
1097
+ }
1098
+
1099
+ /// A clone method to create a copy of this pass.
1100
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
1101
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
1102
+ }
1103
+
1104
+ /// Return the dialect that must be loaded in the context before this pass.
1105
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
1106
+
1107
+ }
1108
+
1109
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
1110
+ /// instantiation because Pass classes should only be visible by the current
1111
+ /// library.
1112
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFForToWhileLoopBase<DerivedT>)
1113
+
1114
+ protected:
1115
+ };
1116
+
1117
+ template <typename DerivedT>
1118
+ class SCFParallelLoopFusionBase : public ::mlir::OperationPass<> {
1119
+ public:
1120
+ using Base = SCFParallelLoopFusionBase;
1121
+
1122
+ SCFParallelLoopFusionBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {}
1123
+ SCFParallelLoopFusionBase(const SCFParallelLoopFusionBase &other) : ::mlir::OperationPass<>(other) {}
1124
+
1125
+ /// Returns the command-line argument attached to this pass.
1126
+ static constexpr ::llvm::StringLiteral getArgumentName() {
1127
+ return ::llvm::StringLiteral("scf-parallel-loop-fusion");
1128
+ }
1129
+ ::llvm::StringRef getArgument() const override { return "scf-parallel-loop-fusion"; }
1130
+
1131
+ ::llvm::StringRef getDescription() const override { return "Fuse adjacent parallel loops"; }
1132
+
1133
+ /// Returns the derived pass name.
1134
+ static constexpr ::llvm::StringLiteral getPassName() {
1135
+ return ::llvm::StringLiteral("SCFParallelLoopFusion");
1136
+ }
1137
+ ::llvm::StringRef getName() const override { return "SCFParallelLoopFusion"; }
1138
+
1139
+ /// Support isa/dyn_cast functionality for the derived pass class.
1140
+ static bool classof(const ::mlir::Pass *pass) {
1141
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
1142
+ }
1143
+
1144
+ /// A clone method to create a copy of this pass.
1145
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
1146
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
1147
+ }
1148
+
1149
+ /// Return the dialect that must be loaded in the context before this pass.
1150
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
1151
+
1152
+ }
1153
+
1154
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
1155
+ /// instantiation because Pass classes should only be visible by the current
1156
+ /// library.
1157
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFParallelLoopFusionBase<DerivedT>)
1158
+
1159
+ protected:
1160
+ };
1161
+
1162
+ template <typename DerivedT>
1163
+ class SCFParallelLoopSpecializationBase : public ::mlir::OperationPass<> {
1164
+ public:
1165
+ using Base = SCFParallelLoopSpecializationBase;
1166
+
1167
+ SCFParallelLoopSpecializationBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {}
1168
+ SCFParallelLoopSpecializationBase(const SCFParallelLoopSpecializationBase &other) : ::mlir::OperationPass<>(other) {}
1169
+
1170
+ /// Returns the command-line argument attached to this pass.
1171
+ static constexpr ::llvm::StringLiteral getArgumentName() {
1172
+ return ::llvm::StringLiteral("scf-parallel-loop-specialization");
1173
+ }
1174
+ ::llvm::StringRef getArgument() const override { return "scf-parallel-loop-specialization"; }
1175
+
1176
+ ::llvm::StringRef getDescription() const override { return "Specialize parallel loops for vectorization"; }
1177
+
1178
+ /// Returns the derived pass name.
1179
+ static constexpr ::llvm::StringLiteral getPassName() {
1180
+ return ::llvm::StringLiteral("SCFParallelLoopSpecialization");
1181
+ }
1182
+ ::llvm::StringRef getName() const override { return "SCFParallelLoopSpecialization"; }
1183
+
1184
+ /// Support isa/dyn_cast functionality for the derived pass class.
1185
+ static bool classof(const ::mlir::Pass *pass) {
1186
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
1187
+ }
1188
+
1189
+ /// A clone method to create a copy of this pass.
1190
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
1191
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
1192
+ }
1193
+
1194
+ /// Return the dialect that must be loaded in the context before this pass.
1195
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
1196
+
1197
+ }
1198
+
1199
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
1200
+ /// instantiation because Pass classes should only be visible by the current
1201
+ /// library.
1202
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFParallelLoopSpecializationBase<DerivedT>)
1203
+
1204
+ protected:
1205
+ };
1206
+
1207
+ template <typename DerivedT>
1208
+ class SCFParallelLoopTilingBase : public ::mlir::OperationPass<> {
1209
+ public:
1210
+ using Base = SCFParallelLoopTilingBase;
1211
+
1212
+ SCFParallelLoopTilingBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {}
1213
+ SCFParallelLoopTilingBase(const SCFParallelLoopTilingBase &other) : ::mlir::OperationPass<>(other) {}
1214
+
1215
+ /// Returns the command-line argument attached to this pass.
1216
+ static constexpr ::llvm::StringLiteral getArgumentName() {
1217
+ return ::llvm::StringLiteral("scf-parallel-loop-tiling");
1218
+ }
1219
+ ::llvm::StringRef getArgument() const override { return "scf-parallel-loop-tiling"; }
1220
+
1221
+ ::llvm::StringRef getDescription() const override { return "Tile parallel loops"; }
1222
+
1223
+ /// Returns the derived pass name.
1224
+ static constexpr ::llvm::StringLiteral getPassName() {
1225
+ return ::llvm::StringLiteral("SCFParallelLoopTiling");
1226
+ }
1227
+ ::llvm::StringRef getName() const override { return "SCFParallelLoopTiling"; }
1228
+
1229
+ /// Support isa/dyn_cast functionality for the derived pass class.
1230
+ static bool classof(const ::mlir::Pass *pass) {
1231
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
1232
+ }
1233
+
1234
+ /// A clone method to create a copy of this pass.
1235
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
1236
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
1237
+ }
1238
+
1239
+ /// Return the dialect that must be loaded in the context before this pass.
1240
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
1241
+
1242
+ registry.insert<affine::AffineDialect>();
1243
+
1244
+ }
1245
+
1246
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
1247
+ /// instantiation because Pass classes should only be visible by the current
1248
+ /// library.
1249
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SCFParallelLoopTilingBase<DerivedT>)
1250
+
1251
+ protected:
1252
+ ::mlir::Pass::ListOption<int64_t> tileSizes{*this, "parallel-loop-tile-sizes", ::llvm::cl::desc("Factors to tile parallel loops by")};
1253
+ ::mlir::Pass::Option<bool> noMinMaxBounds{*this, "no-min-max-bounds", ::llvm::cl::desc("Perform tiling with fixed upper bound with inbound check inside the internal loops"), ::llvm::cl::init(false)};
1254
+ };
1255
+
1256
+ template <typename DerivedT>
1257
+ class TestSCFParallelLoopCollapsingBase : public ::mlir::OperationPass<> {
1258
+ public:
1259
+ using Base = TestSCFParallelLoopCollapsingBase;
1260
+
1261
+ TestSCFParallelLoopCollapsingBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {}
1262
+ TestSCFParallelLoopCollapsingBase(const TestSCFParallelLoopCollapsingBase &other) : ::mlir::OperationPass<>(other) {}
1263
+
1264
+ /// Returns the command-line argument attached to this pass.
1265
+ static constexpr ::llvm::StringLiteral getArgumentName() {
1266
+ return ::llvm::StringLiteral("test-scf-parallel-loop-collapsing");
1267
+ }
1268
+ ::llvm::StringRef getArgument() const override { return "test-scf-parallel-loop-collapsing"; }
1269
+
1270
+ ::llvm::StringRef getDescription() const override { return "Test parallel loops collapsing transformation"; }
1271
+
1272
+ /// Returns the derived pass name.
1273
+ static constexpr ::llvm::StringLiteral getPassName() {
1274
+ return ::llvm::StringLiteral("TestSCFParallelLoopCollapsing");
1275
+ }
1276
+ ::llvm::StringRef getName() const override { return "TestSCFParallelLoopCollapsing"; }
1277
+
1278
+ /// Support isa/dyn_cast functionality for the derived pass class.
1279
+ static bool classof(const ::mlir::Pass *pass) {
1280
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
1281
+ }
1282
+
1283
+ /// A clone method to create a copy of this pass.
1284
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
1285
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
1286
+ }
1287
+
1288
+ /// Return the dialect that must be loaded in the context before this pass.
1289
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
1290
+
1291
+ }
1292
+
1293
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
1294
+ /// instantiation because Pass classes should only be visible by the current
1295
+ /// library.
1296
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestSCFParallelLoopCollapsingBase<DerivedT>)
1297
+
1298
+ protected:
1299
+ ::mlir::Pass::ListOption<unsigned> clCollapsedIndices0{*this, "collapsed-indices-0", ::llvm::cl::desc("Which loop indices to combine 0th loop index")};
1300
+ ::mlir::Pass::ListOption<unsigned> clCollapsedIndices1{*this, "collapsed-indices-1", ::llvm::cl::desc("Which loop indices to combine into the position 1 loop index")};
1301
+ ::mlir::Pass::ListOption<unsigned> clCollapsedIndices2{*this, "collapsed-indices-2", ::llvm::cl::desc("Which loop indices to combine into the position 2 loop index")};
1302
+ };
1303
+ #undef GEN_PASS_CLASSES
1304
+ #endif // GEN_PASS_CLASSES
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/Patterns.h ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //===- Patterns.h - SCF dialect rewrite patterns ----------------*- C++ -*-===//
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_SCF_TRANSFORMS_PATTERNS_H
10
+ #define MLIR_DIALECT_SCF_TRANSFORMS_PATTERNS_H
11
+
12
+ #include "mlir/Dialect/SCF/IR/SCF.h"
13
+ #include "mlir/Dialect/SCF/Transforms/Transforms.h"
14
+ #include "mlir/IR/PatternMatch.h"
15
+
16
+ namespace mlir {
17
+
18
+ class ConversionTarget;
19
+ class TypeConverter;
20
+
21
+ namespace scf {
22
+
23
+ // TODO: such patterns should be auto-generated.
24
+ class ForLoopPipeliningPattern : public OpRewritePattern<ForOp> {
25
+ public:
26
+ ForLoopPipeliningPattern(const PipeliningOption &options,
27
+ MLIRContext *context)
28
+ : OpRewritePattern<ForOp>(context), options(options) {}
29
+ LogicalResult matchAndRewrite(ForOp forOp,
30
+ PatternRewriter &rewriter) const override {
31
+ return returningMatchAndRewrite(forOp, rewriter);
32
+ }
33
+
34
+ FailureOr<ForOp> returningMatchAndRewrite(ForOp forOp,
35
+ PatternRewriter &rewriter) const {
36
+ return pipelineForLoop(rewriter, forOp, options);
37
+ }
38
+
39
+ protected:
40
+ PipeliningOption options;
41
+ };
42
+
43
+ /// Populates patterns for SCF structural type conversions and sets up the
44
+ /// provided ConversionTarget with the appropriate legality configuration for
45
+ /// the ops to get converted properly.
46
+ ///
47
+ /// A "structural" type conversion is one where the underlying ops are
48
+ /// completely agnostic to the actual types involved and simply need to update
49
+ /// their types. An example of this is scf.if -- the scf.if op and the
50
+ /// corresponding scf.yield ops need to update their types accordingly to the
51
+ /// TypeConverter, but otherwise don't care what type conversions are happening.
52
+ void populateSCFStructuralTypeConversionsAndLegality(
53
+ TypeConverter &typeConverter, RewritePatternSet &patterns,
54
+ ConversionTarget &target);
55
+
56
+ /// Similar to `populateSCFStructuralTypeConversionsAndLegality` but does not
57
+ /// populate the conversion target.
58
+ void populateSCFStructuralTypeConversions(TypeConverter &typeConverter,
59
+ RewritePatternSet &patterns);
60
+
61
+ /// Updates the ConversionTarget with dynamic legality of SCF operations based
62
+ /// on the provided type converter.
63
+ void populateSCFStructuralTypeConversionTarget(
64
+ const TypeConverter &typeConverter, ConversionTarget &target);
65
+
66
+ /// Populates the provided pattern set with patterns that do 1:N type
67
+ /// conversions on (some) SCF ops. This is intended to be used with
68
+ /// applyPartialOneToNConversion.
69
+ void populateSCFStructuralOneToNTypeConversions(TypeConverter &typeConverter,
70
+ RewritePatternSet &patterns);
71
+
72
+ /// Populate patterns for SCF software pipelining transformation. See the
73
+ /// ForLoopPipeliningPattern for the transformation details.
74
+ void populateSCFLoopPipeliningPatterns(RewritePatternSet &patterns,
75
+ const PipeliningOption &options);
76
+
77
+ /// Populate patterns for canonicalizing operations inside SCF loop bodies.
78
+ /// At the moment, only affine.min/max computations with iteration variables,
79
+ /// loop bounds and loop steps are canonicalized.
80
+ void populateSCFForLoopCanonicalizationPatterns(RewritePatternSet &patterns);
81
+
82
+ } // namespace scf
83
+ } // namespace mlir
84
+
85
+ #endif // MLIR_DIALECT_SCF_TRANSFORMS_PATTERNS_H
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/TileUsingInterface.h ADDED
@@ -0,0 +1,246 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //===- TileUsingInterface.h - Tiling ops using TilingInterface --*- C++ -*-===//
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_SCF_TRANSFORMS_TILEUSINGINTERFACE_H
10
+ #define MLIR_DIALECT_SCF_TRANSFORMS_TILEUSINGINTERFACE_H
11
+
12
+ #include "mlir/Dialect/SCF/IR/SCF.h"
13
+ #include "mlir/Dialect/Tensor/Transforms/Transforms.h"
14
+ #include "mlir/IR/PatternMatch.h"
15
+ #include "mlir/Interfaces/TilingInterface.h"
16
+
17
+ #include <deque>
18
+
19
+ namespace mlir {
20
+ class Operation;
21
+ class RewriterBase;
22
+ class TilingInterface;
23
+ } // namespace mlir
24
+
25
+ namespace mlir {
26
+ namespace scf {
27
+
28
+ using SCFTileSizeComputationFunction =
29
+ std::function<SmallVector<OpFoldResult>(OpBuilder &, Operation *)>;
30
+
31
+ /// Options to use to control tiling.
32
+ struct SCFTilingOptions {
33
+ /// Computation function that returns the tile sizes for each operation.
34
+ /// Delayed construction of constant tile sizes should occur to interoperate
35
+ /// with folding.
36
+ SCFTileSizeComputationFunction tileSizeComputationFunction = nullptr;
37
+
38
+ SCFTilingOptions &
39
+ setTileSizeComputationFunction(SCFTileSizeComputationFunction fun) {
40
+ tileSizeComputationFunction = std::move(fun);
41
+ return *this;
42
+ }
43
+ /// Convenience function to set the `tileSizeComputationFunction` to a
44
+ /// function that computes tile sizes at the point they are needed. Allows
45
+ /// proper interaction with folding.
46
+ SCFTilingOptions &setTileSizes(ArrayRef<OpFoldResult> ts);
47
+
48
+ /// The interchange vector to reorder the tiled loops.
49
+ SmallVector<int64_t> interchangeVector = {};
50
+ SCFTilingOptions &setInterchange(ArrayRef<int64_t> interchange) {
51
+ interchangeVector = llvm::to_vector(interchange);
52
+ return *this;
53
+ }
54
+ };
55
+
56
+ /// Transformation information returned after tiling.
57
+ struct SCFTilingResult {
58
+ /// Tiled operations that are generated during tiling. The order does not
59
+ /// matter except the last op. The replacements are expected to be the results
60
+ /// of the last op.
61
+ SmallVector<Operation *> tiledOps;
62
+ /// The `scf.for` operations that iterate over the tiles.
63
+ SmallVector<Operation *> loops;
64
+ /// Values to use as replacements for the untiled op. Is the same size as the
65
+ /// number of results of the untiled op.
66
+ SmallVector<Value> replacements;
67
+ };
68
+
69
+ /// Method to tile an op that implements the `TilingInterface` using
70
+ /// `scf.for` for iterating over the tiles.
71
+ FailureOr<SCFTilingResult> tileUsingSCFForOp(RewriterBase &rewriter,
72
+ TilingInterface op,
73
+ const SCFTilingOptions &options);
74
+
75
+ /// Options used to control tile + fuse.
76
+ struct SCFTileAndFuseOptions {
77
+ /// The tiling options used to control the tiling of the consumer.
78
+ SCFTilingOptions tilingOptions;
79
+ SCFTileAndFuseOptions &setTilingOptions(SCFTilingOptions options) {
80
+ tilingOptions = options;
81
+ return *this;
82
+ }
83
+ };
84
+
85
+ /// Fuse the producer of the source of `candidateSliceOp` by computing the
86
+ /// required slice of the producer in-place. Note that the method
87
+ /// replaces the uses of `candidateSliceOp` with the tiled and fused producer
88
+ /// value but does not delete the slice operation.
89
+ struct SCFFuseProducerOfSliceResult {
90
+ OpResult origProducer; // Original untiled producer.
91
+ Value tiledAndFusedProducer; // Tile and fused producer value.
92
+ SmallVector<Operation *> tiledOps;
93
+ };
94
+ std::optional<SCFFuseProducerOfSliceResult>
95
+ tileAndFuseProducerOfSlice(RewriterBase &rewriter,
96
+ tensor::ExtractSliceOp candidateSliceOp,
97
+ MutableArrayRef<scf::ForOp> loops);
98
+
99
+ /// Reconstruct the fused producer from within the tiled-and-fused code. Based
100
+ /// on the slice of the producer computed in place it is possible that within
101
+ /// the loop nest same slice of the producer is computed multiple times. It is
102
+ /// in general not possible to recompute the value of the fused producer from
103
+ /// the tiled loop code in such cases. For the cases where no slice of the
104
+ /// producer is computed in a redundant fashion it is possible to reconstruct
105
+ /// the value of the original producer from within the tiled loop. It is upto
106
+ /// the caller to ensure that the producer is not computed redundantly within
107
+ /// the tiled loop nest. For example, consider
108
+ ///
109
+ /// ```mlir
110
+ /// %0 = linalg.matmul ins(...) outs(...) -> tensor<?x?xf32>
111
+ /// %1 = linalg.matmul ins(%0, ..) outs(...) -> tensor<?x?x?f32>
112
+ /// ```
113
+ ///
114
+ /// If `%1` is tiled in a 2D fashion and `%0` is fused with it, the resulting IR
115
+ /// is,
116
+ ///
117
+ /// ```mlir
118
+ /// %t1_0 = scf.for .... iter_args(%arg0 = ...) {
119
+ /// %t1_1 = scf.for ... iter_args(%arg1 = %arg0) {
120
+ /// ...
121
+ /// %t1_2 = linalg.matmul ins(...) outs(...) -> tensor<?x?xf32>
122
+ /// %t1_3 = linalg.matmul ins(%t1_2, ...)
123
+ /// %t1_4 = tensor.insert_slice %t1_3 into %arg1 ...
124
+ /// scf.yield %t1_4
125
+ /// }
126
+ /// scf.yield %t1_1
127
+ /// }
128
+ /// ```
129
+ ///
130
+ /// Here `%t1_2` is the same for all iterations of the inner `scf.for`. Instead
131
+ /// if `%1` were tiled only along the rows, the resultant code would be
132
+ ///
133
+ /// ```mlir
134
+ /// %t2_0 = scf.for .... iter_args(%arg0 = ...) {
135
+ /// ...
136
+ /// %t2_1 = linalg.matmul ins(...) outs(...) -> tensor<?x?xf32>
137
+ /// %t2_2 = linalg.matmul ins(%t2_1, ...)
138
+ /// %t2_3 = tensor.insert_slice %t2_2 into %arg0 ...
139
+ /// scf.yield %t2_3
140
+ /// }
141
+ /// ```
142
+ ///
143
+ /// Here there is no intersection in the different slices of `%t2_1` computed
144
+ /// across iterations of the `scf.for`. In such cases, the value of the original
145
+ /// `%0` can be reconstructed from within the loop body. This is useful in cases
146
+ /// where `%0` had other uses as well. If not reconstructed from within the loop
147
+ /// body, uses of `%0` could not be replaced, making it still live and the
148
+ /// fusion immaterial.
149
+ void yieldReplacementForFusedProducer(
150
+ RewriterBase &rewriter, tensor::ExtractSliceOp sliceOp,
151
+ scf::SCFFuseProducerOfSliceResult fusedProducerInfo,
152
+ MutableArrayRef<scf::ForOp> loops);
153
+
154
+ /// Transformation information returned after tile and fuse.
155
+ struct SCFTileAndFuseResult {
156
+ /// List of untiled operations that were fused with the tiled consumer.
157
+ llvm::SetVector<Operation *> fusedProducers;
158
+ /// List of tiled and fused operations generated. The first one in this list
159
+ /// is guaranteed to be the tiled operations generated during tiling of the
160
+ /// generated operation.
161
+ llvm::SetVector<Operation *> tiledAndFusedOps;
162
+ /// The `scf.for` operations that iterate over the tiles.
163
+ SmallVector<Operation *> loops;
164
+ /// The replacement values to use for the tiled and fused operations.
165
+ llvm::DenseMap<Value, Value> replacements;
166
+ };
167
+
168
+ /// Method to tile and fuse a sequence of operations, by tiling the consumer
169
+ /// and fusing its producers. Note that this assumes that it is valid to
170
+ /// tile+fuse the producer into the innermost tiled loop. Its up to the caller
171
+ /// to ensure that the tile sizes provided make this fusion valid.
172
+ ///
173
+ /// For example, for the following sequence
174
+ ///
175
+ /// ```mlir
176
+ /// %0 =
177
+ /// %1 = linalg.fill ... outs(%0 : ... )
178
+ /// %2 = linalg.matmul ... outs(%1 : ...) ...
179
+ /// ```
180
+ ///
181
+ /// it is legal to fuse the fill with the matmul only if the matmul is tiled
182
+ /// along the parallel dimensions and not the reduction dimension, i.e. the tile
183
+ /// size for the reduction dimension should be 0. The resulting fused
184
+ /// transformation is
185
+ ///
186
+ /// ```mlir
187
+ /// %1 = scf.for ... iter_args(%arg0 = %0)
188
+ /// %2 = tensor.extract_slice %arg0
189
+ /// %3 = linalg.fill .. outs(%2 : ... )
190
+ /// %4 = linalg.matmul .. outs(%3 : ...)
191
+ /// }
192
+ /// ```
193
+ FailureOr<SCFTileAndFuseResult>
194
+ tileConsumerAndFuseProducerGreedilyUsingSCFForOp(
195
+ RewriterBase &rewriter, TilingInterface consumer,
196
+ const SCFTileAndFuseOptions &options);
197
+
198
+ /// Method to lower an `op` that implements the `TilingInterface` to
199
+ /// loops/scalars.
200
+ FailureOr<SmallVector<scf::ForOp>>
201
+ lowerToLoopsUsingSCFForOp(RewriterBase &rewriter, TilingInterface op);
202
+
203
+ /// Transformation information returned after reduction tiling.
204
+ struct SCFReductionTilingResult {
205
+ /// The partial reduction tiled op generated.
206
+ Operation *parallelTiledOp;
207
+ /// The final reduction operation merging all the partial reductions.
208
+ Operation *mergeOp;
209
+ /// Initial op
210
+ Operation *initialOp;
211
+ /// The `scf.for` operations that iterate over the tiles.
212
+ SmallVector<scf::ForOp> loops;
213
+ };
214
+
215
+ /// Method to tile a reduction and generate a parallel op within a serial loop.
216
+ /// Each of the partial reductions are calculated in parallel. Then after the
217
+ /// loop all the partial reduction are merged into a final reduction.
218
+ /// For example for the following sequence
219
+ ///
220
+ /// ```mlir
221
+ /// %0 = linalg.generic %in ["parallel", "reduction"]
222
+ /// : tensor<7x9xf32> -> tensor<7xf32>
223
+ /// ```
224
+ ///
225
+ /// into:
226
+ ///
227
+ /// ```mlir
228
+ /// %0 = linalg.fill ... : tensor<7x4xf32>
229
+ /// %1 = scf.for ... iter_args(%arg0 = %0)
230
+ /// %2 = tensor.extract_slice %arg0 : tensor<7x4xf32> -> tensor<7x?xf32>
231
+ /// %3 = tensor.extract_slice %in : tensor<7x9xf32> -> tensor<7x?xf32>
232
+ /// %4 = linalg.generic %2, %3 ["parallel", "parallel"]
233
+ /// : tensor<7x?xf32> -> tensor<7x?xf32>
234
+ /// %5 = tensor.insert_slice %3, %0[0, 0] : tensor<7x4xf32>
235
+ /// }
236
+ /// %6 = linalg.generic %1 ["parallel", "reduction"]
237
+ /// : tensor<7x4xf32> -> tensor<7xf32>
238
+ /// ```
239
+ FailureOr<scf::SCFReductionTilingResult>
240
+ tileReductionUsingScf(RewriterBase &b, PartialReductionOpInterface op,
241
+ ArrayRef<OpFoldResult> tileSize);
242
+
243
+ } // namespace scf
244
+ } // namespace mlir
245
+
246
+ #endif // MLIR_DIALECT_SCF_TRANSFORMS_TILEUSINGINTERFACE_H
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Transforms/Transforms.h ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //===- Transforms.h - SCF dialect transformation utilities ------*- C++ -*-===//
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
+ // This header file defines transformations on SCF operations.
10
+ //
11
+ //===----------------------------------------------------------------------===//
12
+
13
+ #ifndef MLIR_DIALECT_SCF_TRANSFORMS_TRANSFORMS_H_
14
+ #define MLIR_DIALECT_SCF_TRANSFORMS_TRANSFORMS_H_
15
+
16
+ #include "mlir/Dialect/SCF/Utils/AffineCanonicalizationUtils.h"
17
+ #include "mlir/Support/LLVM.h"
18
+ #include "llvm/ADT/ArrayRef.h"
19
+
20
+ namespace mlir {
21
+
22
+ struct LogicalResult;
23
+ class Region;
24
+ class RewriterBase;
25
+ class Operation;
26
+ class Value;
27
+
28
+ namespace scf {
29
+
30
+ class IfOp;
31
+ class ForOp;
32
+ class ParallelOp;
33
+
34
+ /// Fuses all adjacent scf.parallel operations with identical bounds and step
35
+ /// into one scf.parallel operations. Uses a naive aliasing and dependency
36
+ /// analysis.
37
+ void naivelyFuseParallelOps(Region &region);
38
+
39
+ /// Rewrite a for loop with bounds/step that potentially do not divide evenly
40
+ /// into a for loop where the step divides the iteration space evenly, followed
41
+ /// by another scf.for for the last (partial) iteration (if any; returned via
42
+ /// `partialIteration`). This transformation is called "loop peeling".
43
+ ///
44
+ /// This transformation is beneficial for a wide range of transformations such
45
+ /// as vectorization or loop tiling: It enables additional canonicalizations
46
+ /// inside the peeled loop body such as rewriting masked loads into unmaked
47
+ /// loads.
48
+ ///
49
+ /// E.g., assuming a lower bound of 0 (for illustration purposes):
50
+ /// ```
51
+ /// scf.for %iv = %c0 to %ub step %c4 {
52
+ /// (loop body)
53
+ /// }
54
+ /// ```
55
+ /// is rewritten into the following pseudo IR:
56
+ /// ```
57
+ /// %newUb = %ub - (%ub mod %c4)
58
+ /// scf.for %iv = %c0 to %newUb step %c4 {
59
+ /// (loop body)
60
+ /// }
61
+ /// scf.for %iv2 = %newUb to %ub {
62
+ /// (loop body)
63
+ /// }
64
+ /// ```
65
+ ///
66
+ /// After loop peeling, this function tries to simplify affine.min and
67
+ /// affine.max ops in the body of the peeled loop and in the body of the partial
68
+ /// iteration loop, taking advantage of the fact that the peeled loop has only
69
+ /// "full" iterations. This simplification is expected to enable further
70
+ /// canonicalization opportunities through other patterns.
71
+ ///
72
+ /// The return value indicates whether the loop was rewritten or not. Loops are
73
+ /// not rewritten if:
74
+ /// * Loop step size is 1 or
75
+ /// * Loop bounds and step size are static, and step already divides the
76
+ /// iteration space evenly.
77
+ ///
78
+ /// Note: This function rewrites the given scf.for loop in-place and creates a
79
+ /// new scf.for operation for the last iteration. It replaces all uses of the
80
+ /// unpeeled loop with the results of the newly generated scf.for.
81
+ LogicalResult peelForLoopAndSimplifyBounds(RewriterBase &rewriter, ForOp forOp,
82
+ scf::ForOp &partialIteration);
83
+
84
+ /// Tile a parallel loop of the form
85
+ /// scf.parallel (%i0, %i1) = (%arg0, %arg1) to (%arg2, %arg3)
86
+ /// step (%arg4, %arg5)
87
+ ///
88
+ /// into
89
+ /// scf.parallel (%i0, %i1) = (%arg0, %arg1) to (%arg2, %arg3)
90
+ /// step (%arg4*tileSize[0],
91
+ /// %arg5*tileSize[1])
92
+ /// scf.parallel (%j0, %j1) = (0, 0) to (min(tileSize[0], %arg2-%j0)
93
+ /// min(tileSize[1], %arg3-%j1))
94
+ /// step (%arg4, %arg5)
95
+ /// The old loop is replaced with the new one.
96
+ ///
97
+ /// The function returns the resulting ParallelOps, i.e. {outer_loop_op,
98
+ /// inner_loop_op}.
99
+ std::pair<ParallelOp, ParallelOp>
100
+ tileParallelLoop(ParallelOp op, llvm::ArrayRef<int64_t> tileSizes,
101
+ bool noMinMaxBounds);
102
+
103
+ /// Options to dictate how loops should be pipelined.
104
+ struct PipeliningOption {
105
+ /// Lambda returning all the operation in the forOp, with their stage, in the
106
+ /// order picked for the pipelined loop.
107
+ using GetScheduleFnType = std::function<void(
108
+ scf::ForOp, std::vector<std::pair<Operation *, unsigned>> &)>;
109
+ GetScheduleFnType getScheduleFn = nullptr;
110
+ enum class PipelinerPart {
111
+ Prologue,
112
+ Kernel,
113
+ Epilogue,
114
+ };
115
+ /// Lambda called by the pipeliner to allow the user to annotate the IR while
116
+ /// it is generated.
117
+ /// The callback passes the operation created along with the part of the
118
+ /// pipeline and the iteration index. The iteration index is always 0 for the
119
+ /// kernel. For the prologue and epilogue, it corresponds to the iteration
120
+ /// peeled out of the loop in the range [0, maxStage[.
121
+ using AnnotationlFnType =
122
+ std::function<void(Operation *, PipelinerPart, unsigned)>;
123
+ AnnotationlFnType annotateFn = nullptr;
124
+
125
+ /// Control whether the epilogue should be peeled out of the loop or
126
+ /// operations should be predicated to skip the early stages in the last loop
127
+ /// iterations. If the epilogue is predicated; the user needs to provide a
128
+ /// lambda to generate the predicated version of operations.
129
+ bool peelEpilogue = true;
130
+
131
+ // Callback to predicate operations when the prologue or epilogue are not
132
+ // peeled. This takes the original operation, an i1 predicate value and the
133
+ // pattern rewriter. It is expected to replace the given operation with
134
+ // the predicated equivalent and return it, or return nullptr if the
135
+ // predication is impossible. In the latter case, pipelining will fail and
136
+ // may leave IR in a partially transformed state.
137
+ using PredicateOpFn =
138
+ std::function<Operation *(RewriterBase &, Operation *, Value)>;
139
+ PredicateOpFn predicateFn = nullptr;
140
+
141
+ // TODO: add option to decide if the prologue should be peeled.
142
+ };
143
+
144
+ /// Generate a pipelined version of the scf.for loop based on the schedule given
145
+ /// as option. This applies the mechanical transformation of changing the loop
146
+ /// and generating the prologue/epilogue for the pipelining and doesn't make any
147
+ /// decision regarding the schedule.
148
+ /// Based on the options the loop is split into several stages.
149
+ /// The transformation assumes that the scheduling given by user is valid.
150
+ /// For example if we break a loop into 3 stages named S0, S1, S2 we would
151
+ /// generate the following code with the number in parenthesis as the iteration
152
+ /// index:
153
+ ///
154
+ /// S0(0) // Prologue
155
+ /// S0(1) S1(0) // Prologue
156
+ /// scf.for %I = %C0 to %N - 2 {
157
+ /// S0(I+2) S1(I+1) S2(I) // Pipelined kernel
158
+ /// }
159
+ /// S1(N) S2(N-1) // Epilogue
160
+ /// S2(N) // Epilogue
161
+ ///
162
+ /// If `modifiedIR` is provided, it will be set to a value that indicates
163
+ /// whether pipelining modified the IR before failing, signaling to the caller
164
+ /// whether they can proceed with different transformations.
165
+ FailureOr<ForOp> pipelineForLoop(RewriterBase &rewriter, ForOp forOp,
166
+ const PipeliningOption &options,
167
+ bool *modifiedIR = nullptr);
168
+
169
+ } // namespace scf
170
+ } // namespace mlir
171
+
172
+ #endif // MLIR_DIALECT_SCF_TRANSFORMS_TRANSFORMS_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Utils/AffineCanonicalizationUtils.h ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //===- AffineCanonicalizationUtils.h ----------------------------*- C++ -*-===//
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
+ // This header file defines utility functions to canonicalize affine ops
10
+ // within SCF op regions.
11
+ //
12
+ //===----------------------------------------------------------------------===//
13
+
14
+ #ifndef MLIR_DIALECT_SCF_UTILS_AFFINECANONICALIZATIONUTILS_H_
15
+ #define MLIR_DIALECT_SCF_UTILS_AFFINECANONICALIZATIONUTILS_H_
16
+
17
+ #include "mlir/Support/LLVM.h"
18
+ #include "mlir/Support/LogicalResult.h"
19
+
20
+ namespace mlir {
21
+ class AffineMap;
22
+ struct LogicalResult;
23
+ class Operation;
24
+ class OpFoldResult;
25
+ class RewriterBase;
26
+ class Value;
27
+ class ValueRange;
28
+
29
+ namespace affine {
30
+ class FlatAffineValueConstraints;
31
+ } // namespace affine
32
+
33
+ namespace scf {
34
+ class IfOp;
35
+
36
+ /// Match "for loop"-like operations: If the first parameter is an iteration
37
+ /// variable, return lower/upper bounds via the second/third parameter and the
38
+ /// step size via the last parameter. The function should return `success` in
39
+ /// that case. If the first parameter is not an iteration variable, return
40
+ /// `failure`.
41
+ using LoopMatcherFn = function_ref<LogicalResult(
42
+ Value, OpFoldResult &, OpFoldResult &, OpFoldResult &)>;
43
+
44
+ /// Match "for loop"-like operations from the SCF dialect.
45
+ LogicalResult matchForLikeLoop(Value iv, OpFoldResult &lb, OpFoldResult &ub,
46
+ OpFoldResult &step);
47
+
48
+ /// Populate the given constraint set with induction variable constraints of a
49
+ /// "for" loop with the given range and step.
50
+ LogicalResult addLoopRangeConstraints(affine::FlatAffineValueConstraints &cstr,
51
+ Value iv, OpFoldResult lb,
52
+ OpFoldResult ub, OpFoldResult step);
53
+
54
+ /// Try to canonicalize the given affine.min/max operation in the context of
55
+ /// for `loops` with a known range.
56
+ ///
57
+ /// `loopMatcher` is used to retrieve loop bounds and the step size for a given
58
+ /// iteration variable.
59
+ ///
60
+ /// Note: `loopMatcher` allows this function to be used with any "for loop"-like
61
+ /// operation (scf.for, scf.parallel and even ops defined in other dialects).
62
+ LogicalResult canonicalizeMinMaxOpInLoop(RewriterBase &rewriter, Operation *op,
63
+ LoopMatcherFn loopMatcher);
64
+
65
+ /// Try to simplify the given affine.min/max operation `op` after loop peeling.
66
+ /// This function can simplify min/max operations such as (ub is the previous
67
+ /// upper bound of the unpeeled loop):
68
+ /// ```
69
+ /// #map = affine_map<(d0)[s0, s1] -> (s0, -d0 + s1)>
70
+ /// %r = affine.min #map(%iv)[%step, %ub]
71
+ /// ```
72
+ /// and rewrites them into (in the case the peeled loop):
73
+ /// ```
74
+ /// %r = %step
75
+ /// ```
76
+ /// min/max operations inside the partial iteration are rewritten in a similar
77
+ /// way.
78
+ LogicalResult rewritePeeledMinMaxOp(RewriterBase &rewriter, Operation *op,
79
+ Value iv, Value ub, Value step,
80
+ bool insideLoop);
81
+
82
+ } // namespace scf
83
+ } // namespace mlir
84
+
85
+ #endif // MLIR_DIALECT_SCF_UTILS_AFFINECANONICALIZATIONUTILS_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SCF/Utils/Utils.h ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //===- Utils.h - SCF dialect utilities --------------------------*- C++ -*-===//
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
+ // This header file defines prototypes for various SCF utilities.
10
+ //
11
+ //===----------------------------------------------------------------------===//
12
+
13
+ #ifndef MLIR_DIALECT_SCF_UTILS_UTILS_H_
14
+ #define MLIR_DIALECT_SCF_UTILS_UTILS_H_
15
+
16
+ #include "mlir/Dialect/SCF/IR/SCF.h"
17
+ #include "mlir/IR/PatternMatch.h"
18
+ #include "mlir/Support/LLVM.h"
19
+ #include "mlir/Support/LogicalResult.h"
20
+ #include "llvm/ADT/STLExtras.h"
21
+ #include <optional>
22
+
23
+ namespace mlir {
24
+ class Location;
25
+ class Operation;
26
+ class OpBuilder;
27
+ class Region;
28
+ class RewriterBase;
29
+ class ValueRange;
30
+ class Value;
31
+
32
+ namespace func {
33
+ class CallOp;
34
+ class FuncOp;
35
+ } // namespace func
36
+
37
+ /// Update a perfectly nested loop nest to yield new values from the innermost
38
+ /// loop and propagating it up through the loop nest. This function
39
+ /// - Expects `loopNest` to be a perfectly nested loop with outer most loop
40
+ /// first and innermost loop last.
41
+ /// - `newIterOperands` are the initialization values to be used for the
42
+ /// outermost loop
43
+ /// - `newYielValueFn` is the callback that generates the new values to be
44
+ /// yielded from within the innermost loop.
45
+ /// - The original loops are not erased, but are left in a "no-op" state where
46
+ /// the body of the loop just yields the basic block arguments that correspond
47
+ /// to the initialization values of a loop. The original loops are dead after
48
+ /// this method.
49
+ /// - If `replaceIterOperandsUsesInLoop` is true, all uses of the
50
+ /// `newIterOperands` within the generated new loop are replaced with the
51
+ /// corresponding `BlockArgument` in the loop body.
52
+ SmallVector<scf::ForOp> replaceLoopNestWithNewYields(
53
+ RewriterBase &rewriter, MutableArrayRef<scf::ForOp> loopNest,
54
+ ValueRange newIterOperands, const NewYieldValuesFn &newYieldValuesFn,
55
+ bool replaceIterOperandsUsesInLoop = true);
56
+
57
+ /// Outline a region with a single block into a new FuncOp.
58
+ /// Assumes the FuncOp result types is the type of the yielded operands of the
59
+ /// single block. This constraint makes it easy to determine the result.
60
+ /// This method also clones the `arith::ConstantIndexOp` at the start of
61
+ /// `outlinedFuncBody` to alloc simple canonicalizations.
62
+ /// Creates a new FuncOp and thus cannot be used in a FuncOp pass.
63
+ /// The client is responsible for providing a unique `funcName` that will not
64
+ /// collide with another FuncOp name. If `callOp` is provided, it will be set
65
+ /// to point to the operation that calls the outlined function.
66
+ // TODO: support more than single-block regions.
67
+ // TODO: more flexible constant handling.
68
+ FailureOr<func::FuncOp>
69
+ outlineSingleBlockRegion(RewriterBase &rewriter, Location loc, Region &region,
70
+ StringRef funcName, func::CallOp *callOp = nullptr);
71
+
72
+ /// Outline the then and/or else regions of `ifOp` as follows:
73
+ /// - if `thenFn` is not null, `thenFnName` must be specified and the `then`
74
+ /// region is inlined into a new FuncOp that is captured by the pointer.
75
+ /// - if `elseFn` is not null, `elseFnName` must be specified and the `else`
76
+ /// region is inlined into a new FuncOp that is captured by the pointer.
77
+ /// Creates new FuncOps and thus cannot be used in a FuncOp pass.
78
+ /// The client is responsible for providing a unique `thenFnName`/`elseFnName`
79
+ /// that will not collide with another FuncOp name.
80
+ LogicalResult outlineIfOp(RewriterBase &b, scf::IfOp ifOp, func::FuncOp *thenFn,
81
+ StringRef thenFnName, func::FuncOp *elseFn,
82
+ StringRef elseFnName);
83
+
84
+ /// Get a list of innermost parallel loops contained in `rootOp`. Innermost
85
+ /// parallel loops are those that do not contain further parallel loops
86
+ /// themselves.
87
+ bool getInnermostParallelLoops(Operation *rootOp,
88
+ SmallVectorImpl<scf::ParallelOp> &result);
89
+
90
+ /// Return the min/max expressions for `value` if it is an induction variable
91
+ /// from scf.for or scf.parallel loop.
92
+ /// if `loopFilter` is passed, the filter determines which loop to consider.
93
+ /// Other induction variables are ignored.
94
+ std::optional<std::pair<AffineExpr, AffineExpr>>
95
+ getSCFMinMaxExpr(Value value, SmallVectorImpl<Value> &dims,
96
+ SmallVectorImpl<Value> &symbols,
97
+ llvm::function_ref<bool(Operation *)> loopFilter = nullptr);
98
+
99
+ /// Replace a perfect nest of "for" loops with a single linearized loop. Assumes
100
+ /// `loops` contains a list of perfectly nested loops with bounds and steps
101
+ /// independent of any loop induction variable involved in the nest.
102
+ LogicalResult coalesceLoops(MutableArrayRef<scf::ForOp> loops);
103
+
104
+ /// Take the ParallelLoop and for each set of dimension indices, combine them
105
+ /// into a single dimension. combinedDimensions must contain each index into
106
+ /// loops exactly once.
107
+ void collapseParallelLoops(scf::ParallelOp loops,
108
+ ArrayRef<std::vector<unsigned>> combinedDimensions);
109
+
110
+ /// Unrolls this for operation by the specified unroll factor. Returns failure
111
+ /// if the loop cannot be unrolled either due to restrictions or due to invalid
112
+ /// unroll factors. Requires positive loop bounds and step. If specified,
113
+ /// annotates the Ops in each unrolled iteration by applying `annotateFn`.
114
+ LogicalResult loopUnrollByFactor(
115
+ scf::ForOp forOp, uint64_t unrollFactor,
116
+ function_ref<void(unsigned, Operation *, OpBuilder)> annotateFn = nullptr);
117
+
118
+ /// Tile a nest of standard for loops rooted at `rootForOp` by finding such
119
+ /// parametric tile sizes that the outer loops have a fixed number of iterations
120
+ /// as defined in `sizes`.
121
+ using Loops = SmallVector<scf::ForOp, 8>;
122
+ using TileLoops = std::pair<Loops, Loops>;
123
+ TileLoops extractFixedOuterLoops(scf::ForOp rootFOrOp, ArrayRef<int64_t> sizes);
124
+
125
+ /// Performs tiling fo imperfectly nested loops (with interchange) by
126
+ /// strip-mining the `forOps` by `sizes` and sinking them, in their order of
127
+ /// occurrence in `forOps`, under each of the `targets`.
128
+ /// Returns the new AffineForOps, one per each of (`forOps`, `targets`) pair,
129
+ /// nested immediately under each of `targets`.
130
+ SmallVector<Loops, 8> tile(ArrayRef<scf::ForOp> forOps, ArrayRef<Value> sizes,
131
+ ArrayRef<scf::ForOp> targets);
132
+
133
+ /// Performs tiling (with interchange) by strip-mining the `forOps` by `sizes`
134
+ /// and sinking them, in their order of occurrence in `forOps`, under `target`.
135
+ /// Returns the new AffineForOps, one per `forOps`, nested immediately under
136
+ /// `target`.
137
+ Loops tile(ArrayRef<scf::ForOp> forOps, ArrayRef<Value> sizes,
138
+ scf::ForOp target);
139
+
140
+ /// Tile a nest of scf::ForOp loops rooted at `rootForOp` with the given
141
+ /// (parametric) sizes. Sizes are expected to be strictly positive values at
142
+ /// runtime. If more sizes than loops are provided, discard the trailing values
143
+ /// in sizes. Assumes the loop nest is permutable.
144
+ /// Returns the newly created intra-tile loops.
145
+ Loops tilePerfectlyNested(scf::ForOp rootForOp, ArrayRef<Value> sizes);
146
+
147
+ /// Get perfectly nested sequence of loops starting at root of loop nest
148
+ /// (the first op being another AffineFor, and the second op - a terminator).
149
+ /// A loop is perfectly nested iff: the first op in the loop's body is another
150
+ /// AffineForOp, and the second op is a terminator).
151
+ void getPerfectlyNestedLoops(SmallVectorImpl<scf::ForOp> &nestedLoops,
152
+ scf::ForOp root);
153
+
154
+ /// Given two scf.forall loops, `target` and `source`, fuses `target` into
155
+ /// `source`. Assumes that the given loops are siblings and are independent of
156
+ /// each other.
157
+ ///
158
+ /// This function does not perform any legality checks and simply fuses the
159
+ /// loops. The caller is responsible for ensuring that the loops are legal to
160
+ /// fuse.
161
+ scf::ForallOp fuseIndependentSiblingForallLoops(scf::ForallOp target,
162
+ scf::ForallOp source,
163
+ RewriterBase &rewriter);
164
+
165
+ } // namespace mlir
166
+
167
+ #endif // MLIR_DIALECT_SCF_UTILS_UTILS_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/Analysis/ShapeMappingAnalysis.h ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //===- ShapeMappingAnalysis.h - Preserve shape Info ------------*- C++ -*-===//
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_SHAPE_ANALYSIS_SHAPEMAPPINGANALYSIS_H_
10
+ #define MLIR_DIALECT_SHAPE_ANALYSIS_SHAPEMAPPINGANALYSIS_H_
11
+
12
+ #include "mlir/IR/BuiltinAttributes.h"
13
+ #include "mlir/IR/Value.h"
14
+ #include "llvm/ADT/DenseMap.h"
15
+ #include "llvm/ADT/STLExtras.h"
16
+ #include "llvm/ADT/SmallVector.h"
17
+
18
+ namespace mlir {
19
+
20
+ namespace shape {
21
+
22
+ /// ShapeMappingValue works as the value of ShapeMappingAnalysis table, where
23
+ /// `funcSymbol` is the symbol of mapping function, and `inputs` are the actual
24
+ /// parameters for the function.
25
+ struct ShapeMappingValue {
26
+ ShapeMappingValue() = default;
27
+ ShapeMappingValue(FlatSymbolRefAttr symbol, llvm::SmallVector<Value> &&inps)
28
+ : funcSymbol(symbol), inputs(inps) {}
29
+
30
+ FlatSymbolRefAttr funcSymbol;
31
+ llvm::SmallVector<Value> inputs;
32
+ };
33
+
34
+ /// ShapeMappingAnalysis is used together with OutlineShapeComputationPass to
35
+ /// preserve Value and corresponding shape function / arguments mapping
36
+ /// information
37
+ struct ShapeMappingAnalysis {
38
+ ShapeMappingAnalysis(Operation *op) : operation(op) { (void)operation; }
39
+
40
+ /// Dumps the shape mapping information to the given stream.
41
+ void print(raw_ostream &os) const {
42
+ os << "// ---- Shape Mapping Information -----\n";
43
+ for (const auto &it : shapeMapping) {
44
+ const ShapeMappingValue &mappingValue = it.second;
45
+ os << "// Shape for " << it.first << " :: " << mappingValue.funcSymbol;
46
+ llvm::interleaveComma(mappingValue.inputs, os << "(");
47
+ os << ")\n";
48
+ }
49
+ }
50
+
51
+ llvm::DenseMap<Value, ShapeMappingValue> shapeMapping;
52
+
53
+ private:
54
+ Operation *operation;
55
+ };
56
+
57
+ } // namespace shape
58
+ } // namespace mlir
59
+
60
+ #endif // MLIR_DIALECT_SHAPE_ANALYSIS_SHAPEMAPPINGANALYSIS_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/Shape.h ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //===- Shape.h - MLIR Shape dialect -----------------------------*- C++ -*-===//
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
+ // This file defines the shape dialect that is used to describe and solve shape
10
+ // relations of MLIR operations using ShapedType.
11
+ //
12
+ //===----------------------------------------------------------------------===//
13
+
14
+ #ifndef MLIR_DIALECT_SHAPE_IR_SHAPE_H
15
+ #define MLIR_DIALECT_SHAPE_IR_SHAPE_H
16
+
17
+ #include "mlir/Bytecode/BytecodeOpInterface.h"
18
+ #include "mlir/IR/BuiltinOps.h"
19
+ #include "mlir/IR/Dialect.h"
20
+ #include "mlir/IR/OpDefinition.h"
21
+ #include "mlir/IR/OpImplementation.h"
22
+ #include "mlir/IR/SymbolTable.h"
23
+ #include "mlir/Interfaces/CallInterfaces.h"
24
+ #include "mlir/Interfaces/CastInterfaces.h"
25
+ #include "mlir/Interfaces/ControlFlowInterfaces.h"
26
+ #include "mlir/Interfaces/FunctionInterfaces.h"
27
+ #include "mlir/Interfaces/InferTypeOpInterface.h"
28
+ #include "mlir/Interfaces/SideEffectInterfaces.h"
29
+
30
+ #define GET_TYPEDEF_CLASSES
31
+ #include "mlir/Dialect/Shape/IR/ShapeOpsTypes.h.inc"
32
+
33
+ namespace mlir {
34
+ class PatternRewriter;
35
+
36
+ namespace shape {
37
+
38
+ /// Alias type for extent tensors.
39
+ RankedTensorType getExtentTensorType(MLIRContext *ctx,
40
+ int64_t rank = ShapedType::kDynamic);
41
+
42
+ // Check if a type is an extent tensor, e.g., tensor<?xindex>.
43
+ bool isExtentTensorType(Type);
44
+
45
+ // Given an input shape Value, try to obtain the shape's values.
46
+ LogicalResult getShapeVec(Value input, SmallVectorImpl<int64_t> &shapeValues);
47
+
48
+ } // namespace shape
49
+ } // namespace mlir
50
+
51
+ #define GET_OP_CLASSES
52
+ #include "mlir/Dialect/Shape/IR/ShapeOps.h.inc"
53
+
54
+ #include "mlir/Dialect/Shape/IR/ShapeOpsDialect.h.inc"
55
+
56
+ #endif // MLIR_DIALECT_SHAPE_IR_SHAPE_H
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeCanonicalization.inc ADDED
@@ -0,0 +1,384 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2
+ |* *|
3
+ |* Rewriters *|
4
+ |* *|
5
+ |* Automatically generated file, do not edit! *|
6
+ |* From: ShapeCanonicalization.td *|
7
+ |* *|
8
+ \*===----------------------------------------------------------------------===*/
9
+
10
+ /* Generated from:
11
+ external/llvm-project/mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td:22
12
+ */
13
+ struct AssumingAllOneOp : public ::mlir::RewritePattern {
14
+ AssumingAllOneOp(::mlir::MLIRContext *context)
15
+ : ::mlir::RewritePattern("shape.assuming_all", 1, context, {}) {}
16
+ ::mlir::LogicalResult matchAndRewrite(::mlir::Operation *op0,
17
+ ::mlir::PatternRewriter &rewriter) const override {
18
+ // Variables for capturing values and attributes used while creating ops
19
+ ::mlir::Operation::operand_range args(op0->getOperands());
20
+ ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops;
21
+
22
+ // Match
23
+ tblgen_ops.push_back(op0);
24
+ auto castedOp0 = ::llvm::dyn_cast<::mlir::shape::AssumingAllOp>(op0); (void)castedOp0;
25
+ args = castedOp0.getODSOperands(0);
26
+ if (!((
27
+ args.size() == 1
28
+ ))){
29
+ return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) {
30
+ diag << "entities 'args' failed to satisfy constraint: ''";
31
+ });
32
+ }
33
+
34
+ // Rewrite
35
+ auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc;
36
+ ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values;
37
+
38
+ for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ args }) {
39
+ tblgen_repl_values.push_back(v);
40
+ }
41
+
42
+ rewriter.replaceOp(op0, tblgen_repl_values);
43
+ return ::mlir::success();
44
+ };
45
+ };
46
+
47
+ /* Generated from:
48
+ external/llvm-project/mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td:26
49
+ */
50
+ struct CstrBroadcastableEqOps : public ::mlir::RewritePattern {
51
+ CstrBroadcastableEqOps(::mlir::MLIRContext *context)
52
+ : ::mlir::RewritePattern("shape.cstr_broadcastable", 1, context, {"shape.const_witness"}) {}
53
+ ::mlir::LogicalResult matchAndRewrite(::mlir::Operation *op0,
54
+ ::mlir::PatternRewriter &rewriter) const override {
55
+ // Variables for capturing values and attributes used while creating ops
56
+ ::mlir::Operation::operand_range shapes(op0->getOperands());
57
+ ::mlir::shape::CstrBroadcastableOp op;
58
+ ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops;
59
+
60
+ // Match
61
+ tblgen_ops.push_back(op0);
62
+ auto castedOp0 = ::llvm::dyn_cast<::mlir::shape::CstrBroadcastableOp>(op0); (void)castedOp0;
63
+ op = castedOp0;
64
+ shapes = castedOp0.getODSOperands(0);
65
+ if (!((
66
+ llvm::all_equal(shapes)
67
+ ))){
68
+ return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) {
69
+ diag << "entities 'shapes' failed to satisfy constraint: ''";
70
+ });
71
+ }
72
+
73
+ // Rewrite
74
+ auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc;
75
+ ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values;
76
+ ::mlir::shape::ConstWitnessOp tblgen_ConstWitnessOp_0;
77
+ {
78
+ ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values;
79
+ ::llvm::SmallVector<::mlir::NamedAttribute, 4> tblgen_attrs; (void)tblgen_attrs;
80
+ if (auto tmpAttr = rewriter.getBoolAttr(true)) {
81
+ tblgen_attrs.emplace_back(rewriter.getStringAttr("passing"), tmpAttr);
82
+ }
83
+ ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types;
84
+ for (auto v: castedOp0.getODSResults(0)) {
85
+ tblgen_types.push_back(v.getType());
86
+ }
87
+ tblgen_ConstWitnessOp_0 = rewriter.create<::mlir::shape::ConstWitnessOp>(odsLoc, tblgen_types, tblgen_values, tblgen_attrs);
88
+ }
89
+
90
+ for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ConstWitnessOp_0.getODSResults(0) }) {
91
+ tblgen_repl_values.push_back(v);
92
+ }
93
+
94
+ rewriter.replaceOp(op0, tblgen_repl_values);
95
+ return ::mlir::success();
96
+ };
97
+ };
98
+
99
+ /* Generated from:
100
+ external/llvm-project/mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td:30
101
+ */
102
+ struct CstrEqEqOps : public ::mlir::RewritePattern {
103
+ CstrEqEqOps(::mlir::MLIRContext *context)
104
+ : ::mlir::RewritePattern("shape.cstr_eq", 1, context, {"shape.const_witness"}) {}
105
+ ::mlir::LogicalResult matchAndRewrite(::mlir::Operation *op0,
106
+ ::mlir::PatternRewriter &rewriter) const override {
107
+ // Variables for capturing values and attributes used while creating ops
108
+ ::mlir::Operation::operand_range shapes(op0->getOperands());
109
+ ::mlir::shape::CstrEqOp op;
110
+ ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops;
111
+
112
+ // Match
113
+ tblgen_ops.push_back(op0);
114
+ auto castedOp0 = ::llvm::dyn_cast<::mlir::shape::CstrEqOp>(op0); (void)castedOp0;
115
+ op = castedOp0;
116
+ shapes = castedOp0.getODSOperands(0);
117
+ if (!((
118
+ llvm::all_equal(shapes)
119
+ ))){
120
+ return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) {
121
+ diag << "entities 'shapes' failed to satisfy constraint: ''";
122
+ });
123
+ }
124
+
125
+ // Rewrite
126
+ auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc()}); (void)odsLoc;
127
+ ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values;
128
+ ::mlir::shape::ConstWitnessOp tblgen_ConstWitnessOp_0;
129
+ {
130
+ ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values;
131
+ ::llvm::SmallVector<::mlir::NamedAttribute, 4> tblgen_attrs; (void)tblgen_attrs;
132
+ if (auto tmpAttr = rewriter.getBoolAttr(true)) {
133
+ tblgen_attrs.emplace_back(rewriter.getStringAttr("passing"), tmpAttr);
134
+ }
135
+ ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types;
136
+ for (auto v: castedOp0.getODSResults(0)) {
137
+ tblgen_types.push_back(v.getType());
138
+ }
139
+ tblgen_ConstWitnessOp_0 = rewriter.create<::mlir::shape::ConstWitnessOp>(odsLoc, tblgen_types, tblgen_values, tblgen_attrs);
140
+ }
141
+
142
+ for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ConstWitnessOp_0.getODSResults(0) }) {
143
+ tblgen_repl_values.push_back(v);
144
+ }
145
+
146
+ rewriter.replaceOp(op0, tblgen_repl_values);
147
+ return ::mlir::success();
148
+ };
149
+ };
150
+
151
+ /* Generated from:
152
+ external/llvm-project/mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td:50
153
+ */
154
+ struct ExtractFromShapeOfExtentTensor : public ::mlir::RewritePattern {
155
+ ExtractFromShapeOfExtentTensor(::mlir::MLIRContext *context)
156
+ : ::mlir::RewritePattern("tensor.extract", 2, context, {"tensor.dim"}) {}
157
+ ::mlir::LogicalResult matchAndRewrite(::mlir::Operation *op0,
158
+ ::mlir::PatternRewriter &rewriter) const override {
159
+ // Variables for capturing values and attributes used while creating ops
160
+ ::mlir::Operation::operand_range indices(op0->getOperands());
161
+ ::mlir::Operation::operand_range arg(op0->getOperands());
162
+ ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops;
163
+
164
+ // Match
165
+ tblgen_ops.push_back(op0);
166
+ auto castedOp0 = ::llvm::dyn_cast<::mlir::tensor::ExtractOp>(op0); (void)castedOp0;
167
+ {
168
+ auto *op1 = (*castedOp0.getODSOperands(0).begin()).getDefiningOp();
169
+ if (!(op1)){
170
+ return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) {
171
+ diag << "There's no operation that defines operand 0 of castedOp0";
172
+ });
173
+ }
174
+ auto castedOp1 = ::llvm::dyn_cast<::mlir::shape::ShapeOfOp>(op1); (void)castedOp1;
175
+ if (!(castedOp1)){
176
+ return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) {
177
+ diag << "castedOp1 is not ::mlir::shape::ShapeOfOp type";
178
+ });
179
+ }
180
+ arg = castedOp1.getODSOperands(0);
181
+ tblgen_ops.push_back(op1);
182
+ }
183
+ indices = castedOp0.getODSOperands(1);
184
+
185
+ // Rewrite
186
+ auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc;
187
+ ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values;
188
+ auto nativeVar_0 = indices.front(); (void)nativeVar_0;
189
+ ::mlir::tensor::DimOp tblgen_DimOp_1;
190
+ {
191
+ ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values;
192
+ ::llvm::SmallVector<::mlir::NamedAttribute, 4> tblgen_attrs; (void)tblgen_attrs;
193
+ tblgen_values.push_back((*arg.begin()));
194
+ tblgen_values.push_back(nativeVar_0);
195
+ ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types;
196
+ for (auto v: castedOp0.getODSResults(0)) {
197
+ tblgen_types.push_back(v.getType());
198
+ }
199
+ tblgen_DimOp_1 = rewriter.create<::mlir::tensor::DimOp>(odsLoc, tblgen_types, tblgen_values, tblgen_attrs);
200
+ }
201
+
202
+ for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_DimOp_1.getODSResults(0) }) {
203
+ tblgen_repl_values.push_back(v);
204
+ }
205
+
206
+ rewriter.replaceOp(op0, tblgen_repl_values);
207
+ return ::mlir::success();
208
+ };
209
+ };
210
+
211
+ /* Generated from:
212
+ external/llvm-project/mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td:34
213
+ */
214
+ struct IndexToSizeToIndexCanonicalization : public ::mlir::RewritePattern {
215
+ IndexToSizeToIndexCanonicalization(::mlir::MLIRContext *context)
216
+ : ::mlir::RewritePattern("shape.size_to_index", 2, context, {}) {}
217
+ ::mlir::LogicalResult matchAndRewrite(::mlir::Operation *op0,
218
+ ::mlir::PatternRewriter &rewriter) const override {
219
+ // Variables for capturing values and attributes used while creating ops
220
+ ::mlir::Operation::operand_range arg(op0->getOperands());
221
+ ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops;
222
+
223
+ // Match
224
+ tblgen_ops.push_back(op0);
225
+ auto castedOp0 = ::llvm::dyn_cast<::mlir::shape::SizeToIndexOp>(op0); (void)castedOp0;
226
+ {
227
+ auto *op1 = (*castedOp0.getODSOperands(0).begin()).getDefiningOp();
228
+ if (!(op1)){
229
+ return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) {
230
+ diag << "There's no operation that defines operand 0 of castedOp0";
231
+ });
232
+ }
233
+ auto castedOp1 = ::llvm::dyn_cast<::mlir::shape::IndexToSizeOp>(op1); (void)castedOp1;
234
+ if (!(castedOp1)){
235
+ return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) {
236
+ diag << "castedOp1 is not ::mlir::shape::IndexToSizeOp type";
237
+ });
238
+ }
239
+ arg = castedOp1.getODSOperands(0);
240
+ tblgen_ops.push_back(op1);
241
+ }
242
+
243
+ // Rewrite
244
+ auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc;
245
+ ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values;
246
+
247
+ for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ arg }) {
248
+ tblgen_repl_values.push_back(v);
249
+ }
250
+
251
+ rewriter.replaceOp(op0, tblgen_repl_values);
252
+ return ::mlir::success();
253
+ };
254
+ };
255
+
256
+ /* Generated from:
257
+ external/llvm-project/mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td:38
258
+ */
259
+ struct SizeToIndexToSizeCanonicalization : public ::mlir::RewritePattern {
260
+ SizeToIndexToSizeCanonicalization(::mlir::MLIRContext *context)
261
+ : ::mlir::RewritePattern("shape.index_to_size", 2, context, {}) {}
262
+ ::mlir::LogicalResult matchAndRewrite(::mlir::Operation *op0,
263
+ ::mlir::PatternRewriter &rewriter) const override {
264
+ // Variables for capturing values and attributes used while creating ops
265
+ ::mlir::Operation::operand_range arg(op0->getOperands());
266
+ ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops;
267
+
268
+ // Match
269
+ tblgen_ops.push_back(op0);
270
+ auto castedOp0 = ::llvm::dyn_cast<::mlir::shape::IndexToSizeOp>(op0); (void)castedOp0;
271
+ {
272
+ auto *op1 = (*castedOp0.getODSOperands(0).begin()).getDefiningOp();
273
+ if (!(op1)){
274
+ return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) {
275
+ diag << "There's no operation that defines operand 0 of castedOp0";
276
+ });
277
+ }
278
+ auto castedOp1 = ::llvm::dyn_cast<::mlir::shape::SizeToIndexOp>(op1); (void)castedOp1;
279
+ if (!(castedOp1)){
280
+ return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) {
281
+ diag << "castedOp1 is not ::mlir::shape::SizeToIndexOp type";
282
+ });
283
+ }
284
+ arg = castedOp1.getODSOperands(0);
285
+ tblgen_ops.push_back(op1);
286
+ }
287
+
288
+ // Rewrite
289
+ auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc;
290
+ ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values;
291
+
292
+ for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ arg }) {
293
+ tblgen_repl_values.push_back(v);
294
+ }
295
+
296
+ rewriter.replaceOp(op0, tblgen_repl_values);
297
+ return ::mlir::success();
298
+ };
299
+ };
300
+
301
+ /* Generated from:
302
+ external/llvm-project/mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td:44
303
+ */
304
+ struct TensorCastConstShape : public ::mlir::RewritePattern {
305
+ TensorCastConstShape(::mlir::MLIRContext *context)
306
+ : ::mlir::RewritePattern("tensor.cast", 2, context, {"shape.const_shape"}) {}
307
+ ::mlir::LogicalResult matchAndRewrite(::mlir::Operation *op0,
308
+ ::mlir::PatternRewriter &rewriter) const override {
309
+ // Variables for capturing values and attributes used while creating ops
310
+ ::mlir::DenseIntElementsAttr arg;
311
+ ::mlir::tensor::CastOp res;
312
+ ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops;
313
+
314
+ // Match
315
+ tblgen_ops.push_back(op0);
316
+ auto castedOp0 = ::llvm::dyn_cast<::mlir::tensor::CastOp>(op0); (void)castedOp0;
317
+ res = castedOp0;
318
+ {
319
+ auto *op1 = (*castedOp0.getODSOperands(0).begin()).getDefiningOp();
320
+ if (!(op1)){
321
+ return rewriter.notifyMatchFailure(castedOp0, [&](::mlir::Diagnostic &diag) {
322
+ diag << "There's no operation that defines operand 0 of castedOp0";
323
+ });
324
+ }
325
+ auto castedOp1 = ::llvm::dyn_cast<::mlir::shape::ConstShapeOp>(op1); (void)castedOp1;
326
+ if (!(castedOp1)){
327
+ return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) {
328
+ diag << "castedOp1 is not ::mlir::shape::ConstShapeOp type";
329
+ });
330
+ }
331
+ {
332
+ auto tblgen_attr = op1->getAttrOfType<::mlir::DenseIntElementsAttr>("shape");(void)tblgen_attr;
333
+ if (!(tblgen_attr)){
334
+ return rewriter.notifyMatchFailure(op1, [&](::mlir::Diagnostic &diag) {
335
+ diag << "expected op 'shape.const_shape' to have attribute 'shape' of type '::mlir::DenseIntElementsAttr'";
336
+ });
337
+ }
338
+ arg = tblgen_attr;
339
+ }
340
+ tblgen_ops.push_back(op1);
341
+ }
342
+ if (!((
343
+ ::llvm::dyn_cast<ShapedType>((*res.getODSResults(0).begin()).getType()).hasStaticShape()
344
+ ))){
345
+ return rewriter.notifyMatchFailure(op0, [&](::mlir::Diagnostic &diag) {
346
+ diag << "entities 'res' failed to satisfy constraint: ''";
347
+ });
348
+ }
349
+
350
+ // Rewrite
351
+ auto odsLoc = rewriter.getFusedLoc({tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc;
352
+ ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values;
353
+ ::mlir::shape::ConstShapeOp tblgen_ConstShapeOp_0;
354
+ {
355
+ ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values;
356
+ ::llvm::SmallVector<::mlir::NamedAttribute, 4> tblgen_attrs; (void)tblgen_attrs;
357
+ if (auto tmpAttr = arg) {
358
+ tblgen_attrs.emplace_back(rewriter.getStringAttr("shape"), tmpAttr);
359
+ }
360
+ ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types;
361
+ for (auto v: castedOp0.getODSResults(0)) {
362
+ tblgen_types.push_back(v.getType());
363
+ }
364
+ tblgen_ConstShapeOp_0 = rewriter.create<::mlir::shape::ConstShapeOp>(odsLoc, tblgen_types, tblgen_values, tblgen_attrs);
365
+ }
366
+
367
+ for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ConstShapeOp_0.getODSResults(0) }) {
368
+ tblgen_repl_values.push_back(v);
369
+ }
370
+
371
+ rewriter.replaceOp(op0, tblgen_repl_values);
372
+ return ::mlir::success();
373
+ };
374
+ };
375
+
376
+ void LLVM_ATTRIBUTE_UNUSED populateWithGenerated(::mlir::RewritePatternSet &patterns) {
377
+ patterns.add<AssumingAllOneOp>(patterns.getContext());
378
+ patterns.add<CstrBroadcastableEqOps>(patterns.getContext());
379
+ patterns.add<CstrEqEqOps>(patterns.getContext());
380
+ patterns.add<ExtractFromShapeOfExtentTensor>(patterns.getContext());
381
+ patterns.add<IndexToSizeToIndexCanonicalization>(patterns.getContext());
382
+ patterns.add<SizeToIndexToSizeCanonicalization>(patterns.getContext());
383
+ patterns.add<TensorCastConstShape>(patterns.getContext());
384
+ }
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.cpp.inc ADDED
The diff for this file is too large to render. See raw diff
 
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.h.inc ADDED
The diff for this file is too large to render. See raw diff
 
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOpsDialect.cpp.inc ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2
+ |* *|
3
+ |* Dialect Definitions *|
4
+ |* *|
5
+ |* Automatically generated file, do not edit! *|
6
+ |* From: ShapeOps.td *|
7
+ |* *|
8
+ \*===----------------------------------------------------------------------===*/
9
+
10
+ MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::ShapeDialect)
11
+ namespace mlir {
12
+ namespace shape {
13
+
14
+ ShapeDialect::ShapeDialect(::mlir::MLIRContext *context)
15
+ : ::mlir::Dialect(getDialectNamespace(), context, ::mlir::TypeID::get<ShapeDialect>()) {
16
+
17
+ getContext()->loadDialect<arith::ArithDialect>();
18
+
19
+ getContext()->loadDialect<tensor::TensorDialect>();
20
+
21
+ initialize();
22
+ }
23
+
24
+ ShapeDialect::~ShapeDialect() = default;
25
+
26
+ } // namespace shape
27
+ } // namespace mlir
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOpsDialect.h.inc ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2
+ |* *|
3
+ |* Dialect Declarations *|
4
+ |* *|
5
+ |* Automatically generated file, do not edit! *|
6
+ |* From: ShapeOps.td *|
7
+ |* *|
8
+ \*===----------------------------------------------------------------------===*/
9
+
10
+ namespace mlir {
11
+ namespace shape {
12
+
13
+ class ShapeDialect : public ::mlir::Dialect {
14
+ explicit ShapeDialect(::mlir::MLIRContext *context);
15
+
16
+ void initialize();
17
+ friend class ::mlir::MLIRContext;
18
+ public:
19
+ ~ShapeDialect() override;
20
+ static constexpr ::llvm::StringLiteral getDialectNamespace() {
21
+ return ::llvm::StringLiteral("shape");
22
+ }
23
+
24
+ /// Parse a type registered to this dialect.
25
+ ::mlir::Type parseType(::mlir::DialectAsmParser &parser) const override;
26
+
27
+ /// Print a type registered to this dialect.
28
+ void printType(::mlir::Type type,
29
+ ::mlir::DialectAsmPrinter &os) const override;
30
+
31
+ /// Materialize a single constant operation from a given attribute value with
32
+ /// the desired resultant type.
33
+ ::mlir::Operation *materializeConstant(::mlir::OpBuilder &builder,
34
+ ::mlir::Attribute value,
35
+ ::mlir::Type type,
36
+ ::mlir::Location loc) override;
37
+
38
+ /// Provides a hook for verifying dialect attributes attached to the given
39
+ /// op.
40
+ ::mlir::LogicalResult verifyOperationAttribute(
41
+ ::mlir::Operation *op, ::mlir::NamedAttribute attribute) override;
42
+ };
43
+ } // namespace shape
44
+ } // namespace mlir
45
+ MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::ShapeDialect)
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOpsTypes.cpp.inc ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2
+ |* *|
3
+ |* TypeDef Definitions *|
4
+ |* *|
5
+ |* Automatically generated file, do not edit! *|
6
+ |* *|
7
+ \*===----------------------------------------------------------------------===*/
8
+
9
+ #ifdef GET_TYPEDEF_LIST
10
+ #undef GET_TYPEDEF_LIST
11
+
12
+ ::mlir::shape::ShapeType,
13
+ ::mlir::shape::SizeType,
14
+ ::mlir::shape::ValueShapeType,
15
+ ::mlir::shape::WitnessType
16
+
17
+ #endif // GET_TYPEDEF_LIST
18
+
19
+ #ifdef GET_TYPEDEF_CLASSES
20
+ #undef GET_TYPEDEF_CLASSES
21
+
22
+ static ::mlir::OptionalParseResult generatedTypeParser(::mlir::AsmParser &parser, ::llvm::StringRef *mnemonic, ::mlir::Type &value) {
23
+ return ::mlir::AsmParser::KeywordSwitch<::mlir::OptionalParseResult>(parser)
24
+ .Case(::mlir::shape::ShapeType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
25
+ value = ::mlir::shape::ShapeType::get(parser.getContext());
26
+ return ::mlir::success(!!value);
27
+ })
28
+ .Case(::mlir::shape::SizeType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
29
+ value = ::mlir::shape::SizeType::get(parser.getContext());
30
+ return ::mlir::success(!!value);
31
+ })
32
+ .Case(::mlir::shape::ValueShapeType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
33
+ value = ::mlir::shape::ValueShapeType::get(parser.getContext());
34
+ return ::mlir::success(!!value);
35
+ })
36
+ .Case(::mlir::shape::WitnessType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
37
+ value = ::mlir::shape::WitnessType::get(parser.getContext());
38
+ return ::mlir::success(!!value);
39
+ })
40
+ .Default([&](llvm::StringRef keyword, llvm::SMLoc) {
41
+ *mnemonic = keyword;
42
+ return std::nullopt;
43
+ });
44
+ }
45
+
46
+ static ::mlir::LogicalResult generatedTypePrinter(::mlir::Type def, ::mlir::AsmPrinter &printer) {
47
+ return ::llvm::TypeSwitch<::mlir::Type, ::mlir::LogicalResult>(def) .Case<::mlir::shape::ShapeType>([&](auto t) {
48
+ printer << ::mlir::shape::ShapeType::getMnemonic();
49
+ return ::mlir::success();
50
+ })
51
+ .Case<::mlir::shape::SizeType>([&](auto t) {
52
+ printer << ::mlir::shape::SizeType::getMnemonic();
53
+ return ::mlir::success();
54
+ })
55
+ .Case<::mlir::shape::ValueShapeType>([&](auto t) {
56
+ printer << ::mlir::shape::ValueShapeType::getMnemonic();
57
+ return ::mlir::success();
58
+ })
59
+ .Case<::mlir::shape::WitnessType>([&](auto t) {
60
+ printer << ::mlir::shape::WitnessType::getMnemonic();
61
+ return ::mlir::success();
62
+ })
63
+ .Default([](auto) { return ::mlir::failure(); });
64
+ }
65
+
66
+ namespace mlir {
67
+ namespace shape {
68
+ } // namespace shape
69
+ } // namespace mlir
70
+ MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::ShapeType)
71
+ namespace mlir {
72
+ namespace shape {
73
+ } // namespace shape
74
+ } // namespace mlir
75
+ MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::SizeType)
76
+ namespace mlir {
77
+ namespace shape {
78
+ } // namespace shape
79
+ } // namespace mlir
80
+ MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::ValueShapeType)
81
+ namespace mlir {
82
+ namespace shape {
83
+ } // namespace shape
84
+ } // namespace mlir
85
+ MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::shape::WitnessType)
86
+ namespace mlir {
87
+ namespace shape {
88
+
89
+ /// Parse a type registered to this dialect.
90
+ ::mlir::Type ShapeDialect::parseType(::mlir::DialectAsmParser &parser) const {
91
+ ::llvm::SMLoc typeLoc = parser.getCurrentLocation();
92
+ ::llvm::StringRef mnemonic;
93
+ ::mlir::Type genType;
94
+ auto parseResult = generatedTypeParser(parser, &mnemonic, genType);
95
+ if (parseResult.has_value())
96
+ return genType;
97
+
98
+ parser.emitError(typeLoc) << "unknown type `"
99
+ << mnemonic << "` in dialect `" << getNamespace() << "`";
100
+ return {};
101
+ }
102
+ /// Print a type registered to this dialect.
103
+ void ShapeDialect::printType(::mlir::Type type,
104
+ ::mlir::DialectAsmPrinter &printer) const {
105
+ if (::mlir::succeeded(generatedTypePrinter(type, printer)))
106
+ return;
107
+
108
+ }
109
+ } // namespace shape
110
+ } // namespace mlir
111
+
112
+ #endif // GET_TYPEDEF_CLASSES
113
+
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/IR/ShapeOpsTypes.h.inc ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2
+ |* *|
3
+ |* TypeDef Declarations *|
4
+ |* *|
5
+ |* Automatically generated file, do not edit! *|
6
+ |* *|
7
+ \*===----------------------------------------------------------------------===*/
8
+
9
+ #ifdef GET_TYPEDEF_CLASSES
10
+ #undef GET_TYPEDEF_CLASSES
11
+
12
+
13
+ namespace mlir {
14
+ class AsmParser;
15
+ class AsmPrinter;
16
+ } // namespace mlir
17
+ namespace mlir {
18
+ namespace shape {
19
+ class ShapeType;
20
+ class SizeType;
21
+ class ValueShapeType;
22
+ class WitnessType;
23
+ class ShapeType : public ::mlir::Type::TypeBase<ShapeType, ::mlir::Type, ::mlir::TypeStorage> {
24
+ public:
25
+ using Base::Base;
26
+ static constexpr ::llvm::StringLiteral getMnemonic() {
27
+ return {"shape"};
28
+ }
29
+
30
+ };
31
+ class SizeType : public ::mlir::Type::TypeBase<SizeType, ::mlir::Type, ::mlir::TypeStorage> {
32
+ public:
33
+ using Base::Base;
34
+ static constexpr ::llvm::StringLiteral getMnemonic() {
35
+ return {"size"};
36
+ }
37
+
38
+ };
39
+ class ValueShapeType : public ::mlir::Type::TypeBase<ValueShapeType, ::mlir::Type, ::mlir::TypeStorage> {
40
+ public:
41
+ using Base::Base;
42
+ static constexpr ::llvm::StringLiteral getMnemonic() {
43
+ return {"value_shape"};
44
+ }
45
+
46
+ };
47
+ class WitnessType : public ::mlir::Type::TypeBase<WitnessType, ::mlir::Type, ::mlir::TypeStorage> {
48
+ public:
49
+ using Base::Base;
50
+ static constexpr ::llvm::StringLiteral getMnemonic() {
51
+ return {"witness"};
52
+ }
53
+
54
+ };
55
+ } // namespace shape
56
+ } // namespace mlir
57
+ MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::ShapeType)
58
+ MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::SizeType)
59
+ MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::ValueShapeType)
60
+ MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::shape::WitnessType)
61
+
62
+ #endif // GET_TYPEDEF_CLASSES
63
+
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/Transforms/BufferizableOpInterfaceImpl.h ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //===- BufferizableOpInterfaceImpl.h - Impl. of BufferizableOpInterface ---===//
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_SHAPE_BUFFERIZABLEOPINTERFACEIMPL_H
10
+ #define MLIR_DIALECT_SHAPE_BUFFERIZABLEOPINTERFACEIMPL_H
11
+
12
+ namespace mlir {
13
+ class DialectRegistry;
14
+
15
+ namespace shape {
16
+ void registerBufferizableOpInterfaceExternalModels(DialectRegistry &registry);
17
+ } // namespace shape
18
+ } // namespace mlir
19
+
20
+ #endif // MLIR_DIALECT_SHAPE_BUFFERIZABLEOPINTERFACEIMPL_H
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/Transforms/Passes.h ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //===- Passes.h - Pass Entrypoints ------------------------------*- C++ -*-===//
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
+ // This header file defines prototypes that expose pass constructors in the
10
+ // shape transformation library.
11
+ //
12
+ //===----------------------------------------------------------------------===//
13
+
14
+ #ifndef MLIR_DIALECT_SHAPE_TRANSFORMS_PASSES_H_
15
+ #define MLIR_DIALECT_SHAPE_TRANSFORMS_PASSES_H_
16
+
17
+ #include "mlir/Pass/Pass.h"
18
+
19
+ namespace mlir {
20
+ class ConversionTarget;
21
+ class ModuleOp;
22
+ class TypeConverter;
23
+ namespace func {
24
+ class FuncOp;
25
+ } // namespace func
26
+ } // namespace mlir
27
+
28
+ namespace mlir {
29
+
30
+ #define GEN_PASS_DECL
31
+ #include "mlir/Dialect/Shape/Transforms/Passes.h.inc"
32
+
33
+ /// Creates an instance of the ShapeToShapeLowering pass that legalizes Shape
34
+ /// dialect to be convertible to Arith. For example, `shape.num_elements` get
35
+ /// transformed to `shape.reduce`, which can be lowered to SCF and Arith.
36
+ std::unique_ptr<Pass> createShapeToShapeLowering();
37
+
38
+ /// Collects a set of patterns to rewrite ops within the Shape dialect.
39
+ void populateShapeRewritePatterns(RewritePatternSet &patterns);
40
+
41
+ // Collects a set of patterns to replace all constraints with passing witnesses.
42
+ // This is intended to then allow all ShapeConstraint related ops and data to
43
+ // have no effects and allow them to be freely removed such as through
44
+ // canonicalization and dead code elimination.
45
+ //
46
+ // After this pass, no cstr_ operations exist.
47
+ void populateRemoveShapeConstraintsPatterns(RewritePatternSet &patterns);
48
+ std::unique_ptr<OperationPass<func::FuncOp>> createRemoveShapeConstraintsPass();
49
+
50
+ // Bufferizes shape dialect ops.
51
+ //
52
+ // Note that most shape dialect ops must be converted to std before
53
+ // bufferization happens, as they are intended to be bufferized at the std
54
+ // level.
55
+ std::unique_ptr<OperationPass<func::FuncOp>> createShapeBufferizePass();
56
+
57
+ /// Outline the shape computation part by adding shape.func and populate
58
+ /// conrresponding mapping infomation into ShapeMappingAnalysis.
59
+ std::unique_ptr<OperationPass<ModuleOp>> createOutlineShapeComputationPass();
60
+
61
+ //===----------------------------------------------------------------------===//
62
+ // Registration
63
+ //===----------------------------------------------------------------------===//
64
+
65
+ /// Generate the code for registering passes.
66
+ #define GEN_PASS_REGISTRATION
67
+ #include "mlir/Dialect/Shape/Transforms/Passes.h.inc"
68
+
69
+ } // namespace mlir
70
+
71
+ #endif // MLIR_DIALECT_SHAPE_TRANSFORMS_PASSES_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/Shape/Transforms/Passes.h.inc ADDED
@@ -0,0 +1,520 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Autogenerated by mlir-tblgen; don't manually edit */
2
+
3
+ #ifdef GEN_PASS_DECL
4
+ // Generate declarations for all passes.
5
+ #define GEN_PASS_DECL_OUTLINESHAPECOMPUTATION
6
+ #define GEN_PASS_DECL_REMOVESHAPECONSTRAINTS
7
+ #define GEN_PASS_DECL_SHAPEBUFFERIZE
8
+ #define GEN_PASS_DECL_SHAPETOSHAPELOWERING
9
+ #undef GEN_PASS_DECL
10
+ #endif // GEN_PASS_DECL
11
+
12
+ //===----------------------------------------------------------------------===//
13
+ // OutlineShapeComputation
14
+ //===----------------------------------------------------------------------===//
15
+ #ifdef GEN_PASS_DECL_OUTLINESHAPECOMPUTATION
16
+ #undef GEN_PASS_DECL_OUTLINESHAPECOMPUTATION
17
+ #endif // GEN_PASS_DECL_OUTLINESHAPECOMPUTATION
18
+ #ifdef GEN_PASS_DEF_OUTLINESHAPECOMPUTATION
19
+ namespace impl {
20
+
21
+ template <typename DerivedT>
22
+ class OutlineShapeComputationBase : public ::mlir::OperationPass<ModuleOp> {
23
+ public:
24
+ using Base = OutlineShapeComputationBase;
25
+
26
+ OutlineShapeComputationBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
27
+ OutlineShapeComputationBase(const OutlineShapeComputationBase &other) : ::mlir::OperationPass<ModuleOp>(other) {}
28
+
29
+ /// Returns the command-line argument attached to this pass.
30
+ static constexpr ::llvm::StringLiteral getArgumentName() {
31
+ return ::llvm::StringLiteral("outline-shape-computation");
32
+ }
33
+ ::llvm::StringRef getArgument() const override { return "outline-shape-computation"; }
34
+
35
+ ::llvm::StringRef getDescription() const override { return "Using shape.func to preserve shape computation"; }
36
+
37
+ /// Returns the derived pass name.
38
+ static constexpr ::llvm::StringLiteral getPassName() {
39
+ return ::llvm::StringLiteral("OutlineShapeComputation");
40
+ }
41
+ ::llvm::StringRef getName() const override { return "OutlineShapeComputation"; }
42
+
43
+ /// Support isa/dyn_cast functionality for the derived pass class.
44
+ static bool classof(const ::mlir::Pass *pass) {
45
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
46
+ }
47
+
48
+ /// A clone method to create a copy of this pass.
49
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
50
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
51
+ }
52
+
53
+ /// Return the dialect that must be loaded in the context before this pass.
54
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
55
+
56
+ registry.insert<shape::ShapeDialect>();
57
+
58
+ }
59
+
60
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
61
+ /// instantiation because Pass classes should only be visible by the current
62
+ /// library.
63
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(OutlineShapeComputationBase<DerivedT>)
64
+
65
+ protected:
66
+ private:
67
+ };
68
+ } // namespace impl
69
+ #undef GEN_PASS_DEF_OUTLINESHAPECOMPUTATION
70
+ #endif // GEN_PASS_DEF_OUTLINESHAPECOMPUTATION
71
+
72
+ //===----------------------------------------------------------------------===//
73
+ // RemoveShapeConstraints
74
+ //===----------------------------------------------------------------------===//
75
+ #ifdef GEN_PASS_DECL_REMOVESHAPECONSTRAINTS
76
+ #undef GEN_PASS_DECL_REMOVESHAPECONSTRAINTS
77
+ #endif // GEN_PASS_DECL_REMOVESHAPECONSTRAINTS
78
+ #ifdef GEN_PASS_DEF_REMOVESHAPECONSTRAINTS
79
+ namespace impl {
80
+
81
+ template <typename DerivedT>
82
+ class RemoveShapeConstraintsBase : public ::mlir::OperationPass<func::FuncOp> {
83
+ public:
84
+ using Base = RemoveShapeConstraintsBase;
85
+
86
+ RemoveShapeConstraintsBase() : ::mlir::OperationPass<func::FuncOp>(::mlir::TypeID::get<DerivedT>()) {}
87
+ RemoveShapeConstraintsBase(const RemoveShapeConstraintsBase &other) : ::mlir::OperationPass<func::FuncOp>(other) {}
88
+
89
+ /// Returns the command-line argument attached to this pass.
90
+ static constexpr ::llvm::StringLiteral getArgumentName() {
91
+ return ::llvm::StringLiteral("remove-shape-constraints");
92
+ }
93
+ ::llvm::StringRef getArgument() const override { return "remove-shape-constraints"; }
94
+
95
+ ::llvm::StringRef getDescription() const override { return "Replace all cstr_ ops with a true witness"; }
96
+
97
+ /// Returns the derived pass name.
98
+ static constexpr ::llvm::StringLiteral getPassName() {
99
+ return ::llvm::StringLiteral("RemoveShapeConstraints");
100
+ }
101
+ ::llvm::StringRef getName() const override { return "RemoveShapeConstraints"; }
102
+
103
+ /// Support isa/dyn_cast functionality for the derived pass class.
104
+ static bool classof(const ::mlir::Pass *pass) {
105
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
106
+ }
107
+
108
+ /// A clone method to create a copy of this pass.
109
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
110
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
111
+ }
112
+
113
+ /// Return the dialect that must be loaded in the context before this pass.
114
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
115
+
116
+ }
117
+
118
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
119
+ /// instantiation because Pass classes should only be visible by the current
120
+ /// library.
121
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(RemoveShapeConstraintsBase<DerivedT>)
122
+
123
+ protected:
124
+ private:
125
+ };
126
+ } // namespace impl
127
+ #undef GEN_PASS_DEF_REMOVESHAPECONSTRAINTS
128
+ #endif // GEN_PASS_DEF_REMOVESHAPECONSTRAINTS
129
+
130
+ //===----------------------------------------------------------------------===//
131
+ // ShapeBufferize
132
+ //===----------------------------------------------------------------------===//
133
+ #ifdef GEN_PASS_DECL_SHAPEBUFFERIZE
134
+ #undef GEN_PASS_DECL_SHAPEBUFFERIZE
135
+ #endif // GEN_PASS_DECL_SHAPEBUFFERIZE
136
+ #ifdef GEN_PASS_DEF_SHAPEBUFFERIZE
137
+ namespace impl {
138
+
139
+ template <typename DerivedT>
140
+ class ShapeBufferizeBase : public ::mlir::OperationPass<func::FuncOp> {
141
+ public:
142
+ using Base = ShapeBufferizeBase;
143
+
144
+ ShapeBufferizeBase() : ::mlir::OperationPass<func::FuncOp>(::mlir::TypeID::get<DerivedT>()) {}
145
+ ShapeBufferizeBase(const ShapeBufferizeBase &other) : ::mlir::OperationPass<func::FuncOp>(other) {}
146
+
147
+ /// Returns the command-line argument attached to this pass.
148
+ static constexpr ::llvm::StringLiteral getArgumentName() {
149
+ return ::llvm::StringLiteral("shape-bufferize");
150
+ }
151
+ ::llvm::StringRef getArgument() const override { return "shape-bufferize"; }
152
+
153
+ ::llvm::StringRef getDescription() const override { return "Bufferize the shape dialect."; }
154
+
155
+ /// Returns the derived pass name.
156
+ static constexpr ::llvm::StringLiteral getPassName() {
157
+ return ::llvm::StringLiteral("ShapeBufferize");
158
+ }
159
+ ::llvm::StringRef getName() const override { return "ShapeBufferize"; }
160
+
161
+ /// Support isa/dyn_cast functionality for the derived pass class.
162
+ static bool classof(const ::mlir::Pass *pass) {
163
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
164
+ }
165
+
166
+ /// A clone method to create a copy of this pass.
167
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
168
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
169
+ }
170
+
171
+ /// Return the dialect that must be loaded in the context before this pass.
172
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
173
+
174
+ registry.insert<bufferization::BufferizationDialect>();
175
+
176
+ registry.insert<memref::MemRefDialect>();
177
+
178
+ }
179
+
180
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
181
+ /// instantiation because Pass classes should only be visible by the current
182
+ /// library.
183
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ShapeBufferizeBase<DerivedT>)
184
+
185
+ protected:
186
+ private:
187
+ };
188
+ } // namespace impl
189
+ #undef GEN_PASS_DEF_SHAPEBUFFERIZE
190
+ #endif // GEN_PASS_DEF_SHAPEBUFFERIZE
191
+
192
+ //===----------------------------------------------------------------------===//
193
+ // ShapeToShapeLowering
194
+ //===----------------------------------------------------------------------===//
195
+ #ifdef GEN_PASS_DECL_SHAPETOSHAPELOWERING
196
+ #undef GEN_PASS_DECL_SHAPETOSHAPELOWERING
197
+ #endif // GEN_PASS_DECL_SHAPETOSHAPELOWERING
198
+ #ifdef GEN_PASS_DEF_SHAPETOSHAPELOWERING
199
+ namespace impl {
200
+
201
+ template <typename DerivedT>
202
+ class ShapeToShapeLoweringBase : public ::mlir::OperationPass<func::FuncOp> {
203
+ public:
204
+ using Base = ShapeToShapeLoweringBase;
205
+
206
+ ShapeToShapeLoweringBase() : ::mlir::OperationPass<func::FuncOp>(::mlir::TypeID::get<DerivedT>()) {}
207
+ ShapeToShapeLoweringBase(const ShapeToShapeLoweringBase &other) : ::mlir::OperationPass<func::FuncOp>(other) {}
208
+
209
+ /// Returns the command-line argument attached to this pass.
210
+ static constexpr ::llvm::StringLiteral getArgumentName() {
211
+ return ::llvm::StringLiteral("shape-to-shape-lowering");
212
+ }
213
+ ::llvm::StringRef getArgument() const override { return "shape-to-shape-lowering"; }
214
+
215
+ ::llvm::StringRef getDescription() const override { return "Legalize Shape dialect to be convertible to Arith"; }
216
+
217
+ /// Returns the derived pass name.
218
+ static constexpr ::llvm::StringLiteral getPassName() {
219
+ return ::llvm::StringLiteral("ShapeToShapeLowering");
220
+ }
221
+ ::llvm::StringRef getName() const override { return "ShapeToShapeLowering"; }
222
+
223
+ /// Support isa/dyn_cast functionality for the derived pass class.
224
+ static bool classof(const ::mlir::Pass *pass) {
225
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
226
+ }
227
+
228
+ /// A clone method to create a copy of this pass.
229
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
230
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
231
+ }
232
+
233
+ /// Return the dialect that must be loaded in the context before this pass.
234
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
235
+
236
+ }
237
+
238
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
239
+ /// instantiation because Pass classes should only be visible by the current
240
+ /// library.
241
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ShapeToShapeLoweringBase<DerivedT>)
242
+
243
+ protected:
244
+ private:
245
+ };
246
+ } // namespace impl
247
+ #undef GEN_PASS_DEF_SHAPETOSHAPELOWERING
248
+ #endif // GEN_PASS_DEF_SHAPETOSHAPELOWERING
249
+ #ifdef GEN_PASS_REGISTRATION
250
+
251
+ //===----------------------------------------------------------------------===//
252
+ // OutlineShapeComputation Registration
253
+ //===----------------------------------------------------------------------===//
254
+
255
+ inline void registerOutlineShapeComputation() {
256
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
257
+ return mlir::createOutlineShapeComputationPass();
258
+ });
259
+ }
260
+
261
+ // Old registration code, kept for temporary backwards compatibility.
262
+ inline void registerOutlineShapeComputationPass() {
263
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
264
+ return mlir::createOutlineShapeComputationPass();
265
+ });
266
+ }
267
+
268
+ //===----------------------------------------------------------------------===//
269
+ // RemoveShapeConstraints Registration
270
+ //===----------------------------------------------------------------------===//
271
+
272
+ inline void registerRemoveShapeConstraints() {
273
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
274
+ return mlir::createRemoveShapeConstraintsPass();
275
+ });
276
+ }
277
+
278
+ // Old registration code, kept for temporary backwards compatibility.
279
+ inline void registerRemoveShapeConstraintsPass() {
280
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
281
+ return mlir::createRemoveShapeConstraintsPass();
282
+ });
283
+ }
284
+
285
+ //===----------------------------------------------------------------------===//
286
+ // ShapeBufferize Registration
287
+ //===----------------------------------------------------------------------===//
288
+
289
+ inline void registerShapeBufferize() {
290
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
291
+ return mlir::createShapeBufferizePass();
292
+ });
293
+ }
294
+
295
+ // Old registration code, kept for temporary backwards compatibility.
296
+ inline void registerShapeBufferizePass() {
297
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
298
+ return mlir::createShapeBufferizePass();
299
+ });
300
+ }
301
+
302
+ //===----------------------------------------------------------------------===//
303
+ // ShapeToShapeLowering Registration
304
+ //===----------------------------------------------------------------------===//
305
+
306
+ inline void registerShapeToShapeLowering() {
307
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
308
+ return mlir::createShapeToShapeLowering();
309
+ });
310
+ }
311
+
312
+ // Old registration code, kept for temporary backwards compatibility.
313
+ inline void registerShapeToShapeLoweringPass() {
314
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
315
+ return mlir::createShapeToShapeLowering();
316
+ });
317
+ }
318
+
319
+ //===----------------------------------------------------------------------===//
320
+ // Shape Registration
321
+ //===----------------------------------------------------------------------===//
322
+
323
+ inline void registerShapePasses() {
324
+ registerOutlineShapeComputation();
325
+ registerRemoveShapeConstraints();
326
+ registerShapeBufferize();
327
+ registerShapeToShapeLowering();
328
+ }
329
+ #undef GEN_PASS_REGISTRATION
330
+ #endif // GEN_PASS_REGISTRATION
331
+ // Deprecated. Please use the new per-pass macros.
332
+ #ifdef GEN_PASS_CLASSES
333
+
334
+ template <typename DerivedT>
335
+ class OutlineShapeComputationBase : public ::mlir::OperationPass<ModuleOp> {
336
+ public:
337
+ using Base = OutlineShapeComputationBase;
338
+
339
+ OutlineShapeComputationBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
340
+ OutlineShapeComputationBase(const OutlineShapeComputationBase &other) : ::mlir::OperationPass<ModuleOp>(other) {}
341
+
342
+ /// Returns the command-line argument attached to this pass.
343
+ static constexpr ::llvm::StringLiteral getArgumentName() {
344
+ return ::llvm::StringLiteral("outline-shape-computation");
345
+ }
346
+ ::llvm::StringRef getArgument() const override { return "outline-shape-computation"; }
347
+
348
+ ::llvm::StringRef getDescription() const override { return "Using shape.func to preserve shape computation"; }
349
+
350
+ /// Returns the derived pass name.
351
+ static constexpr ::llvm::StringLiteral getPassName() {
352
+ return ::llvm::StringLiteral("OutlineShapeComputation");
353
+ }
354
+ ::llvm::StringRef getName() const override { return "OutlineShapeComputation"; }
355
+
356
+ /// Support isa/dyn_cast functionality for the derived pass class.
357
+ static bool classof(const ::mlir::Pass *pass) {
358
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
359
+ }
360
+
361
+ /// A clone method to create a copy of this pass.
362
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
363
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
364
+ }
365
+
366
+ /// Return the dialect that must be loaded in the context before this pass.
367
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
368
+
369
+ registry.insert<shape::ShapeDialect>();
370
+
371
+ }
372
+
373
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
374
+ /// instantiation because Pass classes should only be visible by the current
375
+ /// library.
376
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(OutlineShapeComputationBase<DerivedT>)
377
+
378
+ protected:
379
+ };
380
+
381
+ template <typename DerivedT>
382
+ class RemoveShapeConstraintsBase : public ::mlir::OperationPass<func::FuncOp> {
383
+ public:
384
+ using Base = RemoveShapeConstraintsBase;
385
+
386
+ RemoveShapeConstraintsBase() : ::mlir::OperationPass<func::FuncOp>(::mlir::TypeID::get<DerivedT>()) {}
387
+ RemoveShapeConstraintsBase(const RemoveShapeConstraintsBase &other) : ::mlir::OperationPass<func::FuncOp>(other) {}
388
+
389
+ /// Returns the command-line argument attached to this pass.
390
+ static constexpr ::llvm::StringLiteral getArgumentName() {
391
+ return ::llvm::StringLiteral("remove-shape-constraints");
392
+ }
393
+ ::llvm::StringRef getArgument() const override { return "remove-shape-constraints"; }
394
+
395
+ ::llvm::StringRef getDescription() const override { return "Replace all cstr_ ops with a true witness"; }
396
+
397
+ /// Returns the derived pass name.
398
+ static constexpr ::llvm::StringLiteral getPassName() {
399
+ return ::llvm::StringLiteral("RemoveShapeConstraints");
400
+ }
401
+ ::llvm::StringRef getName() const override { return "RemoveShapeConstraints"; }
402
+
403
+ /// Support isa/dyn_cast functionality for the derived pass class.
404
+ static bool classof(const ::mlir::Pass *pass) {
405
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
406
+ }
407
+
408
+ /// A clone method to create a copy of this pass.
409
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
410
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
411
+ }
412
+
413
+ /// Return the dialect that must be loaded in the context before this pass.
414
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
415
+
416
+ }
417
+
418
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
419
+ /// instantiation because Pass classes should only be visible by the current
420
+ /// library.
421
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(RemoveShapeConstraintsBase<DerivedT>)
422
+
423
+ protected:
424
+ };
425
+
426
+ template <typename DerivedT>
427
+ class ShapeBufferizeBase : public ::mlir::OperationPass<func::FuncOp> {
428
+ public:
429
+ using Base = ShapeBufferizeBase;
430
+
431
+ ShapeBufferizeBase() : ::mlir::OperationPass<func::FuncOp>(::mlir::TypeID::get<DerivedT>()) {}
432
+ ShapeBufferizeBase(const ShapeBufferizeBase &other) : ::mlir::OperationPass<func::FuncOp>(other) {}
433
+
434
+ /// Returns the command-line argument attached to this pass.
435
+ static constexpr ::llvm::StringLiteral getArgumentName() {
436
+ return ::llvm::StringLiteral("shape-bufferize");
437
+ }
438
+ ::llvm::StringRef getArgument() const override { return "shape-bufferize"; }
439
+
440
+ ::llvm::StringRef getDescription() const override { return "Bufferize the shape dialect."; }
441
+
442
+ /// Returns the derived pass name.
443
+ static constexpr ::llvm::StringLiteral getPassName() {
444
+ return ::llvm::StringLiteral("ShapeBufferize");
445
+ }
446
+ ::llvm::StringRef getName() const override { return "ShapeBufferize"; }
447
+
448
+ /// Support isa/dyn_cast functionality for the derived pass class.
449
+ static bool classof(const ::mlir::Pass *pass) {
450
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
451
+ }
452
+
453
+ /// A clone method to create a copy of this pass.
454
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
455
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
456
+ }
457
+
458
+ /// Return the dialect that must be loaded in the context before this pass.
459
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
460
+
461
+ registry.insert<bufferization::BufferizationDialect>();
462
+
463
+ registry.insert<memref::MemRefDialect>();
464
+
465
+ }
466
+
467
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
468
+ /// instantiation because Pass classes should only be visible by the current
469
+ /// library.
470
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ShapeBufferizeBase<DerivedT>)
471
+
472
+ protected:
473
+ };
474
+
475
+ template <typename DerivedT>
476
+ class ShapeToShapeLoweringBase : public ::mlir::OperationPass<func::FuncOp> {
477
+ public:
478
+ using Base = ShapeToShapeLoweringBase;
479
+
480
+ ShapeToShapeLoweringBase() : ::mlir::OperationPass<func::FuncOp>(::mlir::TypeID::get<DerivedT>()) {}
481
+ ShapeToShapeLoweringBase(const ShapeToShapeLoweringBase &other) : ::mlir::OperationPass<func::FuncOp>(other) {}
482
+
483
+ /// Returns the command-line argument attached to this pass.
484
+ static constexpr ::llvm::StringLiteral getArgumentName() {
485
+ return ::llvm::StringLiteral("shape-to-shape-lowering");
486
+ }
487
+ ::llvm::StringRef getArgument() const override { return "shape-to-shape-lowering"; }
488
+
489
+ ::llvm::StringRef getDescription() const override { return "Legalize Shape dialect to be convertible to Arith"; }
490
+
491
+ /// Returns the derived pass name.
492
+ static constexpr ::llvm::StringLiteral getPassName() {
493
+ return ::llvm::StringLiteral("ShapeToShapeLowering");
494
+ }
495
+ ::llvm::StringRef getName() const override { return "ShapeToShapeLowering"; }
496
+
497
+ /// Support isa/dyn_cast functionality for the derived pass class.
498
+ static bool classof(const ::mlir::Pass *pass) {
499
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
500
+ }
501
+
502
+ /// A clone method to create a copy of this pass.
503
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
504
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
505
+ }
506
+
507
+ /// Return the dialect that must be loaded in the context before this pass.
508
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
509
+
510
+ }
511
+
512
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
513
+ /// instantiation because Pass classes should only be visible by the current
514
+ /// library.
515
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ShapeToShapeLoweringBase<DerivedT>)
516
+
517
+ protected:
518
+ };
519
+ #undef GEN_PASS_CLASSES
520
+ #endif // GEN_PASS_CLASSES
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/Enums.h ADDED
@@ -0,0 +1,451 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //===- Enums.h - Enums for the SparseTensor dialect -------------*- C++ -*-===//
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
+ // Typedefs and enums shared between MLIR code for manipulating the
10
+ // IR, and the lightweight runtime support library for sparse tensor
11
+ // manipulations. That is, all the enums are used to define the API
12
+ // of the runtime library and hence are also needed when generating
13
+ // calls into the runtime library. Moveover, the `DimLevelType` enum
14
+ // is also used as the internal IR encoding of dimension level types,
15
+ // to avoid code duplication (e.g., for the predicates).
16
+ //
17
+ // This file also defines x-macros <https://en.wikipedia.org/wiki/X_Macro>
18
+ // so that we can generate variations of the public functions for each
19
+ // supported primary- and/or overhead-type.
20
+ //
21
+ // Because this file defines a library which is a dependency of the
22
+ // runtime library itself, this file must not depend on any MLIR internals
23
+ // (e.g., operators, attributes, ArrayRefs, etc) lest the runtime library
24
+ // inherit those dependencies.
25
+ //
26
+ //===----------------------------------------------------------------------===//
27
+
28
+ #ifndef MLIR_DIALECT_SPARSETENSOR_IR_ENUMS_H
29
+ #define MLIR_DIALECT_SPARSETENSOR_IR_ENUMS_H
30
+
31
+ // NOTE: Client code will need to include "mlir/ExecutionEngine/Float16bits.h"
32
+ // if they want to use the `MLIR_SPARSETENSOR_FOREVERY_V` macro.
33
+
34
+ #include <cinttypes>
35
+ #include <complex>
36
+ #include <optional>
37
+
38
+ namespace mlir {
39
+ namespace sparse_tensor {
40
+
41
+ /// This type is used in the public API at all places where MLIR expects
42
+ /// values with the built-in type "index". For now, we simply assume that
43
+ /// type is 64-bit, but targets with different "index" bitwidths should
44
+ /// link with an alternatively built runtime support library.
45
+ using index_type = uint64_t;
46
+
47
+ /// Encoding of overhead types (both position overhead and coordinate
48
+ /// overhead), for "overloading" @newSparseTensor.
49
+ enum class OverheadType : uint32_t {
50
+ kIndex = 0,
51
+ kU64 = 1,
52
+ kU32 = 2,
53
+ kU16 = 3,
54
+ kU8 = 4
55
+ };
56
+
57
+ // This x-macro calls its argument on every overhead type which has
58
+ // fixed-width. It excludes `index_type` because that type is often
59
+ // handled specially (e.g., by translating it into the architecture-dependent
60
+ // equivalent fixed-width overhead type).
61
+ #define MLIR_SPARSETENSOR_FOREVERY_FIXED_O(DO) \
62
+ DO(64, uint64_t) \
63
+ DO(32, uint32_t) \
64
+ DO(16, uint16_t) \
65
+ DO(8, uint8_t)
66
+
67
+ // This x-macro calls its argument on every overhead type, including
68
+ // `index_type`.
69
+ #define MLIR_SPARSETENSOR_FOREVERY_O(DO) \
70
+ MLIR_SPARSETENSOR_FOREVERY_FIXED_O(DO) \
71
+ DO(0, index_type)
72
+
73
+ // These are not just shorthands but indicate the particular
74
+ // implementation used (e.g., as opposed to C99's `complex double`,
75
+ // or MLIR's `ComplexType`).
76
+ using complex64 = std::complex<double>;
77
+ using complex32 = std::complex<float>;
78
+
79
+ /// Encoding of the elemental type, for "overloading" @newSparseTensor.
80
+ enum class PrimaryType : uint32_t {
81
+ kF64 = 1,
82
+ kF32 = 2,
83
+ kF16 = 3,
84
+ kBF16 = 4,
85
+ kI64 = 5,
86
+ kI32 = 6,
87
+ kI16 = 7,
88
+ kI8 = 8,
89
+ kC64 = 9,
90
+ kC32 = 10
91
+ };
92
+
93
+ // This x-macro includes all `V` types.
94
+ #define MLIR_SPARSETENSOR_FOREVERY_V(DO) \
95
+ DO(F64, double) \
96
+ DO(F32, float) \
97
+ DO(F16, f16) \
98
+ DO(BF16, bf16) \
99
+ DO(I64, int64_t) \
100
+ DO(I32, int32_t) \
101
+ DO(I16, int16_t) \
102
+ DO(I8, int8_t) \
103
+ DO(C64, complex64) \
104
+ DO(C32, complex32)
105
+
106
+ // This x-macro includes all `V` types and supports variadic arguments.
107
+ #define MLIR_SPARSETENSOR_FOREVERY_V_VAR(DO, ...) \
108
+ DO(F64, double, __VA_ARGS__) \
109
+ DO(F32, float, __VA_ARGS__) \
110
+ DO(F16, f16, __VA_ARGS__) \
111
+ DO(BF16, bf16, __VA_ARGS__) \
112
+ DO(I64, int64_t, __VA_ARGS__) \
113
+ DO(I32, int32_t, __VA_ARGS__) \
114
+ DO(I16, int16_t, __VA_ARGS__) \
115
+ DO(I8, int8_t, __VA_ARGS__) \
116
+ DO(C64, complex64, __VA_ARGS__) \
117
+ DO(C32, complex32, __VA_ARGS__)
118
+
119
+ // This x-macro calls its argument on every pair of overhead and `V` types.
120
+ #define MLIR_SPARSETENSOR_FOREVERY_V_O(DO) \
121
+ MLIR_SPARSETENSOR_FOREVERY_V_VAR(DO, 64, uint64_t) \
122
+ MLIR_SPARSETENSOR_FOREVERY_V_VAR(DO, 32, uint32_t) \
123
+ MLIR_SPARSETENSOR_FOREVERY_V_VAR(DO, 16, uint16_t) \
124
+ MLIR_SPARSETENSOR_FOREVERY_V_VAR(DO, 8, uint8_t) \
125
+ MLIR_SPARSETENSOR_FOREVERY_V_VAR(DO, 0, index_type)
126
+
127
+ constexpr bool isFloatingPrimaryType(PrimaryType valTy) {
128
+ return PrimaryType::kF64 <= valTy && valTy <= PrimaryType::kBF16;
129
+ }
130
+
131
+ constexpr bool isIntegralPrimaryType(PrimaryType valTy) {
132
+ return PrimaryType::kI64 <= valTy && valTy <= PrimaryType::kI8;
133
+ }
134
+
135
+ constexpr bool isRealPrimaryType(PrimaryType valTy) {
136
+ return PrimaryType::kF64 <= valTy && valTy <= PrimaryType::kI8;
137
+ }
138
+
139
+ constexpr bool isComplexPrimaryType(PrimaryType valTy) {
140
+ return PrimaryType::kC64 <= valTy && valTy <= PrimaryType::kC32;
141
+ }
142
+
143
+ /// The actions performed by @newSparseTensor.
144
+ enum class Action : uint32_t {
145
+ kEmpty = 0,
146
+ // newSparseTensor no longer handles `kFromFile=1`, so we leave this
147
+ // number reserved to help catch any code that still needs updating.
148
+ kFromCOO = 2,
149
+ kSparseToSparse = 3,
150
+ kEmptyCOO = 4,
151
+ kToCOO = 5,
152
+ kToIterator = 6,
153
+ kPack = 7,
154
+ };
155
+
156
+ /// This enum defines all the sparse representations supportable by
157
+ /// the SparseTensor dialect. We use a lightweight encoding to encode
158
+ /// both the "format" per se (dense, compressed, singleton) as well as
159
+ /// the "properties" (ordered, unique). The encoding is chosen for
160
+ /// performance of the runtime library, and thus may change in future
161
+ /// versions; consequently, client code should use the predicate functions
162
+ /// defined below, rather than relying on knowledge about the particular
163
+ /// binary encoding.
164
+ ///
165
+ /// The `Undef` "format" is a special value used internally for cases
166
+ /// where we need to store an undefined or indeterminate `DimLevelType`.
167
+ /// It should not be used externally, since it does not indicate an
168
+ /// actual/representable format.
169
+ ///
170
+ // TODO: We should generalize TwoOutOfFour to N out of M and use property to
171
+ // encode the value of N and M.
172
+ // TODO: Update DimLevelType to use lower 8 bits for storage formats and the
173
+ // higher 4 bits to store level properties. Consider LooseCompressed and
174
+ // TwoOutOfFour as properties instead of formats.
175
+ enum class DimLevelType : uint8_t {
176
+ Undef = 0, // 0b00000_00
177
+ Dense = 4, // 0b00001_00
178
+ Compressed = 8, // 0b00010_00
179
+ CompressedNu = 9, // 0b00010_01
180
+ CompressedNo = 10, // 0b00010_10
181
+ CompressedNuNo = 11, // 0b00010_11
182
+ Singleton = 16, // 0b00100_00
183
+ SingletonNu = 17, // 0b00100_01
184
+ SingletonNo = 18, // 0b00100_10
185
+ SingletonNuNo = 19, // 0b00100_11
186
+ LooseCompressed = 32, // 0b01000_00
187
+ LooseCompressedNu = 33, // 0b01000_01
188
+ LooseCompressedNo = 34, // 0b01000_10
189
+ LooseCompressedNuNo = 35, // 0b01000_11
190
+ TwoOutOfFour = 64, // 0b10000_00
191
+ };
192
+
193
+ /// This enum defines all supported storage format without the level properties.
194
+ enum class LevelFormat : uint8_t {
195
+ Dense = 4, // 0b00001_00
196
+ Compressed = 8, // 0b00010_00
197
+ Singleton = 16, // 0b00100_00
198
+ LooseCompressed = 32, // 0b01000_00
199
+ TwoOutOfFour = 64, // 0b10000_00
200
+ };
201
+
202
+ /// This enum defines all the nondefault properties for storage formats.
203
+ enum class LevelNondefaultProperty : uint8_t {
204
+ Nonunique = 1, // 0b00000_01
205
+ Nonordered = 2, // 0b00000_10
206
+ };
207
+
208
+ /// Returns string representation of the given dimension level type.
209
+ constexpr const char *toMLIRString(DimLevelType dlt) {
210
+ switch (dlt) {
211
+ case DimLevelType::Undef:
212
+ return "undef";
213
+ case DimLevelType::Dense:
214
+ return "dense";
215
+ case DimLevelType::Compressed:
216
+ return "compressed";
217
+ case DimLevelType::CompressedNu:
218
+ return "compressed(nonunique)";
219
+ case DimLevelType::CompressedNo:
220
+ return "compressed(nonordered)";
221
+ case DimLevelType::CompressedNuNo:
222
+ return "compressed(nonunique, nonordered)";
223
+ case DimLevelType::Singleton:
224
+ return "singleton";
225
+ case DimLevelType::SingletonNu:
226
+ return "singleton(nonunique)";
227
+ case DimLevelType::SingletonNo:
228
+ return "singleton(nonordered)";
229
+ case DimLevelType::SingletonNuNo:
230
+ return "singleton(nonunique, nonordered)";
231
+ case DimLevelType::LooseCompressed:
232
+ return "loose_compressed";
233
+ case DimLevelType::LooseCompressedNu:
234
+ return "loose_compressed(nonunique)";
235
+ case DimLevelType::LooseCompressedNo:
236
+ return "loose_compressed(nonordered)";
237
+ case DimLevelType::LooseCompressedNuNo:
238
+ return "loose_compressed(nonunique, nonordered)";
239
+ case DimLevelType::TwoOutOfFour:
240
+ return "block2_4";
241
+ }
242
+ return "";
243
+ }
244
+
245
+ /// Check that the `DimLevelType` contains a valid (possibly undefined) value.
246
+ constexpr bool isValidDLT(DimLevelType dlt) {
247
+ const uint8_t formatBits = static_cast<uint8_t>(dlt) >> 2;
248
+ const uint8_t propertyBits = static_cast<uint8_t>(dlt) & 3;
249
+ // If undefined or dense, then must be unique and ordered.
250
+ // Otherwise, the format must be one of the known ones.
251
+ return (formatBits <= 1 || formatBits == 16)
252
+ ? (propertyBits == 0)
253
+ : (formatBits == 2 || formatBits == 4 || formatBits == 8);
254
+ }
255
+
256
+ /// Check if the `DimLevelType` is the special undefined value.
257
+ constexpr bool isUndefDLT(DimLevelType dlt) {
258
+ return dlt == DimLevelType::Undef;
259
+ }
260
+
261
+ /// Check if the `DimLevelType` is dense.
262
+ constexpr bool isDenseDLT(DimLevelType dlt) {
263
+ return dlt == DimLevelType::Dense;
264
+ }
265
+
266
+ /// Check if the `DimLevelType` is 2:4
267
+ constexpr bool isTwoOutOfFourDLT(DimLevelType dlt) {
268
+ return dlt == DimLevelType::TwoOutOfFour;
269
+ }
270
+
271
+ // We use the idiom `(dlt & ~3) == format` in order to only return true
272
+ // for valid DLTs. Whereas the `dlt & format` idiom is a bit faster but
273
+ // can return false-positives on invalid DLTs.
274
+
275
+ /// Check if the `DimLevelType` is compressed (regardless of properties).
276
+ constexpr bool isCompressedDLT(DimLevelType dlt) {
277
+ return (static_cast<uint8_t>(dlt) & ~3) ==
278
+ static_cast<uint8_t>(DimLevelType::Compressed);
279
+ }
280
+
281
+ /// Check if the `DimLevelType` is compressed (regardless of properties).
282
+ constexpr bool isLooseCompressedDLT(DimLevelType dlt) {
283
+ return (static_cast<uint8_t>(dlt) & ~3) ==
284
+ static_cast<uint8_t>(DimLevelType::LooseCompressed);
285
+ }
286
+
287
+ /// Check if the `DimLevelType` is singleton (regardless of properties).
288
+ constexpr bool isSingletonDLT(DimLevelType dlt) {
289
+ return (static_cast<uint8_t>(dlt) & ~3) ==
290
+ static_cast<uint8_t>(DimLevelType::Singleton);
291
+ }
292
+
293
+ /// Check if the `DimLevelType` is ordered (regardless of storage format).
294
+ constexpr bool isOrderedDLT(DimLevelType dlt) {
295
+ return !(static_cast<uint8_t>(dlt) & 2);
296
+ }
297
+
298
+ /// Check if the `DimLevelType` is unique (regardless of storage format).
299
+ constexpr bool isUniqueDLT(DimLevelType dlt) {
300
+ return !(static_cast<uint8_t>(dlt) & 1);
301
+ }
302
+
303
+ /// Convert a DimLevelType to its corresponding LevelFormat.
304
+ /// Returns std::nullopt when input dlt is Undef.
305
+ constexpr std::optional<LevelFormat> getLevelFormat(DimLevelType dlt) {
306
+ if (dlt == DimLevelType::Undef)
307
+ return std::nullopt;
308
+ return static_cast<LevelFormat>(static_cast<uint8_t>(dlt) & ~3);
309
+ }
310
+
311
+ /// Convert a LevelFormat to its corresponding DimLevelType with the given
312
+ /// properties. Returns std::nullopt when the properties are not applicable for
313
+ /// the input level format.
314
+ /// TODO: factor out a new LevelProperties type so we can add new properties
315
+ /// without changing this function's signature
316
+ constexpr std::optional<DimLevelType>
317
+ buildLevelType(LevelFormat lf, bool ordered, bool unique) {
318
+ auto dlt = static_cast<DimLevelType>(static_cast<uint8_t>(lf) |
319
+ (ordered ? 0 : 2) | (unique ? 0 : 1));
320
+ return isValidDLT(dlt) ? std::optional(dlt) : std::nullopt;
321
+ }
322
+
323
+ /// Ensure the above conversion works as intended.
324
+ static_assert(
325
+ (getLevelFormat(DimLevelType::Undef) == std::nullopt &&
326
+ *getLevelFormat(DimLevelType::Dense) == LevelFormat::Dense &&
327
+ *getLevelFormat(DimLevelType::Compressed) == LevelFormat::Compressed &&
328
+ *getLevelFormat(DimLevelType::CompressedNu) == LevelFormat::Compressed &&
329
+ *getLevelFormat(DimLevelType::CompressedNo) == LevelFormat::Compressed &&
330
+ *getLevelFormat(DimLevelType::CompressedNuNo) == LevelFormat::Compressed &&
331
+ *getLevelFormat(DimLevelType::Singleton) == LevelFormat::Singleton &&
332
+ *getLevelFormat(DimLevelType::SingletonNu) == LevelFormat::Singleton &&
333
+ *getLevelFormat(DimLevelType::SingletonNo) == LevelFormat::Singleton &&
334
+ *getLevelFormat(DimLevelType::SingletonNuNo) == LevelFormat::Singleton),
335
+ "getLevelFormat conversion is broken");
336
+
337
+ static_assert(
338
+ (buildLevelType(LevelFormat::Dense, false, true) == std::nullopt &&
339
+ buildLevelType(LevelFormat::Dense, true, false) == std::nullopt &&
340
+ buildLevelType(LevelFormat::Dense, false, false) == std::nullopt &&
341
+ *buildLevelType(LevelFormat::Dense, true, true) == DimLevelType::Dense &&
342
+ buildLevelType(LevelFormat::TwoOutOfFour, false, true) == std::nullopt &&
343
+ buildLevelType(LevelFormat::TwoOutOfFour, true, false) == std::nullopt &&
344
+ buildLevelType(LevelFormat::TwoOutOfFour, false, false) == std::nullopt &&
345
+ *buildLevelType(LevelFormat::TwoOutOfFour, true, true) ==
346
+ DimLevelType::TwoOutOfFour &&
347
+ *buildLevelType(LevelFormat::Compressed, true, true) ==
348
+ DimLevelType::Compressed &&
349
+ *buildLevelType(LevelFormat::Compressed, true, false) ==
350
+ DimLevelType::CompressedNu &&
351
+ *buildLevelType(LevelFormat::Compressed, false, true) ==
352
+ DimLevelType::CompressedNo &&
353
+ *buildLevelType(LevelFormat::Compressed, false, false) ==
354
+ DimLevelType::CompressedNuNo &&
355
+ *buildLevelType(LevelFormat::Singleton, true, true) ==
356
+ DimLevelType::Singleton &&
357
+ *buildLevelType(LevelFormat::Singleton, true, false) ==
358
+ DimLevelType::SingletonNu &&
359
+ *buildLevelType(LevelFormat::Singleton, false, true) ==
360
+ DimLevelType::SingletonNo &&
361
+ *buildLevelType(LevelFormat::Singleton, false, false) ==
362
+ DimLevelType::SingletonNuNo),
363
+ "buildLevelType conversion is broken");
364
+
365
+ // Ensure the above predicates work as intended.
366
+ static_assert((isValidDLT(DimLevelType::Undef) &&
367
+ isValidDLT(DimLevelType::Dense) &&
368
+ isValidDLT(DimLevelType::Compressed) &&
369
+ isValidDLT(DimLevelType::CompressedNu) &&
370
+ isValidDLT(DimLevelType::CompressedNo) &&
371
+ isValidDLT(DimLevelType::CompressedNuNo) &&
372
+ isValidDLT(DimLevelType::Singleton) &&
373
+ isValidDLT(DimLevelType::SingletonNu) &&
374
+ isValidDLT(DimLevelType::SingletonNo) &&
375
+ isValidDLT(DimLevelType::SingletonNuNo) &&
376
+ isValidDLT(DimLevelType::LooseCompressed) &&
377
+ isValidDLT(DimLevelType::LooseCompressedNu) &&
378
+ isValidDLT(DimLevelType::LooseCompressedNo) &&
379
+ isValidDLT(DimLevelType::LooseCompressedNuNo) &&
380
+ isValidDLT(DimLevelType::TwoOutOfFour)),
381
+ "isValidDLT definition is broken");
382
+
383
+ static_assert((!isCompressedDLT(DimLevelType::Dense) &&
384
+ isCompressedDLT(DimLevelType::Compressed) &&
385
+ isCompressedDLT(DimLevelType::CompressedNu) &&
386
+ isCompressedDLT(DimLevelType::CompressedNo) &&
387
+ isCompressedDLT(DimLevelType::CompressedNuNo) &&
388
+ !isCompressedDLT(DimLevelType::Singleton) &&
389
+ !isCompressedDLT(DimLevelType::SingletonNu) &&
390
+ !isCompressedDLT(DimLevelType::SingletonNo) &&
391
+ !isCompressedDLT(DimLevelType::SingletonNuNo)),
392
+ "isCompressedDLT definition is broken");
393
+
394
+ static_assert((!isLooseCompressedDLT(DimLevelType::Dense) &&
395
+ isLooseCompressedDLT(DimLevelType::LooseCompressed) &&
396
+ isLooseCompressedDLT(DimLevelType::LooseCompressedNu) &&
397
+ isLooseCompressedDLT(DimLevelType::LooseCompressedNo) &&
398
+ isLooseCompressedDLT(DimLevelType::LooseCompressedNuNo) &&
399
+ !isLooseCompressedDLT(DimLevelType::Singleton) &&
400
+ !isLooseCompressedDLT(DimLevelType::SingletonNu) &&
401
+ !isLooseCompressedDLT(DimLevelType::SingletonNo) &&
402
+ !isLooseCompressedDLT(DimLevelType::SingletonNuNo)),
403
+ "isLooseCompressedDLT definition is broken");
404
+
405
+ static_assert((!isSingletonDLT(DimLevelType::Dense) &&
406
+ !isSingletonDLT(DimLevelType::Compressed) &&
407
+ !isSingletonDLT(DimLevelType::CompressedNu) &&
408
+ !isSingletonDLT(DimLevelType::CompressedNo) &&
409
+ !isSingletonDLT(DimLevelType::CompressedNuNo) &&
410
+ isSingletonDLT(DimLevelType::Singleton) &&
411
+ isSingletonDLT(DimLevelType::SingletonNu) &&
412
+ isSingletonDLT(DimLevelType::SingletonNo) &&
413
+ isSingletonDLT(DimLevelType::SingletonNuNo)),
414
+ "isSingletonDLT definition is broken");
415
+
416
+ static_assert((isOrderedDLT(DimLevelType::Dense) &&
417
+ isOrderedDLT(DimLevelType::TwoOutOfFour) &&
418
+ isOrderedDLT(DimLevelType::Compressed) &&
419
+ isOrderedDLT(DimLevelType::CompressedNu) &&
420
+ !isOrderedDLT(DimLevelType::CompressedNo) &&
421
+ !isOrderedDLT(DimLevelType::CompressedNuNo) &&
422
+ isOrderedDLT(DimLevelType::Singleton) &&
423
+ isOrderedDLT(DimLevelType::SingletonNu) &&
424
+ !isOrderedDLT(DimLevelType::SingletonNo) &&
425
+ !isOrderedDLT(DimLevelType::SingletonNuNo) &&
426
+ isOrderedDLT(DimLevelType::LooseCompressed) &&
427
+ isOrderedDLT(DimLevelType::LooseCompressedNu) &&
428
+ !isOrderedDLT(DimLevelType::LooseCompressedNo) &&
429
+ !isOrderedDLT(DimLevelType::LooseCompressedNuNo)),
430
+ "isOrderedDLT definition is broken");
431
+
432
+ static_assert((isUniqueDLT(DimLevelType::Dense) &&
433
+ isUniqueDLT(DimLevelType::TwoOutOfFour) &&
434
+ isUniqueDLT(DimLevelType::Compressed) &&
435
+ !isUniqueDLT(DimLevelType::CompressedNu) &&
436
+ isUniqueDLT(DimLevelType::CompressedNo) &&
437
+ !isUniqueDLT(DimLevelType::CompressedNuNo) &&
438
+ isUniqueDLT(DimLevelType::Singleton) &&
439
+ !isUniqueDLT(DimLevelType::SingletonNu) &&
440
+ isUniqueDLT(DimLevelType::SingletonNo) &&
441
+ !isUniqueDLT(DimLevelType::SingletonNuNo) &&
442
+ isUniqueDLT(DimLevelType::LooseCompressed) &&
443
+ !isUniqueDLT(DimLevelType::LooseCompressedNu) &&
444
+ isUniqueDLT(DimLevelType::LooseCompressedNo) &&
445
+ !isUniqueDLT(DimLevelType::LooseCompressedNuNo)),
446
+ "isUniqueDLT definition is broken");
447
+
448
+ } // namespace sparse_tensor
449
+ } // namespace mlir
450
+
451
+ #endif // MLIR_DIALECT_SPARSETENSOR_IR_ENUMS_H
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensor.h ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //===- SparseTensor.h - Sparse tensor dialect -------------------*- C++ -*-===//
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_SPARSETENSOR_IR_SPARSETENSOR_H_
10
+ #define MLIR_DIALECT_SPARSETENSOR_IR_SPARSETENSOR_H_
11
+
12
+ #include "mlir/Bytecode/BytecodeOpInterface.h"
13
+ #include "mlir/Dialect/SparseTensor/IR/Enums.h"
14
+ #include "mlir/IR/BuiltinTypes.h"
15
+ #include "mlir/IR/Dialect.h"
16
+ #include "mlir/IR/OpDefinition.h"
17
+ #include "mlir/IR/OpImplementation.h"
18
+ #include "mlir/IR/TensorEncoding.h"
19
+ #include "mlir/Interfaces/InferTypeOpInterface.h"
20
+ #include "mlir/Interfaces/SideEffectInterfaces.h"
21
+
22
+ //===----------------------------------------------------------------------===//
23
+ //
24
+ // Type aliases to help code be more self-documenting. Unfortunately
25
+ // these are not type-checked, so they only provide documentation rather
26
+ // than doing anything to prevent mixups.
27
+ //
28
+ // We must include these here (rather than in "SparseTensorType.h")
29
+ // because they are used by methods declared in the tablegen files.
30
+ //
31
+ //===----------------------------------------------------------------------===//
32
+
33
+ namespace mlir {
34
+ namespace sparse_tensor {
35
+
36
+ /// The type of dimension identifiers, and dimension-ranks. We use the
37
+ /// same type for both identifiers and ranks because the latter are used
38
+ /// mainly for ordering-comparisons against the former (just like how the
39
+ /// one-past-the-end iterators are used).
40
+ using Dimension = uint64_t;
41
+
42
+ /// The type of level identifiers, and level-ranks. We use the same
43
+ /// type for both identifiers and ranks because the latter are used
44
+ /// mainly for ordering-comparisons against the former (just like how
45
+ /// the one-past-the-end iterators are used).
46
+ using Level = uint64_t;
47
+
48
+ /// The type for individual components of a compile-time shape. We avoid
49
+ /// calling this "size" because we use the term "sizes" to indicate the
50
+ /// actual run-time sizes, whereas this type also allows the value
51
+ /// `ShapedType::kDynamic`.
52
+ using DynSize = int64_t;
53
+
54
+ /// The type for individual components of a compile-time shape which
55
+ /// are known not to be `ShapedType::kDynamic`.
56
+ using StaticSize = int64_t;
57
+
58
+ } // namespace sparse_tensor
59
+ } // namespace mlir
60
+
61
+ //===----------------------------------------------------------------------===//
62
+ // TableGen-defined classes
63
+ //===----------------------------------------------------------------------===//
64
+
65
+ // We must include Enums.h.inc before AttrDefs.h.inc due to dependency between
66
+ // StorageSpecifierKindAttr and StorageSpeciferKind Enum.
67
+
68
+ #define GET_ATTRDEF_CLASSES
69
+ #include "mlir/Dialect/SparseTensor/IR/SparseTensorAttrEnums.h.inc"
70
+
71
+ #define GET_ATTRDEF_CLASSES
72
+ #include "mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.h.inc"
73
+
74
+ #define GET_TYPEDEF_CLASSES
75
+ #include "mlir/Dialect/SparseTensor/IR/SparseTensorTypes.h.inc"
76
+
77
+ #define GET_OP_CLASSES
78
+ #include "mlir/Dialect/SparseTensor/IR/SparseTensorOps.h.inc"
79
+
80
+ #include "mlir/Dialect/SparseTensor/IR/SparseTensorOpsDialect.h.inc"
81
+
82
+ //===----------------------------------------------------------------------===//
83
+ // Additional convenience methods.
84
+ //===----------------------------------------------------------------------===//
85
+
86
+ namespace mlir {
87
+ namespace sparse_tensor {
88
+
89
+ // NOTE: `Value::getType` doesn't check for null before trying to
90
+ // dereference things. Therefore we check, because an assertion-failure
91
+ // is easier to debug than a segfault. Presumably other `T::getType`
92
+ // methods are similarly susceptible.
93
+
94
+ /// Convenience method to abbreviate casting `getType()`.
95
+ template <typename T>
96
+ inline RankedTensorType getRankedTensorType(T &&t) {
97
+ assert(static_cast<bool>(std::forward<T>(t)) &&
98
+ "getRankedTensorType got null argument");
99
+ return cast<RankedTensorType>(std::forward<T>(t).getType());
100
+ }
101
+
102
+ /// Convenience method to abbreviate casting `getType()`.
103
+ template <typename T>
104
+ inline MemRefType getMemRefType(T &&t) {
105
+ assert(static_cast<bool>(std::forward<T>(t)) &&
106
+ "getMemRefType got null argument");
107
+ return cast<MemRefType>(std::forward<T>(t).getType());
108
+ }
109
+
110
+ /// Convenience method to get a sparse encoding attribute from a type.
111
+ /// Returns null-attribute for any type without an encoding.
112
+ SparseTensorEncodingAttr getSparseTensorEncoding(Type type);
113
+
114
+ /// Convenience method to query whether a given DLT needs both position and
115
+ /// coordinates array or only coordinates array.
116
+ constexpr inline bool isDLTWithPos(DimLevelType dlt) {
117
+ return isLooseCompressedDLT(dlt) || isCompressedDLT(dlt);
118
+ }
119
+ constexpr inline bool isDLTWithCrd(DimLevelType dlt) {
120
+ return isSingletonDLT(dlt) || isLooseCompressedDLT(dlt) ||
121
+ isCompressedDLT(dlt);
122
+ }
123
+
124
+ /// Returns true iff the given sparse tensor encoding attribute has a trailing
125
+ /// COO region starting at the given level.
126
+ bool isCOOType(SparseTensorEncodingAttr enc, Level startLvl, bool isUnique);
127
+
128
+ /// Returns true iff the given type is a COO type where the last level
129
+ /// is unique.
130
+ bool isUniqueCOOType(Type tp);
131
+
132
+ /// Returns the starting level for a trailing COO region that spans
133
+ /// at least two levels. If no such COO region is found, then returns
134
+ /// the level-rank.
135
+ Level getCOOStart(SparseTensorEncodingAttr enc);
136
+
137
+ /// Helpers to setup a COO type.
138
+ RankedTensorType getCOOFromTypeWithOrdering(RankedTensorType src,
139
+ AffineMap ordering, bool ordered);
140
+
141
+ RankedTensorType getCOOFromType(RankedTensorType src, bool ordered);
142
+
143
+ /// Returns true iff MLIR operand has any sparse operand.
144
+ inline bool hasAnySparseOperand(Operation *op) {
145
+ return llvm::any_of(op->getOperands().getTypes(), [](Type t) {
146
+ return getSparseTensorEncoding(t) != nullptr;
147
+ });
148
+ }
149
+
150
+ /// Returns true iff MLIR operand has any sparse result.
151
+ inline bool hasAnySparseResult(Operation *op) {
152
+ return llvm::any_of(op->getResults().getTypes(), [](Type t) {
153
+ return getSparseTensorEncoding(t) != nullptr;
154
+ });
155
+ }
156
+
157
+ /// Returns true iff MLIR operand has any sparse operand or result.
158
+ inline bool hasAnySparseOperandOrResult(Operation *op) {
159
+ return hasAnySparseOperand(op) || hasAnySparseResult(op);
160
+ }
161
+
162
+ //
163
+ // Reordering.
164
+ //
165
+
166
+ // This CPP guard is to disable deprecation warnings for the LLVM
167
+ // build-bot, while making it easy to re-enable it for local development.
168
+ #if 0
169
+ #define DEPRECATED \
170
+ LLVM_DEPRECATED("The toOrigDim/toStoredDim functions are deprecated " \
171
+ "because they only work for permutations; therefore any " \
172
+ "code using them cannot support non-permutations.", \
173
+ "")
174
+ #else
175
+ #define DEPRECATED
176
+ #endif
177
+
178
+ /// [deprecated] Convenience method to translate the given level to the
179
+ /// corresponding dimension. Requires: `0 <= l < lvlRank`.
180
+ DEPRECATED Dimension toOrigDim(SparseTensorEncodingAttr enc, Level l);
181
+ DEPRECATED Dimension toOrigDim(RankedTensorType type, Level l);
182
+
183
+ /// [deprecated] Convenience method to translate the given dimension to
184
+ /// the corresponding level. Requires: `0 <= d < dimRank`.
185
+ DEPRECATED Level toStoredDim(SparseTensorEncodingAttr enc, Dimension d);
186
+ DEPRECATED Level toStoredDim(RankedTensorType type, Dimension d);
187
+
188
+ #undef DEPRECATED
189
+
190
+ namespace detail {
191
+ Type getIntegerOrIndexType(MLIRContext *ctx, unsigned bitwidth);
192
+ } // namespace detail
193
+
194
+ } // namespace sparse_tensor
195
+ } // namespace mlir
196
+
197
+ #endif // MLIR_DIALECT_SPARSETENSOR_IR_SPARSETENSOR_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.cpp.inc ADDED
@@ -0,0 +1,386 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2
+ |* *|
3
+ |* AttrDef Definitions *|
4
+ |* *|
5
+ |* Automatically generated file, do not edit! *|
6
+ |* *|
7
+ \*===----------------------------------------------------------------------===*/
8
+
9
+ #ifdef GET_ATTRDEF_LIST
10
+ #undef GET_ATTRDEF_LIST
11
+
12
+ ::mlir::sparse_tensor::SparseTensorDimSliceAttr,
13
+ ::mlir::sparse_tensor::SparseTensorEncodingAttr,
14
+ ::mlir::sparse_tensor::SparseTensorSortKindAttr,
15
+ ::mlir::sparse_tensor::StorageSpecifierKindAttr
16
+
17
+ #endif // GET_ATTRDEF_LIST
18
+
19
+ #ifdef GET_ATTRDEF_CLASSES
20
+ #undef GET_ATTRDEF_CLASSES
21
+
22
+ static ::mlir::OptionalParseResult generatedAttributeParser(::mlir::AsmParser &parser, ::llvm::StringRef *mnemonic, ::mlir::Type type, ::mlir::Attribute &value) {
23
+ return ::mlir::AsmParser::KeywordSwitch<::mlir::OptionalParseResult>(parser)
24
+ .Case(::mlir::sparse_tensor::SparseTensorDimSliceAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
25
+ value = ::mlir::sparse_tensor::SparseTensorDimSliceAttr::parse(parser, type);
26
+ return ::mlir::success(!!value);
27
+ })
28
+ .Case(::mlir::sparse_tensor::SparseTensorEncodingAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
29
+ value = ::mlir::sparse_tensor::SparseTensorEncodingAttr::parse(parser, type);
30
+ return ::mlir::success(!!value);
31
+ })
32
+ .Case(::mlir::sparse_tensor::SparseTensorSortKindAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
33
+ value = ::mlir::sparse_tensor::SparseTensorSortKindAttr::parse(parser, type);
34
+ return ::mlir::success(!!value);
35
+ })
36
+ .Case(::mlir::sparse_tensor::StorageSpecifierKindAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
37
+ value = ::mlir::sparse_tensor::StorageSpecifierKindAttr::parse(parser, type);
38
+ return ::mlir::success(!!value);
39
+ })
40
+ .Default([&](llvm::StringRef keyword, llvm::SMLoc) {
41
+ *mnemonic = keyword;
42
+ return std::nullopt;
43
+ });
44
+ }
45
+
46
+ static ::mlir::LogicalResult generatedAttributePrinter(::mlir::Attribute def, ::mlir::AsmPrinter &printer) {
47
+ return ::llvm::TypeSwitch<::mlir::Attribute, ::mlir::LogicalResult>(def) .Case<::mlir::sparse_tensor::SparseTensorDimSliceAttr>([&](auto t) {
48
+ printer << ::mlir::sparse_tensor::SparseTensorDimSliceAttr::getMnemonic();
49
+ t.print(printer);
50
+ return ::mlir::success();
51
+ })
52
+ .Case<::mlir::sparse_tensor::SparseTensorEncodingAttr>([&](auto t) {
53
+ printer << ::mlir::sparse_tensor::SparseTensorEncodingAttr::getMnemonic();
54
+ t.print(printer);
55
+ return ::mlir::success();
56
+ })
57
+ .Case<::mlir::sparse_tensor::SparseTensorSortKindAttr>([&](auto t) {
58
+ printer << ::mlir::sparse_tensor::SparseTensorSortKindAttr::getMnemonic();
59
+ t.print(printer);
60
+ return ::mlir::success();
61
+ })
62
+ .Case<::mlir::sparse_tensor::StorageSpecifierKindAttr>([&](auto t) {
63
+ printer << ::mlir::sparse_tensor::StorageSpecifierKindAttr::getMnemonic();
64
+ t.print(printer);
65
+ return ::mlir::success();
66
+ })
67
+ .Default([](auto) { return ::mlir::failure(); });
68
+ }
69
+
70
+ namespace mlir {
71
+ namespace sparse_tensor {
72
+ namespace detail {
73
+ struct SparseTensorDimSliceAttrStorage : public ::mlir::AttributeStorage {
74
+ using KeyTy = std::tuple<int64_t, int64_t, int64_t>;
75
+ SparseTensorDimSliceAttrStorage(int64_t offset, int64_t size, int64_t stride) : offset(std::move(offset)), size(std::move(size)), stride(std::move(stride)) {}
76
+
77
+ KeyTy getAsKey() const {
78
+ return KeyTy(offset, size, stride);
79
+ }
80
+
81
+ bool operator==(const KeyTy &tblgenKey) const {
82
+ return (offset == std::get<0>(tblgenKey)) && (size == std::get<1>(tblgenKey)) && (stride == std::get<2>(tblgenKey));
83
+ }
84
+
85
+ static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) {
86
+ return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey), std::get<2>(tblgenKey));
87
+ }
88
+
89
+ static SparseTensorDimSliceAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
90
+ auto offset = std::move(std::get<0>(tblgenKey));
91
+ auto size = std::move(std::get<1>(tblgenKey));
92
+ auto stride = std::move(std::get<2>(tblgenKey));
93
+ return new (allocator.allocate<SparseTensorDimSliceAttrStorage>()) SparseTensorDimSliceAttrStorage(std::move(offset), std::move(size), std::move(stride));
94
+ }
95
+
96
+ int64_t offset;
97
+ int64_t size;
98
+ int64_t stride;
99
+ };
100
+ } // namespace detail
101
+ SparseTensorDimSliceAttr SparseTensorDimSliceAttr::get(::mlir::MLIRContext *context, int64_t offset, int64_t size, int64_t stride) {
102
+ return Base::get(context, std::move(offset), std::move(size), std::move(stride));
103
+ }
104
+
105
+ SparseTensorDimSliceAttr SparseTensorDimSliceAttr::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, int64_t offset, int64_t size, int64_t stride) {
106
+ return Base::getChecked(emitError, context, offset, size, stride);
107
+ }
108
+
109
+ SparseTensorDimSliceAttr SparseTensorDimSliceAttr::get(::mlir::MLIRContext *context) {
110
+ return Base::get(context, 0, kDynamic, 1);
111
+ }
112
+
113
+ SparseTensorDimSliceAttr SparseTensorDimSliceAttr::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context) {
114
+ return Base::getChecked(emitError, context, 0, kDynamic, 1);
115
+ }
116
+
117
+ int64_t SparseTensorDimSliceAttr::getOffset() const {
118
+ return getImpl()->offset;
119
+ }
120
+
121
+ int64_t SparseTensorDimSliceAttr::getSize() const {
122
+ return getImpl()->size;
123
+ }
124
+
125
+ int64_t SparseTensorDimSliceAttr::getStride() const {
126
+ return getImpl()->stride;
127
+ }
128
+
129
+ } // namespace sparse_tensor
130
+ } // namespace mlir
131
+ MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::SparseTensorDimSliceAttr)
132
+ namespace mlir {
133
+ namespace sparse_tensor {
134
+ namespace detail {
135
+ struct SparseTensorEncodingAttrStorage : public ::mlir::AttributeStorage {
136
+ using KeyTy = std::tuple<::llvm::ArrayRef<::mlir::sparse_tensor::DimLevelType>, AffineMap, AffineMap, unsigned, unsigned, ::llvm::ArrayRef<::mlir::sparse_tensor::SparseTensorDimSliceAttr>>;
137
+ SparseTensorEncodingAttrStorage(::llvm::ArrayRef<::mlir::sparse_tensor::DimLevelType> lvlTypes, AffineMap dimToLvl, AffineMap lvlToDim, unsigned posWidth, unsigned crdWidth, ::llvm::ArrayRef<::mlir::sparse_tensor::SparseTensorDimSliceAttr> dimSlices) : lvlTypes(std::move(lvlTypes)), dimToLvl(std::move(dimToLvl)), lvlToDim(std::move(lvlToDim)), posWidth(std::move(posWidth)), crdWidth(std::move(crdWidth)), dimSlices(std::move(dimSlices)) {}
138
+
139
+ KeyTy getAsKey() const {
140
+ return KeyTy(lvlTypes, dimToLvl, lvlToDim, posWidth, crdWidth, dimSlices);
141
+ }
142
+
143
+ bool operator==(const KeyTy &tblgenKey) const {
144
+ return (lvlTypes == std::get<0>(tblgenKey)) && (dimToLvl == std::get<1>(tblgenKey)) && (lvlToDim == std::get<2>(tblgenKey)) && (posWidth == std::get<3>(tblgenKey)) && (crdWidth == std::get<4>(tblgenKey)) && (dimSlices == std::get<5>(tblgenKey));
145
+ }
146
+
147
+ static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) {
148
+ return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey), std::get<2>(tblgenKey), std::get<3>(tblgenKey), std::get<4>(tblgenKey), std::get<5>(tblgenKey));
149
+ }
150
+
151
+ static SparseTensorEncodingAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
152
+ auto lvlTypes = std::move(std::get<0>(tblgenKey));
153
+ auto dimToLvl = std::move(std::get<1>(tblgenKey));
154
+ auto lvlToDim = std::move(std::get<2>(tblgenKey));
155
+ auto posWidth = std::move(std::get<3>(tblgenKey));
156
+ auto crdWidth = std::move(std::get<4>(tblgenKey));
157
+ auto dimSlices = std::move(std::get<5>(tblgenKey));
158
+ lvlTypes = allocator.copyInto(lvlTypes);
159
+ dimSlices = allocator.copyInto(dimSlices);
160
+ return new (allocator.allocate<SparseTensorEncodingAttrStorage>()) SparseTensorEncodingAttrStorage(std::move(lvlTypes), std::move(dimToLvl), std::move(lvlToDim), std::move(posWidth), std::move(crdWidth), std::move(dimSlices));
161
+ }
162
+
163
+ ::llvm::ArrayRef<::mlir::sparse_tensor::DimLevelType> lvlTypes;
164
+ AffineMap dimToLvl;
165
+ AffineMap lvlToDim;
166
+ unsigned posWidth;
167
+ unsigned crdWidth;
168
+ ::llvm::ArrayRef<::mlir::sparse_tensor::SparseTensorDimSliceAttr> dimSlices;
169
+ };
170
+ } // namespace detail
171
+ SparseTensorEncodingAttr SparseTensorEncodingAttr::get(::mlir::MLIRContext *context, ::llvm::ArrayRef<::mlir::sparse_tensor::DimLevelType> lvlTypes, AffineMap dimToLvl, AffineMap lvlToDim, unsigned posWidth, unsigned crdWidth, ::llvm::ArrayRef<::mlir::sparse_tensor::SparseTensorDimSliceAttr> dimSlices) {
172
+ return Base::get(context, std::move(lvlTypes), std::move(dimToLvl), std::move(lvlToDim), std::move(posWidth), std::move(crdWidth), std::move(dimSlices));
173
+ }
174
+
175
+ SparseTensorEncodingAttr SparseTensorEncodingAttr::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ::llvm::ArrayRef<::mlir::sparse_tensor::DimLevelType> lvlTypes, AffineMap dimToLvl, AffineMap lvlToDim, unsigned posWidth, unsigned crdWidth, ::llvm::ArrayRef<::mlir::sparse_tensor::SparseTensorDimSliceAttr> dimSlices) {
176
+ return Base::getChecked(emitError, context, lvlTypes, dimToLvl, lvlToDim, posWidth, crdWidth, dimSlices);
177
+ }
178
+
179
+ SparseTensorEncodingAttr SparseTensorEncodingAttr::get(::mlir::MLIRContext *context, ArrayRef<::mlir::sparse_tensor::DimLevelType> lvlTypes, AffineMap dimToLvl, AffineMap lvlToDim, unsigned posWidth, unsigned crdWidth) {
180
+ return Base::get(context, lvlTypes, dimToLvl, lvlToDim, posWidth, crdWidth,
181
+ ArrayRef<::mlir::sparse_tensor::SparseTensorDimSliceAttr>{});
182
+ }
183
+
184
+ SparseTensorEncodingAttr SparseTensorEncodingAttr::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ArrayRef<::mlir::sparse_tensor::DimLevelType> lvlTypes, AffineMap dimToLvl, AffineMap lvlToDim, unsigned posWidth, unsigned crdWidth) {
185
+ return Base::getChecked(emitError, context, lvlTypes, dimToLvl, lvlToDim, posWidth, crdWidth,
186
+ ArrayRef<::mlir::sparse_tensor::SparseTensorDimSliceAttr>{});
187
+ }
188
+
189
+ ::llvm::ArrayRef<::mlir::sparse_tensor::DimLevelType> SparseTensorEncodingAttr::getLvlTypes() const {
190
+ return getImpl()->lvlTypes;
191
+ }
192
+
193
+ AffineMap SparseTensorEncodingAttr::getDimToLvl() const {
194
+ return getImpl()->dimToLvl;
195
+ }
196
+
197
+ AffineMap SparseTensorEncodingAttr::getLvlToDim() const {
198
+ return getImpl()->lvlToDim;
199
+ }
200
+
201
+ unsigned SparseTensorEncodingAttr::getPosWidth() const {
202
+ return getImpl()->posWidth;
203
+ }
204
+
205
+ unsigned SparseTensorEncodingAttr::getCrdWidth() const {
206
+ return getImpl()->crdWidth;
207
+ }
208
+
209
+ ::llvm::ArrayRef<::mlir::sparse_tensor::SparseTensorDimSliceAttr> SparseTensorEncodingAttr::getDimSlices() const {
210
+ return getImpl()->dimSlices;
211
+ }
212
+
213
+ } // namespace sparse_tensor
214
+ } // namespace mlir
215
+ MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::SparseTensorEncodingAttr)
216
+ namespace mlir {
217
+ namespace sparse_tensor {
218
+ namespace detail {
219
+ struct SparseTensorSortKindAttrStorage : public ::mlir::AttributeStorage {
220
+ using KeyTy = std::tuple<::mlir::sparse_tensor::SparseTensorSortKind>;
221
+ SparseTensorSortKindAttrStorage(::mlir::sparse_tensor::SparseTensorSortKind value) : value(std::move(value)) {}
222
+
223
+ KeyTy getAsKey() const {
224
+ return KeyTy(value);
225
+ }
226
+
227
+ bool operator==(const KeyTy &tblgenKey) const {
228
+ return (value == std::get<0>(tblgenKey));
229
+ }
230
+
231
+ static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) {
232
+ return ::llvm::hash_combine(std::get<0>(tblgenKey));
233
+ }
234
+
235
+ static SparseTensorSortKindAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
236
+ auto value = std::move(std::get<0>(tblgenKey));
237
+ return new (allocator.allocate<SparseTensorSortKindAttrStorage>()) SparseTensorSortKindAttrStorage(std::move(value));
238
+ }
239
+
240
+ ::mlir::sparse_tensor::SparseTensorSortKind value;
241
+ };
242
+ } // namespace detail
243
+ SparseTensorSortKindAttr SparseTensorSortKindAttr::get(::mlir::MLIRContext *context, ::mlir::sparse_tensor::SparseTensorSortKind value) {
244
+ return Base::get(context, std::move(value));
245
+ }
246
+
247
+ ::mlir::Attribute SparseTensorSortKindAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) {
248
+ ::mlir::Builder odsBuilder(odsParser.getContext());
249
+ ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
250
+ (void) odsLoc;
251
+ ::mlir::FailureOr<::mlir::sparse_tensor::SparseTensorSortKind> _result_value;
252
+
253
+ // Parse variable 'value'
254
+ _result_value = [&]() -> ::mlir::FailureOr<::mlir::sparse_tensor::SparseTensorSortKind> {
255
+ auto loc = odsParser.getCurrentLocation();
256
+ ::llvm::StringRef enumKeyword;
257
+ if (::mlir::failed(odsParser.parseKeyword(&enumKeyword)))
258
+ return ::mlir::failure();
259
+ auto maybeEnum = ::mlir::sparse_tensor::symbolizeSparseTensorSortKind(enumKeyword);
260
+ if (maybeEnum)
261
+ return *maybeEnum;
262
+ return {(::mlir::LogicalResult)(odsParser.emitError(loc) << "expected " << "::mlir::sparse_tensor::SparseTensorSortKind" << " to be one of: " << "hybrid_quick_sort" << ", " << "insertion_sort_stable" << ", " << "quick_sort" << ", " << "heap_sort")};
263
+ }();
264
+ if (::mlir::failed(_result_value)) {
265
+ odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse SparseTensorSortKindAttr parameter 'value' which is to be a `::mlir::sparse_tensor::SparseTensorSortKind`");
266
+ return {};
267
+ }
268
+ assert(::mlir::succeeded(_result_value));
269
+ return SparseTensorSortKindAttr::get(odsParser.getContext(),
270
+ ::mlir::sparse_tensor::SparseTensorSortKind((*_result_value)));
271
+ }
272
+
273
+ void SparseTensorSortKindAttr::print(::mlir::AsmPrinter &odsPrinter) const {
274
+ ::mlir::Builder odsBuilder(getContext());
275
+ odsPrinter << ' ';
276
+ odsPrinter << stringifySparseTensorSortKind(getValue());
277
+ }
278
+
279
+ ::mlir::sparse_tensor::SparseTensorSortKind SparseTensorSortKindAttr::getValue() const {
280
+ return getImpl()->value;
281
+ }
282
+
283
+ } // namespace sparse_tensor
284
+ } // namespace mlir
285
+ MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::SparseTensorSortKindAttr)
286
+ namespace mlir {
287
+ namespace sparse_tensor {
288
+ namespace detail {
289
+ struct StorageSpecifierKindAttrStorage : public ::mlir::AttributeStorage {
290
+ using KeyTy = std::tuple<::mlir::sparse_tensor::StorageSpecifierKind>;
291
+ StorageSpecifierKindAttrStorage(::mlir::sparse_tensor::StorageSpecifierKind value) : value(std::move(value)) {}
292
+
293
+ KeyTy getAsKey() const {
294
+ return KeyTy(value);
295
+ }
296
+
297
+ bool operator==(const KeyTy &tblgenKey) const {
298
+ return (value == std::get<0>(tblgenKey));
299
+ }
300
+
301
+ static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) {
302
+ return ::llvm::hash_combine(std::get<0>(tblgenKey));
303
+ }
304
+
305
+ static StorageSpecifierKindAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
306
+ auto value = std::move(std::get<0>(tblgenKey));
307
+ return new (allocator.allocate<StorageSpecifierKindAttrStorage>()) StorageSpecifierKindAttrStorage(std::move(value));
308
+ }
309
+
310
+ ::mlir::sparse_tensor::StorageSpecifierKind value;
311
+ };
312
+ } // namespace detail
313
+ StorageSpecifierKindAttr StorageSpecifierKindAttr::get(::mlir::MLIRContext *context, ::mlir::sparse_tensor::StorageSpecifierKind value) {
314
+ return Base::get(context, std::move(value));
315
+ }
316
+
317
+ ::mlir::Attribute StorageSpecifierKindAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) {
318
+ ::mlir::Builder odsBuilder(odsParser.getContext());
319
+ ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
320
+ (void) odsLoc;
321
+ ::mlir::FailureOr<::mlir::sparse_tensor::StorageSpecifierKind> _result_value;
322
+
323
+ // Parse variable 'value'
324
+ _result_value = [&]() -> ::mlir::FailureOr<::mlir::sparse_tensor::StorageSpecifierKind> {
325
+ auto loc = odsParser.getCurrentLocation();
326
+ ::llvm::StringRef enumKeyword;
327
+ if (::mlir::failed(odsParser.parseKeyword(&enumKeyword)))
328
+ return ::mlir::failure();
329
+ auto maybeEnum = ::mlir::sparse_tensor::symbolizeStorageSpecifierKind(enumKeyword);
330
+ if (maybeEnum)
331
+ return *maybeEnum;
332
+ return {(::mlir::LogicalResult)(odsParser.emitError(loc) << "expected " << "::mlir::sparse_tensor::StorageSpecifierKind" << " to be one of: " << "lvl_sz" << ", " << "pos_mem_sz" << ", " << "crd_mem_sz" << ", " << "val_mem_sz" << ", " << "dim_offset" << ", " << "dim_stride")};
333
+ }();
334
+ if (::mlir::failed(_result_value)) {
335
+ odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse SparseTensorStorageSpecifierKindAttr parameter 'value' which is to be a `::mlir::sparse_tensor::StorageSpecifierKind`");
336
+ return {};
337
+ }
338
+ assert(::mlir::succeeded(_result_value));
339
+ return StorageSpecifierKindAttr::get(odsParser.getContext(),
340
+ ::mlir::sparse_tensor::StorageSpecifierKind((*_result_value)));
341
+ }
342
+
343
+ void StorageSpecifierKindAttr::print(::mlir::AsmPrinter &odsPrinter) const {
344
+ ::mlir::Builder odsBuilder(getContext());
345
+ odsPrinter << ' ';
346
+ odsPrinter << stringifyStorageSpecifierKind(getValue());
347
+ }
348
+
349
+ ::mlir::sparse_tensor::StorageSpecifierKind StorageSpecifierKindAttr::getValue() const {
350
+ return getImpl()->value;
351
+ }
352
+
353
+ } // namespace sparse_tensor
354
+ } // namespace mlir
355
+ MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::StorageSpecifierKindAttr)
356
+ namespace mlir {
357
+ namespace sparse_tensor {
358
+
359
+ /// Parse an attribute registered to this dialect.
360
+ ::mlir::Attribute SparseTensorDialect::parseAttribute(::mlir::DialectAsmParser &parser,
361
+ ::mlir::Type type) const {
362
+ ::llvm::SMLoc typeLoc = parser.getCurrentLocation();
363
+ ::llvm::StringRef attrTag;
364
+ {
365
+ ::mlir::Attribute attr;
366
+ auto parseResult = generatedAttributeParser(parser, &attrTag, type, attr);
367
+ if (parseResult.has_value())
368
+ return attr;
369
+ }
370
+
371
+ parser.emitError(typeLoc) << "unknown attribute `"
372
+ << attrTag << "` in dialect `" << getNamespace() << "`";
373
+ return {};
374
+ }
375
+ /// Print an attribute registered to this dialect.
376
+ void SparseTensorDialect::printAttribute(::mlir::Attribute attr,
377
+ ::mlir::DialectAsmPrinter &printer) const {
378
+ if (::mlir::succeeded(generatedAttributePrinter(attr, printer)))
379
+ return;
380
+
381
+ }
382
+ } // namespace sparse_tensor
383
+ } // namespace mlir
384
+
385
+ #endif // GET_ATTRDEF_CLASSES
386
+
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.h.inc ADDED
@@ -0,0 +1,238 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2
+ |* *|
3
+ |* AttrDef Declarations *|
4
+ |* *|
5
+ |* Automatically generated file, do not edit! *|
6
+ |* *|
7
+ \*===----------------------------------------------------------------------===*/
8
+
9
+ #ifdef GET_ATTRDEF_CLASSES
10
+ #undef GET_ATTRDEF_CLASSES
11
+
12
+
13
+ namespace mlir {
14
+ class AsmParser;
15
+ class AsmPrinter;
16
+ } // namespace mlir
17
+ namespace mlir {
18
+ namespace sparse_tensor {
19
+ class SparseTensorDimSliceAttr;
20
+ class SparseTensorEncodingAttr;
21
+ class SparseTensorSortKindAttr;
22
+ class StorageSpecifierKindAttr;
23
+ namespace detail {
24
+ struct SparseTensorDimSliceAttrStorage;
25
+ } // namespace detail
26
+ class SparseTensorDimSliceAttr : public ::mlir::Attribute::AttrBase<SparseTensorDimSliceAttr, ::mlir::Attribute, detail::SparseTensorDimSliceAttrStorage> {
27
+ public:
28
+ using Base::Base;
29
+ void print(llvm::raw_ostream &os) const;
30
+
31
+ /// Special value for dynamic offset/size/stride.
32
+ static constexpr int64_t kDynamic = -1;
33
+ static constexpr bool isDynamic(int64_t v) { return v == kDynamic; }
34
+ static std::optional<uint64_t> getStatic(int64_t v);
35
+ static std::string getStaticString(int64_t v);
36
+
37
+ std::optional<uint64_t> getStaticOffset() const;
38
+ std::optional<uint64_t> getStaticStride() const;
39
+ std::optional<uint64_t> getStaticSize() const;
40
+ bool isCompletelyDynamic() const;
41
+ using Base::getChecked;
42
+ static SparseTensorDimSliceAttr get(::mlir::MLIRContext *context, int64_t offset, int64_t size, int64_t stride);
43
+ static SparseTensorDimSliceAttr getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, int64_t offset, int64_t size, int64_t stride);
44
+ static SparseTensorDimSliceAttr get(::mlir::MLIRContext *context);
45
+ static SparseTensorDimSliceAttr getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context);
46
+ static ::mlir::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, int64_t offset, int64_t size, int64_t stride);
47
+ static constexpr ::llvm::StringLiteral getMnemonic() {
48
+ return {"slice"};
49
+ }
50
+
51
+ static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType);
52
+ void print(::mlir::AsmPrinter &odsPrinter) const;
53
+ int64_t getOffset() const;
54
+ int64_t getSize() const;
55
+ int64_t getStride() const;
56
+ };
57
+ namespace detail {
58
+ struct SparseTensorEncodingAttrStorage;
59
+ } // namespace detail
60
+ class SparseTensorEncodingAttr : public ::mlir::Attribute::AttrBase<SparseTensorEncodingAttr, ::mlir::Attribute, detail::SparseTensorEncodingAttrStorage, ::mlir::VerifiableTensorEncoding::Trait> {
61
+ public:
62
+ using Base::Base;
63
+ //
64
+ // Factory methods.
65
+ //
66
+
67
+ /// Constructs a new encoding with the given dimToLvl mapping,
68
+ /// and all other fields inherited from `this`.
69
+ SparseTensorEncodingAttr withDimToLvl(AffineMap dimToLvl) const;
70
+ SparseTensorEncodingAttr withDimToLvl(SparseTensorEncodingAttr enc) const;
71
+
72
+ /// Constructs a new encoding with dimToLvl reset to the default/identity,
73
+ /// and all other fields inherited from `this`.
74
+ SparseTensorEncodingAttr withoutDimToLvl() const;
75
+
76
+ /// Constructs a new encoding with the given pointer and index
77
+ /// bitwidths, and all other fields inherited from `this`.
78
+ SparseTensorEncodingAttr withBitWidths(unsigned posWidth, unsigned crdWidth) const;
79
+
80
+ /// Constructs a new encoding with the pointer and index bitwidths
81
+ /// reset to the default, and all other fields inherited from `this`.
82
+ SparseTensorEncodingAttr withoutBitWidths() const;
83
+
84
+ /// Constructs a new encoding with the given dimSlices, and all
85
+ /// other fields inherited from `this`.
86
+ SparseTensorEncodingAttr withDimSlices(ArrayRef<::mlir::sparse_tensor::SparseTensorDimSliceAttr> dimSlices) const;
87
+
88
+ /// Constructs a new encoding with the dimSlices reset to the default,
89
+ /// and all other fields inherited from `this`.
90
+ SparseTensorEncodingAttr withoutDimSlices() const;
91
+
92
+ //
93
+ // Rank methods.
94
+ //
95
+
96
+ /// Returns the expected number of tensor dimensions. Asserts that
97
+ /// the encoding is non-null (since no fixed result is valid for every
98
+ /// dense-tensor).
99
+ ::mlir::sparse_tensor::Dimension getDimRank() const;
100
+
101
+ /// Returns the number of storage levels. Asserts that the encoding
102
+ /// is non-null (since no fixed result is valid for every dense-tensor).
103
+ ::mlir::sparse_tensor::Level getLvlRank() const;
104
+
105
+ //
106
+ // lvlTypes methods.
107
+ //
108
+
109
+ /// Safely looks up the level-type for the requested level. (Returns
110
+ /// `DimLevelType::Dense` for the null encoding, since dense-tensors
111
+ /// are always all-dense.)
112
+ ::mlir::sparse_tensor::DimLevelType getLvlType(::mlir::sparse_tensor::Level l) const;
113
+
114
+ bool isDenseLvl(::mlir::sparse_tensor::Level l) const { return isDenseDLT(getLvlType(l)); }
115
+ bool isTwoOutOfFourLvl(::mlir::sparse_tensor::Level l) const { return isTwoOutOfFourDLT(getLvlType(l)); }
116
+ bool isCompressedLvl(::mlir::sparse_tensor::Level l) const { return isCompressedDLT(getLvlType(l)); }
117
+ bool isLooseCompressedLvl(::mlir::sparse_tensor::Level l) const { return isLooseCompressedDLT(getLvlType(l)); }
118
+ bool isSingletonLvl(::mlir::sparse_tensor::Level l) const { return isSingletonDLT(getLvlType(l)); }
119
+ bool isOrderedLvl(::mlir::sparse_tensor::Level l) const { return isOrderedDLT(getLvlType(l)); }
120
+ bool isUniqueLvl(::mlir::sparse_tensor::Level l) const { return isUniqueDLT(getLvlType(l)); }
121
+
122
+ /// Returns true if every level is dense. Also returns true for
123
+ /// the null encoding (since dense-tensors are always all-dense).
124
+ bool isAllDense() const;
125
+
126
+ /// Returns true if every level is ordered. Also returns true for
127
+ /// the null encoding (since dense-tensors are always all-ordered).
128
+ bool isAllOrdered() const;
129
+
130
+ //
131
+ // dimToLvl methods.
132
+ //
133
+
134
+ /// Returns true if the dimToLvl mapping is the identity.
135
+ /// Also returns true for the null encoding (since dense-tensors
136
+ /// always have the identity mapping).
137
+ bool isIdentity() const;
138
+
139
+ /// Returns true if the dimToLvl mapping is a permutation.
140
+ /// Also returns true for the null encoding (since dense-tensors
141
+ /// always have the identity mapping).
142
+ bool isPermutation() const;
143
+
144
+ //
145
+ // posWidth/crdWidth methods.
146
+ //
147
+
148
+ /// Returns the type for position storage based on posWidth.
149
+ /// Asserts that the encoding is non-null (since there's nowhere
150
+ /// to get the `MLIRContext` from).
151
+ Type getPosType() const;
152
+
153
+ /// Returns the type for coordinate storage based on crdWidth.
154
+ /// Asserts that the encoding is non-null (since there's nowhere
155
+ /// to get the `MLIRContext` from).
156
+ Type getCrdType() const;
157
+
158
+ //
159
+ // dimSlices methods.
160
+ //
161
+
162
+ bool isSlice() const;
163
+
164
+ ::mlir::sparse_tensor::SparseTensorDimSliceAttr getDimSlice(::mlir::sparse_tensor::Dimension dim) const;
165
+
166
+ std::optional<uint64_t> getStaticDimSliceOffset(::mlir::sparse_tensor::Dimension dim) const;
167
+ std::optional<uint64_t> getStaticDimSliceSize(::mlir::sparse_tensor::Dimension dim) const;
168
+ std::optional<uint64_t> getStaticDimSliceStride(::mlir::sparse_tensor::Dimension dim) const;
169
+ std::optional<uint64_t> getStaticLvlSliceOffset(::mlir::sparse_tensor::Level lvl) const;
170
+ std::optional<uint64_t> getStaticLvlSliceSize(::mlir::sparse_tensor::Level lvl) const;
171
+ std::optional<uint64_t> getStaticLvlSliceStride(::mlir::sparse_tensor::Level lvl) const;
172
+
173
+ //
174
+ // Printing methods.
175
+ //
176
+
177
+ void printSymbols(AffineMap &map, AsmPrinter &printer) const;
178
+ void printDimensions(AffineMap &map, AsmPrinter &printer, ArrayRef<::mlir::sparse_tensor::SparseTensorDimSliceAttr> dimSlices) const;
179
+ void printLevels(AffineMap &map, AsmPrinter &printer, ArrayRef<::mlir::sparse_tensor::DimLevelType> lvlTypes) const;
180
+ using Base::getChecked;
181
+ static SparseTensorEncodingAttr get(::mlir::MLIRContext *context, ::llvm::ArrayRef<::mlir::sparse_tensor::DimLevelType> lvlTypes, AffineMap dimToLvl, AffineMap lvlToDim, unsigned posWidth, unsigned crdWidth, ::llvm::ArrayRef<::mlir::sparse_tensor::SparseTensorDimSliceAttr> dimSlices);
182
+ static SparseTensorEncodingAttr getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ::llvm::ArrayRef<::mlir::sparse_tensor::DimLevelType> lvlTypes, AffineMap dimToLvl, AffineMap lvlToDim, unsigned posWidth, unsigned crdWidth, ::llvm::ArrayRef<::mlir::sparse_tensor::SparseTensorDimSliceAttr> dimSlices);
183
+ static SparseTensorEncodingAttr get(::mlir::MLIRContext *context, ArrayRef<::mlir::sparse_tensor::DimLevelType> lvlTypes, AffineMap dimToLvl, AffineMap lvlToDim, unsigned posWidth, unsigned crdWidth);
184
+ static SparseTensorEncodingAttr getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ArrayRef<::mlir::sparse_tensor::DimLevelType> lvlTypes, AffineMap dimToLvl, AffineMap lvlToDim, unsigned posWidth, unsigned crdWidth);
185
+ static ::mlir::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::llvm::ArrayRef<::mlir::sparse_tensor::DimLevelType> lvlTypes, AffineMap dimToLvl, AffineMap lvlToDim, unsigned posWidth, unsigned crdWidth, ::llvm::ArrayRef<::mlir::sparse_tensor::SparseTensorDimSliceAttr> dimSlices);
186
+ static constexpr ::llvm::StringLiteral getMnemonic() {
187
+ return {"encoding"};
188
+ }
189
+
190
+ static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType);
191
+ void print(::mlir::AsmPrinter &odsPrinter) const;
192
+ ::llvm::ArrayRef<::mlir::sparse_tensor::DimLevelType> getLvlTypes() const;
193
+ AffineMap getDimToLvl() const;
194
+ AffineMap getLvlToDim() const;
195
+ unsigned getPosWidth() const;
196
+ unsigned getCrdWidth() const;
197
+ ::llvm::ArrayRef<::mlir::sparse_tensor::SparseTensorDimSliceAttr> getDimSlices() const;
198
+ ::mlir::LogicalResult verifyEncoding(ArrayRef<int64_t> shape, Type elementType, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) const;
199
+ };
200
+ namespace detail {
201
+ struct SparseTensorSortKindAttrStorage;
202
+ } // namespace detail
203
+ class SparseTensorSortKindAttr : public ::mlir::Attribute::AttrBase<SparseTensorSortKindAttr, ::mlir::Attribute, detail::SparseTensorSortKindAttrStorage> {
204
+ public:
205
+ using Base::Base;
206
+ static SparseTensorSortKindAttr get(::mlir::MLIRContext *context, ::mlir::sparse_tensor::SparseTensorSortKind value);
207
+ static constexpr ::llvm::StringLiteral getMnemonic() {
208
+ return {"SparseTensorSortAlgorithm"};
209
+ }
210
+
211
+ static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType);
212
+ void print(::mlir::AsmPrinter &odsPrinter) const;
213
+ ::mlir::sparse_tensor::SparseTensorSortKind getValue() const;
214
+ };
215
+ namespace detail {
216
+ struct StorageSpecifierKindAttrStorage;
217
+ } // namespace detail
218
+ class StorageSpecifierKindAttr : public ::mlir::Attribute::AttrBase<StorageSpecifierKindAttr, ::mlir::Attribute, detail::StorageSpecifierKindAttrStorage> {
219
+ public:
220
+ using Base::Base;
221
+ static StorageSpecifierKindAttr get(::mlir::MLIRContext *context, ::mlir::sparse_tensor::StorageSpecifierKind value);
222
+ static constexpr ::llvm::StringLiteral getMnemonic() {
223
+ return {"kind"};
224
+ }
225
+
226
+ static ::mlir::Attribute parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType);
227
+ void print(::mlir::AsmPrinter &odsPrinter) const;
228
+ ::mlir::sparse_tensor::StorageSpecifierKind getValue() const;
229
+ };
230
+ } // namespace sparse_tensor
231
+ } // namespace mlir
232
+ MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::SparseTensorDimSliceAttr)
233
+ MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::SparseTensorEncodingAttr)
234
+ MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::SparseTensorSortKindAttr)
235
+ MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::StorageSpecifierKindAttr)
236
+
237
+ #endif // GET_ATTRDEF_CLASSES
238
+
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrEnums.cpp.inc ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2
+ |* *|
3
+ |* Enum Utility Definitions *|
4
+ |* *|
5
+ |* Automatically generated file, do not edit! *|
6
+ |* From: SparseTensorAttrDefs.td *|
7
+ |* *|
8
+ \*===----------------------------------------------------------------------===*/
9
+
10
+ namespace mlir {
11
+ namespace sparse_tensor {
12
+ ::llvm::StringRef stringifySparseTensorSortKind(SparseTensorSortKind val) {
13
+ switch (val) {
14
+ case SparseTensorSortKind::HybridQuickSort: return "hybrid_quick_sort";
15
+ case SparseTensorSortKind::InsertionSortStable: return "insertion_sort_stable";
16
+ case SparseTensorSortKind::QuickSort: return "quick_sort";
17
+ case SparseTensorSortKind::HeapSort: return "heap_sort";
18
+ }
19
+ return "";
20
+ }
21
+
22
+ ::std::optional<SparseTensorSortKind> symbolizeSparseTensorSortKind(::llvm::StringRef str) {
23
+ return ::llvm::StringSwitch<::std::optional<SparseTensorSortKind>>(str)
24
+ .Case("hybrid_quick_sort", SparseTensorSortKind::HybridQuickSort)
25
+ .Case("insertion_sort_stable", SparseTensorSortKind::InsertionSortStable)
26
+ .Case("quick_sort", SparseTensorSortKind::QuickSort)
27
+ .Case("heap_sort", SparseTensorSortKind::HeapSort)
28
+ .Default(::std::nullopt);
29
+ }
30
+ ::std::optional<SparseTensorSortKind> symbolizeSparseTensorSortKind(uint32_t value) {
31
+ switch (value) {
32
+ case 0: return SparseTensorSortKind::HybridQuickSort;
33
+ case 1: return SparseTensorSortKind::InsertionSortStable;
34
+ case 2: return SparseTensorSortKind::QuickSort;
35
+ case 3: return SparseTensorSortKind::HeapSort;
36
+ default: return ::std::nullopt;
37
+ }
38
+ }
39
+
40
+ } // namespace sparse_tensor
41
+ } // namespace mlir
42
+
43
+ namespace mlir {
44
+ namespace sparse_tensor {
45
+ ::llvm::StringRef stringifyStorageSpecifierKind(StorageSpecifierKind val) {
46
+ switch (val) {
47
+ case StorageSpecifierKind::LvlSize: return "lvl_sz";
48
+ case StorageSpecifierKind::PosMemSize: return "pos_mem_sz";
49
+ case StorageSpecifierKind::CrdMemSize: return "crd_mem_sz";
50
+ case StorageSpecifierKind::ValMemSize: return "val_mem_sz";
51
+ case StorageSpecifierKind::DimOffset: return "dim_offset";
52
+ case StorageSpecifierKind::DimStride: return "dim_stride";
53
+ }
54
+ return "";
55
+ }
56
+
57
+ ::std::optional<StorageSpecifierKind> symbolizeStorageSpecifierKind(::llvm::StringRef str) {
58
+ return ::llvm::StringSwitch<::std::optional<StorageSpecifierKind>>(str)
59
+ .Case("lvl_sz", StorageSpecifierKind::LvlSize)
60
+ .Case("pos_mem_sz", StorageSpecifierKind::PosMemSize)
61
+ .Case("crd_mem_sz", StorageSpecifierKind::CrdMemSize)
62
+ .Case("val_mem_sz", StorageSpecifierKind::ValMemSize)
63
+ .Case("dim_offset", StorageSpecifierKind::DimOffset)
64
+ .Case("dim_stride", StorageSpecifierKind::DimStride)
65
+ .Default(::std::nullopt);
66
+ }
67
+ ::std::optional<StorageSpecifierKind> symbolizeStorageSpecifierKind(uint32_t value) {
68
+ switch (value) {
69
+ case 0: return StorageSpecifierKind::LvlSize;
70
+ case 1: return StorageSpecifierKind::PosMemSize;
71
+ case 2: return StorageSpecifierKind::CrdMemSize;
72
+ case 3: return StorageSpecifierKind::ValMemSize;
73
+ case 4: return StorageSpecifierKind::DimOffset;
74
+ case 5: return StorageSpecifierKind::DimStride;
75
+ default: return ::std::nullopt;
76
+ }
77
+ }
78
+
79
+ } // namespace sparse_tensor
80
+ } // namespace mlir
81
+
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrEnums.h.inc ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2
+ |* *|
3
+ |* Enum Utility Declarations *|
4
+ |* *|
5
+ |* Automatically generated file, do not edit! *|
6
+ |* From: SparseTensorAttrDefs.td *|
7
+ |* *|
8
+ \*===----------------------------------------------------------------------===*/
9
+
10
+ namespace mlir {
11
+ namespace sparse_tensor {
12
+ // sparse tensor sort algorithm
13
+ enum class SparseTensorSortKind : uint32_t {
14
+ HybridQuickSort = 0,
15
+ InsertionSortStable = 1,
16
+ QuickSort = 2,
17
+ HeapSort = 3,
18
+ };
19
+
20
+ ::std::optional<SparseTensorSortKind> symbolizeSparseTensorSortKind(uint32_t);
21
+ ::llvm::StringRef stringifySparseTensorSortKind(SparseTensorSortKind);
22
+ ::std::optional<SparseTensorSortKind> symbolizeSparseTensorSortKind(::llvm::StringRef);
23
+ inline constexpr unsigned getMaxEnumValForSparseTensorSortKind() {
24
+ return 3;
25
+ }
26
+
27
+
28
+ inline ::llvm::StringRef stringifyEnum(SparseTensorSortKind enumValue) {
29
+ return stringifySparseTensorSortKind(enumValue);
30
+ }
31
+
32
+ template <typename EnumType>
33
+ ::std::optional<EnumType> symbolizeEnum(::llvm::StringRef);
34
+
35
+ template <>
36
+ inline ::std::optional<SparseTensorSortKind> symbolizeEnum<SparseTensorSortKind>(::llvm::StringRef str) {
37
+ return symbolizeSparseTensorSortKind(str);
38
+ }
39
+ } // namespace sparse_tensor
40
+ } // namespace mlir
41
+
42
+ namespace mlir {
43
+ template <typename T, typename>
44
+ struct FieldParser;
45
+
46
+ template<>
47
+ struct FieldParser<::mlir::sparse_tensor::SparseTensorSortKind, ::mlir::sparse_tensor::SparseTensorSortKind> {
48
+ template <typename ParserT>
49
+ static FailureOr<::mlir::sparse_tensor::SparseTensorSortKind> parse(ParserT &parser) {
50
+ // Parse the keyword/string containing the enum.
51
+ std::string enumKeyword;
52
+ auto loc = parser.getCurrentLocation();
53
+ if (failed(parser.parseOptionalKeywordOrString(&enumKeyword)))
54
+ return parser.emitError(loc, "expected keyword for sparse tensor sort algorithm");
55
+
56
+ // Symbolize the keyword.
57
+ if (::std::optional<::mlir::sparse_tensor::SparseTensorSortKind> attr = ::mlir::sparse_tensor::symbolizeEnum<::mlir::sparse_tensor::SparseTensorSortKind>(enumKeyword))
58
+ return *attr;
59
+ return parser.emitError(loc, "invalid sparse tensor sort algorithm specification: ") << enumKeyword;
60
+ }
61
+ };
62
+ } // namespace mlir
63
+
64
+ namespace llvm {
65
+ inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::sparse_tensor::SparseTensorSortKind value) {
66
+ auto valueStr = stringifyEnum(value);
67
+ return p << valueStr;
68
+ }
69
+ } // namespace llvm
70
+
71
+ namespace llvm {
72
+ template<> struct DenseMapInfo<::mlir::sparse_tensor::SparseTensorSortKind> {
73
+ using StorageInfo = ::llvm::DenseMapInfo<uint32_t>;
74
+
75
+ static inline ::mlir::sparse_tensor::SparseTensorSortKind getEmptyKey() {
76
+ return static_cast<::mlir::sparse_tensor::SparseTensorSortKind>(StorageInfo::getEmptyKey());
77
+ }
78
+
79
+ static inline ::mlir::sparse_tensor::SparseTensorSortKind getTombstoneKey() {
80
+ return static_cast<::mlir::sparse_tensor::SparseTensorSortKind>(StorageInfo::getTombstoneKey());
81
+ }
82
+
83
+ static unsigned getHashValue(const ::mlir::sparse_tensor::SparseTensorSortKind &val) {
84
+ return StorageInfo::getHashValue(static_cast<uint32_t>(val));
85
+ }
86
+
87
+ static bool isEqual(const ::mlir::sparse_tensor::SparseTensorSortKind &lhs, const ::mlir::sparse_tensor::SparseTensorSortKind &rhs) {
88
+ return lhs == rhs;
89
+ }
90
+ };
91
+ }
92
+
93
+ namespace mlir {
94
+ namespace sparse_tensor {
95
+ // sparse tensor storage specifier kind
96
+ enum class StorageSpecifierKind : uint32_t {
97
+ LvlSize = 0,
98
+ PosMemSize = 1,
99
+ CrdMemSize = 2,
100
+ ValMemSize = 3,
101
+ DimOffset = 4,
102
+ DimStride = 5,
103
+ };
104
+
105
+ ::std::optional<StorageSpecifierKind> symbolizeStorageSpecifierKind(uint32_t);
106
+ ::llvm::StringRef stringifyStorageSpecifierKind(StorageSpecifierKind);
107
+ ::std::optional<StorageSpecifierKind> symbolizeStorageSpecifierKind(::llvm::StringRef);
108
+ inline constexpr unsigned getMaxEnumValForStorageSpecifierKind() {
109
+ return 5;
110
+ }
111
+
112
+
113
+ inline ::llvm::StringRef stringifyEnum(StorageSpecifierKind enumValue) {
114
+ return stringifyStorageSpecifierKind(enumValue);
115
+ }
116
+
117
+ template <typename EnumType>
118
+ ::std::optional<EnumType> symbolizeEnum(::llvm::StringRef);
119
+
120
+ template <>
121
+ inline ::std::optional<StorageSpecifierKind> symbolizeEnum<StorageSpecifierKind>(::llvm::StringRef str) {
122
+ return symbolizeStorageSpecifierKind(str);
123
+ }
124
+ } // namespace sparse_tensor
125
+ } // namespace mlir
126
+
127
+ namespace mlir {
128
+ template <typename T, typename>
129
+ struct FieldParser;
130
+
131
+ template<>
132
+ struct FieldParser<::mlir::sparse_tensor::StorageSpecifierKind, ::mlir::sparse_tensor::StorageSpecifierKind> {
133
+ template <typename ParserT>
134
+ static FailureOr<::mlir::sparse_tensor::StorageSpecifierKind> parse(ParserT &parser) {
135
+ // Parse the keyword/string containing the enum.
136
+ std::string enumKeyword;
137
+ auto loc = parser.getCurrentLocation();
138
+ if (failed(parser.parseOptionalKeywordOrString(&enumKeyword)))
139
+ return parser.emitError(loc, "expected keyword for sparse tensor storage specifier kind");
140
+
141
+ // Symbolize the keyword.
142
+ if (::std::optional<::mlir::sparse_tensor::StorageSpecifierKind> attr = ::mlir::sparse_tensor::symbolizeEnum<::mlir::sparse_tensor::StorageSpecifierKind>(enumKeyword))
143
+ return *attr;
144
+ return parser.emitError(loc, "invalid sparse tensor storage specifier kind specification: ") << enumKeyword;
145
+ }
146
+ };
147
+ } // namespace mlir
148
+
149
+ namespace llvm {
150
+ inline ::llvm::raw_ostream &operator<<(::llvm::raw_ostream &p, ::mlir::sparse_tensor::StorageSpecifierKind value) {
151
+ auto valueStr = stringifyEnum(value);
152
+ return p << valueStr;
153
+ }
154
+ } // namespace llvm
155
+
156
+ namespace llvm {
157
+ template<> struct DenseMapInfo<::mlir::sparse_tensor::StorageSpecifierKind> {
158
+ using StorageInfo = ::llvm::DenseMapInfo<uint32_t>;
159
+
160
+ static inline ::mlir::sparse_tensor::StorageSpecifierKind getEmptyKey() {
161
+ return static_cast<::mlir::sparse_tensor::StorageSpecifierKind>(StorageInfo::getEmptyKey());
162
+ }
163
+
164
+ static inline ::mlir::sparse_tensor::StorageSpecifierKind getTombstoneKey() {
165
+ return static_cast<::mlir::sparse_tensor::StorageSpecifierKind>(StorageInfo::getTombstoneKey());
166
+ }
167
+
168
+ static unsigned getHashValue(const ::mlir::sparse_tensor::StorageSpecifierKind &val) {
169
+ return StorageInfo::getHashValue(static_cast<uint32_t>(val));
170
+ }
171
+
172
+ static bool isEqual(const ::mlir::sparse_tensor::StorageSpecifierKind &lhs, const ::mlir::sparse_tensor::StorageSpecifierKind &rhs) {
173
+ return lhs == rhs;
174
+ }
175
+ };
176
+ }
177
+
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.cpp.inc ADDED
The diff for this file is too large to render. See raw diff
 
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.h.inc ADDED
The diff for this file is too large to render. See raw diff
 
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOpsDialect.cpp.inc ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2
+ |* *|
3
+ |* Dialect Definitions *|
4
+ |* *|
5
+ |* Automatically generated file, do not edit! *|
6
+ |* From: SparseTensorOps.td *|
7
+ |* *|
8
+ \*===----------------------------------------------------------------------===*/
9
+
10
+ MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::SparseTensorDialect)
11
+ namespace mlir {
12
+ namespace sparse_tensor {
13
+
14
+ SparseTensorDialect::SparseTensorDialect(::mlir::MLIRContext *context)
15
+ : ::mlir::Dialect(getDialectNamespace(), context, ::mlir::TypeID::get<SparseTensorDialect>()) {
16
+
17
+ initialize();
18
+ }
19
+
20
+ SparseTensorDialect::~SparseTensorDialect() = default;
21
+
22
+ } // namespace sparse_tensor
23
+ } // namespace mlir
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOpsDialect.h.inc ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2
+ |* *|
3
+ |* Dialect Declarations *|
4
+ |* *|
5
+ |* Automatically generated file, do not edit! *|
6
+ |* From: SparseTensorOps.td *|
7
+ |* *|
8
+ \*===----------------------------------------------------------------------===*/
9
+
10
+ namespace mlir {
11
+ namespace sparse_tensor {
12
+
13
+ class SparseTensorDialect : public ::mlir::Dialect {
14
+ explicit SparseTensorDialect(::mlir::MLIRContext *context);
15
+
16
+ void initialize();
17
+ friend class ::mlir::MLIRContext;
18
+ public:
19
+ ~SparseTensorDialect() override;
20
+ static constexpr ::llvm::StringLiteral getDialectNamespace() {
21
+ return ::llvm::StringLiteral("sparse_tensor");
22
+ }
23
+
24
+ /// Parse an attribute registered to this dialect.
25
+ ::mlir::Attribute parseAttribute(::mlir::DialectAsmParser &parser,
26
+ ::mlir::Type type) const override;
27
+
28
+ /// Print an attribute registered to this dialect.
29
+ void printAttribute(::mlir::Attribute attr,
30
+ ::mlir::DialectAsmPrinter &os) const override;
31
+
32
+ /// Parse a type registered to this dialect.
33
+ ::mlir::Type parseType(::mlir::DialectAsmParser &parser) const override;
34
+
35
+ /// Print a type registered to this dialect.
36
+ void printType(::mlir::Type type,
37
+ ::mlir::DialectAsmPrinter &os) const override;
38
+ };
39
+ } // namespace sparse_tensor
40
+ } // namespace mlir
41
+ MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::SparseTensorDialect)
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorStorageLayout.h ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //===- SparseTensorStorageLayout.h ------------------------------*- C++ -*-===//
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
+ // This header file defines utilities for the sparse memory layout.
10
+ //
11
+ //===----------------------------------------------------------------------===//
12
+
13
+ #ifndef MLIR_DIALECT_SPARSETENSOR_IR_SPARSETENSORSTORAGELAYOUT_H_
14
+ #define MLIR_DIALECT_SPARSETENSOR_IR_SPARSETENSORSTORAGELAYOUT_H_
15
+
16
+ #include "mlir/Dialect/SparseTensor/IR/SparseTensor.h"
17
+ #include "mlir/Dialect/SparseTensor/IR/SparseTensorType.h"
18
+
19
+ namespace mlir {
20
+ namespace sparse_tensor {
21
+
22
+ ///===----------------------------------------------------------------------===//
23
+ /// The sparse tensor storage scheme for a tensor is organized as a single
24
+ /// compound type with the following fields. Note that every memref with ? size
25
+ /// actually behaves as a "vector", i.e. the stored size is the capacity and the
26
+ /// used size resides in the storage_specifier struct.
27
+ ///
28
+ /// struct {
29
+ /// ; per-level l:
30
+ /// ; if dense:
31
+ /// <nothing>
32
+ /// ; if compresed:
33
+ /// memref<? x pos> positions-l ; positions for sparse level l
34
+ /// memref<? x crd> coordinates-l ; coordinates for sparse level l
35
+ /// ; if singleton:
36
+ /// memref<? x crd> coordinates-l ; coordinates for singleton level l
37
+ ///
38
+ /// memref<? x eltType> values ; values
39
+ ///
40
+ /// struct sparse_tensor.storage_specifier {
41
+ /// array<rank x int> lvlSizes ; sizes/cardinalities for each level
42
+ /// array<n x int> memSizes; ; sizes/lengths for each data memref
43
+ /// }
44
+ /// };
45
+ ///
46
+ /// In addition, for a "trailing COO region", defined as a compressed level
47
+ /// followed by one or more singleton levels, the default SOA storage that
48
+ /// is inherent to the TACO format is optimized into an AOS storage where
49
+ /// all coordinates of a stored element appear consecutively. In such cases,
50
+ /// a special operation (sparse_tensor.coordinates_buffer) must be used to
51
+ /// access the AOS coordinates array. In the code below, the method
52
+ /// `getCOOStart` is used to find the start of the "trailing COO region".
53
+ ///
54
+ /// If the sparse tensor is a slice (produced by `tensor.extract_slice`
55
+ /// operation), instead of allocating a new sparse tensor for it, it reuses the
56
+ /// same sets of MemRefs but attaching a additional set of slicing-metadata for
57
+ /// per-dimension slice offset and stride.
58
+ ///
59
+ /// Examples.
60
+ ///
61
+ /// #CSR storage of 2-dim matrix yields
62
+ /// memref<?xindex> ; positions-1
63
+ /// memref<?xindex> ; coordinates-1
64
+ /// memref<?xf64> ; values
65
+ /// struct<(array<2 x i64>, array<3 x i64>)>) ; lvl0, lvl1, 3xsizes
66
+ ///
67
+ /// #COO storage of 2-dim matrix yields
68
+ /// memref<?xindex>, ; positions-0, essentially
69
+ /// [0,sz] memref<?xindex> ; AOS coordinates storage
70
+ /// memref<?xf64> ; values
71
+ /// struct<(array<2 x i64>, array<3 x i64>)>) ; lvl0, lvl1, 3xsizes
72
+ ///
73
+ /// Slice on #COO storage of 2-dim matrix yields
74
+ /// ;; Inherited from the original sparse tensors
75
+ /// memref<?xindex>, ; positions-0, essentially
76
+ /// [0,sz] memref<?xindex> ; AOS coordinates storage
77
+ /// memref<?xf64> ; values
78
+ /// struct<(array<2 x i64>, array<3 x i64>, ; lvl0, lvl1, 3xsizes
79
+ /// ;; Extra slicing-metadata
80
+ /// array<2 x i64>, array<2 x i64>)>) ; dim offset, dim stride.
81
+ ///
82
+ ///===----------------------------------------------------------------------===//
83
+
84
+ enum class SparseTensorFieldKind : uint32_t {
85
+ StorageSpec = 0,
86
+ PosMemRef = static_cast<uint32_t>(StorageSpecifierKind::PosMemSize),
87
+ CrdMemRef = static_cast<uint32_t>(StorageSpecifierKind::CrdMemSize),
88
+ ValMemRef = static_cast<uint32_t>(StorageSpecifierKind::ValMemSize)
89
+ };
90
+
91
+ inline StorageSpecifierKind toSpecifierKind(SparseTensorFieldKind kind) {
92
+ assert(kind != SparseTensorFieldKind::StorageSpec);
93
+ return static_cast<StorageSpecifierKind>(kind);
94
+ }
95
+
96
+ inline SparseTensorFieldKind toFieldKind(StorageSpecifierKind kind) {
97
+ assert(kind != StorageSpecifierKind::LvlSize);
98
+ return static_cast<SparseTensorFieldKind>(kind);
99
+ }
100
+
101
+ /// The type of field indices. This alias is to help code be more
102
+ /// self-documenting; unfortunately it is not type-checked, so it only
103
+ /// provides documentation rather than doing anything to prevent mixups.
104
+ using FieldIndex = unsigned;
105
+
106
+ /// Provides methods to access fields of a sparse tensor with the given
107
+ /// encoding.
108
+ class StorageLayout {
109
+ public:
110
+ // TODO: Functions/methods marked with [NUMFIELDS] should use
111
+ // `FieldIndex` for their return type, via the same reasoning for why
112
+ // `Dimension`/`Level` are used both for identifiers and ranks.
113
+ explicit StorageLayout(const SparseTensorType &stt)
114
+ : StorageLayout(stt.getEncoding()) {}
115
+ explicit StorageLayout(SparseTensorEncodingAttr enc) : enc(enc) {
116
+ assert(enc);
117
+ }
118
+
119
+ /// For each field that will be allocated for the given sparse tensor
120
+ /// encoding, calls the callback with the corresponding field index,
121
+ /// field kind, level, and level-type (the last two are only for level
122
+ /// memrefs). The field index always starts with zero and increments
123
+ /// by one between each callback invocation. Ideally, all other methods
124
+ /// should rely on this function to query a sparse tensor fields instead
125
+ /// of relying on ad-hoc index computation.
126
+ void foreachField(
127
+ llvm::function_ref<bool(
128
+ FieldIndex /*fieldIdx*/, SparseTensorFieldKind /*fieldKind*/,
129
+ Level /*lvl (if applicable)*/, DimLevelType /*DLT (if applicable)*/)>)
130
+ const;
131
+
132
+ /// Gets the field index for required field.
133
+ FieldIndex getMemRefFieldIndex(SparseTensorFieldKind kind,
134
+ std::optional<Level> lvl) const {
135
+ return getFieldIndexAndStride(kind, lvl).first;
136
+ }
137
+
138
+ /// Gets the total number of fields for the given sparse tensor encoding.
139
+ unsigned getNumFields() const;
140
+
141
+ /// Gets the total number of data fields (coordinate arrays, position
142
+ /// arrays, and a value array) for the given sparse tensor encoding.
143
+ unsigned getNumDataFields() const;
144
+
145
+ std::pair<FieldIndex, unsigned>
146
+ getFieldIndexAndStride(SparseTensorFieldKind kind,
147
+ std::optional<Level> lvl) const;
148
+
149
+ private:
150
+ const SparseTensorEncodingAttr enc;
151
+ };
152
+
153
+ //
154
+ // Wrapper functions to invoke StorageLayout-related method.
155
+ //
156
+
157
+ // See note [NUMFIELDS].
158
+ inline unsigned getNumFieldsFromEncoding(SparseTensorEncodingAttr enc) {
159
+ return StorageLayout(enc).getNumFields();
160
+ }
161
+
162
+ // See note [NUMFIELDS].
163
+ inline unsigned getNumDataFieldsFromEncoding(SparseTensorEncodingAttr enc) {
164
+ return StorageLayout(enc).getNumDataFields();
165
+ }
166
+
167
+ inline void foreachFieldInSparseTensor(
168
+ SparseTensorEncodingAttr enc,
169
+ llvm::function_ref<bool(FieldIndex, SparseTensorFieldKind, Level,
170
+ DimLevelType)>
171
+ callback) {
172
+ return StorageLayout(enc).foreachField(callback);
173
+ }
174
+
175
+ void foreachFieldAndTypeInSparseTensor(
176
+ SparseTensorType,
177
+ llvm::function_ref<bool(Type, FieldIndex, SparseTensorFieldKind, Level,
178
+ DimLevelType)>);
179
+
180
+ } // namespace sparse_tensor
181
+ } // namespace mlir
182
+
183
+ #endif // MLIR_DIALECT_SPARSETENSOR_IR_SPARSETENSORSTORAGELAYOUT_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorType.h ADDED
@@ -0,0 +1,325 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //===- SparseTensorType.h - Wrapper around RankedTensorType -----*- C++ -*-===//
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
+ // This header defines the `SparseTensorType` wrapper class.
10
+ //
11
+ //===----------------------------------------------------------------------===//
12
+
13
+ #ifndef MLIR_DIALECT_SPARSETENSOR_IR_SPARSETENSORTYPE_H_
14
+ #define MLIR_DIALECT_SPARSETENSOR_IR_SPARSETENSORTYPE_H_
15
+
16
+ #include "mlir/Dialect/SparseTensor/IR/SparseTensor.h"
17
+
18
+ namespace mlir {
19
+ namespace sparse_tensor {
20
+
21
+ //===----------------------------------------------------------------------===//
22
+ /// A wrapper around `RankedTensorType`, which has three goals:
23
+ ///
24
+ /// (1) To provide a uniform API for querying aspects of sparse-tensor
25
+ /// types; in particular, to make the "dimension" vs "level" distinction
26
+ /// overt (i.e., explicit everywhere). Thus, throughout the sparse-compiler
27
+ /// this class should be preferred over using `RankedTensorType` or
28
+ /// `ShapedType` directly, since the methods of the latter do not make
29
+ /// the "dimension" vs "level" distinction overt.
30
+ ///
31
+ /// (2) To provide a uniform abstraction over both sparse-tensor
32
+ /// types (i.e., `RankedTensorType` with `SparseTensorEncodingAttr`)
33
+ /// and dense-tensor types (i.e., `RankedTensorType` without an encoding).
34
+ /// That is, we want to manipulate dense-tensor types using the same API
35
+ /// that we use for manipulating sparse-tensor types; both to keep the
36
+ /// "dimension" vs "level" distinction overt, and to avoid needing to
37
+ /// handle certain cases specially in the sparse-compiler.
38
+ ///
39
+ /// (3) To provide uniform handling of "defaults". In particular
40
+ /// this means that dense-tensors should always return the same answers
41
+ /// as sparse-tensors with a default encoding. But it additionally means
42
+ /// that the answers should be normalized, so that there's no way to
43
+ /// distinguish between non-provided data (which is filled in by default)
44
+ /// vs explicitly-provided data which equals the defaults.
45
+ ///
46
+ class SparseTensorType {
47
+ public:
48
+ // We memoize `lvlRank`, `dimToLvl`, and `lvlToDim` to avoid repeating
49
+ // the conditionals throughout the rest of the class.
50
+ SparseTensorType(RankedTensorType rtp)
51
+ : rtp(rtp), enc(getSparseTensorEncoding(rtp)),
52
+ lvlRank(enc ? enc.getLvlRank() : getDimRank()),
53
+ dimToLvl(enc.isIdentity() ? AffineMap() : enc.getDimToLvl()),
54
+ lvlToDim(enc.isIdentity() ? AffineMap() : enc.getLvlToDim()) {
55
+ assert(rtp && "got null RankedTensorType");
56
+ assert((!isIdentity() || getDimRank() == lvlRank) && "Rank mismatch");
57
+ }
58
+
59
+ SparseTensorType(ShapedType stp, SparseTensorEncodingAttr enc)
60
+ : SparseTensorType(
61
+ RankedTensorType::get(stp.getShape(), stp.getElementType(), enc)) {}
62
+
63
+ // Copy-assignment would be implicitly deleted (because our fields
64
+ // are const), so we explicitly delete it for clarity.
65
+ SparseTensorType &operator=(const SparseTensorType &) = delete;
66
+ // So we must explicitly define the copy-ctor to silence -Wdeprecated-copy.
67
+ SparseTensorType(const SparseTensorType &) = default;
68
+
69
+ //
70
+ // Factory methods.
71
+ //
72
+
73
+ /// Constructs a new `SparseTensorType` with the same dimension-shape
74
+ /// and element type, but with the encoding replaced by the given encoding.
75
+ SparseTensorType withEncoding(SparseTensorEncodingAttr newEnc) const {
76
+ return SparseTensorType(rtp, newEnc);
77
+ }
78
+
79
+ /// Constructs a new `SparseTensorType` with the same dimension-shape
80
+ /// and element type, but with the encoding replaced by
81
+ /// `getEncoding().withDimToLvl(dimToLvl)`.
82
+ SparseTensorType withDimToLvl(AffineMap dimToLvl) const {
83
+ return withEncoding(enc.withDimToLvl(dimToLvl));
84
+ }
85
+
86
+ SparseTensorType withDimToLvl(SparseTensorEncodingAttr dimToLvlEnc) const {
87
+ return withEncoding(enc.withDimToLvl(dimToLvlEnc));
88
+ }
89
+
90
+ SparseTensorType withDimToLvl(const SparseTensorType &dimToLvlSTT) const {
91
+ return withDimToLvl(dimToLvlSTT.getEncoding());
92
+ }
93
+
94
+ /// Constructs a new `SparseTensorType` with the same dimension-shape
95
+ /// and element type, but with the encoding replaced by
96
+ /// `getEncoding().withoutDimToLvl()`.
97
+ SparseTensorType withoutDimToLvl() const {
98
+ return withEncoding(enc.withoutDimToLvl());
99
+ }
100
+
101
+ /// Constructs a new `SparseTensorType` with the same dimension-shape
102
+ /// and element type, but with the encoding replaced by
103
+ /// `getEncoding().withBitWidths(posWidth, crdWidth)`.
104
+ SparseTensorType withBitWidths(unsigned posWidth, unsigned crdWidth) const {
105
+ return withEncoding(enc.withBitWidths(posWidth, crdWidth));
106
+ }
107
+
108
+ /// Constructs a new `SparseTensorType` with the same dimension-shape
109
+ /// and element type, but with the encoding replaced by
110
+ /// `getEncoding().withoutBitWidths()`.
111
+ SparseTensorType withoutBitWidths() const {
112
+ return withEncoding(enc.withoutBitWidths());
113
+ }
114
+
115
+ SparseTensorType
116
+ withDimSlices(ArrayRef<SparseTensorDimSliceAttr> dimSlices) const {
117
+ return withEncoding(enc.withDimSlices(dimSlices));
118
+ }
119
+
120
+ SparseTensorType withoutDimSlices() const {
121
+ return withEncoding(enc.withoutDimSlices());
122
+ }
123
+
124
+ //
125
+ // Other methods.
126
+ //
127
+
128
+ /// Allow implicit conversion to `RankedTensorType`, `ShapedType`,
129
+ /// and `Type`. These are implicit to help alleviate the impedance
130
+ /// mismatch for code that has not been converted to use `SparseTensorType`
131
+ /// directly. Once more uses have been converted to `SparseTensorType`,
132
+ /// we may want to make these explicit instead.
133
+ ///
134
+ /// WARNING: This user-defined-conversion method causes overload
135
+ /// ambiguity whenever passing a `SparseTensorType` directly to a
136
+ /// function which is overloaded to accept either `Type` or `TypeRange`.
137
+ /// In particular, this includes `RewriterBase::replaceOpWithNewOp<OpTy>`
138
+ /// and `OpBuilder::create<OpTy>` whenever the `OpTy::build` is overloaded
139
+ /// thus. This happens because the `TypeRange<T>(T&&)` ctor is implicit
140
+ /// as well, and there's no SFINAE we can add to this method that would
141
+ /// block subsequent application of that ctor. The only way to fix the
142
+ /// overload ambiguity is to avoid *implicit* conversion at the callsite:
143
+ /// e.g., by using `static_cast` to make the conversion explicit, by
144
+ /// assigning the `SparseTensorType` to a temporary variable of the
145
+ /// desired type, etc.
146
+ //
147
+ // NOTE: We implement this as a single templated user-defined-conversion
148
+ // function to avoid ambiguity problems when the desired result is `Type`
149
+ // (since both `RankedTensorType` and `ShapedType` can be implicitly
150
+ // converted to `Type`).
151
+ template <typename T, typename = std::enable_if_t<
152
+ std::is_convertible_v<RankedTensorType, T>>>
153
+ /*implicit*/ operator T() const {
154
+ return rtp;
155
+ }
156
+
157
+ /// Explicitly convert to `RankedTensorType`. This method is
158
+ /// a convenience for resolving overload-ambiguity issues with
159
+ /// implicit conversion.
160
+ RankedTensorType getRankedTensorType() const { return rtp; }
161
+
162
+ bool operator==(const SparseTensorType &other) const {
163
+ // All other fields are derived from `rtp` and therefore don't need
164
+ // to be checked.
165
+ return rtp == other.rtp;
166
+ }
167
+
168
+ bool operator!=(const SparseTensorType &other) const {
169
+ return !(*this == other);
170
+ }
171
+
172
+ MLIRContext *getContext() const { return rtp.getContext(); }
173
+
174
+ Type getElementType() const { return rtp.getElementType(); }
175
+
176
+ /// Returns the encoding (or the null-attribute for dense-tensors).
177
+ SparseTensorEncodingAttr getEncoding() const { return enc; }
178
+
179
+ /// Returns true for tensors which have an encoding, and false for
180
+ /// those which do not. Therefore tensors with an all-dense encoding
181
+ /// return true.
182
+ bool hasEncoding() const { return static_cast<bool>(enc); }
183
+
184
+ /// Returns true for tensors where every level is dense.
185
+ /// (This is always true for dense-tensors.)
186
+ bool isAllDense() const { return enc.isAllDense(); }
187
+
188
+ /// Returns true for tensors where every level is ordered.
189
+ /// (This is always true for dense-tensors.)
190
+ bool isAllOrdered() const { return enc.isAllOrdered(); }
191
+
192
+ /// Returns true if the dimToLvl mapping is the identity.
193
+ /// (This is always true for dense-tensors.)
194
+ bool isIdentity() const { return !dimToLvl; }
195
+
196
+ /// Returns true if the dimToLvl mapping is a permutation.
197
+ /// (This is always true for dense-tensors.)
198
+ bool isPermutation() const { return enc.isPermutation(); }
199
+
200
+ /// Returns the dimToLvl mapping (or the null-map for the identity).
201
+ /// If you intend to compare the results of this method for equality,
202
+ /// see `hasSameDimToLvl` instead.
203
+ AffineMap getDimToLvl() const { return dimToLvl; }
204
+
205
+ /// Returns the lvlToDiml mapping (or the null-map for the identity).
206
+ AffineMap getLvlToDim() const { return lvlToDim; }
207
+
208
+ /// Returns the dimToLvl mapping, where the identity map is expanded out
209
+ /// into a full `AffineMap`. This method is provided as a convenience,
210
+ /// but for most purposes other methods (`isIdentity`, `getDimToLvl`,
211
+ /// etc) will be more helpful.
212
+ AffineMap getExpandedDimToLvl() const {
213
+ return dimToLvl
214
+ ? dimToLvl
215
+ : AffineMap::getMultiDimIdentityMap(getDimRank(), getContext());
216
+ }
217
+
218
+ /// Returns true iff the two types have the same mapping. This method
219
+ /// takes care to handle identity maps properly, so it should be preferred
220
+ /// over using `getDimToLvl` followed by `AffineMap::operator==`.
221
+ bool hasSameDimToLvl(const SparseTensorType &other) const {
222
+ // If the maps are the identity, then we need to check the rank
223
+ // to be sure they're the same size identity. (And since identity
224
+ // means dimRank==lvlRank, we use lvlRank as a minor optimization.)
225
+ return isIdentity() ? (other.isIdentity() && lvlRank == other.lvlRank)
226
+ : (dimToLvl == other.dimToLvl);
227
+ }
228
+
229
+ /// Returns the dimension-rank.
230
+ Dimension getDimRank() const { return rtp.getRank(); }
231
+
232
+ /// Returns the level-rank.
233
+ Level getLvlRank() const { return lvlRank; }
234
+
235
+ /// Returns the dimension-shape.
236
+ ArrayRef<DynSize> getDimShape() const { return rtp.getShape(); }
237
+
238
+ /// Safely looks up the requested dimension-DynSize. If you intend
239
+ /// to check the result with `ShapedType::isDynamic`, then see the
240
+ /// `getStaticDimSize` method instead.
241
+ DynSize getDynamicDimSize(Dimension d) const {
242
+ assert(d < getDimRank() && "Dimension is out of bounds");
243
+ return getDimShape()[d];
244
+ }
245
+
246
+ /// Safely looks up the requested dimension-size, mapping dynamic
247
+ /// sizes to `std::nullopt`.
248
+ std::optional<StaticSize> getStaticDimSize(Dimension d) const {
249
+ const DynSize sh = getDynamicDimSize(d);
250
+ return ShapedType::isDynamic(sh) ? std::nullopt
251
+ : std::optional<StaticSize>(sh);
252
+ }
253
+
254
+ /// Returns true if no dimension has dynamic size.
255
+ bool hasStaticDimShape() const { return rtp.hasStaticShape(); }
256
+
257
+ /// Returns true if any dimension has dynamic size.
258
+ bool hasDynamicDimShape() const { return !hasStaticDimShape(); }
259
+
260
+ /// Returns true if the given dimension has dynamic size. If you
261
+ /// intend to call `getDynamicDimSize` based on the result, then see
262
+ /// the `getStaticDimSize` method instead.
263
+ bool isDynamicDim(Dimension d) const {
264
+ // We don't use `rtp.isDynamicDim(d)` because we want the
265
+ // OOB error message to be consistent with `getDynamicDimSize`.
266
+ return ShapedType::isDynamic(getDynamicDimSize(d));
267
+ }
268
+
269
+ /// Returns the number of dimensions which have dynamic sizes.
270
+ /// The return type is `int64_t` to maintain consistency with
271
+ /// `ShapedType::Trait<T>::getNumDynamicDims`.
272
+ int64_t getNumDynamicDims() const { return rtp.getNumDynamicDims(); }
273
+
274
+ DimLevelType getLvlType(Level l) const {
275
+ // This OOB check is for dense-tensors, since this class knows
276
+ // their lvlRank (whereas STEA::getLvlType will/can only check
277
+ // OOB for sparse-tensors).
278
+ assert(l < lvlRank && "Level out of bounds");
279
+ return enc.getLvlType(l);
280
+ }
281
+
282
+ // We can't just delegate these, since we want to use this class's
283
+ // `getLvlType` method instead of STEA's.
284
+ bool isDenseLvl(Level l) const { return isDenseDLT(getLvlType(l)); }
285
+ bool isCompressedLvl(Level l) const { return isCompressedDLT(getLvlType(l)); }
286
+ bool isSingletonLvl(Level l) const { return isSingletonDLT(getLvlType(l)); }
287
+ bool isOrderedLvl(Level l) const { return isOrderedDLT(getLvlType(l)); }
288
+ bool isUniqueLvl(Level l) const { return isUniqueDLT(getLvlType(l)); }
289
+
290
+ /// Returns the coordinate-overhead bitwidth, defaulting to zero.
291
+ unsigned getCrdWidth() const { return enc ? enc.getCrdWidth() : 0; }
292
+
293
+ /// Returns the position-overhead bitwidth, defaulting to zero.
294
+ unsigned getPosWidth() const { return enc ? enc.getPosWidth() : 0; }
295
+
296
+ /// Returns the coordinate-overhead MLIR type, defaulting to `IndexType`.
297
+ Type getCrdType() const {
298
+ return detail::getIntegerOrIndexType(getContext(), getCrdWidth());
299
+ }
300
+
301
+ /// Returns the position-overhead MLIR type, defaulting to `IndexType`.
302
+ Type getPosType() const {
303
+ return detail::getIntegerOrIndexType(getContext(), getPosWidth());
304
+ }
305
+
306
+ private:
307
+ // These two must be const, to ensure coherence of the memoized fields.
308
+ const RankedTensorType rtp;
309
+ const SparseTensorEncodingAttr enc;
310
+ // Memoized to avoid frequent redundant conditionals.
311
+ const Level lvlRank;
312
+ const AffineMap dimToLvl;
313
+ const AffineMap lvlToDim;
314
+ };
315
+
316
+ /// Convenience method to abbreviate wrapping `getRankedTensorType`.
317
+ template <typename T>
318
+ inline SparseTensorType getSparseTensorType(T t) {
319
+ return SparseTensorType(getRankedTensorType(t));
320
+ }
321
+
322
+ } // namespace sparse_tensor
323
+ } // namespace mlir
324
+
325
+ #endif // MLIR_DIALECT_SPARSETENSOR_IR_SPARSETENSORTYPE_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorTypes.cpp.inc ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2
+ |* *|
3
+ |* TypeDef Definitions *|
4
+ |* *|
5
+ |* Automatically generated file, do not edit! *|
6
+ |* *|
7
+ \*===----------------------------------------------------------------------===*/
8
+
9
+ #ifdef GET_TYPEDEF_LIST
10
+ #undef GET_TYPEDEF_LIST
11
+
12
+ ::mlir::sparse_tensor::StorageSpecifierType
13
+
14
+ #endif // GET_TYPEDEF_LIST
15
+
16
+ #ifdef GET_TYPEDEF_CLASSES
17
+ #undef GET_TYPEDEF_CLASSES
18
+
19
+ static ::mlir::OptionalParseResult generatedTypeParser(::mlir::AsmParser &parser, ::llvm::StringRef *mnemonic, ::mlir::Type &value) {
20
+ return ::mlir::AsmParser::KeywordSwitch<::mlir::OptionalParseResult>(parser)
21
+ .Case(::mlir::sparse_tensor::StorageSpecifierType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
22
+ value = ::mlir::sparse_tensor::StorageSpecifierType::parse(parser);
23
+ return ::mlir::success(!!value);
24
+ })
25
+ .Default([&](llvm::StringRef keyword, llvm::SMLoc) {
26
+ *mnemonic = keyword;
27
+ return std::nullopt;
28
+ });
29
+ }
30
+
31
+ static ::mlir::LogicalResult generatedTypePrinter(::mlir::Type def, ::mlir::AsmPrinter &printer) {
32
+ return ::llvm::TypeSwitch<::mlir::Type, ::mlir::LogicalResult>(def) .Case<::mlir::sparse_tensor::StorageSpecifierType>([&](auto t) {
33
+ printer << ::mlir::sparse_tensor::StorageSpecifierType::getMnemonic();
34
+ t.print(printer);
35
+ return ::mlir::success();
36
+ })
37
+ .Default([](auto) { return ::mlir::failure(); });
38
+ }
39
+
40
+ namespace mlir {
41
+ namespace sparse_tensor {
42
+ namespace detail {
43
+ struct StorageSpecifierTypeStorage : public ::mlir::TypeStorage {
44
+ using KeyTy = std::tuple<::mlir::sparse_tensor::SparseTensorEncodingAttr>;
45
+ StorageSpecifierTypeStorage(::mlir::sparse_tensor::SparseTensorEncodingAttr encoding) : encoding(std::move(encoding)) {}
46
+
47
+ KeyTy getAsKey() const {
48
+ return KeyTy(encoding);
49
+ }
50
+
51
+ bool operator==(const KeyTy &tblgenKey) const {
52
+ return (encoding == std::get<0>(tblgenKey));
53
+ }
54
+
55
+ static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) {
56
+ return ::llvm::hash_combine(std::get<0>(tblgenKey));
57
+ }
58
+
59
+ static StorageSpecifierTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, KeyTy &&tblgenKey) {
60
+ auto encoding = std::move(std::get<0>(tblgenKey));
61
+ return new (allocator.allocate<StorageSpecifierTypeStorage>()) StorageSpecifierTypeStorage(std::move(encoding));
62
+ }
63
+
64
+ ::mlir::sparse_tensor::SparseTensorEncodingAttr encoding;
65
+ };
66
+ } // namespace detail
67
+ StorageSpecifierType StorageSpecifierType::get(SparseTensorEncodingAttr encoding) {
68
+ return get(encoding.getContext(), encoding);
69
+ }
70
+
71
+ StorageSpecifierType StorageSpecifierType::get(Type type) {
72
+ return get(getSparseTensorEncoding(type));
73
+ }
74
+
75
+ StorageSpecifierType StorageSpecifierType::get(Value tensor) {
76
+ return get(tensor.getType());
77
+ }
78
+
79
+ ::mlir::Type StorageSpecifierType::parse(::mlir::AsmParser &odsParser) {
80
+ ::mlir::Builder odsBuilder(odsParser.getContext());
81
+ ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
82
+ (void) odsLoc;
83
+ ::mlir::FailureOr<::mlir::sparse_tensor::SparseTensorEncodingAttr> _result_encoding;
84
+ // Parse literal '<'
85
+ if (odsParser.parseLess()) return {};
86
+
87
+ // Parse variable 'encoding'
88
+ _result_encoding = ::mlir::FieldParser<::mlir::sparse_tensor::SparseTensorEncodingAttr>::parse(odsParser);
89
+ if (::mlir::failed(_result_encoding)) {
90
+ odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse SparseTensor_StorageSpecifier parameter 'encoding' which is to be a `::mlir::sparse_tensor::SparseTensorEncodingAttr`");
91
+ return {};
92
+ }
93
+ // Parse literal '>'
94
+ if (odsParser.parseGreater()) return {};
95
+ assert(::mlir::succeeded(_result_encoding));
96
+ return StorageSpecifierType::get(odsParser.getContext(),
97
+ ::mlir::sparse_tensor::SparseTensorEncodingAttr(::llvm::cast<::mlir::sparse_tensor::SparseTensorEncodingAttr>((*_result_encoding))));
98
+ }
99
+
100
+ void StorageSpecifierType::print(::mlir::AsmPrinter &odsPrinter) const {
101
+ ::mlir::Builder odsBuilder(getContext());
102
+ odsPrinter << "<";
103
+ odsPrinter << getEncoding();
104
+ odsPrinter << ">";
105
+ }
106
+
107
+ ::mlir::sparse_tensor::SparseTensorEncodingAttr StorageSpecifierType::getEncoding() const {
108
+ return getImpl()->encoding;
109
+ }
110
+
111
+ } // namespace sparse_tensor
112
+ } // namespace mlir
113
+ MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::StorageSpecifierType)
114
+ namespace mlir {
115
+ namespace sparse_tensor {
116
+
117
+ /// Parse a type registered to this dialect.
118
+ ::mlir::Type SparseTensorDialect::parseType(::mlir::DialectAsmParser &parser) const {
119
+ ::llvm::SMLoc typeLoc = parser.getCurrentLocation();
120
+ ::llvm::StringRef mnemonic;
121
+ ::mlir::Type genType;
122
+ auto parseResult = generatedTypeParser(parser, &mnemonic, genType);
123
+ if (parseResult.has_value())
124
+ return genType;
125
+
126
+ parser.emitError(typeLoc) << "unknown type `"
127
+ << mnemonic << "` in dialect `" << getNamespace() << "`";
128
+ return {};
129
+ }
130
+ /// Print a type registered to this dialect.
131
+ void SparseTensorDialect::printType(::mlir::Type type,
132
+ ::mlir::DialectAsmPrinter &printer) const {
133
+ if (::mlir::succeeded(generatedTypePrinter(type, printer)))
134
+ return;
135
+
136
+ }
137
+ } // namespace sparse_tensor
138
+ } // namespace mlir
139
+
140
+ #endif // GET_TYPEDEF_CLASSES
141
+
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorTypes.h.inc ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2
+ |* *|
3
+ |* TypeDef Declarations *|
4
+ |* *|
5
+ |* Automatically generated file, do not edit! *|
6
+ |* *|
7
+ \*===----------------------------------------------------------------------===*/
8
+
9
+ #ifdef GET_TYPEDEF_CLASSES
10
+ #undef GET_TYPEDEF_CLASSES
11
+
12
+
13
+ namespace mlir {
14
+ class AsmParser;
15
+ class AsmPrinter;
16
+ } // namespace mlir
17
+ namespace mlir {
18
+ namespace sparse_tensor {
19
+ class StorageSpecifierType;
20
+ namespace detail {
21
+ struct StorageSpecifierTypeStorage;
22
+ } // namespace detail
23
+ class StorageSpecifierType : public ::mlir::Type::TypeBase<StorageSpecifierType, ::mlir::Type, detail::StorageSpecifierTypeStorage> {
24
+ public:
25
+ using Base::Base;
26
+ static StorageSpecifierType get(::mlir::MLIRContext *context, SparseTensorEncodingAttr encoding);
27
+ static StorageSpecifierType get(SparseTensorEncodingAttr encoding);
28
+ static StorageSpecifierType get(Type type);
29
+ static StorageSpecifierType get(Value tensor);
30
+ static constexpr ::llvm::StringLiteral getMnemonic() {
31
+ return {"storage_specifier"};
32
+ }
33
+
34
+ static ::mlir::Type parse(::mlir::AsmParser &odsParser);
35
+ void print(::mlir::AsmPrinter &odsPrinter) const;
36
+ ::mlir::sparse_tensor::SparseTensorEncodingAttr getEncoding() const;
37
+ };
38
+ } // namespace sparse_tensor
39
+ } // namespace mlir
40
+ MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::sparse_tensor::StorageSpecifierType)
41
+
42
+ #endif // GET_TYPEDEF_CLASSES
43
+
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Transforms/BufferizableOpInterfaceImpl.h ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //===- BufferizableOpInterfaceImpl.h - Impl. of BufferizableOpInterface ---===//
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_SPARSETENSOR_TRANSFORMS_BUFFERIZABLEOPINTERFACEIMPL_H_
10
+ #define MLIR_DIALECT_SPARSETENSOR_TRANSFORMS_BUFFERIZABLEOPINTERFACEIMPL_H_
11
+
12
+ namespace mlir {
13
+ class DialectRegistry;
14
+
15
+ namespace sparse_tensor {
16
+ void registerBufferizableOpInterfaceExternalModels(DialectRegistry &registry);
17
+ } // namespace sparse_tensor
18
+ } // namespace mlir
19
+
20
+ #endif // MLIR_DIALECT_SPARSETENSOR_TRANSFORMS_BUFFERIZABLEOPINTERFACEIMPL_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.capi.cpp.inc ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Autogenerated by mlir-tblgen; don't manually edit. */
2
+ //===----------------------------------------------------------------------===//
3
+ // SparseTensor Group Registration
4
+ //===----------------------------------------------------------------------===//
5
+
6
+ void mlirRegisterSparseTensorPasses(void) {
7
+ registerSparseTensorPasses();
8
+ }
9
+
10
+ MlirPass mlirCreateSparseTensorPostSparsificationRewrite(void) {
11
+ return wrap(mlir::createPostSparsificationRewritePass().release());
12
+ }
13
+ void mlirRegisterSparseTensorPostSparsificationRewrite(void) {
14
+ registerPostSparsificationRewrite();
15
+ }
16
+
17
+
18
+ MlirPass mlirCreateSparseTensorPreSparsificationRewrite(void) {
19
+ return wrap(mlir::createPreSparsificationRewritePass().release());
20
+ }
21
+ void mlirRegisterSparseTensorPreSparsificationRewrite(void) {
22
+ registerPreSparsificationRewrite();
23
+ }
24
+
25
+
26
+ MlirPass mlirCreateSparseTensorSparseBufferRewrite(void) {
27
+ return wrap(mlir::createSparseBufferRewritePass().release());
28
+ }
29
+ void mlirRegisterSparseTensorSparseBufferRewrite(void) {
30
+ registerSparseBufferRewrite();
31
+ }
32
+
33
+
34
+ MlirPass mlirCreateSparseTensorSparseGPUCodegen(void) {
35
+ return wrap(mlir::createSparseGPUCodegenPass().release());
36
+ }
37
+ void mlirRegisterSparseTensorSparseGPUCodegen(void) {
38
+ registerSparseGPUCodegen();
39
+ }
40
+
41
+
42
+ MlirPass mlirCreateSparseTensorSparseTensorCodegen(void) {
43
+ return wrap(mlir::createSparseTensorCodegenPass().release());
44
+ }
45
+ void mlirRegisterSparseTensorSparseTensorCodegen(void) {
46
+ registerSparseTensorCodegen();
47
+ }
48
+
49
+
50
+ MlirPass mlirCreateSparseTensorSparseTensorConversionPass(void) {
51
+ return wrap(mlir::createSparseTensorConversionPass().release());
52
+ }
53
+ void mlirRegisterSparseTensorSparseTensorConversionPass(void) {
54
+ registerSparseTensorConversionPass();
55
+ }
56
+
57
+
58
+ MlirPass mlirCreateSparseTensorSparseVectorization(void) {
59
+ return wrap(mlir::createSparseVectorizationPass().release());
60
+ }
61
+ void mlirRegisterSparseTensorSparseVectorization(void) {
62
+ registerSparseVectorization();
63
+ }
64
+
65
+
66
+ MlirPass mlirCreateSparseTensorSparsificationAndBufferization(void) {
67
+ return wrap(mlir::createSparsificationAndBufferizationPass().release());
68
+ }
69
+ void mlirRegisterSparseTensorSparsificationAndBufferization(void) {
70
+ registerSparsificationAndBufferization();
71
+ }
72
+
73
+
74
+ MlirPass mlirCreateSparseTensorSparsificationPass(void) {
75
+ return wrap(mlir::createSparsificationPass().release());
76
+ }
77
+ void mlirRegisterSparseTensorSparsificationPass(void) {
78
+ registerSparsificationPass();
79
+ }
80
+
81
+
82
+ MlirPass mlirCreateSparseTensorStageSparseOperations(void) {
83
+ return wrap(mlir::createStageSparseOperationsPass().release());
84
+ }
85
+ void mlirRegisterSparseTensorStageSparseOperations(void) {
86
+ registerStageSparseOperations();
87
+ }
88
+
89
+
90
+ MlirPass mlirCreateSparseTensorStorageSpecifierToLLVM(void) {
91
+ return wrap(mlir::createStorageSpecifierToLLVMPass().release());
92
+ }
93
+ void mlirRegisterSparseTensorStorageSpecifierToLLVM(void) {
94
+ registerStorageSpecifierToLLVM();
95
+ }
96
+
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.capi.h.inc ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* Autogenerated by mlir-tblgen; don't manually edit. */
3
+
4
+ #include "mlir-c/Pass.h"
5
+
6
+ #ifdef __cplusplus
7
+ extern "C" {
8
+ #endif
9
+
10
+ // Registration for the entire group
11
+ MLIR_CAPI_EXPORTED void mlirRegisterSparseTensorPasses(void);
12
+
13
+
14
+ /* Create SparseTensor Pass. */
15
+ MLIR_CAPI_EXPORTED MlirPass mlirCreateSparseTensorPostSparsificationRewrite(void);
16
+ MLIR_CAPI_EXPORTED void mlirRegisterSparseTensorPostSparsificationRewrite(void);
17
+
18
+
19
+ /* Create SparseTensor Pass. */
20
+ MLIR_CAPI_EXPORTED MlirPass mlirCreateSparseTensorPreSparsificationRewrite(void);
21
+ MLIR_CAPI_EXPORTED void mlirRegisterSparseTensorPreSparsificationRewrite(void);
22
+
23
+
24
+ /* Create SparseTensor Pass. */
25
+ MLIR_CAPI_EXPORTED MlirPass mlirCreateSparseTensorSparseBufferRewrite(void);
26
+ MLIR_CAPI_EXPORTED void mlirRegisterSparseTensorSparseBufferRewrite(void);
27
+
28
+
29
+ /* Create SparseTensor Pass. */
30
+ MLIR_CAPI_EXPORTED MlirPass mlirCreateSparseTensorSparseGPUCodegen(void);
31
+ MLIR_CAPI_EXPORTED void mlirRegisterSparseTensorSparseGPUCodegen(void);
32
+
33
+
34
+ /* Create SparseTensor Pass. */
35
+ MLIR_CAPI_EXPORTED MlirPass mlirCreateSparseTensorSparseTensorCodegen(void);
36
+ MLIR_CAPI_EXPORTED void mlirRegisterSparseTensorSparseTensorCodegen(void);
37
+
38
+
39
+ /* Create SparseTensor Pass. */
40
+ MLIR_CAPI_EXPORTED MlirPass mlirCreateSparseTensorSparseTensorConversionPass(void);
41
+ MLIR_CAPI_EXPORTED void mlirRegisterSparseTensorSparseTensorConversionPass(void);
42
+
43
+
44
+ /* Create SparseTensor Pass. */
45
+ MLIR_CAPI_EXPORTED MlirPass mlirCreateSparseTensorSparseVectorization(void);
46
+ MLIR_CAPI_EXPORTED void mlirRegisterSparseTensorSparseVectorization(void);
47
+
48
+
49
+ /* Create SparseTensor Pass. */
50
+ MLIR_CAPI_EXPORTED MlirPass mlirCreateSparseTensorSparsificationAndBufferization(void);
51
+ MLIR_CAPI_EXPORTED void mlirRegisterSparseTensorSparsificationAndBufferization(void);
52
+
53
+
54
+ /* Create SparseTensor Pass. */
55
+ MLIR_CAPI_EXPORTED MlirPass mlirCreateSparseTensorSparsificationPass(void);
56
+ MLIR_CAPI_EXPORTED void mlirRegisterSparseTensorSparsificationPass(void);
57
+
58
+
59
+ /* Create SparseTensor Pass. */
60
+ MLIR_CAPI_EXPORTED MlirPass mlirCreateSparseTensorStageSparseOperations(void);
61
+ MLIR_CAPI_EXPORTED void mlirRegisterSparseTensorStageSparseOperations(void);
62
+
63
+
64
+ /* Create SparseTensor Pass. */
65
+ MLIR_CAPI_EXPORTED MlirPass mlirCreateSparseTensorStorageSpecifierToLLVM(void);
66
+ MLIR_CAPI_EXPORTED void mlirRegisterSparseTensorStorageSpecifierToLLVM(void);
67
+
68
+
69
+
70
+ #ifdef __cplusplus
71
+ }
72
+ #endif
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.h ADDED
@@ -0,0 +1,253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //===- Passes.h - Sparse tensor pass entry points ---------------*- C++ -*-===//
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
+ // This header file defines prototypes of all sparse tensor passes.
10
+ //
11
+ //===----------------------------------------------------------------------===//
12
+
13
+ #ifndef MLIR_DIALECT_SPARSETENSOR_TRANSFORMS_PASSES_H_
14
+ #define MLIR_DIALECT_SPARSETENSOR_TRANSFORMS_PASSES_H_
15
+
16
+ #include "mlir/IR/PatternMatch.h"
17
+ #include "mlir/Pass/Pass.h"
18
+ #include "mlir/Transforms/DialectConversion.h"
19
+
20
+ //===----------------------------------------------------------------------===//
21
+ // Include the generated pass header (which needs some early definitions).
22
+ //===----------------------------------------------------------------------===//
23
+
24
+ namespace mlir {
25
+
26
+ namespace bufferization {
27
+ struct OneShotBufferizationOptions;
28
+ } // namespace bufferization
29
+
30
+ /// Defines a parallelization strategy. Any independent loop is a candidate
31
+ /// for parallelization. The loop is made parallel if (1) allowed by the
32
+ /// strategy (e.g., AnyStorageOuterLoop considers either a dense or sparse
33
+ /// outermost loop only), and (2) the generated code is an actual for-loop
34
+ /// (and not a co-iterating while-loop).
35
+ enum class SparseParallelizationStrategy {
36
+ kNone,
37
+ kDenseOuterLoop,
38
+ kAnyStorageOuterLoop,
39
+ kDenseAnyLoop,
40
+ kAnyStorageAnyLoop
41
+ };
42
+
43
+ /// Defines data movement strategy between host and device for GPU.
44
+ // TODO : Zero copy is disabled due to correctness bugs (tracker #64316)
45
+ enum class GPUDataTransferStrategy { kRegularDMA, kZeroCopy, kPinnedDMA };
46
+
47
+ #define GEN_PASS_DECL
48
+ #include "mlir/Dialect/SparseTensor/Transforms/Passes.h.inc"
49
+
50
+ //===----------------------------------------------------------------------===//
51
+ // The PreSparsificationRewriting pass.
52
+ //===----------------------------------------------------------------------===//
53
+
54
+ void populatePreSparsificationRewriting(RewritePatternSet &patterns);
55
+
56
+ std::unique_ptr<Pass> createPreSparsificationRewritePass();
57
+
58
+ //===----------------------------------------------------------------------===//
59
+ // The Sparsification pass.
60
+ //===----------------------------------------------------------------------===//
61
+
62
+ /// Options for the Sparsification pass.
63
+ struct SparsificationOptions {
64
+ SparsificationOptions(SparseParallelizationStrategy p,
65
+ GPUDataTransferStrategy t, bool idxReduc,
66
+ bool gpuLibgen, bool enableRT)
67
+ : parallelizationStrategy(p), gpuDataTransferStrategy(t),
68
+ enableIndexReduction(idxReduc), enableGPULibgen(gpuLibgen),
69
+ enableRuntimeLibrary(enableRT) {}
70
+ SparsificationOptions()
71
+ : SparsificationOptions(SparseParallelizationStrategy::kNone,
72
+ GPUDataTransferStrategy::kRegularDMA, false,
73
+ false, true) {}
74
+ SparseParallelizationStrategy parallelizationStrategy;
75
+ GPUDataTransferStrategy gpuDataTransferStrategy;
76
+ bool enableIndexReduction;
77
+ bool enableGPULibgen;
78
+ bool enableRuntimeLibrary;
79
+ };
80
+
81
+ /// Sets up sparsification rewriting rules with the given options.
82
+ void populateSparsificationPatterns(
83
+ RewritePatternSet &patterns,
84
+ const SparsificationOptions &options = SparsificationOptions());
85
+
86
+ std::unique_ptr<Pass> createSparsificationPass();
87
+ std::unique_ptr<Pass>
88
+ createSparsificationPass(const SparsificationOptions &options);
89
+
90
+ //===----------------------------------------------------------------------===//
91
+ // The StageSparseOperations pass.
92
+ //===----------------------------------------------------------------------===//
93
+
94
+ /// Sets up StageSparseOperation rewriting rules.
95
+ void populateStageSparseOperationsPatterns(RewritePatternSet &patterns);
96
+
97
+ std::unique_ptr<Pass> createStageSparseOperationsPass();
98
+
99
+ //===----------------------------------------------------------------------===//
100
+ // The PostSparsificationRewriting pass.
101
+ //===----------------------------------------------------------------------===//
102
+
103
+ void populatePostSparsificationRewriting(RewritePatternSet &patterns,
104
+ bool enableRT, bool enableForeach,
105
+ bool enableConvert);
106
+
107
+ std::unique_ptr<Pass> createPostSparsificationRewritePass();
108
+ std::unique_ptr<Pass>
109
+ createPostSparsificationRewritePass(bool enableRT, bool enableForeach = true,
110
+ bool enableConvert = true);
111
+
112
+ //===----------------------------------------------------------------------===//
113
+ // The SparseTensorConversion pass.
114
+ //===----------------------------------------------------------------------===//
115
+
116
+ /// Sparse tensor type converter into an opaque pointer.
117
+ class SparseTensorTypeToPtrConverter : public TypeConverter {
118
+ public:
119
+ SparseTensorTypeToPtrConverter();
120
+ };
121
+
122
+ /// Defines a strategy for implementing sparse-to-sparse conversion.
123
+ /// `kAuto` leaves it up to the compiler to automatically determine
124
+ /// the method used. `kViaCOO` converts the source tensor to COO and
125
+ /// then converts the COO to the target format. `kDirect` converts
126
+ /// directly via the algorithm in <https://arxiv.org/abs/2001.02609>;
127
+ /// however, beware that there are many formats not supported by this
128
+ /// conversion method.
129
+ enum class SparseToSparseConversionStrategy { kAuto, kViaCOO, kDirect };
130
+
131
+ /// Converts command-line sparse2sparse flag to the strategy enum.
132
+ SparseToSparseConversionStrategy sparseToSparseConversionStrategy(int32_t flag);
133
+
134
+ /// SparseTensorConversion options.
135
+ struct SparseTensorConversionOptions {
136
+ SparseTensorConversionOptions(SparseToSparseConversionStrategy s2s)
137
+ : sparseToSparseStrategy(s2s) {}
138
+ SparseTensorConversionOptions()
139
+ : SparseTensorConversionOptions(SparseToSparseConversionStrategy::kAuto) {
140
+ }
141
+ SparseToSparseConversionStrategy sparseToSparseStrategy;
142
+ };
143
+
144
+ /// Sets up sparse tensor conversion rules.
145
+ void populateSparseTensorConversionPatterns(
146
+ TypeConverter &typeConverter, RewritePatternSet &patterns,
147
+ const SparseTensorConversionOptions &options =
148
+ SparseTensorConversionOptions());
149
+
150
+ std::unique_ptr<Pass> createSparseTensorConversionPass();
151
+ std::unique_ptr<Pass>
152
+ createSparseTensorConversionPass(const SparseTensorConversionOptions &options);
153
+
154
+ //===----------------------------------------------------------------------===//
155
+ // The SparseTensorCodegen pass.
156
+ //===----------------------------------------------------------------------===//
157
+
158
+ /// Sparse tensor type converter into an actual buffer.
159
+ class SparseTensorTypeToBufferConverter : public TypeConverter {
160
+ public:
161
+ SparseTensorTypeToBufferConverter();
162
+ };
163
+
164
+ /// Sets up sparse tensor codegen rules.
165
+ void populateSparseTensorCodegenPatterns(TypeConverter &typeConverter,
166
+ RewritePatternSet &patterns,
167
+ bool createSparseDeallocs,
168
+ bool enableBufferInitialization);
169
+
170
+ std::unique_ptr<Pass> createSparseTensorCodegenPass();
171
+ std::unique_ptr<Pass>
172
+ createSparseTensorCodegenPass(bool createSparseDeallocs,
173
+ bool enableBufferInitialization);
174
+
175
+ //===----------------------------------------------------------------------===//
176
+ // The SparseBufferRewrite pass.
177
+ //===----------------------------------------------------------------------===//
178
+
179
+ void populateSparseBufferRewriting(RewritePatternSet &patterns,
180
+ bool enableBufferInitialization);
181
+
182
+ std::unique_ptr<Pass> createSparseBufferRewritePass();
183
+ std::unique_ptr<Pass>
184
+ createSparseBufferRewritePass(bool enableBufferInitialization);
185
+
186
+ //===----------------------------------------------------------------------===//
187
+ // The SparseVectorization pass.
188
+ //===----------------------------------------------------------------------===//
189
+
190
+ void populateSparseVectorizationPatterns(RewritePatternSet &patterns,
191
+ unsigned vectorLength,
192
+ bool enableVLAVectorization,
193
+ bool enableSIMDIndex32);
194
+
195
+ std::unique_ptr<Pass> createSparseVectorizationPass();
196
+ std::unique_ptr<Pass> createSparseVectorizationPass(unsigned vectorLength,
197
+ bool enableVLAVectorization,
198
+ bool enableSIMDIndex32);
199
+
200
+ //===----------------------------------------------------------------------===//
201
+ // The SparseGPU pass.
202
+ //===----------------------------------------------------------------------===//
203
+
204
+ void populateSparseGPUCodegenPatterns(RewritePatternSet &patterns,
205
+ unsigned numThreads);
206
+
207
+ void populateSparseGPULibgenPatterns(RewritePatternSet &patterns, bool enableRT,
208
+ GPUDataTransferStrategy gpuDataTransfer);
209
+
210
+ std::unique_ptr<Pass> createSparseGPUCodegenPass();
211
+ std::unique_ptr<Pass> createSparseGPUCodegenPass(unsigned numThreads);
212
+
213
+ //===----------------------------------------------------------------------===//
214
+ // The SparseStorageSpecifierToLLVM pass.
215
+ //===----------------------------------------------------------------------===//
216
+
217
+ class StorageSpecifierToLLVMTypeConverter : public TypeConverter {
218
+ public:
219
+ StorageSpecifierToLLVMTypeConverter();
220
+ };
221
+
222
+ void populateStorageSpecifierToLLVMPatterns(TypeConverter &converter,
223
+ RewritePatternSet &patterns);
224
+ std::unique_ptr<Pass> createStorageSpecifierToLLVMPass();
225
+
226
+ //===----------------------------------------------------------------------===//
227
+ // The mini-pipeline for sparsification and bufferization.
228
+ //===----------------------------------------------------------------------===//
229
+
230
+ bufferization::OneShotBufferizationOptions
231
+ getBufferizationOptionsForSparsification(bool analysisOnly);
232
+
233
+ std::unique_ptr<Pass> createSparsificationAndBufferizationPass();
234
+
235
+ std::unique_ptr<Pass> createSparsificationAndBufferizationPass(
236
+ const bufferization::OneShotBufferizationOptions &bufferizationOptions,
237
+ const SparsificationOptions &sparsificationOptions,
238
+ const SparseTensorConversionOptions &sparseTensorConversionOptions,
239
+ bool createSparseDeallocs, bool enableRuntimeLibrary,
240
+ bool enableBufferInitialization, unsigned vectorLength,
241
+ bool enableVLAVectorization, bool enableSIMDIndex32);
242
+
243
+ //===----------------------------------------------------------------------===//
244
+ // Registration.
245
+ //===----------------------------------------------------------------------===//
246
+
247
+ /// Generate the code for registering passes.
248
+ #define GEN_PASS_REGISTRATION
249
+ #include "mlir/Dialect/SparseTensor/Transforms/Passes.h.inc"
250
+
251
+ } // namespace mlir
252
+
253
+ #endif // MLIR_DIALECT_SPARSETENSOR_TRANSFORMS_PASSES_H_
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.h.inc ADDED
@@ -0,0 +1,1758 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Autogenerated by mlir-tblgen; don't manually edit */
2
+
3
+ #ifdef GEN_PASS_DECL
4
+ // Generate declarations for all passes.
5
+ #define GEN_PASS_DECL_POSTSPARSIFICATIONREWRITE
6
+ #define GEN_PASS_DECL_PRESPARSIFICATIONREWRITE
7
+ #define GEN_PASS_DECL_SPARSEBUFFERREWRITE
8
+ #define GEN_PASS_DECL_SPARSEGPUCODEGEN
9
+ #define GEN_PASS_DECL_SPARSETENSORCODEGEN
10
+ #define GEN_PASS_DECL_SPARSETENSORCONVERSIONPASS
11
+ #define GEN_PASS_DECL_SPARSEVECTORIZATION
12
+ #define GEN_PASS_DECL_SPARSIFICATIONANDBUFFERIZATION
13
+ #define GEN_PASS_DECL_SPARSIFICATIONPASS
14
+ #define GEN_PASS_DECL_STAGESPARSEOPERATIONS
15
+ #define GEN_PASS_DECL_STORAGESPECIFIERTOLLVM
16
+ #undef GEN_PASS_DECL
17
+ #endif // GEN_PASS_DECL
18
+
19
+ //===----------------------------------------------------------------------===//
20
+ // PostSparsificationRewrite
21
+ //===----------------------------------------------------------------------===//
22
+ #ifdef GEN_PASS_DECL_POSTSPARSIFICATIONREWRITE
23
+ struct PostSparsificationRewriteOptions {
24
+ bool enableRuntimeLibrary = true;
25
+ bool enableForeach = true;
26
+ bool enableConvert = true;
27
+ };
28
+ #undef GEN_PASS_DECL_POSTSPARSIFICATIONREWRITE
29
+ #endif // GEN_PASS_DECL_POSTSPARSIFICATIONREWRITE
30
+ #ifdef GEN_PASS_DEF_POSTSPARSIFICATIONREWRITE
31
+ namespace impl {
32
+
33
+ template <typename DerivedT>
34
+ class PostSparsificationRewriteBase : public ::mlir::OperationPass<ModuleOp> {
35
+ public:
36
+ using Base = PostSparsificationRewriteBase;
37
+
38
+ PostSparsificationRewriteBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
39
+ PostSparsificationRewriteBase(const PostSparsificationRewriteBase &other) : ::mlir::OperationPass<ModuleOp>(other) {}
40
+
41
+ /// Returns the command-line argument attached to this pass.
42
+ static constexpr ::llvm::StringLiteral getArgumentName() {
43
+ return ::llvm::StringLiteral("post-sparsification-rewrite");
44
+ }
45
+ ::llvm::StringRef getArgument() const override { return "post-sparsification-rewrite"; }
46
+
47
+ ::llvm::StringRef getDescription() const override { return "Applies sparse tensor rewriting rules after sparsification"; }
48
+
49
+ /// Returns the derived pass name.
50
+ static constexpr ::llvm::StringLiteral getPassName() {
51
+ return ::llvm::StringLiteral("PostSparsificationRewrite");
52
+ }
53
+ ::llvm::StringRef getName() const override { return "PostSparsificationRewrite"; }
54
+
55
+ /// Support isa/dyn_cast functionality for the derived pass class.
56
+ static bool classof(const ::mlir::Pass *pass) {
57
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
58
+ }
59
+
60
+ /// A clone method to create a copy of this pass.
61
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
62
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
63
+ }
64
+
65
+ /// Return the dialect that must be loaded in the context before this pass.
66
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
67
+
68
+ registry.insert<arith::ArithDialect>();
69
+
70
+ registry.insert<bufferization::BufferizationDialect>();
71
+
72
+ registry.insert<linalg::LinalgDialect>();
73
+
74
+ registry.insert<memref::MemRefDialect>();
75
+
76
+ registry.insert<scf::SCFDialect>();
77
+
78
+ registry.insert<sparse_tensor::SparseTensorDialect>();
79
+
80
+ }
81
+
82
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
83
+ /// instantiation because Pass classes should only be visible by the current
84
+ /// library.
85
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(PostSparsificationRewriteBase<DerivedT>)
86
+
87
+ PostSparsificationRewriteBase(const PostSparsificationRewriteOptions &options) : PostSparsificationRewriteBase() {
88
+ enableRuntimeLibrary = options.enableRuntimeLibrary;
89
+ enableForeach = options.enableForeach;
90
+ enableConvert = options.enableConvert;
91
+ }
92
+ protected:
93
+ ::mlir::Pass::Option<bool> enableRuntimeLibrary{*this, "enable-runtime-library", ::llvm::cl::desc("Enable runtime library for manipulating sparse tensors"), ::llvm::cl::init(true)};
94
+ ::mlir::Pass::Option<bool> enableForeach{*this, "enable-foreach", ::llvm::cl::desc("Enable rewriting rules for the foreach operator"), ::llvm::cl::init(true)};
95
+ ::mlir::Pass::Option<bool> enableConvert{*this, "enable-convert", ::llvm::cl::desc("Enable rewriting rules for the convert operator"), ::llvm::cl::init(true)};
96
+ private:
97
+ };
98
+ } // namespace impl
99
+ #undef GEN_PASS_DEF_POSTSPARSIFICATIONREWRITE
100
+ #endif // GEN_PASS_DEF_POSTSPARSIFICATIONREWRITE
101
+
102
+ //===----------------------------------------------------------------------===//
103
+ // PreSparsificationRewrite
104
+ //===----------------------------------------------------------------------===//
105
+ #ifdef GEN_PASS_DECL_PRESPARSIFICATIONREWRITE
106
+ #undef GEN_PASS_DECL_PRESPARSIFICATIONREWRITE
107
+ #endif // GEN_PASS_DECL_PRESPARSIFICATIONREWRITE
108
+ #ifdef GEN_PASS_DEF_PRESPARSIFICATIONREWRITE
109
+ namespace impl {
110
+
111
+ template <typename DerivedT>
112
+ class PreSparsificationRewriteBase : public ::mlir::OperationPass<ModuleOp> {
113
+ public:
114
+ using Base = PreSparsificationRewriteBase;
115
+
116
+ PreSparsificationRewriteBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
117
+ PreSparsificationRewriteBase(const PreSparsificationRewriteBase &other) : ::mlir::OperationPass<ModuleOp>(other) {}
118
+
119
+ /// Returns the command-line argument attached to this pass.
120
+ static constexpr ::llvm::StringLiteral getArgumentName() {
121
+ return ::llvm::StringLiteral("pre-sparsification-rewrite");
122
+ }
123
+ ::llvm::StringRef getArgument() const override { return "pre-sparsification-rewrite"; }
124
+
125
+ ::llvm::StringRef getDescription() const override { return "Applies sparse tensor rewriting rules prior to sparsification"; }
126
+
127
+ /// Returns the derived pass name.
128
+ static constexpr ::llvm::StringLiteral getPassName() {
129
+ return ::llvm::StringLiteral("PreSparsificationRewrite");
130
+ }
131
+ ::llvm::StringRef getName() const override { return "PreSparsificationRewrite"; }
132
+
133
+ /// Support isa/dyn_cast functionality for the derived pass class.
134
+ static bool classof(const ::mlir::Pass *pass) {
135
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
136
+ }
137
+
138
+ /// A clone method to create a copy of this pass.
139
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
140
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
141
+ }
142
+
143
+ /// Return the dialect that must be loaded in the context before this pass.
144
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
145
+
146
+ registry.insert<arith::ArithDialect>();
147
+
148
+ registry.insert<bufferization::BufferizationDialect>();
149
+
150
+ registry.insert<linalg::LinalgDialect>();
151
+
152
+ registry.insert<memref::MemRefDialect>();
153
+
154
+ registry.insert<scf::SCFDialect>();
155
+
156
+ registry.insert<sparse_tensor::SparseTensorDialect>();
157
+
158
+ }
159
+
160
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
161
+ /// instantiation because Pass classes should only be visible by the current
162
+ /// library.
163
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(PreSparsificationRewriteBase<DerivedT>)
164
+
165
+ protected:
166
+ private:
167
+ };
168
+ } // namespace impl
169
+ #undef GEN_PASS_DEF_PRESPARSIFICATIONREWRITE
170
+ #endif // GEN_PASS_DEF_PRESPARSIFICATIONREWRITE
171
+
172
+ //===----------------------------------------------------------------------===//
173
+ // SparseBufferRewrite
174
+ //===----------------------------------------------------------------------===//
175
+ #ifdef GEN_PASS_DECL_SPARSEBUFFERREWRITE
176
+ struct SparseBufferRewriteOptions {
177
+ bool enableBufferInitialization = false;
178
+ };
179
+ #undef GEN_PASS_DECL_SPARSEBUFFERREWRITE
180
+ #endif // GEN_PASS_DECL_SPARSEBUFFERREWRITE
181
+ #ifdef GEN_PASS_DEF_SPARSEBUFFERREWRITE
182
+ namespace impl {
183
+
184
+ template <typename DerivedT>
185
+ class SparseBufferRewriteBase : public ::mlir::OperationPass<ModuleOp> {
186
+ public:
187
+ using Base = SparseBufferRewriteBase;
188
+
189
+ SparseBufferRewriteBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
190
+ SparseBufferRewriteBase(const SparseBufferRewriteBase &other) : ::mlir::OperationPass<ModuleOp>(other) {}
191
+
192
+ /// Returns the command-line argument attached to this pass.
193
+ static constexpr ::llvm::StringLiteral getArgumentName() {
194
+ return ::llvm::StringLiteral("sparse-buffer-rewrite");
195
+ }
196
+ ::llvm::StringRef getArgument() const override { return "sparse-buffer-rewrite"; }
197
+
198
+ ::llvm::StringRef getDescription() const override { return "Rewrite sparse primitives on buffers to actual code"; }
199
+
200
+ /// Returns the derived pass name.
201
+ static constexpr ::llvm::StringLiteral getPassName() {
202
+ return ::llvm::StringLiteral("SparseBufferRewrite");
203
+ }
204
+ ::llvm::StringRef getName() const override { return "SparseBufferRewrite"; }
205
+
206
+ /// Support isa/dyn_cast functionality for the derived pass class.
207
+ static bool classof(const ::mlir::Pass *pass) {
208
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
209
+ }
210
+
211
+ /// A clone method to create a copy of this pass.
212
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
213
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
214
+ }
215
+
216
+ /// Return the dialect that must be loaded in the context before this pass.
217
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
218
+
219
+ registry.insert<arith::ArithDialect>();
220
+
221
+ registry.insert<linalg::LinalgDialect>();
222
+
223
+ registry.insert<memref::MemRefDialect>();
224
+
225
+ registry.insert<scf::SCFDialect>();
226
+
227
+ registry.insert<sparse_tensor::SparseTensorDialect>();
228
+
229
+ }
230
+
231
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
232
+ /// instantiation because Pass classes should only be visible by the current
233
+ /// library.
234
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SparseBufferRewriteBase<DerivedT>)
235
+
236
+ SparseBufferRewriteBase(const SparseBufferRewriteOptions &options) : SparseBufferRewriteBase() {
237
+ enableBufferInitialization = options.enableBufferInitialization;
238
+ }
239
+ protected:
240
+ ::mlir::Pass::Option<bool> enableBufferInitialization{*this, "enable-buffer-initialization", ::llvm::cl::desc("Enable zero-initialization of the memory buffers"), ::llvm::cl::init(false)};
241
+ private:
242
+ };
243
+ } // namespace impl
244
+ #undef GEN_PASS_DEF_SPARSEBUFFERREWRITE
245
+ #endif // GEN_PASS_DEF_SPARSEBUFFERREWRITE
246
+
247
+ //===----------------------------------------------------------------------===//
248
+ // SparseGPUCodegen
249
+ //===----------------------------------------------------------------------===//
250
+ #ifdef GEN_PASS_DECL_SPARSEGPUCODEGEN
251
+ struct SparseGPUCodegenOptions {
252
+ int32_t numThreads = 1024;
253
+ };
254
+ #undef GEN_PASS_DECL_SPARSEGPUCODEGEN
255
+ #endif // GEN_PASS_DECL_SPARSEGPUCODEGEN
256
+ #ifdef GEN_PASS_DEF_SPARSEGPUCODEGEN
257
+ namespace impl {
258
+
259
+ template <typename DerivedT>
260
+ class SparseGPUCodegenBase : public ::mlir::OperationPass<ModuleOp> {
261
+ public:
262
+ using Base = SparseGPUCodegenBase;
263
+
264
+ SparseGPUCodegenBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
265
+ SparseGPUCodegenBase(const SparseGPUCodegenBase &other) : ::mlir::OperationPass<ModuleOp>(other) {}
266
+
267
+ /// Returns the command-line argument attached to this pass.
268
+ static constexpr ::llvm::StringLiteral getArgumentName() {
269
+ return ::llvm::StringLiteral("sparse-gpu-codegen");
270
+ }
271
+ ::llvm::StringRef getArgument() const override { return "sparse-gpu-codegen"; }
272
+
273
+ ::llvm::StringRef getDescription() const override { return "Generates GPU code during sparsification"; }
274
+
275
+ /// Returns the derived pass name.
276
+ static constexpr ::llvm::StringLiteral getPassName() {
277
+ return ::llvm::StringLiteral("SparseGPUCodegen");
278
+ }
279
+ ::llvm::StringRef getName() const override { return "SparseGPUCodegen"; }
280
+
281
+ /// Support isa/dyn_cast functionality for the derived pass class.
282
+ static bool classof(const ::mlir::Pass *pass) {
283
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
284
+ }
285
+
286
+ /// A clone method to create a copy of this pass.
287
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
288
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
289
+ }
290
+
291
+ /// Return the dialect that must be loaded in the context before this pass.
292
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
293
+
294
+ registry.insert<arith::ArithDialect>();
295
+
296
+ registry.insert<bufferization::BufferizationDialect>();
297
+
298
+ registry.insert<gpu::GPUDialect>();
299
+
300
+ registry.insert<linalg::LinalgDialect>();
301
+
302
+ registry.insert<memref::MemRefDialect>();
303
+
304
+ registry.insert<scf::SCFDialect>();
305
+
306
+ registry.insert<sparse_tensor::SparseTensorDialect>();
307
+
308
+ }
309
+
310
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
311
+ /// instantiation because Pass classes should only be visible by the current
312
+ /// library.
313
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SparseGPUCodegenBase<DerivedT>)
314
+
315
+ SparseGPUCodegenBase(const SparseGPUCodegenOptions &options) : SparseGPUCodegenBase() {
316
+ numThreads = options.numThreads;
317
+ }
318
+ protected:
319
+ ::mlir::Pass::Option<int32_t> numThreads{*this, "num_threads", ::llvm::cl::desc("Sets the number of GPU threads"), ::llvm::cl::init(1024)};
320
+ private:
321
+ };
322
+ } // namespace impl
323
+ #undef GEN_PASS_DEF_SPARSEGPUCODEGEN
324
+ #endif // GEN_PASS_DEF_SPARSEGPUCODEGEN
325
+
326
+ //===----------------------------------------------------------------------===//
327
+ // SparseTensorCodegen
328
+ //===----------------------------------------------------------------------===//
329
+ #ifdef GEN_PASS_DECL_SPARSETENSORCODEGEN
330
+ struct SparseTensorCodegenOptions {
331
+ bool enableBufferInitialization = false;
332
+ bool createSparseDeallocs = true;
333
+ };
334
+ #undef GEN_PASS_DECL_SPARSETENSORCODEGEN
335
+ #endif // GEN_PASS_DECL_SPARSETENSORCODEGEN
336
+ #ifdef GEN_PASS_DEF_SPARSETENSORCODEGEN
337
+ namespace impl {
338
+
339
+ template <typename DerivedT>
340
+ class SparseTensorCodegenBase : public ::mlir::OperationPass<ModuleOp> {
341
+ public:
342
+ using Base = SparseTensorCodegenBase;
343
+
344
+ SparseTensorCodegenBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
345
+ SparseTensorCodegenBase(const SparseTensorCodegenBase &other) : ::mlir::OperationPass<ModuleOp>(other) {}
346
+
347
+ /// Returns the command-line argument attached to this pass.
348
+ static constexpr ::llvm::StringLiteral getArgumentName() {
349
+ return ::llvm::StringLiteral("sparse-tensor-codegen");
350
+ }
351
+ ::llvm::StringRef getArgument() const override { return "sparse-tensor-codegen"; }
352
+
353
+ ::llvm::StringRef getDescription() const override { return "Convert sparse tensors and primitives to actual code"; }
354
+
355
+ /// Returns the derived pass name.
356
+ static constexpr ::llvm::StringLiteral getPassName() {
357
+ return ::llvm::StringLiteral("SparseTensorCodegen");
358
+ }
359
+ ::llvm::StringRef getName() const override { return "SparseTensorCodegen"; }
360
+
361
+ /// Support isa/dyn_cast functionality for the derived pass class.
362
+ static bool classof(const ::mlir::Pass *pass) {
363
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
364
+ }
365
+
366
+ /// A clone method to create a copy of this pass.
367
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
368
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
369
+ }
370
+
371
+ /// Return the dialect that must be loaded in the context before this pass.
372
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
373
+
374
+ registry.insert<arith::ArithDialect>();
375
+
376
+ registry.insert<bufferization::BufferizationDialect>();
377
+
378
+ registry.insert<linalg::LinalgDialect>();
379
+
380
+ registry.insert<memref::MemRefDialect>();
381
+
382
+ registry.insert<scf::SCFDialect>();
383
+
384
+ registry.insert<sparse_tensor::SparseTensorDialect>();
385
+
386
+ }
387
+
388
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
389
+ /// instantiation because Pass classes should only be visible by the current
390
+ /// library.
391
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SparseTensorCodegenBase<DerivedT>)
392
+
393
+ SparseTensorCodegenBase(const SparseTensorCodegenOptions &options) : SparseTensorCodegenBase() {
394
+ enableBufferInitialization = options.enableBufferInitialization;
395
+ createSparseDeallocs = options.createSparseDeallocs;
396
+ }
397
+ protected:
398
+ ::mlir::Pass::Option<bool> enableBufferInitialization{*this, "enable-buffer-initialization", ::llvm::cl::desc("Enable zero-initialization of the memory buffers"), ::llvm::cl::init(false)};
399
+ ::mlir::Pass::Option<bool> createSparseDeallocs{*this, "create-sparse-deallocs", ::llvm::cl::desc("Specify if the temporary buffers created by the sparse compiler should be deallocated. For compatibility with core bufferization passes. This option is only used when enable-runtime-library=false. See also create-deallocs for BufferizationOption."), ::llvm::cl::init(true)};
400
+ private:
401
+ };
402
+ } // namespace impl
403
+ #undef GEN_PASS_DEF_SPARSETENSORCODEGEN
404
+ #endif // GEN_PASS_DEF_SPARSETENSORCODEGEN
405
+
406
+ //===----------------------------------------------------------------------===//
407
+ // SparseTensorConversionPass
408
+ //===----------------------------------------------------------------------===//
409
+ #ifdef GEN_PASS_DECL_SPARSETENSORCONVERSIONPASS
410
+ struct SparseTensorConversionPassOptions {
411
+ int32_t sparseToSparse = 0;
412
+ };
413
+ #undef GEN_PASS_DECL_SPARSETENSORCONVERSIONPASS
414
+ #endif // GEN_PASS_DECL_SPARSETENSORCONVERSIONPASS
415
+ #ifdef GEN_PASS_DEF_SPARSETENSORCONVERSIONPASS
416
+ namespace impl {
417
+
418
+ template <typename DerivedT>
419
+ class SparseTensorConversionPassBase : public ::mlir::OperationPass<ModuleOp> {
420
+ public:
421
+ using Base = SparseTensorConversionPassBase;
422
+
423
+ SparseTensorConversionPassBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
424
+ SparseTensorConversionPassBase(const SparseTensorConversionPassBase &other) : ::mlir::OperationPass<ModuleOp>(other) {}
425
+
426
+ /// Returns the command-line argument attached to this pass.
427
+ static constexpr ::llvm::StringLiteral getArgumentName() {
428
+ return ::llvm::StringLiteral("sparse-tensor-conversion");
429
+ }
430
+ ::llvm::StringRef getArgument() const override { return "sparse-tensor-conversion"; }
431
+
432
+ ::llvm::StringRef getDescription() const override { return "Convert sparse tensors and primitives to library calls"; }
433
+
434
+ /// Returns the derived pass name.
435
+ static constexpr ::llvm::StringLiteral getPassName() {
436
+ return ::llvm::StringLiteral("SparseTensorConversionPass");
437
+ }
438
+ ::llvm::StringRef getName() const override { return "SparseTensorConversionPass"; }
439
+
440
+ /// Support isa/dyn_cast functionality for the derived pass class.
441
+ static bool classof(const ::mlir::Pass *pass) {
442
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
443
+ }
444
+
445
+ /// A clone method to create a copy of this pass.
446
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
447
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
448
+ }
449
+
450
+ /// Return the dialect that must be loaded in the context before this pass.
451
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
452
+
453
+ registry.insert<arith::ArithDialect>();
454
+
455
+ registry.insert<bufferization::BufferizationDialect>();
456
+
457
+ registry.insert<LLVM::LLVMDialect>();
458
+
459
+ registry.insert<linalg::LinalgDialect>();
460
+
461
+ registry.insert<memref::MemRefDialect>();
462
+
463
+ registry.insert<scf::SCFDialect>();
464
+
465
+ registry.insert<sparse_tensor::SparseTensorDialect>();
466
+
467
+ }
468
+
469
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
470
+ /// instantiation because Pass classes should only be visible by the current
471
+ /// library.
472
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SparseTensorConversionPassBase<DerivedT>)
473
+
474
+ SparseTensorConversionPassBase(const SparseTensorConversionPassOptions &options) : SparseTensorConversionPassBase() {
475
+ sparseToSparse = options.sparseToSparse;
476
+ }
477
+ protected:
478
+ ::mlir::Pass::Option<int32_t> sparseToSparse{*this, "s2s-strategy", ::llvm::cl::desc("Set the strategy for sparse-to-sparse conversion"), ::llvm::cl::init(0)};
479
+ private:
480
+ };
481
+ } // namespace impl
482
+ #undef GEN_PASS_DEF_SPARSETENSORCONVERSIONPASS
483
+ #endif // GEN_PASS_DEF_SPARSETENSORCONVERSIONPASS
484
+
485
+ //===----------------------------------------------------------------------===//
486
+ // SparseVectorization
487
+ //===----------------------------------------------------------------------===//
488
+ #ifdef GEN_PASS_DECL_SPARSEVECTORIZATION
489
+ struct SparseVectorizationOptions {
490
+ int32_t vectorLength = 0;
491
+ bool enableVLAVectorization = false;
492
+ bool enableSIMDIndex32 = false;
493
+ };
494
+ #undef GEN_PASS_DECL_SPARSEVECTORIZATION
495
+ #endif // GEN_PASS_DECL_SPARSEVECTORIZATION
496
+ #ifdef GEN_PASS_DEF_SPARSEVECTORIZATION
497
+ namespace impl {
498
+
499
+ template <typename DerivedT>
500
+ class SparseVectorizationBase : public ::mlir::OperationPass<ModuleOp> {
501
+ public:
502
+ using Base = SparseVectorizationBase;
503
+
504
+ SparseVectorizationBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
505
+ SparseVectorizationBase(const SparseVectorizationBase &other) : ::mlir::OperationPass<ModuleOp>(other) {}
506
+
507
+ /// Returns the command-line argument attached to this pass.
508
+ static constexpr ::llvm::StringLiteral getArgumentName() {
509
+ return ::llvm::StringLiteral("sparse-vectorization");
510
+ }
511
+ ::llvm::StringRef getArgument() const override { return "sparse-vectorization"; }
512
+
513
+ ::llvm::StringRef getDescription() const override { return "Vectorizes loops after sparsification"; }
514
+
515
+ /// Returns the derived pass name.
516
+ static constexpr ::llvm::StringLiteral getPassName() {
517
+ return ::llvm::StringLiteral("SparseVectorization");
518
+ }
519
+ ::llvm::StringRef getName() const override { return "SparseVectorization"; }
520
+
521
+ /// Support isa/dyn_cast functionality for the derived pass class.
522
+ static bool classof(const ::mlir::Pass *pass) {
523
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
524
+ }
525
+
526
+ /// A clone method to create a copy of this pass.
527
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
528
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
529
+ }
530
+
531
+ /// Return the dialect that must be loaded in the context before this pass.
532
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
533
+
534
+ registry.insert<arith::ArithDialect>();
535
+
536
+ registry.insert<memref::MemRefDialect>();
537
+
538
+ registry.insert<scf::SCFDialect>();
539
+
540
+ registry.insert<sparse_tensor::SparseTensorDialect>();
541
+
542
+ registry.insert<vector::VectorDialect>();
543
+
544
+ }
545
+
546
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
547
+ /// instantiation because Pass classes should only be visible by the current
548
+ /// library.
549
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SparseVectorizationBase<DerivedT>)
550
+
551
+ SparseVectorizationBase(const SparseVectorizationOptions &options) : SparseVectorizationBase() {
552
+ vectorLength = options.vectorLength;
553
+ enableVLAVectorization = options.enableVLAVectorization;
554
+ enableSIMDIndex32 = options.enableSIMDIndex32;
555
+ }
556
+ protected:
557
+ ::mlir::Pass::Option<int32_t> vectorLength{*this, "vl", ::llvm::cl::desc("Set the vector length (use 0 to disable vectorization)"), ::llvm::cl::init(0)};
558
+ ::mlir::Pass::Option<bool> enableVLAVectorization{*this, "enable-vla-vectorization", ::llvm::cl::desc("Enable vector length agnostic vectorization"), ::llvm::cl::init(false)};
559
+ ::mlir::Pass::Option<bool> enableSIMDIndex32{*this, "enable-simd-index32", ::llvm::cl::desc("Enable i32 indexing into vectors (for efficient gather/scatter)"), ::llvm::cl::init(false)};
560
+ private:
561
+ };
562
+ } // namespace impl
563
+ #undef GEN_PASS_DEF_SPARSEVECTORIZATION
564
+ #endif // GEN_PASS_DEF_SPARSEVECTORIZATION
565
+
566
+ //===----------------------------------------------------------------------===//
567
+ // SparsificationAndBufferization
568
+ //===----------------------------------------------------------------------===//
569
+ #ifdef GEN_PASS_DECL_SPARSIFICATIONANDBUFFERIZATION
570
+ #undef GEN_PASS_DECL_SPARSIFICATIONANDBUFFERIZATION
571
+ #endif // GEN_PASS_DECL_SPARSIFICATIONANDBUFFERIZATION
572
+ #ifdef GEN_PASS_DEF_SPARSIFICATIONANDBUFFERIZATION
573
+ namespace impl {
574
+
575
+ template <typename DerivedT>
576
+ class SparsificationAndBufferizationBase : public ::mlir::OperationPass<ModuleOp> {
577
+ public:
578
+ using Base = SparsificationAndBufferizationBase;
579
+
580
+ SparsificationAndBufferizationBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
581
+ SparsificationAndBufferizationBase(const SparsificationAndBufferizationBase &other) : ::mlir::OperationPass<ModuleOp>(other) {}
582
+
583
+ /// Returns the command-line argument attached to this pass.
584
+ static constexpr ::llvm::StringLiteral getArgumentName() {
585
+ return ::llvm::StringLiteral("sparsification-and-bufferization");
586
+ }
587
+ ::llvm::StringRef getArgument() const override { return "sparsification-and-bufferization"; }
588
+
589
+ ::llvm::StringRef getDescription() const override { return "Mini-pipeline that combines bufferization and sparsifiation"; }
590
+
591
+ /// Returns the derived pass name.
592
+ static constexpr ::llvm::StringLiteral getPassName() {
593
+ return ::llvm::StringLiteral("SparsificationAndBufferization");
594
+ }
595
+ ::llvm::StringRef getName() const override { return "SparsificationAndBufferization"; }
596
+
597
+ /// Support isa/dyn_cast functionality for the derived pass class.
598
+ static bool classof(const ::mlir::Pass *pass) {
599
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
600
+ }
601
+
602
+ /// A clone method to create a copy of this pass.
603
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
604
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
605
+ }
606
+
607
+ /// Return the dialect that must be loaded in the context before this pass.
608
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
609
+
610
+ registry.insert<affine::AffineDialect>();
611
+
612
+ registry.insert<arith::ArithDialect>();
613
+
614
+ registry.insert<bufferization::BufferizationDialect>();
615
+
616
+ registry.insert<gpu::GPUDialect>();
617
+
618
+ registry.insert<LLVM::LLVMDialect>();
619
+
620
+ registry.insert<linalg::LinalgDialect>();
621
+
622
+ registry.insert<memref::MemRefDialect>();
623
+
624
+ registry.insert<scf::SCFDialect>();
625
+
626
+ registry.insert<sparse_tensor::SparseTensorDialect>();
627
+
628
+ }
629
+
630
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
631
+ /// instantiation because Pass classes should only be visible by the current
632
+ /// library.
633
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SparsificationAndBufferizationBase<DerivedT>)
634
+
635
+ protected:
636
+ private:
637
+ };
638
+ } // namespace impl
639
+ #undef GEN_PASS_DEF_SPARSIFICATIONANDBUFFERIZATION
640
+ #endif // GEN_PASS_DEF_SPARSIFICATIONANDBUFFERIZATION
641
+
642
+ //===----------------------------------------------------------------------===//
643
+ // SparsificationPass
644
+ //===----------------------------------------------------------------------===//
645
+ #ifdef GEN_PASS_DECL_SPARSIFICATIONPASS
646
+ struct SparsificationPassOptions {
647
+ bool enableIndexReduction = false;
648
+ mlir::SparseParallelizationStrategy parallelization = mlir::SparseParallelizationStrategy::kNone;
649
+ mlir::GPUDataTransferStrategy gpuDataTransfer = mlir::GPUDataTransferStrategy::kRegularDMA;
650
+ bool enableGPULibgen = false;
651
+ bool enableRuntimeLibrary = true;
652
+ };
653
+ #undef GEN_PASS_DECL_SPARSIFICATIONPASS
654
+ #endif // GEN_PASS_DECL_SPARSIFICATIONPASS
655
+ #ifdef GEN_PASS_DEF_SPARSIFICATIONPASS
656
+ namespace impl {
657
+
658
+ template <typename DerivedT>
659
+ class SparsificationPassBase : public ::mlir::OperationPass<ModuleOp> {
660
+ public:
661
+ using Base = SparsificationPassBase;
662
+
663
+ SparsificationPassBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
664
+ SparsificationPassBase(const SparsificationPassBase &other) : ::mlir::OperationPass<ModuleOp>(other) {}
665
+
666
+ /// Returns the command-line argument attached to this pass.
667
+ static constexpr ::llvm::StringLiteral getArgumentName() {
668
+ return ::llvm::StringLiteral("sparsification");
669
+ }
670
+ ::llvm::StringRef getArgument() const override { return "sparsification"; }
671
+
672
+ ::llvm::StringRef getDescription() const override { return "Automatically generate sparse tensor code from sparse tensor types"; }
673
+
674
+ /// Returns the derived pass name.
675
+ static constexpr ::llvm::StringLiteral getPassName() {
676
+ return ::llvm::StringLiteral("SparsificationPass");
677
+ }
678
+ ::llvm::StringRef getName() const override { return "SparsificationPass"; }
679
+
680
+ /// Support isa/dyn_cast functionality for the derived pass class.
681
+ static bool classof(const ::mlir::Pass *pass) {
682
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
683
+ }
684
+
685
+ /// A clone method to create a copy of this pass.
686
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
687
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
688
+ }
689
+
690
+ /// Return the dialect that must be loaded in the context before this pass.
691
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
692
+
693
+ registry.insert<affine::AffineDialect>();
694
+
695
+ registry.insert<arith::ArithDialect>();
696
+
697
+ registry.insert<bufferization::BufferizationDialect>();
698
+
699
+ registry.insert<gpu::GPUDialect>();
700
+
701
+ registry.insert<LLVM::LLVMDialect>();
702
+
703
+ registry.insert<linalg::LinalgDialect>();
704
+
705
+ registry.insert<memref::MemRefDialect>();
706
+
707
+ registry.insert<scf::SCFDialect>();
708
+
709
+ registry.insert<sparse_tensor::SparseTensorDialect>();
710
+
711
+ }
712
+
713
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
714
+ /// instantiation because Pass classes should only be visible by the current
715
+ /// library.
716
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SparsificationPassBase<DerivedT>)
717
+
718
+ SparsificationPassBase(const SparsificationPassOptions &options) : SparsificationPassBase() {
719
+ enableIndexReduction = options.enableIndexReduction;
720
+ parallelization = options.parallelization;
721
+ gpuDataTransfer = options.gpuDataTransfer;
722
+ enableGPULibgen = options.enableGPULibgen;
723
+ enableRuntimeLibrary = options.enableRuntimeLibrary;
724
+ }
725
+ protected:
726
+ ::mlir::Pass::Option<bool> enableIndexReduction{*this, "enable-index-reduction", ::llvm::cl::desc("Enable dependent index reduction based algorithm to handle non-trivial index expressions on sparse inputs (experimental features)"), ::llvm::cl::init(false)};
727
+ ::mlir::Pass::Option<mlir::SparseParallelizationStrategy> parallelization{*this, "parallelization-strategy", ::llvm::cl::desc("Set the parallelization strategy"), ::llvm::cl::init(mlir::SparseParallelizationStrategy::kNone), llvm::cl::values(
728
+ clEnumValN(mlir::SparseParallelizationStrategy::kNone, "none",
729
+ "Turn off sparse parallelization."),
730
+ clEnumValN(mlir::SparseParallelizationStrategy::kDenseOuterLoop,
731
+ "dense-outer-loop",
732
+ "Enable dense outer loop sparse parallelization."),
733
+ clEnumValN(mlir::SparseParallelizationStrategy::kAnyStorageOuterLoop,
734
+ "any-storage-outer-loop",
735
+ "Enable sparse parallelization regardless of storage for the outer loop."),
736
+ clEnumValN(mlir::SparseParallelizationStrategy::kDenseAnyLoop,
737
+ "dense-any-loop",
738
+ "Enable dense parallelization for any loop."),
739
+ clEnumValN(mlir::SparseParallelizationStrategy::kAnyStorageAnyLoop,
740
+ "any-storage-any-loop",
741
+ "Enable sparse parallelization for any storage and loop."))};
742
+ ::mlir::Pass::Option<mlir::GPUDataTransferStrategy> gpuDataTransfer{*this, "gpu-data-transfer-strategy", ::llvm::cl::desc("Set the data transfer strategy"), ::llvm::cl::init(mlir::GPUDataTransferStrategy::kRegularDMA), llvm::cl::values(
743
+ clEnumValN(mlir::GPUDataTransferStrategy::kRegularDMA,
744
+ "regular-dma",
745
+ "Default option: malloc on host without additional "
746
+ "options or care and then use DMA to copy the data"),
747
+ clEnumValN(mlir::GPUDataTransferStrategy::kPinnedDMA, "pinned-dma",
748
+ "Based on the default option, pin the host memory to "
749
+ "accelerate the data transfer"),
750
+ clEnumValN(mlir::GPUDataTransferStrategy::kZeroCopy, "zero-copy",
751
+ "Use zero-copy to perform the data transfer from the host "
752
+ "to the GPU"))};
753
+ ::mlir::Pass::Option<bool> enableGPULibgen{*this, "enable-gpu-libgen", ::llvm::cl::desc("Enable GPU acceleration by means of direct library calls (like cuSPARSE)"), ::llvm::cl::init(false)};
754
+ ::mlir::Pass::Option<bool> enableRuntimeLibrary{*this, "enable-runtime-library", ::llvm::cl::desc("Enable runtime library for manipulating sparse tensors"), ::llvm::cl::init(true)};
755
+ private:
756
+ };
757
+ } // namespace impl
758
+ #undef GEN_PASS_DEF_SPARSIFICATIONPASS
759
+ #endif // GEN_PASS_DEF_SPARSIFICATIONPASS
760
+
761
+ //===----------------------------------------------------------------------===//
762
+ // StageSparseOperations
763
+ //===----------------------------------------------------------------------===//
764
+ #ifdef GEN_PASS_DECL_STAGESPARSEOPERATIONS
765
+ #undef GEN_PASS_DECL_STAGESPARSEOPERATIONS
766
+ #endif // GEN_PASS_DECL_STAGESPARSEOPERATIONS
767
+ #ifdef GEN_PASS_DEF_STAGESPARSEOPERATIONS
768
+ namespace impl {
769
+
770
+ template <typename DerivedT>
771
+ class StageSparseOperationsBase : public ::mlir::OperationPass<func::FuncOp> {
772
+ public:
773
+ using Base = StageSparseOperationsBase;
774
+
775
+ StageSparseOperationsBase() : ::mlir::OperationPass<func::FuncOp>(::mlir::TypeID::get<DerivedT>()) {}
776
+ StageSparseOperationsBase(const StageSparseOperationsBase &other) : ::mlir::OperationPass<func::FuncOp>(other) {}
777
+
778
+ /// Returns the command-line argument attached to this pass.
779
+ static constexpr ::llvm::StringLiteral getArgumentName() {
780
+ return ::llvm::StringLiteral("stage-sparse-ops");
781
+ }
782
+ ::llvm::StringRef getArgument() const override { return "stage-sparse-ops"; }
783
+
784
+ ::llvm::StringRef getDescription() const override { return "Decompose a complex sparse operation into multiple stages"; }
785
+
786
+ /// Returns the derived pass name.
787
+ static constexpr ::llvm::StringLiteral getPassName() {
788
+ return ::llvm::StringLiteral("StageSparseOperations");
789
+ }
790
+ ::llvm::StringRef getName() const override { return "StageSparseOperations"; }
791
+
792
+ /// Support isa/dyn_cast functionality for the derived pass class.
793
+ static bool classof(const ::mlir::Pass *pass) {
794
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
795
+ }
796
+
797
+ /// A clone method to create a copy of this pass.
798
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
799
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
800
+ }
801
+
802
+ /// Return the dialect that must be loaded in the context before this pass.
803
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
804
+
805
+ registry.insert<sparse_tensor::SparseTensorDialect>();
806
+
807
+ }
808
+
809
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
810
+ /// instantiation because Pass classes should only be visible by the current
811
+ /// library.
812
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StageSparseOperationsBase<DerivedT>)
813
+
814
+ protected:
815
+ private:
816
+ };
817
+ } // namespace impl
818
+ #undef GEN_PASS_DEF_STAGESPARSEOPERATIONS
819
+ #endif // GEN_PASS_DEF_STAGESPARSEOPERATIONS
820
+
821
+ //===----------------------------------------------------------------------===//
822
+ // StorageSpecifierToLLVM
823
+ //===----------------------------------------------------------------------===//
824
+ #ifdef GEN_PASS_DECL_STORAGESPECIFIERTOLLVM
825
+ #undef GEN_PASS_DECL_STORAGESPECIFIERTOLLVM
826
+ #endif // GEN_PASS_DECL_STORAGESPECIFIERTOLLVM
827
+ #ifdef GEN_PASS_DEF_STORAGESPECIFIERTOLLVM
828
+ namespace impl {
829
+
830
+ template <typename DerivedT>
831
+ class StorageSpecifierToLLVMBase : public ::mlir::OperationPass<ModuleOp> {
832
+ public:
833
+ using Base = StorageSpecifierToLLVMBase;
834
+
835
+ StorageSpecifierToLLVMBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
836
+ StorageSpecifierToLLVMBase(const StorageSpecifierToLLVMBase &other) : ::mlir::OperationPass<ModuleOp>(other) {}
837
+
838
+ /// Returns the command-line argument attached to this pass.
839
+ static constexpr ::llvm::StringLiteral getArgumentName() {
840
+ return ::llvm::StringLiteral("sparse-storage-specifier-to-llvm");
841
+ }
842
+ ::llvm::StringRef getArgument() const override { return "sparse-storage-specifier-to-llvm"; }
843
+
844
+ ::llvm::StringRef getDescription() const override { return "Lower sparse storage specifer to llvm structure"; }
845
+
846
+ /// Returns the derived pass name.
847
+ static constexpr ::llvm::StringLiteral getPassName() {
848
+ return ::llvm::StringLiteral("StorageSpecifierToLLVM");
849
+ }
850
+ ::llvm::StringRef getName() const override { return "StorageSpecifierToLLVM"; }
851
+
852
+ /// Support isa/dyn_cast functionality for the derived pass class.
853
+ static bool classof(const ::mlir::Pass *pass) {
854
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
855
+ }
856
+
857
+ /// A clone method to create a copy of this pass.
858
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
859
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
860
+ }
861
+
862
+ /// Return the dialect that must be loaded in the context before this pass.
863
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
864
+
865
+ registry.insert<arith::ArithDialect>();
866
+
867
+ registry.insert<LLVM::LLVMDialect>();
868
+
869
+ registry.insert<sparse_tensor::SparseTensorDialect>();
870
+
871
+ }
872
+
873
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
874
+ /// instantiation because Pass classes should only be visible by the current
875
+ /// library.
876
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StorageSpecifierToLLVMBase<DerivedT>)
877
+
878
+ protected:
879
+ private:
880
+ };
881
+ } // namespace impl
882
+ #undef GEN_PASS_DEF_STORAGESPECIFIERTOLLVM
883
+ #endif // GEN_PASS_DEF_STORAGESPECIFIERTOLLVM
884
+ #ifdef GEN_PASS_REGISTRATION
885
+
886
+ //===----------------------------------------------------------------------===//
887
+ // PostSparsificationRewrite Registration
888
+ //===----------------------------------------------------------------------===//
889
+
890
+ inline void registerPostSparsificationRewrite() {
891
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
892
+ return mlir::createPostSparsificationRewritePass();
893
+ });
894
+ }
895
+
896
+ // Old registration code, kept for temporary backwards compatibility.
897
+ inline void registerPostSparsificationRewritePass() {
898
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
899
+ return mlir::createPostSparsificationRewritePass();
900
+ });
901
+ }
902
+
903
+ //===----------------------------------------------------------------------===//
904
+ // PreSparsificationRewrite Registration
905
+ //===----------------------------------------------------------------------===//
906
+
907
+ inline void registerPreSparsificationRewrite() {
908
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
909
+ return mlir::createPreSparsificationRewritePass();
910
+ });
911
+ }
912
+
913
+ // Old registration code, kept for temporary backwards compatibility.
914
+ inline void registerPreSparsificationRewritePass() {
915
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
916
+ return mlir::createPreSparsificationRewritePass();
917
+ });
918
+ }
919
+
920
+ //===----------------------------------------------------------------------===//
921
+ // SparseBufferRewrite Registration
922
+ //===----------------------------------------------------------------------===//
923
+
924
+ inline void registerSparseBufferRewrite() {
925
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
926
+ return mlir::createSparseBufferRewritePass();
927
+ });
928
+ }
929
+
930
+ // Old registration code, kept for temporary backwards compatibility.
931
+ inline void registerSparseBufferRewritePass() {
932
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
933
+ return mlir::createSparseBufferRewritePass();
934
+ });
935
+ }
936
+
937
+ //===----------------------------------------------------------------------===//
938
+ // SparseGPUCodegen Registration
939
+ //===----------------------------------------------------------------------===//
940
+
941
+ inline void registerSparseGPUCodegen() {
942
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
943
+ return mlir::createSparseGPUCodegenPass();
944
+ });
945
+ }
946
+
947
+ // Old registration code, kept for temporary backwards compatibility.
948
+ inline void registerSparseGPUCodegenPass() {
949
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
950
+ return mlir::createSparseGPUCodegenPass();
951
+ });
952
+ }
953
+
954
+ //===----------------------------------------------------------------------===//
955
+ // SparseTensorCodegen Registration
956
+ //===----------------------------------------------------------------------===//
957
+
958
+ inline void registerSparseTensorCodegen() {
959
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
960
+ return mlir::createSparseTensorCodegenPass();
961
+ });
962
+ }
963
+
964
+ // Old registration code, kept for temporary backwards compatibility.
965
+ inline void registerSparseTensorCodegenPass() {
966
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
967
+ return mlir::createSparseTensorCodegenPass();
968
+ });
969
+ }
970
+
971
+ //===----------------------------------------------------------------------===//
972
+ // SparseTensorConversionPass Registration
973
+ //===----------------------------------------------------------------------===//
974
+
975
+ inline void registerSparseTensorConversionPass() {
976
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
977
+ return mlir::createSparseTensorConversionPass();
978
+ });
979
+ }
980
+
981
+ // Old registration code, kept for temporary backwards compatibility.
982
+ inline void registerSparseTensorConversionPassPass() {
983
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
984
+ return mlir::createSparseTensorConversionPass();
985
+ });
986
+ }
987
+
988
+ //===----------------------------------------------------------------------===//
989
+ // SparseVectorization Registration
990
+ //===----------------------------------------------------------------------===//
991
+
992
+ inline void registerSparseVectorization() {
993
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
994
+ return mlir::createSparseVectorizationPass();
995
+ });
996
+ }
997
+
998
+ // Old registration code, kept for temporary backwards compatibility.
999
+ inline void registerSparseVectorizationPass() {
1000
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
1001
+ return mlir::createSparseVectorizationPass();
1002
+ });
1003
+ }
1004
+
1005
+ //===----------------------------------------------------------------------===//
1006
+ // SparsificationAndBufferization Registration
1007
+ //===----------------------------------------------------------------------===//
1008
+
1009
+ inline void registerSparsificationAndBufferization() {
1010
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
1011
+ return mlir::createSparsificationAndBufferizationPass();
1012
+ });
1013
+ }
1014
+
1015
+ // Old registration code, kept for temporary backwards compatibility.
1016
+ inline void registerSparsificationAndBufferizationPass() {
1017
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
1018
+ return mlir::createSparsificationAndBufferizationPass();
1019
+ });
1020
+ }
1021
+
1022
+ //===----------------------------------------------------------------------===//
1023
+ // SparsificationPass Registration
1024
+ //===----------------------------------------------------------------------===//
1025
+
1026
+ inline void registerSparsificationPass() {
1027
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
1028
+ return mlir::createSparsificationPass();
1029
+ });
1030
+ }
1031
+
1032
+ // Old registration code, kept for temporary backwards compatibility.
1033
+ inline void registerSparsificationPassPass() {
1034
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
1035
+ return mlir::createSparsificationPass();
1036
+ });
1037
+ }
1038
+
1039
+ //===----------------------------------------------------------------------===//
1040
+ // StageSparseOperations Registration
1041
+ //===----------------------------------------------------------------------===//
1042
+
1043
+ inline void registerStageSparseOperations() {
1044
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
1045
+ return mlir::createStageSparseOperationsPass();
1046
+ });
1047
+ }
1048
+
1049
+ // Old registration code, kept for temporary backwards compatibility.
1050
+ inline void registerStageSparseOperationsPass() {
1051
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
1052
+ return mlir::createStageSparseOperationsPass();
1053
+ });
1054
+ }
1055
+
1056
+ //===----------------------------------------------------------------------===//
1057
+ // StorageSpecifierToLLVM Registration
1058
+ //===----------------------------------------------------------------------===//
1059
+
1060
+ inline void registerStorageSpecifierToLLVM() {
1061
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
1062
+ return mlir::createStorageSpecifierToLLVMPass();
1063
+ });
1064
+ }
1065
+
1066
+ // Old registration code, kept for temporary backwards compatibility.
1067
+ inline void registerStorageSpecifierToLLVMPass() {
1068
+ ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> {
1069
+ return mlir::createStorageSpecifierToLLVMPass();
1070
+ });
1071
+ }
1072
+
1073
+ //===----------------------------------------------------------------------===//
1074
+ // SparseTensor Registration
1075
+ //===----------------------------------------------------------------------===//
1076
+
1077
+ inline void registerSparseTensorPasses() {
1078
+ registerPostSparsificationRewrite();
1079
+ registerPreSparsificationRewrite();
1080
+ registerSparseBufferRewrite();
1081
+ registerSparseGPUCodegen();
1082
+ registerSparseTensorCodegen();
1083
+ registerSparseTensorConversionPass();
1084
+ registerSparseVectorization();
1085
+ registerSparsificationAndBufferization();
1086
+ registerSparsificationPass();
1087
+ registerStageSparseOperations();
1088
+ registerStorageSpecifierToLLVM();
1089
+ }
1090
+ #undef GEN_PASS_REGISTRATION
1091
+ #endif // GEN_PASS_REGISTRATION
1092
+ // Deprecated. Please use the new per-pass macros.
1093
+ #ifdef GEN_PASS_CLASSES
1094
+
1095
+ template <typename DerivedT>
1096
+ class PostSparsificationRewriteBase : public ::mlir::OperationPass<ModuleOp> {
1097
+ public:
1098
+ using Base = PostSparsificationRewriteBase;
1099
+
1100
+ PostSparsificationRewriteBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
1101
+ PostSparsificationRewriteBase(const PostSparsificationRewriteBase &other) : ::mlir::OperationPass<ModuleOp>(other) {}
1102
+
1103
+ /// Returns the command-line argument attached to this pass.
1104
+ static constexpr ::llvm::StringLiteral getArgumentName() {
1105
+ return ::llvm::StringLiteral("post-sparsification-rewrite");
1106
+ }
1107
+ ::llvm::StringRef getArgument() const override { return "post-sparsification-rewrite"; }
1108
+
1109
+ ::llvm::StringRef getDescription() const override { return "Applies sparse tensor rewriting rules after sparsification"; }
1110
+
1111
+ /// Returns the derived pass name.
1112
+ static constexpr ::llvm::StringLiteral getPassName() {
1113
+ return ::llvm::StringLiteral("PostSparsificationRewrite");
1114
+ }
1115
+ ::llvm::StringRef getName() const override { return "PostSparsificationRewrite"; }
1116
+
1117
+ /// Support isa/dyn_cast functionality for the derived pass class.
1118
+ static bool classof(const ::mlir::Pass *pass) {
1119
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
1120
+ }
1121
+
1122
+ /// A clone method to create a copy of this pass.
1123
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
1124
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
1125
+ }
1126
+
1127
+ /// Return the dialect that must be loaded in the context before this pass.
1128
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
1129
+
1130
+ registry.insert<arith::ArithDialect>();
1131
+
1132
+ registry.insert<bufferization::BufferizationDialect>();
1133
+
1134
+ registry.insert<linalg::LinalgDialect>();
1135
+
1136
+ registry.insert<memref::MemRefDialect>();
1137
+
1138
+ registry.insert<scf::SCFDialect>();
1139
+
1140
+ registry.insert<sparse_tensor::SparseTensorDialect>();
1141
+
1142
+ }
1143
+
1144
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
1145
+ /// instantiation because Pass classes should only be visible by the current
1146
+ /// library.
1147
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(PostSparsificationRewriteBase<DerivedT>)
1148
+
1149
+ protected:
1150
+ ::mlir::Pass::Option<bool> enableRuntimeLibrary{*this, "enable-runtime-library", ::llvm::cl::desc("Enable runtime library for manipulating sparse tensors"), ::llvm::cl::init(true)};
1151
+ ::mlir::Pass::Option<bool> enableForeach{*this, "enable-foreach", ::llvm::cl::desc("Enable rewriting rules for the foreach operator"), ::llvm::cl::init(true)};
1152
+ ::mlir::Pass::Option<bool> enableConvert{*this, "enable-convert", ::llvm::cl::desc("Enable rewriting rules for the convert operator"), ::llvm::cl::init(true)};
1153
+ };
1154
+
1155
+ template <typename DerivedT>
1156
+ class PreSparsificationRewriteBase : public ::mlir::OperationPass<ModuleOp> {
1157
+ public:
1158
+ using Base = PreSparsificationRewriteBase;
1159
+
1160
+ PreSparsificationRewriteBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
1161
+ PreSparsificationRewriteBase(const PreSparsificationRewriteBase &other) : ::mlir::OperationPass<ModuleOp>(other) {}
1162
+
1163
+ /// Returns the command-line argument attached to this pass.
1164
+ static constexpr ::llvm::StringLiteral getArgumentName() {
1165
+ return ::llvm::StringLiteral("pre-sparsification-rewrite");
1166
+ }
1167
+ ::llvm::StringRef getArgument() const override { return "pre-sparsification-rewrite"; }
1168
+
1169
+ ::llvm::StringRef getDescription() const override { return "Applies sparse tensor rewriting rules prior to sparsification"; }
1170
+
1171
+ /// Returns the derived pass name.
1172
+ static constexpr ::llvm::StringLiteral getPassName() {
1173
+ return ::llvm::StringLiteral("PreSparsificationRewrite");
1174
+ }
1175
+ ::llvm::StringRef getName() const override { return "PreSparsificationRewrite"; }
1176
+
1177
+ /// Support isa/dyn_cast functionality for the derived pass class.
1178
+ static bool classof(const ::mlir::Pass *pass) {
1179
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
1180
+ }
1181
+
1182
+ /// A clone method to create a copy of this pass.
1183
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
1184
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
1185
+ }
1186
+
1187
+ /// Return the dialect that must be loaded in the context before this pass.
1188
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
1189
+
1190
+ registry.insert<arith::ArithDialect>();
1191
+
1192
+ registry.insert<bufferization::BufferizationDialect>();
1193
+
1194
+ registry.insert<linalg::LinalgDialect>();
1195
+
1196
+ registry.insert<memref::MemRefDialect>();
1197
+
1198
+ registry.insert<scf::SCFDialect>();
1199
+
1200
+ registry.insert<sparse_tensor::SparseTensorDialect>();
1201
+
1202
+ }
1203
+
1204
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
1205
+ /// instantiation because Pass classes should only be visible by the current
1206
+ /// library.
1207
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(PreSparsificationRewriteBase<DerivedT>)
1208
+
1209
+ protected:
1210
+ };
1211
+
1212
+ template <typename DerivedT>
1213
+ class SparseBufferRewriteBase : public ::mlir::OperationPass<ModuleOp> {
1214
+ public:
1215
+ using Base = SparseBufferRewriteBase;
1216
+
1217
+ SparseBufferRewriteBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
1218
+ SparseBufferRewriteBase(const SparseBufferRewriteBase &other) : ::mlir::OperationPass<ModuleOp>(other) {}
1219
+
1220
+ /// Returns the command-line argument attached to this pass.
1221
+ static constexpr ::llvm::StringLiteral getArgumentName() {
1222
+ return ::llvm::StringLiteral("sparse-buffer-rewrite");
1223
+ }
1224
+ ::llvm::StringRef getArgument() const override { return "sparse-buffer-rewrite"; }
1225
+
1226
+ ::llvm::StringRef getDescription() const override { return "Rewrite sparse primitives on buffers to actual code"; }
1227
+
1228
+ /// Returns the derived pass name.
1229
+ static constexpr ::llvm::StringLiteral getPassName() {
1230
+ return ::llvm::StringLiteral("SparseBufferRewrite");
1231
+ }
1232
+ ::llvm::StringRef getName() const override { return "SparseBufferRewrite"; }
1233
+
1234
+ /// Support isa/dyn_cast functionality for the derived pass class.
1235
+ static bool classof(const ::mlir::Pass *pass) {
1236
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
1237
+ }
1238
+
1239
+ /// A clone method to create a copy of this pass.
1240
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
1241
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
1242
+ }
1243
+
1244
+ /// Return the dialect that must be loaded in the context before this pass.
1245
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
1246
+
1247
+ registry.insert<arith::ArithDialect>();
1248
+
1249
+ registry.insert<linalg::LinalgDialect>();
1250
+
1251
+ registry.insert<memref::MemRefDialect>();
1252
+
1253
+ registry.insert<scf::SCFDialect>();
1254
+
1255
+ registry.insert<sparse_tensor::SparseTensorDialect>();
1256
+
1257
+ }
1258
+
1259
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
1260
+ /// instantiation because Pass classes should only be visible by the current
1261
+ /// library.
1262
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SparseBufferRewriteBase<DerivedT>)
1263
+
1264
+ protected:
1265
+ ::mlir::Pass::Option<bool> enableBufferInitialization{*this, "enable-buffer-initialization", ::llvm::cl::desc("Enable zero-initialization of the memory buffers"), ::llvm::cl::init(false)};
1266
+ };
1267
+
1268
+ template <typename DerivedT>
1269
+ class SparseGPUCodegenBase : public ::mlir::OperationPass<ModuleOp> {
1270
+ public:
1271
+ using Base = SparseGPUCodegenBase;
1272
+
1273
+ SparseGPUCodegenBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
1274
+ SparseGPUCodegenBase(const SparseGPUCodegenBase &other) : ::mlir::OperationPass<ModuleOp>(other) {}
1275
+
1276
+ /// Returns the command-line argument attached to this pass.
1277
+ static constexpr ::llvm::StringLiteral getArgumentName() {
1278
+ return ::llvm::StringLiteral("sparse-gpu-codegen");
1279
+ }
1280
+ ::llvm::StringRef getArgument() const override { return "sparse-gpu-codegen"; }
1281
+
1282
+ ::llvm::StringRef getDescription() const override { return "Generates GPU code during sparsification"; }
1283
+
1284
+ /// Returns the derived pass name.
1285
+ static constexpr ::llvm::StringLiteral getPassName() {
1286
+ return ::llvm::StringLiteral("SparseGPUCodegen");
1287
+ }
1288
+ ::llvm::StringRef getName() const override { return "SparseGPUCodegen"; }
1289
+
1290
+ /// Support isa/dyn_cast functionality for the derived pass class.
1291
+ static bool classof(const ::mlir::Pass *pass) {
1292
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
1293
+ }
1294
+
1295
+ /// A clone method to create a copy of this pass.
1296
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
1297
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
1298
+ }
1299
+
1300
+ /// Return the dialect that must be loaded in the context before this pass.
1301
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
1302
+
1303
+ registry.insert<arith::ArithDialect>();
1304
+
1305
+ registry.insert<bufferization::BufferizationDialect>();
1306
+
1307
+ registry.insert<gpu::GPUDialect>();
1308
+
1309
+ registry.insert<linalg::LinalgDialect>();
1310
+
1311
+ registry.insert<memref::MemRefDialect>();
1312
+
1313
+ registry.insert<scf::SCFDialect>();
1314
+
1315
+ registry.insert<sparse_tensor::SparseTensorDialect>();
1316
+
1317
+ }
1318
+
1319
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
1320
+ /// instantiation because Pass classes should only be visible by the current
1321
+ /// library.
1322
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SparseGPUCodegenBase<DerivedT>)
1323
+
1324
+ protected:
1325
+ ::mlir::Pass::Option<int32_t> numThreads{*this, "num_threads", ::llvm::cl::desc("Sets the number of GPU threads"), ::llvm::cl::init(1024)};
1326
+ };
1327
+
1328
+ template <typename DerivedT>
1329
+ class SparseTensorCodegenBase : public ::mlir::OperationPass<ModuleOp> {
1330
+ public:
1331
+ using Base = SparseTensorCodegenBase;
1332
+
1333
+ SparseTensorCodegenBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
1334
+ SparseTensorCodegenBase(const SparseTensorCodegenBase &other) : ::mlir::OperationPass<ModuleOp>(other) {}
1335
+
1336
+ /// Returns the command-line argument attached to this pass.
1337
+ static constexpr ::llvm::StringLiteral getArgumentName() {
1338
+ return ::llvm::StringLiteral("sparse-tensor-codegen");
1339
+ }
1340
+ ::llvm::StringRef getArgument() const override { return "sparse-tensor-codegen"; }
1341
+
1342
+ ::llvm::StringRef getDescription() const override { return "Convert sparse tensors and primitives to actual code"; }
1343
+
1344
+ /// Returns the derived pass name.
1345
+ static constexpr ::llvm::StringLiteral getPassName() {
1346
+ return ::llvm::StringLiteral("SparseTensorCodegen");
1347
+ }
1348
+ ::llvm::StringRef getName() const override { return "SparseTensorCodegen"; }
1349
+
1350
+ /// Support isa/dyn_cast functionality for the derived pass class.
1351
+ static bool classof(const ::mlir::Pass *pass) {
1352
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
1353
+ }
1354
+
1355
+ /// A clone method to create a copy of this pass.
1356
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
1357
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
1358
+ }
1359
+
1360
+ /// Return the dialect that must be loaded in the context before this pass.
1361
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
1362
+
1363
+ registry.insert<arith::ArithDialect>();
1364
+
1365
+ registry.insert<bufferization::BufferizationDialect>();
1366
+
1367
+ registry.insert<linalg::LinalgDialect>();
1368
+
1369
+ registry.insert<memref::MemRefDialect>();
1370
+
1371
+ registry.insert<scf::SCFDialect>();
1372
+
1373
+ registry.insert<sparse_tensor::SparseTensorDialect>();
1374
+
1375
+ }
1376
+
1377
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
1378
+ /// instantiation because Pass classes should only be visible by the current
1379
+ /// library.
1380
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SparseTensorCodegenBase<DerivedT>)
1381
+
1382
+ protected:
1383
+ ::mlir::Pass::Option<bool> enableBufferInitialization{*this, "enable-buffer-initialization", ::llvm::cl::desc("Enable zero-initialization of the memory buffers"), ::llvm::cl::init(false)};
1384
+ ::mlir::Pass::Option<bool> createSparseDeallocs{*this, "create-sparse-deallocs", ::llvm::cl::desc("Specify if the temporary buffers created by the sparse compiler should be deallocated. For compatibility with core bufferization passes. This option is only used when enable-runtime-library=false. See also create-deallocs for BufferizationOption."), ::llvm::cl::init(true)};
1385
+ };
1386
+
1387
+ template <typename DerivedT>
1388
+ class SparseTensorConversionPassBase : public ::mlir::OperationPass<ModuleOp> {
1389
+ public:
1390
+ using Base = SparseTensorConversionPassBase;
1391
+
1392
+ SparseTensorConversionPassBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
1393
+ SparseTensorConversionPassBase(const SparseTensorConversionPassBase &other) : ::mlir::OperationPass<ModuleOp>(other) {}
1394
+
1395
+ /// Returns the command-line argument attached to this pass.
1396
+ static constexpr ::llvm::StringLiteral getArgumentName() {
1397
+ return ::llvm::StringLiteral("sparse-tensor-conversion");
1398
+ }
1399
+ ::llvm::StringRef getArgument() const override { return "sparse-tensor-conversion"; }
1400
+
1401
+ ::llvm::StringRef getDescription() const override { return "Convert sparse tensors and primitives to library calls"; }
1402
+
1403
+ /// Returns the derived pass name.
1404
+ static constexpr ::llvm::StringLiteral getPassName() {
1405
+ return ::llvm::StringLiteral("SparseTensorConversionPass");
1406
+ }
1407
+ ::llvm::StringRef getName() const override { return "SparseTensorConversionPass"; }
1408
+
1409
+ /// Support isa/dyn_cast functionality for the derived pass class.
1410
+ static bool classof(const ::mlir::Pass *pass) {
1411
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
1412
+ }
1413
+
1414
+ /// A clone method to create a copy of this pass.
1415
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
1416
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
1417
+ }
1418
+
1419
+ /// Return the dialect that must be loaded in the context before this pass.
1420
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
1421
+
1422
+ registry.insert<arith::ArithDialect>();
1423
+
1424
+ registry.insert<bufferization::BufferizationDialect>();
1425
+
1426
+ registry.insert<LLVM::LLVMDialect>();
1427
+
1428
+ registry.insert<linalg::LinalgDialect>();
1429
+
1430
+ registry.insert<memref::MemRefDialect>();
1431
+
1432
+ registry.insert<scf::SCFDialect>();
1433
+
1434
+ registry.insert<sparse_tensor::SparseTensorDialect>();
1435
+
1436
+ }
1437
+
1438
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
1439
+ /// instantiation because Pass classes should only be visible by the current
1440
+ /// library.
1441
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SparseTensorConversionPassBase<DerivedT>)
1442
+
1443
+ protected:
1444
+ ::mlir::Pass::Option<int32_t> sparseToSparse{*this, "s2s-strategy", ::llvm::cl::desc("Set the strategy for sparse-to-sparse conversion"), ::llvm::cl::init(0)};
1445
+ };
1446
+
1447
+ template <typename DerivedT>
1448
+ class SparseVectorizationBase : public ::mlir::OperationPass<ModuleOp> {
1449
+ public:
1450
+ using Base = SparseVectorizationBase;
1451
+
1452
+ SparseVectorizationBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
1453
+ SparseVectorizationBase(const SparseVectorizationBase &other) : ::mlir::OperationPass<ModuleOp>(other) {}
1454
+
1455
+ /// Returns the command-line argument attached to this pass.
1456
+ static constexpr ::llvm::StringLiteral getArgumentName() {
1457
+ return ::llvm::StringLiteral("sparse-vectorization");
1458
+ }
1459
+ ::llvm::StringRef getArgument() const override { return "sparse-vectorization"; }
1460
+
1461
+ ::llvm::StringRef getDescription() const override { return "Vectorizes loops after sparsification"; }
1462
+
1463
+ /// Returns the derived pass name.
1464
+ static constexpr ::llvm::StringLiteral getPassName() {
1465
+ return ::llvm::StringLiteral("SparseVectorization");
1466
+ }
1467
+ ::llvm::StringRef getName() const override { return "SparseVectorization"; }
1468
+
1469
+ /// Support isa/dyn_cast functionality for the derived pass class.
1470
+ static bool classof(const ::mlir::Pass *pass) {
1471
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
1472
+ }
1473
+
1474
+ /// A clone method to create a copy of this pass.
1475
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
1476
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
1477
+ }
1478
+
1479
+ /// Return the dialect that must be loaded in the context before this pass.
1480
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
1481
+
1482
+ registry.insert<arith::ArithDialect>();
1483
+
1484
+ registry.insert<memref::MemRefDialect>();
1485
+
1486
+ registry.insert<scf::SCFDialect>();
1487
+
1488
+ registry.insert<sparse_tensor::SparseTensorDialect>();
1489
+
1490
+ registry.insert<vector::VectorDialect>();
1491
+
1492
+ }
1493
+
1494
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
1495
+ /// instantiation because Pass classes should only be visible by the current
1496
+ /// library.
1497
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SparseVectorizationBase<DerivedT>)
1498
+
1499
+ protected:
1500
+ ::mlir::Pass::Option<int32_t> vectorLength{*this, "vl", ::llvm::cl::desc("Set the vector length (use 0 to disable vectorization)"), ::llvm::cl::init(0)};
1501
+ ::mlir::Pass::Option<bool> enableVLAVectorization{*this, "enable-vla-vectorization", ::llvm::cl::desc("Enable vector length agnostic vectorization"), ::llvm::cl::init(false)};
1502
+ ::mlir::Pass::Option<bool> enableSIMDIndex32{*this, "enable-simd-index32", ::llvm::cl::desc("Enable i32 indexing into vectors (for efficient gather/scatter)"), ::llvm::cl::init(false)};
1503
+ };
1504
+
1505
+ template <typename DerivedT>
1506
+ class SparsificationAndBufferizationBase : public ::mlir::OperationPass<ModuleOp> {
1507
+ public:
1508
+ using Base = SparsificationAndBufferizationBase;
1509
+
1510
+ SparsificationAndBufferizationBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
1511
+ SparsificationAndBufferizationBase(const SparsificationAndBufferizationBase &other) : ::mlir::OperationPass<ModuleOp>(other) {}
1512
+
1513
+ /// Returns the command-line argument attached to this pass.
1514
+ static constexpr ::llvm::StringLiteral getArgumentName() {
1515
+ return ::llvm::StringLiteral("sparsification-and-bufferization");
1516
+ }
1517
+ ::llvm::StringRef getArgument() const override { return "sparsification-and-bufferization"; }
1518
+
1519
+ ::llvm::StringRef getDescription() const override { return "Mini-pipeline that combines bufferization and sparsifiation"; }
1520
+
1521
+ /// Returns the derived pass name.
1522
+ static constexpr ::llvm::StringLiteral getPassName() {
1523
+ return ::llvm::StringLiteral("SparsificationAndBufferization");
1524
+ }
1525
+ ::llvm::StringRef getName() const override { return "SparsificationAndBufferization"; }
1526
+
1527
+ /// Support isa/dyn_cast functionality for the derived pass class.
1528
+ static bool classof(const ::mlir::Pass *pass) {
1529
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
1530
+ }
1531
+
1532
+ /// A clone method to create a copy of this pass.
1533
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
1534
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
1535
+ }
1536
+
1537
+ /// Return the dialect that must be loaded in the context before this pass.
1538
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
1539
+
1540
+ registry.insert<affine::AffineDialect>();
1541
+
1542
+ registry.insert<arith::ArithDialect>();
1543
+
1544
+ registry.insert<bufferization::BufferizationDialect>();
1545
+
1546
+ registry.insert<gpu::GPUDialect>();
1547
+
1548
+ registry.insert<LLVM::LLVMDialect>();
1549
+
1550
+ registry.insert<linalg::LinalgDialect>();
1551
+
1552
+ registry.insert<memref::MemRefDialect>();
1553
+
1554
+ registry.insert<scf::SCFDialect>();
1555
+
1556
+ registry.insert<sparse_tensor::SparseTensorDialect>();
1557
+
1558
+ }
1559
+
1560
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
1561
+ /// instantiation because Pass classes should only be visible by the current
1562
+ /// library.
1563
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SparsificationAndBufferizationBase<DerivedT>)
1564
+
1565
+ protected:
1566
+ };
1567
+
1568
+ template <typename DerivedT>
1569
+ class SparsificationPassBase : public ::mlir::OperationPass<ModuleOp> {
1570
+ public:
1571
+ using Base = SparsificationPassBase;
1572
+
1573
+ SparsificationPassBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
1574
+ SparsificationPassBase(const SparsificationPassBase &other) : ::mlir::OperationPass<ModuleOp>(other) {}
1575
+
1576
+ /// Returns the command-line argument attached to this pass.
1577
+ static constexpr ::llvm::StringLiteral getArgumentName() {
1578
+ return ::llvm::StringLiteral("sparsification");
1579
+ }
1580
+ ::llvm::StringRef getArgument() const override { return "sparsification"; }
1581
+
1582
+ ::llvm::StringRef getDescription() const override { return "Automatically generate sparse tensor code from sparse tensor types"; }
1583
+
1584
+ /// Returns the derived pass name.
1585
+ static constexpr ::llvm::StringLiteral getPassName() {
1586
+ return ::llvm::StringLiteral("SparsificationPass");
1587
+ }
1588
+ ::llvm::StringRef getName() const override { return "SparsificationPass"; }
1589
+
1590
+ /// Support isa/dyn_cast functionality for the derived pass class.
1591
+ static bool classof(const ::mlir::Pass *pass) {
1592
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
1593
+ }
1594
+
1595
+ /// A clone method to create a copy of this pass.
1596
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
1597
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
1598
+ }
1599
+
1600
+ /// Return the dialect that must be loaded in the context before this pass.
1601
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
1602
+
1603
+ registry.insert<affine::AffineDialect>();
1604
+
1605
+ registry.insert<arith::ArithDialect>();
1606
+
1607
+ registry.insert<bufferization::BufferizationDialect>();
1608
+
1609
+ registry.insert<gpu::GPUDialect>();
1610
+
1611
+ registry.insert<LLVM::LLVMDialect>();
1612
+
1613
+ registry.insert<linalg::LinalgDialect>();
1614
+
1615
+ registry.insert<memref::MemRefDialect>();
1616
+
1617
+ registry.insert<scf::SCFDialect>();
1618
+
1619
+ registry.insert<sparse_tensor::SparseTensorDialect>();
1620
+
1621
+ }
1622
+
1623
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
1624
+ /// instantiation because Pass classes should only be visible by the current
1625
+ /// library.
1626
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SparsificationPassBase<DerivedT>)
1627
+
1628
+ protected:
1629
+ ::mlir::Pass::Option<bool> enableIndexReduction{*this, "enable-index-reduction", ::llvm::cl::desc("Enable dependent index reduction based algorithm to handle non-trivial index expressions on sparse inputs (experimental features)"), ::llvm::cl::init(false)};
1630
+ ::mlir::Pass::Option<mlir::SparseParallelizationStrategy> parallelization{*this, "parallelization-strategy", ::llvm::cl::desc("Set the parallelization strategy"), ::llvm::cl::init(mlir::SparseParallelizationStrategy::kNone), llvm::cl::values(
1631
+ clEnumValN(mlir::SparseParallelizationStrategy::kNone, "none",
1632
+ "Turn off sparse parallelization."),
1633
+ clEnumValN(mlir::SparseParallelizationStrategy::kDenseOuterLoop,
1634
+ "dense-outer-loop",
1635
+ "Enable dense outer loop sparse parallelization."),
1636
+ clEnumValN(mlir::SparseParallelizationStrategy::kAnyStorageOuterLoop,
1637
+ "any-storage-outer-loop",
1638
+ "Enable sparse parallelization regardless of storage for the outer loop."),
1639
+ clEnumValN(mlir::SparseParallelizationStrategy::kDenseAnyLoop,
1640
+ "dense-any-loop",
1641
+ "Enable dense parallelization for any loop."),
1642
+ clEnumValN(mlir::SparseParallelizationStrategy::kAnyStorageAnyLoop,
1643
+ "any-storage-any-loop",
1644
+ "Enable sparse parallelization for any storage and loop."))};
1645
+ ::mlir::Pass::Option<mlir::GPUDataTransferStrategy> gpuDataTransfer{*this, "gpu-data-transfer-strategy", ::llvm::cl::desc("Set the data transfer strategy"), ::llvm::cl::init(mlir::GPUDataTransferStrategy::kRegularDMA), llvm::cl::values(
1646
+ clEnumValN(mlir::GPUDataTransferStrategy::kRegularDMA,
1647
+ "regular-dma",
1648
+ "Default option: malloc on host without additional "
1649
+ "options or care and then use DMA to copy the data"),
1650
+ clEnumValN(mlir::GPUDataTransferStrategy::kPinnedDMA, "pinned-dma",
1651
+ "Based on the default option, pin the host memory to "
1652
+ "accelerate the data transfer"),
1653
+ clEnumValN(mlir::GPUDataTransferStrategy::kZeroCopy, "zero-copy",
1654
+ "Use zero-copy to perform the data transfer from the host "
1655
+ "to the GPU"))};
1656
+ ::mlir::Pass::Option<bool> enableGPULibgen{*this, "enable-gpu-libgen", ::llvm::cl::desc("Enable GPU acceleration by means of direct library calls (like cuSPARSE)"), ::llvm::cl::init(false)};
1657
+ ::mlir::Pass::Option<bool> enableRuntimeLibrary{*this, "enable-runtime-library", ::llvm::cl::desc("Enable runtime library for manipulating sparse tensors"), ::llvm::cl::init(true)};
1658
+ };
1659
+
1660
+ template <typename DerivedT>
1661
+ class StageSparseOperationsBase : public ::mlir::OperationPass<func::FuncOp> {
1662
+ public:
1663
+ using Base = StageSparseOperationsBase;
1664
+
1665
+ StageSparseOperationsBase() : ::mlir::OperationPass<func::FuncOp>(::mlir::TypeID::get<DerivedT>()) {}
1666
+ StageSparseOperationsBase(const StageSparseOperationsBase &other) : ::mlir::OperationPass<func::FuncOp>(other) {}
1667
+
1668
+ /// Returns the command-line argument attached to this pass.
1669
+ static constexpr ::llvm::StringLiteral getArgumentName() {
1670
+ return ::llvm::StringLiteral("stage-sparse-ops");
1671
+ }
1672
+ ::llvm::StringRef getArgument() const override { return "stage-sparse-ops"; }
1673
+
1674
+ ::llvm::StringRef getDescription() const override { return "Decompose a complex sparse operation into multiple stages"; }
1675
+
1676
+ /// Returns the derived pass name.
1677
+ static constexpr ::llvm::StringLiteral getPassName() {
1678
+ return ::llvm::StringLiteral("StageSparseOperations");
1679
+ }
1680
+ ::llvm::StringRef getName() const override { return "StageSparseOperations"; }
1681
+
1682
+ /// Support isa/dyn_cast functionality for the derived pass class.
1683
+ static bool classof(const ::mlir::Pass *pass) {
1684
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
1685
+ }
1686
+
1687
+ /// A clone method to create a copy of this pass.
1688
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
1689
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
1690
+ }
1691
+
1692
+ /// Return the dialect that must be loaded in the context before this pass.
1693
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
1694
+
1695
+ registry.insert<sparse_tensor::SparseTensorDialect>();
1696
+
1697
+ }
1698
+
1699
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
1700
+ /// instantiation because Pass classes should only be visible by the current
1701
+ /// library.
1702
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StageSparseOperationsBase<DerivedT>)
1703
+
1704
+ protected:
1705
+ };
1706
+
1707
+ template <typename DerivedT>
1708
+ class StorageSpecifierToLLVMBase : public ::mlir::OperationPass<ModuleOp> {
1709
+ public:
1710
+ using Base = StorageSpecifierToLLVMBase;
1711
+
1712
+ StorageSpecifierToLLVMBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {}
1713
+ StorageSpecifierToLLVMBase(const StorageSpecifierToLLVMBase &other) : ::mlir::OperationPass<ModuleOp>(other) {}
1714
+
1715
+ /// Returns the command-line argument attached to this pass.
1716
+ static constexpr ::llvm::StringLiteral getArgumentName() {
1717
+ return ::llvm::StringLiteral("sparse-storage-specifier-to-llvm");
1718
+ }
1719
+ ::llvm::StringRef getArgument() const override { return "sparse-storage-specifier-to-llvm"; }
1720
+
1721
+ ::llvm::StringRef getDescription() const override { return "Lower sparse storage specifer to llvm structure"; }
1722
+
1723
+ /// Returns the derived pass name.
1724
+ static constexpr ::llvm::StringLiteral getPassName() {
1725
+ return ::llvm::StringLiteral("StorageSpecifierToLLVM");
1726
+ }
1727
+ ::llvm::StringRef getName() const override { return "StorageSpecifierToLLVM"; }
1728
+
1729
+ /// Support isa/dyn_cast functionality for the derived pass class.
1730
+ static bool classof(const ::mlir::Pass *pass) {
1731
+ return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>();
1732
+ }
1733
+
1734
+ /// A clone method to create a copy of this pass.
1735
+ std::unique_ptr<::mlir::Pass> clonePass() const override {
1736
+ return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this));
1737
+ }
1738
+
1739
+ /// Return the dialect that must be loaded in the context before this pass.
1740
+ void getDependentDialects(::mlir::DialectRegistry &registry) const override {
1741
+
1742
+ registry.insert<arith::ArithDialect>();
1743
+
1744
+ registry.insert<LLVM::LLVMDialect>();
1745
+
1746
+ registry.insert<sparse_tensor::SparseTensorDialect>();
1747
+
1748
+ }
1749
+
1750
+ /// Explicitly declare the TypeID for this class. We declare an explicit private
1751
+ /// instantiation because Pass classes should only be visible by the current
1752
+ /// library.
1753
+ MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StorageSpecifierToLLVMBase<DerivedT>)
1754
+
1755
+ protected:
1756
+ };
1757
+ #undef GEN_PASS_CLASSES
1758
+ #endif // GEN_PASS_CLASSES
miniconda3/envs/active_proaction/lib/python3.10/site-packages/tensorflow/include/external/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Utils/Merger.h ADDED
@@ -0,0 +1,744 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //===- Merger.h - Utilities for defining lattices ---------------*- C++ -*-===//
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
+ // This header file defines utilities for dealing with iteration lattices.
10
+ //
11
+ //===----------------------------------------------------------------------===//
12
+
13
+ #ifndef MLIR_DIALECT_SPARSETENSOR_UTILS_MERGER_H_
14
+ #define MLIR_DIALECT_SPARSETENSOR_UTILS_MERGER_H_
15
+
16
+ #include "mlir/Dialect/Linalg/IR/Linalg.h"
17
+ #include "mlir/Dialect/SparseTensor/IR/Enums.h"
18
+ #include "mlir/Dialect/SparseTensor/IR/SparseTensor.h"
19
+ #include "mlir/IR/Value.h"
20
+ #include "llvm/ADT/BitVector.h"
21
+
22
+ #include <optional>
23
+
24
+ namespace mlir {
25
+ namespace sparse_tensor {
26
+
27
+ namespace detail {
28
+ /// A constant serving as the canonically invalid identifier,
29
+ /// regardless of the identifier type.
30
+ static constexpr unsigned kInvalidId = -1u;
31
+ } // namespace detail
32
+
33
+ /// Tensor identifiers, chosen to be the `BlockArgument::getArgNumber`
34
+ /// of the value passed to `Merger::buildTensorExp`.
35
+ using TensorId = unsigned;
36
+
37
+ /// Loop identifiers.
38
+ using LoopId = unsigned;
39
+
40
+ /// A compressed representation of `std::pair<TensorId, LoopId>`.
41
+ /// The compression scheme is such that this also serves as an index
42
+ /// into the bitvector stored in `LatPoint` (since that bitvector is
43
+ /// just the implementation for a set of `TensorLoopId` values).
44
+ using TensorLoopId = unsigned;
45
+
46
+ /// `TensorExp` identifiers. These are allocated by `Merger::addExp`,
47
+ /// and serve as unique identifiers for the corresponding `TensorExp` object.
48
+ using ExprId = unsigned;
49
+
50
+ /// `LatPoint` identifiers. These are allocated by `Merger::addLat`,
51
+ /// and serve as unique identifiers for the corresponding `LatPoint` object.
52
+ using LatPointId = unsigned;
53
+
54
+ /// `LatSet` identifiers. These are allocated by `Merger::addSet` (and
55
+ /// by other methods calling that one), and serve as unique identifiers
56
+ /// for the corresponding `SmallVector<LatPointId>` object.
57
+ using LatSetId = unsigned;
58
+
59
+ /// A pair of level and its corresponding DimLevelType of a tensor.
60
+ using LvlDLTPair = std::pair<Level, DimLevelType>;
61
+
62
+ /// A pair of loop id and its coefficients. E.g., for affine expression in the
63
+ /// affine map `2 * d0`, loop id = 0, coefficient = 2.
64
+ using LoopCoeffPair = std::pair<LoopId, unsigned>;
65
+
66
+ /// Tensor expression. Represents an MLIR expression in tensor index notation.
67
+ struct TensorExp final {
68
+ enum class Kind;
69
+
70
+ /// Child subexpressions for non-leaf expressions.
71
+ struct Children final {
72
+ ExprId e0;
73
+ ExprId e1;
74
+ };
75
+
76
+ /// The `x` parameter has different types depending on the value of the
77
+ /// `k` parameter. The correspondences are:
78
+ /// * `kTensor` -> `TensorId`
79
+ /// * `kInvariant` -> `kInvalidId`
80
+ /// * `kLoopVar` -> `LoopId`
81
+ /// * else -> `ExprId`
82
+ ///
83
+ /// The `y`, `v`, and `op` parameters either must or must not be
84
+ /// `kInvalidId`/`nullptr`, depending on the value of the `k` parameter;
85
+ /// however, they have uniform C++ types regardless of the value of `k`.
86
+ TensorExp(Kind k, unsigned x, ExprId y, Value v, Operation *op, Attribute a);
87
+
88
+ /// Tensor expression kind.
89
+ Kind kind;
90
+
91
+ union {
92
+ /// `kTensor` expressions simply have a tensor identifier.
93
+ TensorId tensor;
94
+
95
+ /// `kLoopVar` expressions simply have a loop identifier.
96
+ LoopId loop;
97
+
98
+ /// All other expressions hold the `ExprId`s of their children.
99
+ Children children;
100
+ };
101
+
102
+ /// Direct link to IR for an invariant or the destination value (to
103
+ /// infer destination type) of a cast operation During code generation,
104
+ /// this field may be used to cache "hoisted" loop invariant tensor loads.
105
+ Value val;
106
+
107
+ /// Code blocks used by semirings. For the case of kUnary, kBinary, kReduce,
108
+ /// and kSelect, this holds the original operation with all regions. For
109
+ /// kBinaryBranch, this holds the YieldOp for the left or right half
110
+ /// to be merged into a nested scf loop.
111
+ ///
112
+ /// Or the actual operation that we can not sparsify but having all dense
113
+ /// operands for kDenseOp.
114
+ Operation *op;
115
+
116
+ /// An optional attribute that is required to determine the semantics of the
117
+ /// operations. E.g., CmpPredicateAttr for CmpI/CmpF operations.
118
+ Attribute attr;
119
+ };
120
+
121
+ /// Tensor expression kind.
122
+ ///
123
+ /// The `kLoopVar` leaf kind is for representing `linalg::IndexOp`.
124
+ /// That is, its argument is a `LoopId` identifying the loop-variable
125
+ /// in question, and its value will be the current iteration's value
126
+ /// of that loop-variable. See the `LoopId` documentation for more details.
127
+ ///
128
+ /// The `kSynZero` leaf kind is for representing a synthetic zero value, which
129
+ /// can be introduced when sparsifying operations like `arith::cmp` to generate
130
+ /// `arith::cmp %lhs, %syn_zero` when the rhs operand is absent.
131
+ //
132
+ // TODO: Modify this definition so that the numeric values already encode
133
+ // the `ExpArity` (while extending the notion of "arity" to include not
134
+ // just the number of `ExprId` children the node has, but also whether the
135
+ // node has a `Value` and/or `Operation*`). Doing this will avoid needing
136
+ // to enumerate all the kinds in `getExpArity` and in the `TensorExp` ctor,
137
+ // and should help clean up a few other places as well.
138
+ enum class TensorExp::Kind {
139
+ // Leaf.
140
+ kTensor = 0,
141
+ kSynZero,
142
+ kInvariant,
143
+ kLoopVar,
144
+ // Unary operations.
145
+ kAbsF,
146
+ kAbsC,
147
+ kAbsI,
148
+ kCeilF,
149
+ kFloorF,
150
+ kSqrtF,
151
+ kSqrtC,
152
+ kExpm1F,
153
+ kExpm1C,
154
+ kLog1pF,
155
+ kLog1pC,
156
+ kSinF,
157
+ kSinC,
158
+ kTanhF,
159
+ kTanhC,
160
+ kNegF,
161
+ kNegC,
162
+ kNegI,
163
+ kTruncF,
164
+ kExtF,
165
+ kCastFS, // signed
166
+ kCastFU, // unsigned
167
+ kCastSF, // signed
168
+ kCastUF, // unsigned
169
+ kCastS, // signed
170
+ kCastU, // unsigned
171
+ kCastIdx,
172
+ kTruncI,
173
+ kCIm, // complex.im
174
+ kCRe, // complex.re
175
+ kBitCast,
176
+ kBinaryBranch, // semiring unary branch created from a binary op
177
+ kUnary, // semiring unary op
178
+ kSelect, // custom selection criteria
179
+ // Binary operations.
180
+ kMulF,
181
+ kMulC,
182
+ kMulI,
183
+ kDivF,
184
+ kDivC, // complex
185
+ kDivS, // signed
186
+ kDivU, // unsigned
187
+ kAddF,
188
+ kAddC,
189
+ kAddI,
190
+ kSubF,
191
+ kSubC,
192
+ kSubI,
193
+ kAndI,
194
+ kOrI,
195
+ kXorI,
196
+ kCmpI,
197
+ kCmpF,
198
+ kShrS, // signed
199
+ kShrU, // unsigned
200
+ kShlI,
201
+ kBinary, // semiring binary op
202
+ kReduce, // semiring reduction op
203
+ kDenseOp, // special category of operations requiring all dense operands
204
+ };
205
+
206
+ /// Lattice point. Each lattice point consists of a formal conjunction
207
+ /// of `TensorLoopId`s, together with the identifier of the corresponding
208
+ /// tensor expression. The formal conjunction is represented as a set of
209
+ /// `TensorLoopId`, where that set is implemented as a `BitVector`.
210
+ struct LatPoint final {
211
+ /// Construct a lattice point with the empty set of `TensorLoopId`s.
212
+ LatPoint(unsigned size, ExprId e) : bits(size, false), exp(e) {}
213
+
214
+ /// Construct a lattice point from the given set of `TensorLoopId`s.
215
+ LatPoint(const BitVector &bits, ExprId e) : bits(bits), exp(e) {}
216
+
217
+ /// Conjunction of all `TensorLoopId`s involved in the tensor expression.
218
+ BitVector bits;
219
+
220
+ /// Simplified conjunction of `TensorLoopId` as bitvector. This
221
+ /// represents a simplified condition under which this tensor expression
222
+ /// must execute. Pre-computed during codegen to avoid repeated eval.
223
+ BitVector simple;
224
+
225
+ /// Identifier of the tensor expression.
226
+ ExprId exp;
227
+ };
228
+
229
+ /// A class to handle all iteration lattice operations. This class abstracts
230
+ /// away from some implementation details of storing iteration lattices and
231
+ /// tensor expressions. This allows for fine-tuning performance characteristics
232
+ /// independently from the basic algorithm if bottlenecks are identified.
233
+ class Merger {
234
+ public:
235
+ /// Constructs a merger for the given number of tensors, native loops, and
236
+ /// filter loops. The user supplies the number of tensors involved in the
237
+ /// kernel, with the last tensor in this set denoting the output tensor.
238
+ /// The merger adds an additional synthetic tensor at the end of this set
239
+ /// to represent all invariant expressions in the kernel.
240
+ ///
241
+ /// In addition to natives loops (which are specified by the GenericOp),
242
+ /// extra filter loops are needed in order to handle affine expressions on
243
+ /// sparse levels. E.g., (d0, d1, d2) => (d0 + d1, d2), a naive
244
+ /// implementation of the filter loop could be generated as
245
+ ///
246
+ /// for (const auto c0 : coordinates[0]) {
247
+ /// if (c0 == d0 + d1) {
248
+ /// generated_code;
249
+ /// }
250
+ /// }
251
+ ///
252
+ /// to filter out coordinates that are not equal to the affine expression.
253
+ ///
254
+ /// The maxLvlRank specifies the max level rank of all inputs/output tensors.
255
+ /// It is used to pre-allocate sufficient memory for internal storage.
256
+ //
257
+ // TODO: we want to make the filter loop more efficient in the future,
258
+ // e.g., by avoiding scanning the full list of stored coordinates (keeping
259
+ // the last position in ordered list) or even apply binary search to find
260
+ // the coordinate.
261
+ //
262
+ // TODO: would be cleaner to understand/document if the first argument
263
+ // gave the number of input tensors, instead of the current number of
264
+ // input+output tensors.
265
+ Merger(unsigned numInputOutputTensors, unsigned numNativeLoops,
266
+ unsigned numFilterLoops, unsigned maxLvlRank);
267
+
268
+ //
269
+ // Constructing valid tensor and loop identifiers.
270
+ //
271
+
272
+ /// Safely converts the argument to a tensor identifier.
273
+ constexpr TensorId makeTensorId(unsigned t) const {
274
+ assert(isValidTensorId(t));
275
+ return t;
276
+ }
277
+
278
+ /// Safely converts the argument to a loop identifier.
279
+ constexpr LoopId makeLoopId(unsigned i) const {
280
+ assert(isValidLoopId(i));
281
+ return i;
282
+ }
283
+
284
+ /// Safely converts the arguments to a pair of (tensor,loop) identifiers.
285
+ constexpr TensorLoopId makeTensorLoopId(unsigned t, unsigned i) const {
286
+ assert(isValidTensorId(t) && isValidLoopId(i));
287
+ return numTensors * i + t;
288
+ }
289
+
290
+ //
291
+ // Allocating new expressions, points, and sets.
292
+ //
293
+
294
+ /// Constructs a new tensor expression, and returns its identifier.
295
+ ExprId addTensorExp(TensorId t);
296
+ /// Constructs a new loop-variable expression, and returns its identifier.
297
+ ExprId addLoopVarExp(LoopId i);
298
+ /// Constructs a new invariant expression, and returns its identifier.
299
+ ExprId addInvariantExp(Value v);
300
+ /// Constructs a new synthetic zero expression.
301
+ ExprId addSynZeroExp();
302
+ /// Constructs a new unary or binary expression, and returns its identifier.
303
+ ExprId addExp(TensorExp::Kind k, ExprId e0, ExprId e1 = detail::kInvalidId,
304
+ Operation *op = nullptr, Attribute attr = nullptr);
305
+ /// Constructs a new sesquinary expression, and returns its identifier.
306
+ /// Currently no sesquinary `Kind` allows specifying the `op`, but we
307
+ /// allow it anyways because `mapSet` is designed to allow it.
308
+ ExprId addExp(TensorExp::Kind k, ExprId e, Value v, Operation *op = nullptr,
309
+ Attribute attr = nullptr);
310
+
311
+ /// Constructs a new iteration lattice point, and returns its identifier.
312
+ LatPointId addLat(TensorId t, LoopId i, ExprId e);
313
+ LatPointId addLat(const BitVector &bits, ExprId e);
314
+
315
+ /// Constructs a new (initially empty) set, and returns its identifier.
316
+ LatSetId addSet();
317
+
318
+ /// Computes a single conjunction of two lattice points by taking the "union"
319
+ /// of `LoopId` (effectively constructing a larger "intersection" of those
320
+ /// loops) with a newly constructed tensor (sub)expression of given kind.
321
+ /// Returns the identifier of the new lattice point.
322
+ LatPointId conjLat(ExprId e, LatPointId p0, LatPointId p1,
323
+ Operation *op = nullptr);
324
+
325
+ /// Conjunctive merge of two lattice sets: `(s0 /\_op s1)`.
326
+ /// Returns the identifier of the new set.
327
+ LatSetId conjSet(ExprId e, LatSetId s0, LatSetId s1, Operation *op = nullptr);
328
+
329
+ /// Disjunctive merge of two lattice sets: `(s0 /\_op s1, s0, s1)`.
330
+ /// Returns the identifier of the new set.
331
+ LatSetId disjSet(ExprId e, LatSetId s0, LatSetId s1, Operation *op = nullptr);
332
+
333
+ /// Disjunctive merge of two lattice sets and also set one of the operand to
334
+ /// zero: `(s0 /\_op s1 (e0 op e1), s0 (0 op e0), s1 (e1 op 0))`.
335
+ /// Returns the identifier of the new set.
336
+ LatSetId disjSetWithZero(ExprId e, LatSetId s0, LatSetId s1);
337
+
338
+ /// Disjunctive merge of two lattice sets with custom handling of the
339
+ /// overlap, left, and right regions. Any region may be left missing
340
+ /// in the output. Returns the identifier of the new set.
341
+ LatSetId combiSet(ExprId e, LatSetId s0, LatSetId s1, Operation *orig,
342
+ bool includeLeft, TensorExp::Kind ltrans, Operation *opleft,
343
+ bool includeRight, TensorExp::Kind rtrans,
344
+ Operation *opright);
345
+
346
+ /// Maps the unary operator over the lattice set of the operand, i.e. each
347
+ /// lattice point on an expression E is simply copied over, but with OP E
348
+ /// as new expression. Returns the identifier of the new set.
349
+ LatSetId mapSet(TensorExp::Kind kind, LatSetId s, Value v = Value(),
350
+ Operation *op = nullptr);
351
+
352
+ /// Maps the binary operator to the same operation but with one of its operand
353
+ /// set to zero, i.e. each lattice point on an expression E is simply copied
354
+ /// over, but with `OP 0 E` (if lhsZero == true) or `OP E 0` (if lhsZero ==
355
+ /// false) as new expression. Returns the identifier of the new set.
356
+ LatSetId mapBinWithSynZeroSet(ExprId e, LatSetId s, bool lhsZero);
357
+
358
+ /// Optimizes the iteration lattice points in the given set. This
359
+ /// method should be called right before code generation to avoid
360
+ /// generating redundant loops and conditions.
361
+ LatSetId optimizeSet(LatSetId s);
362
+
363
+ /// Simplifies the conditions in a conjunction of a given lattice point
364
+ /// within the given set using just two basic rules:
365
+ /// (1) multiple dense conditions are reduced to single dense, and
366
+ /// (2) a *singleton* sparse/dense is reduced to sparse/random access.
367
+ BitVector simplifyCond(LatSetId s, LatPointId p);
368
+
369
+ /// Returns true if p0 > p1.
370
+ bool latGT(LatPointId p0, LatPointId p1) const;
371
+
372
+ /// Returns true if p0 and p1 only differ in dense.
373
+ bool onlyDenseDiff(LatPointId p0, LatPointId p1) const;
374
+
375
+ /// Gets the tensor-identifier of the `TensorLoopId`.
376
+ constexpr TensorId tensor(TensorLoopId b) const { return b % numTensors; }
377
+ /// Gets the loop-identifier of the `TensorLoopId`.
378
+ constexpr LoopId loop(TensorLoopId b) const { return b / numTensors; }
379
+
380
+ /// Gets the total number of tensors (including the output-tensor and
381
+ /// synthetic-tensor).
382
+ constexpr unsigned getNumTensors() const { return numTensors; }
383
+
384
+ /// Gets the total number of loops (native loops + filter loops).
385
+ constexpr unsigned getNumLoops() const { return numLoops; }
386
+ /// Gets the number of native loops.
387
+ constexpr unsigned getNumNativeLoops() const { return numNativeLoops; }
388
+ /// Gets the number of filter loops.
389
+ constexpr unsigned getNumFilterLoops() const {
390
+ return numLoops - numNativeLoops;
391
+ }
392
+ /// Gets the identifier of the first filter-loop.
393
+ constexpr LoopId getStartingFilterLoopId() const {
394
+ return getNumNativeLoops();
395
+ }
396
+
397
+ /// Returns true if `b` is the `i`th loop of the output tensor.
398
+ constexpr bool isOutTensor(TensorLoopId b, LoopId i) const {
399
+ return b == makeTensorLoopId(outTensor, i);
400
+ }
401
+
402
+ /// Gets the output tensor's identifier.
403
+ constexpr TensorId getOutTensorID() const { return outTensor; }
404
+
405
+ /// Gets the synthetic tensor's identifier (used for all invariant
406
+ /// tensor expressions).
407
+ constexpr TensorId getSynTensorID() const { return syntheticTensor; }
408
+
409
+ constexpr bool isFilterLoop(LoopId i) const {
410
+ assert(isValidLoopId(i));
411
+ return i >= numNativeLoops;
412
+ }
413
+
414
+ /// Returns true if the expression is `(kTensor t)`.
415
+ bool expIsTensor(ExprId e, TensorId t) const {
416
+ const auto &expr = exp(e);
417
+ return expr.kind == TensorExp::Kind::kTensor && expr.tensor == t;
418
+ }
419
+
420
+ /// Returns true if the expression contains the tensor as an operand.
421
+ bool expContainsTensor(ExprId e, TensorId t) const;
422
+
423
+ /// Returns true if the expression contains a negation on output tensor.
424
+ /// I.e., `- outTensor` or `exp - outputTensor`
425
+ /// NOTE: this is an trivial tests in that it does not handle recursive
426
+ /// negation, i.e., it returns true when the expression is `-(-tensor)`.
427
+ bool hasNegateOnOut(ExprId e) const;
428
+
429
+ /// Returns true if given tensor iterates *only* in the given tensor
430
+ /// expression. For the output tensor, this defines a "simply dynamic"
431
+ /// operation [Bik96]. For instance: a(i) *= 2.0 or a(i) += a(i) for
432
+ /// sparse vector a.
433
+ bool isSingleCondition(TensorId t, ExprId e) const;
434
+
435
+ /// Returns true if any `TensorLoopId` in the bitvector corresponds
436
+ /// to sparse level-type.
437
+ bool hasAnySparse(const BitVector &bits) const;
438
+
439
+ /// Returns true if bits contains a dependent index reduction condition on
440
+ /// sparse levels.
441
+ bool hasSparseIdxReduction(const BitVector &bits) const;
442
+
443
+ /// Gets the level-type of the `t`th tensor on `i`th loop.
444
+ DimLevelType getLvlType(TensorId t, LoopId i) const {
445
+ assert(isValidTensorId(t) && isValidLoopId(i));
446
+ return lvlTypes[t][i];
447
+ }
448
+
449
+ /// Gets the level-type of the TensorLoopId.
450
+ DimLevelType getLvlType(TensorLoopId b) const {
451
+ return getLvlType(tensor(b), loop(b));
452
+ }
453
+
454
+ /// Gets the loop identifier for the `lvl`th level of the `t`th tensor.
455
+ std::optional<LoopId> getLoopId(TensorId t, Level lvl) const {
456
+ assert(isValidLevel(t, lvl));
457
+ return lvlToLoop[t][lvl];
458
+ }
459
+
460
+ /// Gets the level number of the the `t`th tensor on `i`th loop.
461
+ std::optional<Level> getLvl(TensorId t, LoopId i) const {
462
+ assert(isValidTensorId(t) && isValidLoopId(i));
463
+ return loopToLvl[t][i];
464
+ }
465
+ std::optional<Level> getLvl(TensorLoopId b) const {
466
+ return getLvl(tensor(b), loop(b));
467
+ }
468
+
469
+ /// Sets the level number and level-type of the `t`th tensor on
470
+ /// `i`th loop.
471
+ void setLevelAndType(TensorId t, LoopId i, Level lvl, DimLevelType dlt) {
472
+ assert(isValidLevel(t, lvl) && isValidLoopId(i) && isValidDLT(dlt));
473
+ lvlTypes[t][i] = dlt;
474
+ loopToLvl[t][i] = lvl;
475
+ lvlToLoop[t][lvl] = i;
476
+ // TODO: Maybe we should favor a constant loop bound when there are multiple
477
+ // choices.
478
+ loopBounds[i] = std::make_pair(t, lvl);
479
+ }
480
+
481
+ using ForeachTensorLoopIdCallback = function_ref<void(
482
+ TensorLoopId, TensorId, std::optional<Level>, DimLevelType, bool)>;
483
+
484
+ /// Iterates over a set of `TensorLoopId`s, invoking the callback
485
+ /// for each `TensorLoopId` and passing it the corresponding tensor
486
+ /// identifier, level, and level-type, following with a boolean value
487
+ /// indicating whether it is a dependent index reduction loop condition.
488
+ void foreachTensorLoopId(LatPointId p,
489
+ ForeachTensorLoopIdCallback callback) const {
490
+ // TODO: the default ought to be simple=true; but we'll need to make
491
+ // sure to update all the tests to make sure they do the right thing.
492
+ foreachTensorLoopId(p, /*simple=*/false, callback);
493
+ }
494
+ void foreachTensorLoopId(LatPointId p, bool simple,
495
+ ForeachTensorLoopIdCallback callback) const {
496
+ const auto &point = lat(p);
497
+ const auto &bits = simple ? point.simple : point.bits;
498
+ for (const TensorLoopId b : bits.set_bits()) {
499
+ const TensorId t = tensor(b);
500
+ const auto optLvl = getLvl(b);
501
+ const auto lvlTp = getLvlType(b);
502
+ if (isLvlWithNonTrivialIdxExp(b)) {
503
+ // This must be an undefined level.
504
+ assert(!optLvl.has_value());
505
+ // Slice the tid along the dependent level to iterate current loop.
506
+ callback(b, t, getLoopDependentLevel(b), lvlTp,
507
+ /*isIdxReduc=*/true);
508
+ } else {
509
+ callback(b, t, optLvl, lvlTp, /*isIdxReduc=*/false);
510
+ }
511
+ }
512
+ }
513
+
514
+ /// Sets whether the output tensor is sparse or not.
515
+ void setHasSparseOut(bool s) { hasSparseOut = s; }
516
+
517
+ /// Establishes the two-way map that i <-> <t, lvl, dlt>.
518
+ void setLoopDependentTensorLevel(LoopId i, TensorId t, Level lvl,
519
+ DimLevelType dlt, unsigned coefficient) {
520
+ assert(isValidLoopId(i) && isValidLevel(t, lvl));
521
+ assert(!loopToUnresolvedLvls[i][t].has_value()); // must be the first def
522
+ loopToUnresolvedLvls[i][t] = std::make_pair(lvl, dlt);
523
+ levelToDependentLoop[t][lvl].emplace_back(i, coefficient);
524
+ }
525
+
526
+ /// Whether the loop has dependent slice.
527
+ bool hasDependentLvl(LoopId i, TensorId t) {
528
+ assert(isValidTensorId(t) && isValidLoopId(i));
529
+ return loopToUnresolvedLvls[i][t].has_value();
530
+ }
531
+
532
+ /// Returns the list of loop indices which appear in the non-trivial index
533
+ /// expression on t_l, e.g., A[i+j] => {i, j}
534
+ std::vector<LoopCoeffPair> &getDependentLoops(TensorId t, Level lvl) {
535
+ assert(isValidLevel(t, lvl));
536
+ return levelToDependentLoop[t][lvl];
537
+ }
538
+
539
+ /// Returns the defining [tid, lvl] for the loop.
540
+ std::pair<TensorId, Level> getLoopDefiningLvl(LoopId i) const {
541
+ assert(isValidLoopId(i));
542
+ return loopBounds[i];
543
+ }
544
+
545
+ /// Checks whether the TensorLoopId represents a tensor level contains
546
+ /// non-trivial index expression.
547
+ bool isLvlWithNonTrivialIdxExp(TensorLoopId b) const {
548
+ const TensorId t = tensor(b);
549
+ const LoopId i = loop(b);
550
+ assert(isValidTensorId(t) && isValidLoopId(i));
551
+ return loopToUnresolvedLvls[i][t].has_value();
552
+ }
553
+
554
+ /// Checks whether the TensorLoopId represents a sparse tensor level contains
555
+ /// non-trivial index expression.
556
+ bool isSparseLvlWithNonTrivialIdxExp(TensorLoopId b) const {
557
+ if (isLvlWithNonTrivialIdxExp(b)) {
558
+ auto dlt = getLoopDependentLevelType(b);
559
+ return isCompressedDLT(dlt) || isSingletonDLT(dlt);
560
+ }
561
+ return false;
562
+ }
563
+
564
+ Level getLoopDependentLevel(TensorLoopId b) const {
565
+ assert(isLvlWithNonTrivialIdxExp(b));
566
+ return loopToUnresolvedLvls[loop(b)][tensor(b)]->first;
567
+ }
568
+
569
+ DimLevelType getLoopDependentLevelType(TensorLoopId b) const {
570
+ assert(isLvlWithNonTrivialIdxExp(b));
571
+ return loopToUnresolvedLvls[loop(b)][tensor(b)]->second;
572
+ }
573
+
574
+ /// Convenience getters to immediately access the stored nodes.
575
+ /// These methods return `const&` because the underlying objects must
576
+ /// not be mutated by client code. The only exception is for mutating
577
+ /// the value associated with an expression, for which there are
578
+ /// dedicated methods below.
579
+ ///
580
+ /// NOTE: It is inadvisable to keep the reference alive for a long
581
+ /// time (e.g., as in `TensorExpr &te = merger.exp(e)`), since insertions
582
+ /// into the merger can cause data movement which will invalidate the
583
+ /// underlying memory address. This isn't just a problem with the `&`
584
+ /// references, but also applies to the `ArrayRef`. In particular,
585
+ /// using `for (LatPointId p : merger.set(s))` will run into the same
586
+ /// dangling-reference problems if the loop body inserts new sets.
587
+ const TensorExp &exp(ExprId e) const {
588
+ assert(isValidExprId(e));
589
+ return tensorExps[e];
590
+ }
591
+ const LatPoint &lat(LatPointId p) const {
592
+ assert(isValidLatPointId(p));
593
+ return latPoints[p];
594
+ }
595
+ ArrayRef<LatPointId> set(LatSetId s) const {
596
+ assert(isValidLatSetId(s));
597
+ return latSets[s];
598
+ }
599
+
600
+ /// Checks whether the given expression has an associated value.
601
+ bool hasExprValue(ExprId e) const { return static_cast<bool>(exp(e).val); }
602
+
603
+ /// Sets the expression to have the associated value. Asserts that
604
+ /// the new value is defined, and that the expression does not already
605
+ /// have a value. If you want to overwrite a previous associated value,
606
+ /// use `updateExprValue` instead.
607
+ void setExprValue(ExprId e, Value v) {
608
+ assert(isValidExprId(e));
609
+ assert(v && "Got an undefined value");
610
+ auto &val = tensorExps[e].val;
611
+ assert(!val && "Expression already has an associated value");
612
+ val = v;
613
+ }
614
+
615
+ /// Clears the value associated with the expression. Asserts that the
616
+ /// expression does indeed have an associated value before clearing it.
617
+ /// If you don't want to check for a previous associated value first,
618
+ /// then use `updateExprValue` instead.
619
+ void clearExprValue(ExprId e) {
620
+ assert(isValidExprId(e));
621
+ auto &val = tensorExps[e].val;
622
+ assert(val && "Expression does not have an associated value to clear");
623
+ val = Value();
624
+ }
625
+
626
+ /// Unilaterally updates the expression to have the associated value.
627
+ /// That is, unlike `setExprValue` and `clearExprValue`, this method
628
+ /// does not perform any checks on whether the expression had a
629
+ /// previously associated value nor whether the new value is defined.
630
+ //
631
+ // TODO: The unilateral update semantics are required by the
632
+ // current implementation of `CodegenEnv::genLoopBoundary`; however,
633
+ // that implementation seems a bit dubious. We would much rather have
634
+ // the semantics `{ clearExprValue(e); setExprValue(e, v); }` or
635
+ // `{ clearExprValue(e); if (v) setExprValue(e, v); }` since those
636
+ // provide better invariants.
637
+ void updateExprValue(ExprId e, Value v) {
638
+ assert(isValidExprId(e));
639
+ tensorExps[e].val = v;
640
+ }
641
+
642
+ #ifndef NDEBUG
643
+ /// Print methods (for debugging).
644
+ void dumpExp(ExprId e) const;
645
+ void dumpLat(LatPointId p) const;
646
+ void dumpSet(LatSetId s) const;
647
+ void dumpBits(const BitVector &bits) const;
648
+ #endif
649
+
650
+ /// Builds the iteration lattices in a bottom-up traversal given the
651
+ /// remaining tensor (sub)expression and the next loop in the iteration
652
+ /// graph. Returns the identifier of the root set.
653
+ LatSetId buildLattices(ExprId e, LoopId i);
654
+
655
+ /// Builds a tensor expression from the given Linalg operation.
656
+ /// On success, returns the identifier of the root expression.
657
+ std::optional<ExprId> buildTensorExpFromLinalg(linalg::GenericOp op);
658
+
659
+ /// Rebuilds SSA format from a tensor expression.
660
+ Value buildExp(RewriterBase &rewriter, Location loc, ExprId e, Value v0,
661
+ Value v1) const;
662
+
663
+ private:
664
+ /// Private helpers.
665
+ constexpr bool isValidTensorId(TensorId t) const { return t < numTensors; }
666
+ constexpr bool isValidLoopId(LoopId i) const {
667
+ return i != detail::kInvalidId && i < numLoops;
668
+ }
669
+ bool isValidLevel(TensorId t, Level lvl) const {
670
+ assert(levelToDependentLoop[t].size() == lvlToLoop[t].size());
671
+ return isValidTensorId(t) && lvl < lvlToLoop[t].size();
672
+ }
673
+ bool isValidExprId(ExprId e) const {
674
+ return e != detail::kInvalidId && e < tensorExps.size();
675
+ }
676
+ bool isValidLatPointId(LatPointId p) const {
677
+ return p != detail::kInvalidId && p < latPoints.size();
678
+ }
679
+ bool isValidLatSetId(LatSetId s) const {
680
+ return s != detail::kInvalidId && s < latSets.size();
681
+ }
682
+ bool maybeZero(ExprId e) const;
683
+ bool isInvariant(ExprId e) const {
684
+ return exp(e).kind == TensorExp::Kind::kInvariant;
685
+ }
686
+ Type inferType(ExprId e, Value src) const;
687
+
688
+ /// Traverses the SSA tree (possibly a DAG) to build a tensor expression.
689
+ /// The boolean value returned indicates whether the result of the current
690
+ /// operation being built depends on any value that is loaded from a sparse
691
+ /// tensor.
692
+ std::pair<std::optional<ExprId>, bool> buildTensorExp(linalg::GenericOp op,
693
+ Value v);
694
+
695
+ /// Merger data structures.
696
+ const TensorId outTensor;
697
+ const TensorId syntheticTensor;
698
+ const unsigned numTensors;
699
+ const unsigned numNativeLoops;
700
+ const unsigned numLoops;
701
+ bool hasSparseOut;
702
+
703
+ // Below we use `std::vector` for things which have a priori fixed
704
+ // sizes, whereas we use `llvm::SmallVector` for things with variable
705
+ // size. Do beware that these two classes differ in the semantics of
706
+ // `operator[]`: `SmallVector` performs OOB checks, whereas `std::vector`
707
+ // does not.
708
+
709
+ /// Map that converts pair<TensorId, LoopId> to the corresponding
710
+ /// level-type.
711
+ std::vector<std::vector<DimLevelType>> lvlTypes;
712
+
713
+ /// Map that converts pair<TensorId, LoopId> to the corresponding
714
+ /// level.
715
+ std::vector<std::vector<std::optional<Level>>> loopToLvl;
716
+
717
+ /// Map that converts pair<TensorId, Level> to the corresponding LoopId.
718
+ std::vector<std::vector<std::optional<LoopId>>> lvlToLoop;
719
+
720
+ /// Map from a loop to its dependencies if any.
721
+ /// The dependencies of a loop is a set of (tensor, level) pairs.
722
+ /// It is currently only set for non-trivial index expressions.
723
+ /// E.g., A[i+j] => i and j will have dependencies {A0, dlt(A0)} to indicate
724
+ /// that i and j are used in the non-trivial index expression on A0.
725
+ std::vector<std::vector<std::optional<LvlDLTPair>>> loopToUnresolvedLvls;
726
+
727
+ /// The inverse map of ldxToDependencies from tensor level -> dependent loop
728
+ /// E.g., A[2i+j], we have A0 => {(2, i), (1, j)}, to indicate that A0 uses
729
+ /// both {i, j} to compute its indices and the coefficients on the loop id are
730
+ /// 2 and 1 respectively.
731
+ std::vector<std::vector<std::vector<LoopCoeffPair>>> levelToDependentLoop;
732
+
733
+ /// Map from a loop to the [tid, lvl] pair that defines the loop boundary.
734
+ std::vector<std::pair<TensorId, Level>> loopBounds;
735
+
736
+ llvm::SmallVector<TensorExp> tensorExps;
737
+ llvm::SmallVector<LatPoint> latPoints;
738
+ llvm::SmallVector<SmallVector<LatPointId>> latSets;
739
+ };
740
+
741
+ } // namespace sparse_tensor
742
+ } // namespace mlir
743
+
744
+ #endif // MLIR_DIALECT_SPARSETENSOR_UTILS_MERGER_H_