1 | /* Autogenerated by mlir-tblgen; don't manually edit */ |
2 | |
3 | //===----------------------------------------------------------------------===// |
4 | // AddDefaultAttrs |
5 | //===----------------------------------------------------------------------===// |
6 | #ifdef GEN_PASS_DECL_ADDDEFAULTATTRS |
7 | #undef GEN_PASS_DECL_ADDDEFAULTATTRS |
8 | #endif // GEN_PASS_DECL_ADDDEFAULTATTRS |
9 | #ifdef GEN_PASS_DEF_ADDDEFAULTATTRS |
10 | namespace impl { |
11 | |
12 | template <typename DerivedT> |
13 | class AddDefaultAttrsBase : public ::mlir::OperationPass<> { |
14 | public: |
15 | using Base = AddDefaultAttrsBase; |
16 | |
17 | AddDefaultAttrsBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {} |
18 | AddDefaultAttrsBase(const AddDefaultAttrsBase &other) : ::mlir::OperationPass<>(other) {} |
19 | |
20 | /// Returns the command-line argument attached to this pass. |
21 | static constexpr ::llvm::StringLiteral getArgumentName() { |
22 | return ::llvm::StringLiteral("tfg-add-default-attrs" ); |
23 | } |
24 | ::llvm::StringRef getArgument() const override { return "tfg-add-default-attrs" ; } |
25 | |
26 | ::llvm::StringRef getDescription() const override { return "Add default-valued attributes to the graph" ; } |
27 | |
28 | /// Returns the derived pass name. |
29 | static constexpr ::llvm::StringLiteral getPassName() { |
30 | return ::llvm::StringLiteral("AddDefaultAttrs" ); |
31 | } |
32 | ::llvm::StringRef getName() const override { return "AddDefaultAttrs" ; } |
33 | |
34 | /// Support isa/dyn_cast functionality for the derived pass class. |
35 | static bool classof(const ::mlir::Pass *pass) { |
36 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
37 | } |
38 | |
39 | /// A clone method to create a copy of this pass. |
40 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
41 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
42 | } |
43 | |
44 | /// Return the dialect that must be loaded in the context before this pass. |
45 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
46 | |
47 | } |
48 | |
49 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
50 | /// instantiation because Pass classes should only be visible by the current |
51 | /// library. |
52 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(AddDefaultAttrsBase<DerivedT>) |
53 | |
54 | protected: |
55 | private: |
56 | }; |
57 | } // namespace impl |
58 | #undef GEN_PASS_DEF_ADDDEFAULTATTRS |
59 | #endif // GEN_PASS_DEF_ADDDEFAULTATTRS |
60 | |
61 | //===----------------------------------------------------------------------===// |
62 | // CSEPass |
63 | //===----------------------------------------------------------------------===// |
64 | #ifdef GEN_PASS_DECL_CSEPASS |
65 | #undef GEN_PASS_DECL_CSEPASS |
66 | #endif // GEN_PASS_DECL_CSEPASS |
67 | #ifdef GEN_PASS_DEF_CSEPASS |
68 | namespace impl { |
69 | |
70 | template <typename DerivedT> |
71 | class CSEPassBase : public ::mlir::OperationPass<GraphFuncOp> { |
72 | public: |
73 | using Base = CSEPassBase; |
74 | |
75 | CSEPassBase() : ::mlir::OperationPass<GraphFuncOp>(::mlir::TypeID::get<DerivedT>()) {} |
76 | CSEPassBase(const CSEPassBase &other) : ::mlir::OperationPass<GraphFuncOp>(other) {} |
77 | |
78 | /// Returns the command-line argument attached to this pass. |
79 | static constexpr ::llvm::StringLiteral getArgumentName() { |
80 | return ::llvm::StringLiteral("tfg-cse" ); |
81 | } |
82 | ::llvm::StringRef getArgument() const override { return "tfg-cse" ; } |
83 | |
84 | ::llvm::StringRef getDescription() const override { return "Common sub-expression elimination, ignoring op names" ; } |
85 | |
86 | /// Returns the derived pass name. |
87 | static constexpr ::llvm::StringLiteral getPassName() { |
88 | return ::llvm::StringLiteral("CSEPass" ); |
89 | } |
90 | ::llvm::StringRef getName() const override { return "CSEPass" ; } |
91 | |
92 | /// Support isa/dyn_cast functionality for the derived pass class. |
93 | static bool classof(const ::mlir::Pass *pass) { |
94 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
95 | } |
96 | |
97 | /// A clone method to create a copy of this pass. |
98 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
99 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
100 | } |
101 | |
102 | /// Return the dialect that must be loaded in the context before this pass. |
103 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
104 | |
105 | } |
106 | |
107 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
108 | /// instantiation because Pass classes should only be visible by the current |
109 | /// library. |
110 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(CSEPassBase<DerivedT>) |
111 | |
112 | protected: |
113 | private: |
114 | }; |
115 | } // namespace impl |
116 | #undef GEN_PASS_DEF_CSEPASS |
117 | #endif // GEN_PASS_DEF_CSEPASS |
118 | |
119 | //===----------------------------------------------------------------------===// |
120 | // ConsolidateAttributes |
121 | //===----------------------------------------------------------------------===// |
122 | #ifdef GEN_PASS_DECL_CONSOLIDATEATTRIBUTES |
123 | #undef GEN_PASS_DECL_CONSOLIDATEATTRIBUTES |
124 | #endif // GEN_PASS_DECL_CONSOLIDATEATTRIBUTES |
125 | #ifdef GEN_PASS_DEF_CONSOLIDATEATTRIBUTES |
126 | namespace impl { |
127 | |
128 | template <typename DerivedT> |
129 | class ConsolidateAttributesBase : public ::mlir::OperationPass<ModuleOp> { |
130 | public: |
131 | using Base = ConsolidateAttributesBase; |
132 | |
133 | ConsolidateAttributesBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {} |
134 | ConsolidateAttributesBase(const ConsolidateAttributesBase &other) : ::mlir::OperationPass<ModuleOp>(other) {} |
135 | |
136 | /// Returns the command-line argument attached to this pass. |
137 | static constexpr ::llvm::StringLiteral getArgumentName() { |
138 | return ::llvm::StringLiteral("tfg-consolidate-attrs" ); |
139 | } |
140 | ::llvm::StringRef getArgument() const override { return "tfg-consolidate-attrs" ; } |
141 | |
142 | ::llvm::StringRef getDescription() const override { return "Reify type data from attributes to types." ; } |
143 | |
144 | /// Returns the derived pass name. |
145 | static constexpr ::llvm::StringLiteral getPassName() { |
146 | return ::llvm::StringLiteral("ConsolidateAttributes" ); |
147 | } |
148 | ::llvm::StringRef getName() const override { return "ConsolidateAttributes" ; } |
149 | |
150 | /// Support isa/dyn_cast functionality for the derived pass class. |
151 | static bool classof(const ::mlir::Pass *pass) { |
152 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
153 | } |
154 | |
155 | /// A clone method to create a copy of this pass. |
156 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
157 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
158 | } |
159 | |
160 | /// Return the dialect that must be loaded in the context before this pass. |
161 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
162 | |
163 | } |
164 | |
165 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
166 | /// instantiation because Pass classes should only be visible by the current |
167 | /// library. |
168 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ConsolidateAttributesBase<DerivedT>) |
169 | |
170 | protected: |
171 | private: |
172 | }; |
173 | } // namespace impl |
174 | #undef GEN_PASS_DEF_CONSOLIDATEATTRIBUTES |
175 | #endif // GEN_PASS_DEF_CONSOLIDATEATTRIBUTES |
176 | |
177 | //===----------------------------------------------------------------------===// |
178 | // ConstantFoldingPass |
179 | //===----------------------------------------------------------------------===// |
180 | #ifdef GEN_PASS_DECL_CONSTANTFOLDINGPASS |
181 | struct ConstantFoldingPassOptions { |
182 | ::llvm::ArrayRef<std::string> feeds_; |
183 | ::llvm::ArrayRef<std::string> fetches_; |
184 | bool disable_compressed_tensor_optimization_ = false; |
185 | bool fold_quantization_emulation_ = true; |
186 | int pattern_category_ = 0; |
187 | }; |
188 | #undef GEN_PASS_DECL_CONSTANTFOLDINGPASS |
189 | #endif // GEN_PASS_DECL_CONSTANTFOLDINGPASS |
190 | #ifdef GEN_PASS_DEF_CONSTANTFOLDINGPASS |
191 | namespace impl { |
192 | |
193 | template <typename DerivedT> |
194 | class ConstantFoldingPassBase : public ::mlir::OperationPass<GraphFuncOp> { |
195 | public: |
196 | using Base = ConstantFoldingPassBase; |
197 | |
198 | ConstantFoldingPassBase() : ::mlir::OperationPass<GraphFuncOp>(::mlir::TypeID::get<DerivedT>()) {} |
199 | ConstantFoldingPassBase(const ConstantFoldingPassBase &other) : ::mlir::OperationPass<GraphFuncOp>(other) {} |
200 | |
201 | /// Returns the command-line argument attached to this pass. |
202 | static constexpr ::llvm::StringLiteral getArgumentName() { |
203 | return ::llvm::StringLiteral("tfg-constant-folding" ); |
204 | } |
205 | ::llvm::StringRef getArgument() const override { return "tfg-constant-folding" ; } |
206 | |
207 | ::llvm::StringRef getDescription() const override { return "constant-folding on tfg" ; } |
208 | |
209 | /// Returns the derived pass name. |
210 | static constexpr ::llvm::StringLiteral getPassName() { |
211 | return ::llvm::StringLiteral("ConstantFoldingPass" ); |
212 | } |
213 | ::llvm::StringRef getName() const override { return "ConstantFoldingPass" ; } |
214 | |
215 | /// Support isa/dyn_cast functionality for the derived pass class. |
216 | static bool classof(const ::mlir::Pass *pass) { |
217 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
218 | } |
219 | |
220 | /// A clone method to create a copy of this pass. |
221 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
222 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
223 | } |
224 | |
225 | /// Return the dialect that must be loaded in the context before this pass. |
226 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
227 | |
228 | } |
229 | |
230 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
231 | /// instantiation because Pass classes should only be visible by the current |
232 | /// library. |
233 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ConstantFoldingPassBase<DerivedT>) |
234 | |
235 | ConstantFoldingPassBase(const ConstantFoldingPassOptions &options) : ConstantFoldingPassBase() { |
236 | feeds_ = options.feeds_; |
237 | fetches_ = options.fetches_; |
238 | disable_compressed_tensor_optimization_ = options.disable_compressed_tensor_optimization_; |
239 | fold_quantization_emulation_ = options.fold_quantization_emulation_; |
240 | pattern_category_ = options.pattern_category_; |
241 | } |
242 | protected: |
243 | ::mlir::Pass::ListOption<std::string> feeds_{*this, "feeds" , ::llvm::cl::desc("Comma separated list of feed ops." ), llvm::cl::ZeroOrMore}; |
244 | ::mlir::Pass::ListOption<std::string> fetches_{*this, "fetches" , ::llvm::cl::desc("Comma separated list of fetch ops." ), llvm::cl::ZeroOrMore}; |
245 | ::mlir::Pass::Option<bool> disable_compressed_tensor_optimization_{*this, "disable-compressed-tensor-optimization" , ::llvm::cl::desc("Determine if we should disable compressed tensor optimization" ), ::llvm::cl::init(false)}; |
246 | ::mlir::Pass::Option<bool> fold_quantization_emulation_{*this, "fold-quantization-emulation" , ::llvm::cl::desc("Determine if we should fold quantization emulation ops" ), ::llvm::cl::init(true)}; |
247 | ::mlir::Pass::Option<int> pattern_category_{*this, "pattern-category" , ::llvm::cl::desc("Select the pattern kind that we would like to run:0 = all patterns, 1 = folder patterns, 2 = propagation patterns" ), ::llvm::cl::init(0)}; |
248 | private: |
249 | }; |
250 | } // namespace impl |
251 | #undef GEN_PASS_DEF_CONSTANTFOLDINGPASS |
252 | #endif // GEN_PASS_DEF_CONSTANTFOLDINGPASS |
253 | |
254 | //===----------------------------------------------------------------------===// |
255 | // ControlFlowSink |
256 | //===----------------------------------------------------------------------===// |
257 | #ifdef GEN_PASS_DECL_CONTROLFLOWSINK |
258 | #undef GEN_PASS_DECL_CONTROLFLOWSINK |
259 | #endif // GEN_PASS_DECL_CONTROLFLOWSINK |
260 | #ifdef GEN_PASS_DEF_CONTROLFLOWSINK |
261 | namespace impl { |
262 | |
263 | template <typename DerivedT> |
264 | class ControlFlowSinkBase : public ::mlir::OperationPass<GraphFuncOp> { |
265 | public: |
266 | using Base = ControlFlowSinkBase; |
267 | |
268 | ControlFlowSinkBase() : ::mlir::OperationPass<GraphFuncOp>(::mlir::TypeID::get<DerivedT>()) {} |
269 | ControlFlowSinkBase(const ControlFlowSinkBase &other) : ::mlir::OperationPass<GraphFuncOp>(other) {} |
270 | |
271 | /// Returns the command-line argument attached to this pass. |
272 | static constexpr ::llvm::StringLiteral getArgumentName() { |
273 | return ::llvm::StringLiteral("tfg-cf-sink" ); |
274 | } |
275 | ::llvm::StringRef getArgument() const override { return "tfg-cf-sink" ; } |
276 | |
277 | ::llvm::StringRef getDescription() const override { return "Perform control-flow sink on region-based control-flow ops." ; } |
278 | |
279 | /// Returns the derived pass name. |
280 | static constexpr ::llvm::StringLiteral getPassName() { |
281 | return ::llvm::StringLiteral("ControlFlowSink" ); |
282 | } |
283 | ::llvm::StringRef getName() const override { return "ControlFlowSink" ; } |
284 | |
285 | /// Support isa/dyn_cast functionality for the derived pass class. |
286 | static bool classof(const ::mlir::Pass *pass) { |
287 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
288 | } |
289 | |
290 | /// A clone method to create a copy of this pass. |
291 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
292 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
293 | } |
294 | |
295 | /// Return the dialect that must be loaded in the context before this pass. |
296 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
297 | |
298 | } |
299 | |
300 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
301 | /// instantiation because Pass classes should only be visible by the current |
302 | /// library. |
303 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ControlFlowSinkBase<DerivedT>) |
304 | |
305 | protected: |
306 | ::mlir::Pass::Statistic num_sunk{this, "num-sunk" , "Number of operations sunk" }; |
307 | private: |
308 | }; |
309 | } // namespace impl |
310 | #undef GEN_PASS_DEF_CONTROLFLOWSINK |
311 | #endif // GEN_PASS_DEF_CONTROLFLOWSINK |
312 | |
313 | //===----------------------------------------------------------------------===// |
314 | // DedupeAndHoistConstant |
315 | //===----------------------------------------------------------------------===// |
316 | #ifdef GEN_PASS_DECL_DEDUPEANDHOISTCONSTANT |
317 | struct DedupeAndHoistConstantOptions { |
318 | int64_t max_size_ = 10; |
319 | bool assume_strict_calls_ = false; |
320 | }; |
321 | #undef GEN_PASS_DECL_DEDUPEANDHOISTCONSTANT |
322 | #endif // GEN_PASS_DECL_DEDUPEANDHOISTCONSTANT |
323 | #ifdef GEN_PASS_DEF_DEDUPEANDHOISTCONSTANT |
324 | namespace impl { |
325 | |
326 | template <typename DerivedT> |
327 | class DedupeAndHoistConstantBase : public ::mlir::OperationPass<ModuleOp> { |
328 | public: |
329 | using Base = DedupeAndHoistConstantBase; |
330 | |
331 | DedupeAndHoistConstantBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {} |
332 | DedupeAndHoistConstantBase(const DedupeAndHoistConstantBase &other) : ::mlir::OperationPass<ModuleOp>(other) {} |
333 | |
334 | /// Returns the command-line argument attached to this pass. |
335 | static constexpr ::llvm::StringLiteral getArgumentName() { |
336 | return ::llvm::StringLiteral("tfg-dedupe-hoist-constant" ); |
337 | } |
338 | ::llvm::StringRef getArgument() const override { return "tfg-dedupe-hoist-constant" ; } |
339 | |
340 | ::llvm::StringRef getDescription() const override { return "Dedupe and hoist constants" ; } |
341 | |
342 | /// Returns the derived pass name. |
343 | static constexpr ::llvm::StringLiteral getPassName() { |
344 | return ::llvm::StringLiteral("DedupeAndHoistConstant" ); |
345 | } |
346 | ::llvm::StringRef getName() const override { return "DedupeAndHoistConstant" ; } |
347 | |
348 | /// Support isa/dyn_cast functionality for the derived pass class. |
349 | static bool classof(const ::mlir::Pass *pass) { |
350 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
351 | } |
352 | |
353 | /// A clone method to create a copy of this pass. |
354 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
355 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
356 | } |
357 | |
358 | /// Return the dialect that must be loaded in the context before this pass. |
359 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
360 | |
361 | } |
362 | |
363 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
364 | /// instantiation because Pass classes should only be visible by the current |
365 | /// library. |
366 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(DedupeAndHoistConstantBase<DerivedT>) |
367 | |
368 | DedupeAndHoistConstantBase(const DedupeAndHoistConstantOptions &options) : DedupeAndHoistConstantBase() { |
369 | max_size_ = options.max_size_; |
370 | assume_strict_calls_ = options.assume_strict_calls_; |
371 | } |
372 | protected: |
373 | ::mlir::Pass::Option<int64_t> max_size_{*this, "max-size" , ::llvm::cl::desc("The maximum number of elements when considering whether a constant is small" ), ::llvm::cl::init(10)}; |
374 | ::mlir::Pass::Option<bool> assume_strict_calls_{*this, "assume-strict-calls" , ::llvm::cl::desc("Assume all function calls are stricts, that is operands are evaluated prior to the call" ), ::llvm::cl::init(false)}; |
375 | private: |
376 | }; |
377 | } // namespace impl |
378 | #undef GEN_PASS_DEF_DEDUPEANDHOISTCONSTANT |
379 | #endif // GEN_PASS_DEF_DEDUPEANDHOISTCONSTANT |
380 | |
381 | //===----------------------------------------------------------------------===// |
382 | // DropOutputShapesAttr |
383 | //===----------------------------------------------------------------------===// |
384 | #ifdef GEN_PASS_DECL_DROPOUTPUTSHAPESATTR |
385 | struct DropOutputShapesAttrOptions { |
386 | ::llvm::ArrayRef<std::string> skip_; |
387 | }; |
388 | #undef GEN_PASS_DECL_DROPOUTPUTSHAPESATTR |
389 | #endif // GEN_PASS_DECL_DROPOUTPUTSHAPESATTR |
390 | #ifdef GEN_PASS_DEF_DROPOUTPUTSHAPESATTR |
391 | namespace impl { |
392 | |
393 | template <typename DerivedT> |
394 | class DropOutputShapesAttrBase : public ::mlir::OperationPass<> { |
395 | public: |
396 | using Base = DropOutputShapesAttrBase; |
397 | |
398 | DropOutputShapesAttrBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {} |
399 | DropOutputShapesAttrBase(const DropOutputShapesAttrBase &other) : ::mlir::OperationPass<>(other) {} |
400 | |
401 | /// Returns the command-line argument attached to this pass. |
402 | static constexpr ::llvm::StringLiteral getArgumentName() { |
403 | return ::llvm::StringLiteral("tfg-drop-unregistered-output-shapes" ); |
404 | } |
405 | ::llvm::StringRef getArgument() const override { return "tfg-drop-unregistered-output-shapes" ; } |
406 | |
407 | ::llvm::StringRef getDescription() const override { return "Drop _output_shapes attribute" ; } |
408 | |
409 | /// Returns the derived pass name. |
410 | static constexpr ::llvm::StringLiteral getPassName() { |
411 | return ::llvm::StringLiteral("DropOutputShapesAttr" ); |
412 | } |
413 | ::llvm::StringRef getName() const override { return "DropOutputShapesAttr" ; } |
414 | |
415 | /// Support isa/dyn_cast functionality for the derived pass class. |
416 | static bool classof(const ::mlir::Pass *pass) { |
417 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
418 | } |
419 | |
420 | /// A clone method to create a copy of this pass. |
421 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
422 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
423 | } |
424 | |
425 | /// Return the dialect that must be loaded in the context before this pass. |
426 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
427 | |
428 | } |
429 | |
430 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
431 | /// instantiation because Pass classes should only be visible by the current |
432 | /// library. |
433 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(DropOutputShapesAttrBase<DerivedT>) |
434 | |
435 | DropOutputShapesAttrBase(const DropOutputShapesAttrOptions &options) : DropOutputShapesAttrBase() { |
436 | skip_ = options.skip_; |
437 | } |
438 | protected: |
439 | ::mlir::Pass::ListOption<std::string> skip_{*this, "skip" , ::llvm::cl::desc("Comma separated list of ops that will be skipped." )}; |
440 | private: |
441 | }; |
442 | } // namespace impl |
443 | #undef GEN_PASS_DEF_DROPOUTPUTSHAPESATTR |
444 | #endif // GEN_PASS_DEF_DROPOUTPUTSHAPESATTR |
445 | |
446 | //===----------------------------------------------------------------------===// |
447 | // EliminatePassthroughIterArgs |
448 | //===----------------------------------------------------------------------===// |
449 | #ifdef GEN_PASS_DECL_ELIMINATEPASSTHROUGHITERARGS |
450 | #undef GEN_PASS_DECL_ELIMINATEPASSTHROUGHITERARGS |
451 | #endif // GEN_PASS_DECL_ELIMINATEPASSTHROUGHITERARGS |
452 | #ifdef GEN_PASS_DEF_ELIMINATEPASSTHROUGHITERARGS |
453 | namespace impl { |
454 | |
455 | template <typename DerivedT> |
456 | class EliminatePassthroughIterArgsBase : public ::mlir::OperationPass<ModuleOp> { |
457 | public: |
458 | using Base = EliminatePassthroughIterArgsBase; |
459 | |
460 | EliminatePassthroughIterArgsBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {} |
461 | EliminatePassthroughIterArgsBase(const EliminatePassthroughIterArgsBase &other) : ::mlir::OperationPass<ModuleOp>(other) {} |
462 | |
463 | /// Returns the command-line argument attached to this pass. |
464 | static constexpr ::llvm::StringLiteral getArgumentName() { |
465 | return ::llvm::StringLiteral("tfg-eliminate-passthrough-iter-args" ); |
466 | } |
467 | ::llvm::StringRef getArgument() const override { return "tfg-eliminate-passthrough-iter-args" ; } |
468 | |
469 | ::llvm::StringRef getDescription() const override { return "Eliminate passthrough loop iteration arguments." ; } |
470 | |
471 | /// Returns the derived pass name. |
472 | static constexpr ::llvm::StringLiteral getPassName() { |
473 | return ::llvm::StringLiteral("EliminatePassthroughIterArgs" ); |
474 | } |
475 | ::llvm::StringRef getName() const override { return "EliminatePassthroughIterArgs" ; } |
476 | |
477 | /// Support isa/dyn_cast functionality for the derived pass class. |
478 | static bool classof(const ::mlir::Pass *pass) { |
479 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
480 | } |
481 | |
482 | /// A clone method to create a copy of this pass. |
483 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
484 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
485 | } |
486 | |
487 | /// Return the dialect that must be loaded in the context before this pass. |
488 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
489 | |
490 | registry.insert<tfg::TFGraphDialect>(); |
491 | |
492 | } |
493 | |
494 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
495 | /// instantiation because Pass classes should only be visible by the current |
496 | /// library. |
497 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(EliminatePassthroughIterArgsBase<DerivedT>) |
498 | |
499 | protected: |
500 | private: |
501 | }; |
502 | } // namespace impl |
503 | #undef GEN_PASS_DEF_ELIMINATEPASSTHROUGHITERARGS |
504 | #endif // GEN_PASS_DEF_ELIMINATEPASSTHROUGHITERARGS |
505 | |
506 | //===----------------------------------------------------------------------===// |
507 | // FuncToGraph |
508 | //===----------------------------------------------------------------------===// |
509 | #ifdef GEN_PASS_DECL_FUNCTOGRAPH |
510 | #undef GEN_PASS_DECL_FUNCTOGRAPH |
511 | #endif // GEN_PASS_DECL_FUNCTOGRAPH |
512 | #ifdef GEN_PASS_DEF_FUNCTOGRAPH |
513 | namespace impl { |
514 | |
515 | template <typename DerivedT> |
516 | class FuncToGraphBase : public ::mlir::OperationPass<ModuleOp> { |
517 | public: |
518 | using Base = FuncToGraphBase; |
519 | |
520 | FuncToGraphBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {} |
521 | FuncToGraphBase(const FuncToGraphBase &other) : ::mlir::OperationPass<ModuleOp>(other) {} |
522 | |
523 | /// Returns the command-line argument attached to this pass. |
524 | static constexpr ::llvm::StringLiteral getArgumentName() { |
525 | return ::llvm::StringLiteral("tfg-lower-func-to-graph" ); |
526 | } |
527 | ::llvm::StringRef getArgument() const override { return "tfg-lower-func-to-graph" ; } |
528 | |
529 | ::llvm::StringRef getDescription() const override { return "Turns a function back to a graph" ; } |
530 | |
531 | /// Returns the derived pass name. |
532 | static constexpr ::llvm::StringLiteral getPassName() { |
533 | return ::llvm::StringLiteral("FuncToGraph" ); |
534 | } |
535 | ::llvm::StringRef getName() const override { return "FuncToGraph" ; } |
536 | |
537 | /// Support isa/dyn_cast functionality for the derived pass class. |
538 | static bool classof(const ::mlir::Pass *pass) { |
539 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
540 | } |
541 | |
542 | /// A clone method to create a copy of this pass. |
543 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
544 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
545 | } |
546 | |
547 | /// Return the dialect that must be loaded in the context before this pass. |
548 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
549 | |
550 | } |
551 | |
552 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
553 | /// instantiation because Pass classes should only be visible by the current |
554 | /// library. |
555 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(FuncToGraphBase<DerivedT>) |
556 | |
557 | protected: |
558 | private: |
559 | }; |
560 | } // namespace impl |
561 | #undef GEN_PASS_DEF_FUNCTOGRAPH |
562 | #endif // GEN_PASS_DEF_FUNCTOGRAPH |
563 | |
564 | //===----------------------------------------------------------------------===// |
565 | // FunctionalToRegion |
566 | //===----------------------------------------------------------------------===// |
567 | #ifdef GEN_PASS_DECL_FUNCTIONALTOREGION |
568 | #undef GEN_PASS_DECL_FUNCTIONALTOREGION |
569 | #endif // GEN_PASS_DECL_FUNCTIONALTOREGION |
570 | #ifdef GEN_PASS_DEF_FUNCTIONALTOREGION |
571 | namespace impl { |
572 | |
573 | template <typename DerivedT> |
574 | class FunctionalToRegionBase : public ::mlir::OperationPass<ModuleOp> { |
575 | public: |
576 | using Base = FunctionalToRegionBase; |
577 | |
578 | FunctionalToRegionBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {} |
579 | FunctionalToRegionBase(const FunctionalToRegionBase &other) : ::mlir::OperationPass<ModuleOp>(other) {} |
580 | |
581 | /// Returns the command-line argument attached to this pass. |
582 | static constexpr ::llvm::StringLiteral getArgumentName() { |
583 | return ::llvm::StringLiteral("tfg-functional-to-region" ); |
584 | } |
585 | ::llvm::StringRef getArgument() const override { return "tfg-functional-to-region" ; } |
586 | |
587 | ::llvm::StringRef getDescription() const override { return "Convert functional control-flow ops to region-based." ; } |
588 | |
589 | /// Returns the derived pass name. |
590 | static constexpr ::llvm::StringLiteral getPassName() { |
591 | return ::llvm::StringLiteral("FunctionalToRegion" ); |
592 | } |
593 | ::llvm::StringRef getName() const override { return "FunctionalToRegion" ; } |
594 | |
595 | /// Support isa/dyn_cast functionality for the derived pass class. |
596 | static bool classof(const ::mlir::Pass *pass) { |
597 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
598 | } |
599 | |
600 | /// A clone method to create a copy of this pass. |
601 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
602 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
603 | } |
604 | |
605 | /// Return the dialect that must be loaded in the context before this pass. |
606 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
607 | |
608 | registry.insert<tfg::TFGraphDialect>(); |
609 | |
610 | } |
611 | |
612 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
613 | /// instantiation because Pass classes should only be visible by the current |
614 | /// library. |
615 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(FunctionalToRegionBase<DerivedT>) |
616 | |
617 | protected: |
618 | private: |
619 | }; |
620 | } // namespace impl |
621 | #undef GEN_PASS_DEF_FUNCTIONALTOREGION |
622 | #endif // GEN_PASS_DEF_FUNCTIONALTOREGION |
623 | |
624 | //===----------------------------------------------------------------------===// |
625 | // GraphToFunc |
626 | //===----------------------------------------------------------------------===// |
627 | #ifdef GEN_PASS_DECL_GRAPHTOFUNC |
628 | struct GraphToFuncOptions { |
629 | ::llvm::ArrayRef<std::string> feeds_; |
630 | ::llvm::ArrayRef<std::string> fetches_; |
631 | ::llvm::ArrayRef<std::string> control_rets_; |
632 | }; |
633 | #undef GEN_PASS_DECL_GRAPHTOFUNC |
634 | #endif // GEN_PASS_DECL_GRAPHTOFUNC |
635 | #ifdef GEN_PASS_DEF_GRAPHTOFUNC |
636 | namespace impl { |
637 | |
638 | template <typename DerivedT> |
639 | class GraphToFuncBase : public ::mlir::OperationPass<ModuleOp> { |
640 | public: |
641 | using Base = GraphToFuncBase; |
642 | |
643 | GraphToFuncBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {} |
644 | GraphToFuncBase(const GraphToFuncBase &other) : ::mlir::OperationPass<ModuleOp>(other) {} |
645 | |
646 | /// Returns the command-line argument attached to this pass. |
647 | static constexpr ::llvm::StringLiteral getArgumentName() { |
648 | return ::llvm::StringLiteral("tfg-lift-graph-to-func" ); |
649 | } |
650 | ::llvm::StringRef getArgument() const override { return "tfg-lift-graph-to-func" ; } |
651 | |
652 | ::llvm::StringRef getDescription() const override { return "Turns a graph into a function." ; } |
653 | |
654 | /// Returns the derived pass name. |
655 | static constexpr ::llvm::StringLiteral getPassName() { |
656 | return ::llvm::StringLiteral("GraphToFunc" ); |
657 | } |
658 | ::llvm::StringRef getName() const override { return "GraphToFunc" ; } |
659 | |
660 | /// Support isa/dyn_cast functionality for the derived pass class. |
661 | static bool classof(const ::mlir::Pass *pass) { |
662 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
663 | } |
664 | |
665 | /// A clone method to create a copy of this pass. |
666 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
667 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
668 | } |
669 | |
670 | /// Return the dialect that must be loaded in the context before this pass. |
671 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
672 | |
673 | } |
674 | |
675 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
676 | /// instantiation because Pass classes should only be visible by the current |
677 | /// library. |
678 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(GraphToFuncBase<DerivedT>) |
679 | |
680 | GraphToFuncBase(const GraphToFuncOptions &options) : GraphToFuncBase() { |
681 | feeds_ = options.feeds_; |
682 | fetches_ = options.fetches_; |
683 | control_rets_ = options.control_rets_; |
684 | } |
685 | protected: |
686 | ::mlir::Pass::ListOption<std::string> feeds_{*this, "feeds" , ::llvm::cl::desc("Comma separated list of ops that will be turned into arguments." )}; |
687 | ::mlir::Pass::ListOption<std::string> fetches_{*this, "fetches" , ::llvm::cl::desc("Comma separated list of ops that will be turned into results." )}; |
688 | ::mlir::Pass::ListOption<std::string> control_rets_{*this, "control_rets" , ::llvm::cl::desc("Comma separated list of ops that will be turned into control returned." )}; |
689 | private: |
690 | }; |
691 | } // namespace impl |
692 | #undef GEN_PASS_DEF_GRAPHTOFUNC |
693 | #endif // GEN_PASS_DEF_GRAPHTOFUNC |
694 | |
695 | //===----------------------------------------------------------------------===// |
696 | // LiftLegacyCall |
697 | //===----------------------------------------------------------------------===// |
698 | #ifdef GEN_PASS_DECL_LIFTLEGACYCALL |
699 | #undef GEN_PASS_DECL_LIFTLEGACYCALL |
700 | #endif // GEN_PASS_DECL_LIFTLEGACYCALL |
701 | #ifdef GEN_PASS_DEF_LIFTLEGACYCALL |
702 | namespace impl { |
703 | |
704 | template <typename DerivedT> |
705 | class LiftLegacyCallBase : public ::mlir::OperationPass<ModuleOp> { |
706 | public: |
707 | using Base = LiftLegacyCallBase; |
708 | |
709 | LiftLegacyCallBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {} |
710 | LiftLegacyCallBase(const LiftLegacyCallBase &other) : ::mlir::OperationPass<ModuleOp>(other) {} |
711 | |
712 | /// Returns the command-line argument attached to this pass. |
713 | static constexpr ::llvm::StringLiteral getArgumentName() { |
714 | return ::llvm::StringLiteral("tfg-lift-legacy-call" ); |
715 | } |
716 | ::llvm::StringRef getArgument() const override { return "tfg-lift-legacy-call" ; } |
717 | |
718 | ::llvm::StringRef getDescription() const override { return "Tag legacy calls with symbol references to add symbol uses" ; } |
719 | |
720 | /// Returns the derived pass name. |
721 | static constexpr ::llvm::StringLiteral getPassName() { |
722 | return ::llvm::StringLiteral("LiftLegacyCall" ); |
723 | } |
724 | ::llvm::StringRef getName() const override { return "LiftLegacyCall" ; } |
725 | |
726 | /// Support isa/dyn_cast functionality for the derived pass class. |
727 | static bool classof(const ::mlir::Pass *pass) { |
728 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
729 | } |
730 | |
731 | /// A clone method to create a copy of this pass. |
732 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
733 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
734 | } |
735 | |
736 | /// Return the dialect that must be loaded in the context before this pass. |
737 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
738 | |
739 | } |
740 | |
741 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
742 | /// instantiation because Pass classes should only be visible by the current |
743 | /// library. |
744 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(LiftLegacyCallBase<DerivedT>) |
745 | |
746 | protected: |
747 | private: |
748 | }; |
749 | } // namespace impl |
750 | #undef GEN_PASS_DEF_LIFTLEGACYCALL |
751 | #endif // GEN_PASS_DEF_LIFTLEGACYCALL |
752 | |
753 | //===----------------------------------------------------------------------===// |
754 | // NameCompress |
755 | //===----------------------------------------------------------------------===// |
756 | #ifdef GEN_PASS_DECL_NAMECOMPRESS |
757 | #undef GEN_PASS_DECL_NAMECOMPRESS |
758 | #endif // GEN_PASS_DECL_NAMECOMPRESS |
759 | #ifdef GEN_PASS_DEF_NAMECOMPRESS |
760 | namespace impl { |
761 | |
762 | template <typename DerivedT> |
763 | class NameCompressBase : public ::mlir::OperationPass<GraphFuncOp> { |
764 | public: |
765 | using Base = NameCompressBase; |
766 | |
767 | NameCompressBase() : ::mlir::OperationPass<GraphFuncOp>(::mlir::TypeID::get<DerivedT>()) {} |
768 | NameCompressBase(const NameCompressBase &other) : ::mlir::OperationPass<GraphFuncOp>(other) {} |
769 | |
770 | /// Returns the command-line argument attached to this pass. |
771 | static constexpr ::llvm::StringLiteral getArgumentName() { |
772 | return ::llvm::StringLiteral("tfg-name-compress" ); |
773 | } |
774 | ::llvm::StringRef getArgument() const override { return "tfg-name-compress" ; } |
775 | |
776 | ::llvm::StringRef getDescription() const override { return "Compress the graph by shortening names" ; } |
777 | |
778 | /// Returns the derived pass name. |
779 | static constexpr ::llvm::StringLiteral getPassName() { |
780 | return ::llvm::StringLiteral("NameCompress" ); |
781 | } |
782 | ::llvm::StringRef getName() const override { return "NameCompress" ; } |
783 | |
784 | /// Support isa/dyn_cast functionality for the derived pass class. |
785 | static bool classof(const ::mlir::Pass *pass) { |
786 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
787 | } |
788 | |
789 | /// A clone method to create a copy of this pass. |
790 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
791 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
792 | } |
793 | |
794 | /// Return the dialect that must be loaded in the context before this pass. |
795 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
796 | |
797 | } |
798 | |
799 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
800 | /// instantiation because Pass classes should only be visible by the current |
801 | /// library. |
802 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(NameCompressBase<DerivedT>) |
803 | |
804 | protected: |
805 | private: |
806 | }; |
807 | } // namespace impl |
808 | #undef GEN_PASS_DEF_NAMECOMPRESS |
809 | #endif // GEN_PASS_DEF_NAMECOMPRESS |
810 | |
811 | //===----------------------------------------------------------------------===// |
812 | // PrepareAttributesForExport |
813 | //===----------------------------------------------------------------------===// |
814 | #ifdef GEN_PASS_DECL_PREPAREATTRIBUTESFOREXPORT |
815 | #undef GEN_PASS_DECL_PREPAREATTRIBUTESFOREXPORT |
816 | #endif // GEN_PASS_DECL_PREPAREATTRIBUTESFOREXPORT |
817 | #ifdef GEN_PASS_DEF_PREPAREATTRIBUTESFOREXPORT |
818 | namespace impl { |
819 | |
820 | template <typename DerivedT> |
821 | class PrepareAttributesForExportBase : public ::mlir::OperationPass<ModuleOp> { |
822 | public: |
823 | using Base = PrepareAttributesForExportBase; |
824 | |
825 | PrepareAttributesForExportBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {} |
826 | PrepareAttributesForExportBase(const PrepareAttributesForExportBase &other) : ::mlir::OperationPass<ModuleOp>(other) {} |
827 | |
828 | /// Returns the command-line argument attached to this pass. |
829 | static constexpr ::llvm::StringLiteral getArgumentName() { |
830 | return ::llvm::StringLiteral("tfg-prepare-attrs-export" ); |
831 | } |
832 | ::llvm::StringRef getArgument() const override { return "tfg-prepare-attrs-export" ; } |
833 | |
834 | ::llvm::StringRef getDescription() const override { return "Legalize ops' attributes for export." ; } |
835 | |
836 | /// Returns the derived pass name. |
837 | static constexpr ::llvm::StringLiteral getPassName() { |
838 | return ::llvm::StringLiteral("PrepareAttributesForExport" ); |
839 | } |
840 | ::llvm::StringRef getName() const override { return "PrepareAttributesForExport" ; } |
841 | |
842 | /// Support isa/dyn_cast functionality for the derived pass class. |
843 | static bool classof(const ::mlir::Pass *pass) { |
844 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
845 | } |
846 | |
847 | /// A clone method to create a copy of this pass. |
848 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
849 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
850 | } |
851 | |
852 | /// Return the dialect that must be loaded in the context before this pass. |
853 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
854 | |
855 | } |
856 | |
857 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
858 | /// instantiation because Pass classes should only be visible by the current |
859 | /// library. |
860 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(PrepareAttributesForExportBase<DerivedT>) |
861 | |
862 | protected: |
863 | private: |
864 | }; |
865 | } // namespace impl |
866 | #undef GEN_PASS_DEF_PREPAREATTRIBUTESFOREXPORT |
867 | #endif // GEN_PASS_DEF_PREPAREATTRIBUTESFOREXPORT |
868 | |
869 | //===----------------------------------------------------------------------===// |
870 | // RegionToFunctional |
871 | //===----------------------------------------------------------------------===// |
872 | #ifdef GEN_PASS_DECL_REGIONTOFUNCTIONAL |
873 | struct RegionToFunctionalOptions { |
874 | bool force_control_capture = false; |
875 | }; |
876 | #undef GEN_PASS_DECL_REGIONTOFUNCTIONAL |
877 | #endif // GEN_PASS_DECL_REGIONTOFUNCTIONAL |
878 | #ifdef GEN_PASS_DEF_REGIONTOFUNCTIONAL |
879 | namespace impl { |
880 | |
881 | template <typename DerivedT> |
882 | class RegionToFunctionalBase : public ::mlir::OperationPass<ModuleOp> { |
883 | public: |
884 | using Base = RegionToFunctionalBase; |
885 | |
886 | RegionToFunctionalBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {} |
887 | RegionToFunctionalBase(const RegionToFunctionalBase &other) : ::mlir::OperationPass<ModuleOp>(other) {} |
888 | |
889 | /// Returns the command-line argument attached to this pass. |
890 | static constexpr ::llvm::StringLiteral getArgumentName() { |
891 | return ::llvm::StringLiteral("tfg-region-to-functional" ); |
892 | } |
893 | ::llvm::StringRef getArgument() const override { return "tfg-region-to-functional" ; } |
894 | |
895 | ::llvm::StringRef getDescription() const override { return "Convert region-based control-flow ops to functional." ; } |
896 | |
897 | /// Returns the derived pass name. |
898 | static constexpr ::llvm::StringLiteral getPassName() { |
899 | return ::llvm::StringLiteral("RegionToFunctional" ); |
900 | } |
901 | ::llvm::StringRef getName() const override { return "RegionToFunctional" ; } |
902 | |
903 | /// Support isa/dyn_cast functionality for the derived pass class. |
904 | static bool classof(const ::mlir::Pass *pass) { |
905 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
906 | } |
907 | |
908 | /// A clone method to create a copy of this pass. |
909 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
910 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
911 | } |
912 | |
913 | /// Return the dialect that must be loaded in the context before this pass. |
914 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
915 | |
916 | registry.insert<tfg::TFGraphDialect>(); |
917 | |
918 | } |
919 | |
920 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
921 | /// instantiation because Pass classes should only be visible by the current |
922 | /// library. |
923 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(RegionToFunctionalBase<DerivedT>) |
924 | |
925 | RegionToFunctionalBase(const RegionToFunctionalOptions &options) : RegionToFunctionalBase() { |
926 | force_control_capture = options.force_control_capture; |
927 | } |
928 | protected: |
929 | ::mlir::Pass::Option<bool> force_control_capture{*this, "force-control-capture" , ::llvm::cl::desc("Force the capture of control tokens by inserting chain `Const` ops" ), ::llvm::cl::init(false)}; |
930 | private: |
931 | }; |
932 | } // namespace impl |
933 | #undef GEN_PASS_DEF_REGIONTOFUNCTIONAL |
934 | #endif // GEN_PASS_DEF_REGIONTOFUNCTIONAL |
935 | |
936 | //===----------------------------------------------------------------------===// |
937 | // Remapper |
938 | //===----------------------------------------------------------------------===// |
939 | #ifdef GEN_PASS_DECL_REMAPPER |
940 | struct RemapperOptions { |
941 | bool enable_onednn_patterns_ = false; |
942 | bool verify_pdll_patterns_only_ = false; |
943 | bool xla_auto_clustering_ = false; |
944 | }; |
945 | #undef GEN_PASS_DECL_REMAPPER |
946 | #endif // GEN_PASS_DECL_REMAPPER |
947 | #ifdef GEN_PASS_DEF_REMAPPER |
948 | namespace impl { |
949 | |
950 | template <typename DerivedT> |
951 | class RemapperBase : public ::mlir::OperationPass<> { |
952 | public: |
953 | using Base = RemapperBase; |
954 | |
955 | RemapperBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {} |
956 | RemapperBase(const RemapperBase &other) : ::mlir::OperationPass<>(other) {} |
957 | |
958 | /// Returns the command-line argument attached to this pass. |
959 | static constexpr ::llvm::StringLiteral getArgumentName() { |
960 | return ::llvm::StringLiteral("tfg-remapper" ); |
961 | } |
962 | ::llvm::StringRef getArgument() const override { return "tfg-remapper" ; } |
963 | |
964 | ::llvm::StringRef getDescription() const override { return "Remap operations to decrease amount of operations" ; } |
965 | |
966 | /// Returns the derived pass name. |
967 | static constexpr ::llvm::StringLiteral getPassName() { |
968 | return ::llvm::StringLiteral("Remapper" ); |
969 | } |
970 | ::llvm::StringRef getName() const override { return "Remapper" ; } |
971 | |
972 | /// Support isa/dyn_cast functionality for the derived pass class. |
973 | static bool classof(const ::mlir::Pass *pass) { |
974 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
975 | } |
976 | |
977 | /// A clone method to create a copy of this pass. |
978 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
979 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
980 | } |
981 | |
982 | /// Return the dialect that must be loaded in the context before this pass. |
983 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
984 | |
985 | } |
986 | |
987 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
988 | /// instantiation because Pass classes should only be visible by the current |
989 | /// library. |
990 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(RemapperBase<DerivedT>) |
991 | |
992 | RemapperBase(const RemapperOptions &options) : RemapperBase() { |
993 | enable_onednn_patterns_ = options.enable_onednn_patterns_; |
994 | verify_pdll_patterns_only_ = options.verify_pdll_patterns_only_; |
995 | xla_auto_clustering_ = options.xla_auto_clustering_; |
996 | } |
997 | protected: |
998 | ::mlir::Pass::Option<bool> enable_onednn_patterns_{*this, "enable-onednn-patterns" , ::llvm::cl::desc("Enable the oneDNN related patterns." ), ::llvm::cl::init(false)}; |
999 | ::mlir::Pass::Option<bool> verify_pdll_patterns_only_{*this, "verify-pdll-patterns-only" , ::llvm::cl::desc("Only enable PDLL patterns." ), ::llvm::cl::init(false)}; |
1000 | ::mlir::Pass::Option<bool> xla_auto_clustering_{*this, "xla-auto-clustering" , ::llvm::cl::desc("Sets XLA auto clustering flag." ), ::llvm::cl::init(false)}; |
1001 | private: |
1002 | }; |
1003 | } // namespace impl |
1004 | #undef GEN_PASS_DEF_REMAPPER |
1005 | #endif // GEN_PASS_DEF_REMAPPER |
1006 | |
1007 | //===----------------------------------------------------------------------===// |
1008 | // ShapeInference |
1009 | //===----------------------------------------------------------------------===// |
1010 | #ifdef GEN_PASS_DECL_SHAPEINFERENCE |
1011 | struct ShapeInferenceOptions { |
1012 | int graph_version_; |
1013 | }; |
1014 | #undef GEN_PASS_DECL_SHAPEINFERENCE |
1015 | #endif // GEN_PASS_DECL_SHAPEINFERENCE |
1016 | #ifdef GEN_PASS_DEF_SHAPEINFERENCE |
1017 | namespace impl { |
1018 | |
1019 | template <typename DerivedT> |
1020 | class ShapeInferenceBase : public ::mlir::OperationPass<> { |
1021 | public: |
1022 | using Base = ShapeInferenceBase; |
1023 | |
1024 | ShapeInferenceBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {} |
1025 | ShapeInferenceBase(const ShapeInferenceBase &other) : ::mlir::OperationPass<>(other) {} |
1026 | |
1027 | /// Returns the command-line argument attached to this pass. |
1028 | static constexpr ::llvm::StringLiteral getArgumentName() { |
1029 | return ::llvm::StringLiteral("tfg-shape-inference" ); |
1030 | } |
1031 | ::llvm::StringRef getArgument() const override { return "tfg-shape-inference" ; } |
1032 | |
1033 | ::llvm::StringRef getDescription() const override { return "Infer the output shape of operations" ; } |
1034 | |
1035 | /// Returns the derived pass name. |
1036 | static constexpr ::llvm::StringLiteral getPassName() { |
1037 | return ::llvm::StringLiteral("ShapeInference" ); |
1038 | } |
1039 | ::llvm::StringRef getName() const override { return "ShapeInference" ; } |
1040 | |
1041 | /// Support isa/dyn_cast functionality for the derived pass class. |
1042 | static bool classof(const ::mlir::Pass *pass) { |
1043 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
1044 | } |
1045 | |
1046 | /// A clone method to create a copy of this pass. |
1047 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
1048 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
1049 | } |
1050 | |
1051 | /// Return the dialect that must be loaded in the context before this pass. |
1052 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
1053 | |
1054 | } |
1055 | |
1056 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
1057 | /// instantiation because Pass classes should only be visible by the current |
1058 | /// library. |
1059 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ShapeInferenceBase<DerivedT>) |
1060 | |
1061 | ShapeInferenceBase(const ShapeInferenceOptions &options) : ShapeInferenceBase() { |
1062 | graph_version_ = options.graph_version_; |
1063 | } |
1064 | protected: |
1065 | ::mlir::Pass::Option<int> graph_version_{*this, "graph-version" , ::llvm::cl::desc("The graph producer version" )}; |
1066 | private: |
1067 | }; |
1068 | } // namespace impl |
1069 | #undef GEN_PASS_DEF_SHAPEINFERENCE |
1070 | #endif // GEN_PASS_DEF_SHAPEINFERENCE |
1071 | |
1072 | //===----------------------------------------------------------------------===// |
1073 | // StripDefaultAttrs |
1074 | //===----------------------------------------------------------------------===// |
1075 | #ifdef GEN_PASS_DECL_STRIPDEFAULTATTRS |
1076 | #undef GEN_PASS_DECL_STRIPDEFAULTATTRS |
1077 | #endif // GEN_PASS_DECL_STRIPDEFAULTATTRS |
1078 | #ifdef GEN_PASS_DEF_STRIPDEFAULTATTRS |
1079 | namespace impl { |
1080 | |
1081 | template <typename DerivedT> |
1082 | class StripDefaultAttrsBase : public ::mlir::OperationPass<> { |
1083 | public: |
1084 | using Base = StripDefaultAttrsBase; |
1085 | |
1086 | StripDefaultAttrsBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {} |
1087 | StripDefaultAttrsBase(const StripDefaultAttrsBase &other) : ::mlir::OperationPass<>(other) {} |
1088 | |
1089 | /// Returns the command-line argument attached to this pass. |
1090 | static constexpr ::llvm::StringLiteral getArgumentName() { |
1091 | return ::llvm::StringLiteral("tfg-strip-default-attrs" ); |
1092 | } |
1093 | ::llvm::StringRef getArgument() const override { return "tfg-strip-default-attrs" ; } |
1094 | |
1095 | ::llvm::StringRef getDescription() const override { return "Removes default-valued attributes from the graph" ; } |
1096 | |
1097 | /// Returns the derived pass name. |
1098 | static constexpr ::llvm::StringLiteral getPassName() { |
1099 | return ::llvm::StringLiteral("StripDefaultAttrs" ); |
1100 | } |
1101 | ::llvm::StringRef getName() const override { return "StripDefaultAttrs" ; } |
1102 | |
1103 | /// Support isa/dyn_cast functionality for the derived pass class. |
1104 | static bool classof(const ::mlir::Pass *pass) { |
1105 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
1106 | } |
1107 | |
1108 | /// A clone method to create a copy of this pass. |
1109 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
1110 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
1111 | } |
1112 | |
1113 | /// Return the dialect that must be loaded in the context before this pass. |
1114 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
1115 | |
1116 | } |
1117 | |
1118 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
1119 | /// instantiation because Pass classes should only be visible by the current |
1120 | /// library. |
1121 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StripDefaultAttrsBase<DerivedT>) |
1122 | |
1123 | protected: |
1124 | private: |
1125 | }; |
1126 | } // namespace impl |
1127 | #undef GEN_PASS_DEF_STRIPDEFAULTATTRS |
1128 | #endif // GEN_PASS_DEF_STRIPDEFAULTATTRS |
1129 | |
1130 | //===----------------------------------------------------------------------===// |
1131 | // TopoSort |
1132 | //===----------------------------------------------------------------------===// |
1133 | #ifdef GEN_PASS_DECL_TOPOSORT |
1134 | #undef GEN_PASS_DECL_TOPOSORT |
1135 | #endif // GEN_PASS_DECL_TOPOSORT |
1136 | #ifdef GEN_PASS_DEF_TOPOSORT |
1137 | namespace impl { |
1138 | |
1139 | template <typename DerivedT> |
1140 | class TopoSortBase : public ::mlir::OperationPass<> { |
1141 | public: |
1142 | using Base = TopoSortBase; |
1143 | |
1144 | TopoSortBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {} |
1145 | TopoSortBase(const TopoSortBase &other) : ::mlir::OperationPass<>(other) {} |
1146 | |
1147 | /// Returns the command-line argument attached to this pass. |
1148 | static constexpr ::llvm::StringLiteral getArgumentName() { |
1149 | return ::llvm::StringLiteral("tfg-toposort" ); |
1150 | } |
1151 | ::llvm::StringRef getArgument() const override { return "tfg-toposort" ; } |
1152 | |
1153 | ::llvm::StringRef getDescription() const override { return "Topologically sort graph and function regions" ; } |
1154 | |
1155 | /// Returns the derived pass name. |
1156 | static constexpr ::llvm::StringLiteral getPassName() { |
1157 | return ::llvm::StringLiteral("TopoSort" ); |
1158 | } |
1159 | ::llvm::StringRef getName() const override { return "TopoSort" ; } |
1160 | |
1161 | /// Support isa/dyn_cast functionality for the derived pass class. |
1162 | static bool classof(const ::mlir::Pass *pass) { |
1163 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
1164 | } |
1165 | |
1166 | /// A clone method to create a copy of this pass. |
1167 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
1168 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
1169 | } |
1170 | |
1171 | /// Return the dialect that must be loaded in the context before this pass. |
1172 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
1173 | |
1174 | } |
1175 | |
1176 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
1177 | /// instantiation because Pass classes should only be visible by the current |
1178 | /// library. |
1179 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TopoSortBase<DerivedT>) |
1180 | |
1181 | protected: |
1182 | private: |
1183 | }; |
1184 | } // namespace impl |
1185 | #undef GEN_PASS_DEF_TOPOSORT |
1186 | #endif // GEN_PASS_DEF_TOPOSORT |
1187 | #ifdef GEN_PASS_REGISTRATION |
1188 | |
1189 | //===----------------------------------------------------------------------===// |
1190 | // AddDefaultAttrs Registration |
1191 | //===----------------------------------------------------------------------===// |
1192 | |
1193 | inline void registerAddDefaultAttrs() { |
1194 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1195 | return CreateAddDefaultAttrsPass(); |
1196 | }); |
1197 | } |
1198 | |
1199 | // Old registration code, kept for temporary backwards compatibility. |
1200 | inline void registerAddDefaultAttrsPass() { |
1201 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1202 | return CreateAddDefaultAttrsPass(); |
1203 | }); |
1204 | } |
1205 | |
1206 | //===----------------------------------------------------------------------===// |
1207 | // CSEPass Registration |
1208 | //===----------------------------------------------------------------------===// |
1209 | |
1210 | inline void registerCSEPass() { |
1211 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1212 | return CreateCSEPass(); |
1213 | }); |
1214 | } |
1215 | |
1216 | // Old registration code, kept for temporary backwards compatibility. |
1217 | inline void registerCSEPassPass() { |
1218 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1219 | return CreateCSEPass(); |
1220 | }); |
1221 | } |
1222 | |
1223 | //===----------------------------------------------------------------------===// |
1224 | // ConsolidateAttributes Registration |
1225 | //===----------------------------------------------------------------------===// |
1226 | |
1227 | inline void registerConsolidateAttributes() { |
1228 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1229 | return CreateConsolidateAttributesPass(); |
1230 | }); |
1231 | } |
1232 | |
1233 | // Old registration code, kept for temporary backwards compatibility. |
1234 | inline void registerConsolidateAttributesPass() { |
1235 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1236 | return CreateConsolidateAttributesPass(); |
1237 | }); |
1238 | } |
1239 | |
1240 | //===----------------------------------------------------------------------===// |
1241 | // ConstantFoldingPass Registration |
1242 | //===----------------------------------------------------------------------===// |
1243 | |
1244 | inline void registerConstantFoldingPass() { |
1245 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1246 | return CreateConstantFoldingPass(); |
1247 | }); |
1248 | } |
1249 | |
1250 | // Old registration code, kept for temporary backwards compatibility. |
1251 | inline void registerConstantFoldingPassPass() { |
1252 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1253 | return CreateConstantFoldingPass(); |
1254 | }); |
1255 | } |
1256 | |
1257 | //===----------------------------------------------------------------------===// |
1258 | // ControlFlowSink Registration |
1259 | //===----------------------------------------------------------------------===// |
1260 | |
1261 | inline void registerControlFlowSink() { |
1262 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1263 | return CreateControlFlowSinkPass(); |
1264 | }); |
1265 | } |
1266 | |
1267 | // Old registration code, kept for temporary backwards compatibility. |
1268 | inline void registerControlFlowSinkPass() { |
1269 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1270 | return CreateControlFlowSinkPass(); |
1271 | }); |
1272 | } |
1273 | |
1274 | //===----------------------------------------------------------------------===// |
1275 | // DedupeAndHoistConstant Registration |
1276 | //===----------------------------------------------------------------------===// |
1277 | |
1278 | inline void registerDedupeAndHoistConstant() { |
1279 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1280 | return CreateDedupeAndHoistConstantPass(); |
1281 | }); |
1282 | } |
1283 | |
1284 | // Old registration code, kept for temporary backwards compatibility. |
1285 | inline void registerDedupeAndHoistConstantPass() { |
1286 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1287 | return CreateDedupeAndHoistConstantPass(); |
1288 | }); |
1289 | } |
1290 | |
1291 | //===----------------------------------------------------------------------===// |
1292 | // DropOutputShapesAttr Registration |
1293 | //===----------------------------------------------------------------------===// |
1294 | |
1295 | inline void registerDropOutputShapesAttr() { |
1296 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1297 | return CreateDropOutputShapesAttrPass(); |
1298 | }); |
1299 | } |
1300 | |
1301 | // Old registration code, kept for temporary backwards compatibility. |
1302 | inline void registerDropOutputShapesAttrPass() { |
1303 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1304 | return CreateDropOutputShapesAttrPass(); |
1305 | }); |
1306 | } |
1307 | |
1308 | //===----------------------------------------------------------------------===// |
1309 | // EliminatePassthroughIterArgs Registration |
1310 | //===----------------------------------------------------------------------===// |
1311 | |
1312 | inline void registerEliminatePassthroughIterArgs() { |
1313 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1314 | return CreateEliminatePassthroughIterArgsPass(); |
1315 | }); |
1316 | } |
1317 | |
1318 | // Old registration code, kept for temporary backwards compatibility. |
1319 | inline void registerEliminatePassthroughIterArgsPass() { |
1320 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1321 | return CreateEliminatePassthroughIterArgsPass(); |
1322 | }); |
1323 | } |
1324 | |
1325 | //===----------------------------------------------------------------------===// |
1326 | // FuncToGraph Registration |
1327 | //===----------------------------------------------------------------------===// |
1328 | |
1329 | inline void registerFuncToGraph() { |
1330 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1331 | return CreateFuncToGraphPass(); |
1332 | }); |
1333 | } |
1334 | |
1335 | // Old registration code, kept for temporary backwards compatibility. |
1336 | inline void registerFuncToGraphPass() { |
1337 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1338 | return CreateFuncToGraphPass(); |
1339 | }); |
1340 | } |
1341 | |
1342 | //===----------------------------------------------------------------------===// |
1343 | // FunctionalToRegion Registration |
1344 | //===----------------------------------------------------------------------===// |
1345 | |
1346 | inline void registerFunctionalToRegion() { |
1347 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1348 | return CreateFunctionalToRegionPass(); |
1349 | }); |
1350 | } |
1351 | |
1352 | // Old registration code, kept for temporary backwards compatibility. |
1353 | inline void registerFunctionalToRegionPass() { |
1354 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1355 | return CreateFunctionalToRegionPass(); |
1356 | }); |
1357 | } |
1358 | |
1359 | //===----------------------------------------------------------------------===// |
1360 | // GraphToFunc Registration |
1361 | //===----------------------------------------------------------------------===// |
1362 | |
1363 | inline void registerGraphToFunc() { |
1364 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1365 | return CreateGraphToFuncPass(); |
1366 | }); |
1367 | } |
1368 | |
1369 | // Old registration code, kept for temporary backwards compatibility. |
1370 | inline void registerGraphToFuncPass() { |
1371 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1372 | return CreateGraphToFuncPass(); |
1373 | }); |
1374 | } |
1375 | |
1376 | //===----------------------------------------------------------------------===// |
1377 | // LiftLegacyCall Registration |
1378 | //===----------------------------------------------------------------------===// |
1379 | |
1380 | inline void registerLiftLegacyCall() { |
1381 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1382 | return CreateLiftLegacyCallPass(); |
1383 | }); |
1384 | } |
1385 | |
1386 | // Old registration code, kept for temporary backwards compatibility. |
1387 | inline void registerLiftLegacyCallPass() { |
1388 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1389 | return CreateLiftLegacyCallPass(); |
1390 | }); |
1391 | } |
1392 | |
1393 | //===----------------------------------------------------------------------===// |
1394 | // NameCompress Registration |
1395 | //===----------------------------------------------------------------------===// |
1396 | |
1397 | inline void registerNameCompress() { |
1398 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1399 | return CreateNameCompressPass(); |
1400 | }); |
1401 | } |
1402 | |
1403 | // Old registration code, kept for temporary backwards compatibility. |
1404 | inline void registerNameCompressPass() { |
1405 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1406 | return CreateNameCompressPass(); |
1407 | }); |
1408 | } |
1409 | |
1410 | //===----------------------------------------------------------------------===// |
1411 | // PrepareAttributesForExport Registration |
1412 | //===----------------------------------------------------------------------===// |
1413 | |
1414 | inline void registerPrepareAttributesForExport() { |
1415 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1416 | return CreatePrepareAttributesForExportPass(); |
1417 | }); |
1418 | } |
1419 | |
1420 | // Old registration code, kept for temporary backwards compatibility. |
1421 | inline void registerPrepareAttributesForExportPass() { |
1422 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1423 | return CreatePrepareAttributesForExportPass(); |
1424 | }); |
1425 | } |
1426 | |
1427 | //===----------------------------------------------------------------------===// |
1428 | // RegionToFunctional Registration |
1429 | //===----------------------------------------------------------------------===// |
1430 | |
1431 | inline void registerRegionToFunctional() { |
1432 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1433 | return CreateRegionToFunctionalPass(); |
1434 | }); |
1435 | } |
1436 | |
1437 | // Old registration code, kept for temporary backwards compatibility. |
1438 | inline void registerRegionToFunctionalPass() { |
1439 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1440 | return CreateRegionToFunctionalPass(); |
1441 | }); |
1442 | } |
1443 | |
1444 | //===----------------------------------------------------------------------===// |
1445 | // Remapper Registration |
1446 | //===----------------------------------------------------------------------===// |
1447 | |
1448 | inline void registerRemapper() { |
1449 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1450 | return CreateRemapperPass(); |
1451 | }); |
1452 | } |
1453 | |
1454 | // Old registration code, kept for temporary backwards compatibility. |
1455 | inline void registerRemapperPass() { |
1456 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1457 | return CreateRemapperPass(); |
1458 | }); |
1459 | } |
1460 | |
1461 | //===----------------------------------------------------------------------===// |
1462 | // ShapeInference Registration |
1463 | //===----------------------------------------------------------------------===// |
1464 | |
1465 | inline void registerShapeInference() { |
1466 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1467 | return CreateShapeInferencePass(); |
1468 | }); |
1469 | } |
1470 | |
1471 | // Old registration code, kept for temporary backwards compatibility. |
1472 | inline void registerShapeInferencePass() { |
1473 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1474 | return CreateShapeInferencePass(); |
1475 | }); |
1476 | } |
1477 | |
1478 | //===----------------------------------------------------------------------===// |
1479 | // StripDefaultAttrs Registration |
1480 | //===----------------------------------------------------------------------===// |
1481 | |
1482 | inline void registerStripDefaultAttrs() { |
1483 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1484 | return CreateStripDefaultAttrsPass(); |
1485 | }); |
1486 | } |
1487 | |
1488 | // Old registration code, kept for temporary backwards compatibility. |
1489 | inline void registerStripDefaultAttrsPass() { |
1490 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1491 | return CreateStripDefaultAttrsPass(); |
1492 | }); |
1493 | } |
1494 | |
1495 | //===----------------------------------------------------------------------===// |
1496 | // TopoSort Registration |
1497 | //===----------------------------------------------------------------------===// |
1498 | |
1499 | inline void registerTopoSort() { |
1500 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1501 | return CreateTopoSortPass(); |
1502 | }); |
1503 | } |
1504 | |
1505 | // Old registration code, kept for temporary backwards compatibility. |
1506 | inline void registerTopoSortPass() { |
1507 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
1508 | return CreateTopoSortPass(); |
1509 | }); |
1510 | } |
1511 | |
1512 | //===----------------------------------------------------------------------===// |
1513 | // TFGraph Registration |
1514 | //===----------------------------------------------------------------------===// |
1515 | |
1516 | inline void registerTFGraphPasses() { |
1517 | registerAddDefaultAttrs(); |
1518 | registerCSEPass(); |
1519 | registerConsolidateAttributes(); |
1520 | registerConstantFoldingPass(); |
1521 | registerControlFlowSink(); |
1522 | registerDedupeAndHoistConstant(); |
1523 | registerDropOutputShapesAttr(); |
1524 | registerEliminatePassthroughIterArgs(); |
1525 | registerFuncToGraph(); |
1526 | registerFunctionalToRegion(); |
1527 | registerGraphToFunc(); |
1528 | registerLiftLegacyCall(); |
1529 | registerNameCompress(); |
1530 | registerPrepareAttributesForExport(); |
1531 | registerRegionToFunctional(); |
1532 | registerRemapper(); |
1533 | registerShapeInference(); |
1534 | registerStripDefaultAttrs(); |
1535 | registerTopoSort(); |
1536 | } |
1537 | #undef GEN_PASS_REGISTRATION |
1538 | #endif // GEN_PASS_REGISTRATION |
1539 | // Deprecated. Please use the new per-pass macros. |
1540 | #ifdef GEN_PASS_CLASSES |
1541 | |
1542 | template <typename DerivedT> |
1543 | class AddDefaultAttrsBase : public ::mlir::OperationPass<> { |
1544 | public: |
1545 | using Base = AddDefaultAttrsBase; |
1546 | |
1547 | AddDefaultAttrsBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {} |
1548 | AddDefaultAttrsBase(const AddDefaultAttrsBase &other) : ::mlir::OperationPass<>(other) {} |
1549 | |
1550 | /// Returns the command-line argument attached to this pass. |
1551 | static constexpr ::llvm::StringLiteral getArgumentName() { |
1552 | return ::llvm::StringLiteral("tfg-add-default-attrs" ); |
1553 | } |
1554 | ::llvm::StringRef getArgument() const override { return "tfg-add-default-attrs" ; } |
1555 | |
1556 | ::llvm::StringRef getDescription() const override { return "Add default-valued attributes to the graph" ; } |
1557 | |
1558 | /// Returns the derived pass name. |
1559 | static constexpr ::llvm::StringLiteral getPassName() { |
1560 | return ::llvm::StringLiteral("AddDefaultAttrs" ); |
1561 | } |
1562 | ::llvm::StringRef getName() const override { return "AddDefaultAttrs" ; } |
1563 | |
1564 | /// Support isa/dyn_cast functionality for the derived pass class. |
1565 | static bool classof(const ::mlir::Pass *pass) { |
1566 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
1567 | } |
1568 | |
1569 | /// A clone method to create a copy of this pass. |
1570 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
1571 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
1572 | } |
1573 | |
1574 | /// Return the dialect that must be loaded in the context before this pass. |
1575 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
1576 | |
1577 | } |
1578 | |
1579 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
1580 | /// instantiation because Pass classes should only be visible by the current |
1581 | /// library. |
1582 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(AddDefaultAttrsBase<DerivedT>) |
1583 | |
1584 | protected: |
1585 | }; |
1586 | |
1587 | template <typename DerivedT> |
1588 | class CSEPassBase : public ::mlir::OperationPass<GraphFuncOp> { |
1589 | public: |
1590 | using Base = CSEPassBase; |
1591 | |
1592 | CSEPassBase() : ::mlir::OperationPass<GraphFuncOp>(::mlir::TypeID::get<DerivedT>()) {} |
1593 | CSEPassBase(const CSEPassBase &other) : ::mlir::OperationPass<GraphFuncOp>(other) {} |
1594 | |
1595 | /// Returns the command-line argument attached to this pass. |
1596 | static constexpr ::llvm::StringLiteral getArgumentName() { |
1597 | return ::llvm::StringLiteral("tfg-cse" ); |
1598 | } |
1599 | ::llvm::StringRef getArgument() const override { return "tfg-cse" ; } |
1600 | |
1601 | ::llvm::StringRef getDescription() const override { return "Common sub-expression elimination, ignoring op names" ; } |
1602 | |
1603 | /// Returns the derived pass name. |
1604 | static constexpr ::llvm::StringLiteral getPassName() { |
1605 | return ::llvm::StringLiteral("CSEPass" ); |
1606 | } |
1607 | ::llvm::StringRef getName() const override { return "CSEPass" ; } |
1608 | |
1609 | /// Support isa/dyn_cast functionality for the derived pass class. |
1610 | static bool classof(const ::mlir::Pass *pass) { |
1611 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
1612 | } |
1613 | |
1614 | /// A clone method to create a copy of this pass. |
1615 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
1616 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
1617 | } |
1618 | |
1619 | /// Return the dialect that must be loaded in the context before this pass. |
1620 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
1621 | |
1622 | } |
1623 | |
1624 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
1625 | /// instantiation because Pass classes should only be visible by the current |
1626 | /// library. |
1627 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(CSEPassBase<DerivedT>) |
1628 | |
1629 | protected: |
1630 | }; |
1631 | |
1632 | template <typename DerivedT> |
1633 | class ConsolidateAttributesBase : public ::mlir::OperationPass<ModuleOp> { |
1634 | public: |
1635 | using Base = ConsolidateAttributesBase; |
1636 | |
1637 | ConsolidateAttributesBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {} |
1638 | ConsolidateAttributesBase(const ConsolidateAttributesBase &other) : ::mlir::OperationPass<ModuleOp>(other) {} |
1639 | |
1640 | /// Returns the command-line argument attached to this pass. |
1641 | static constexpr ::llvm::StringLiteral getArgumentName() { |
1642 | return ::llvm::StringLiteral("tfg-consolidate-attrs" ); |
1643 | } |
1644 | ::llvm::StringRef getArgument() const override { return "tfg-consolidate-attrs" ; } |
1645 | |
1646 | ::llvm::StringRef getDescription() const override { return "Reify type data from attributes to types." ; } |
1647 | |
1648 | /// Returns the derived pass name. |
1649 | static constexpr ::llvm::StringLiteral getPassName() { |
1650 | return ::llvm::StringLiteral("ConsolidateAttributes" ); |
1651 | } |
1652 | ::llvm::StringRef getName() const override { return "ConsolidateAttributes" ; } |
1653 | |
1654 | /// Support isa/dyn_cast functionality for the derived pass class. |
1655 | static bool classof(const ::mlir::Pass *pass) { |
1656 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
1657 | } |
1658 | |
1659 | /// A clone method to create a copy of this pass. |
1660 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
1661 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
1662 | } |
1663 | |
1664 | /// Return the dialect that must be loaded in the context before this pass. |
1665 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
1666 | |
1667 | } |
1668 | |
1669 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
1670 | /// instantiation because Pass classes should only be visible by the current |
1671 | /// library. |
1672 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ConsolidateAttributesBase<DerivedT>) |
1673 | |
1674 | protected: |
1675 | }; |
1676 | |
1677 | template <typename DerivedT> |
1678 | class ConstantFoldingPassBase : public ::mlir::OperationPass<GraphFuncOp> { |
1679 | public: |
1680 | using Base = ConstantFoldingPassBase; |
1681 | |
1682 | ConstantFoldingPassBase() : ::mlir::OperationPass<GraphFuncOp>(::mlir::TypeID::get<DerivedT>()) {} |
1683 | ConstantFoldingPassBase(const ConstantFoldingPassBase &other) : ::mlir::OperationPass<GraphFuncOp>(other) {} |
1684 | |
1685 | /// Returns the command-line argument attached to this pass. |
1686 | static constexpr ::llvm::StringLiteral getArgumentName() { |
1687 | return ::llvm::StringLiteral("tfg-constant-folding" ); |
1688 | } |
1689 | ::llvm::StringRef getArgument() const override { return "tfg-constant-folding" ; } |
1690 | |
1691 | ::llvm::StringRef getDescription() const override { return "constant-folding on tfg" ; } |
1692 | |
1693 | /// Returns the derived pass name. |
1694 | static constexpr ::llvm::StringLiteral getPassName() { |
1695 | return ::llvm::StringLiteral("ConstantFoldingPass" ); |
1696 | } |
1697 | ::llvm::StringRef getName() const override { return "ConstantFoldingPass" ; } |
1698 | |
1699 | /// Support isa/dyn_cast functionality for the derived pass class. |
1700 | static bool classof(const ::mlir::Pass *pass) { |
1701 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
1702 | } |
1703 | |
1704 | /// A clone method to create a copy of this pass. |
1705 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
1706 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
1707 | } |
1708 | |
1709 | /// Return the dialect that must be loaded in the context before this pass. |
1710 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
1711 | |
1712 | } |
1713 | |
1714 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
1715 | /// instantiation because Pass classes should only be visible by the current |
1716 | /// library. |
1717 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ConstantFoldingPassBase<DerivedT>) |
1718 | |
1719 | protected: |
1720 | ::mlir::Pass::ListOption<std::string> feeds_{*this, "feeds" , ::llvm::cl::desc("Comma separated list of feed ops." ), llvm::cl::ZeroOrMore}; |
1721 | ::mlir::Pass::ListOption<std::string> fetches_{*this, "fetches" , ::llvm::cl::desc("Comma separated list of fetch ops." ), llvm::cl::ZeroOrMore}; |
1722 | ::mlir::Pass::Option<bool> disable_compressed_tensor_optimization_{*this, "disable-compressed-tensor-optimization" , ::llvm::cl::desc("Determine if we should disable compressed tensor optimization" ), ::llvm::cl::init(false)}; |
1723 | ::mlir::Pass::Option<bool> fold_quantization_emulation_{*this, "fold-quantization-emulation" , ::llvm::cl::desc("Determine if we should fold quantization emulation ops" ), ::llvm::cl::init(true)}; |
1724 | ::mlir::Pass::Option<int> pattern_category_{*this, "pattern-category" , ::llvm::cl::desc("Select the pattern kind that we would like to run:0 = all patterns, 1 = folder patterns, 2 = propagation patterns" ), ::llvm::cl::init(0)}; |
1725 | }; |
1726 | |
1727 | template <typename DerivedT> |
1728 | class ControlFlowSinkBase : public ::mlir::OperationPass<GraphFuncOp> { |
1729 | public: |
1730 | using Base = ControlFlowSinkBase; |
1731 | |
1732 | ControlFlowSinkBase() : ::mlir::OperationPass<GraphFuncOp>(::mlir::TypeID::get<DerivedT>()) {} |
1733 | ControlFlowSinkBase(const ControlFlowSinkBase &other) : ::mlir::OperationPass<GraphFuncOp>(other) {} |
1734 | |
1735 | /// Returns the command-line argument attached to this pass. |
1736 | static constexpr ::llvm::StringLiteral getArgumentName() { |
1737 | return ::llvm::StringLiteral("tfg-cf-sink" ); |
1738 | } |
1739 | ::llvm::StringRef getArgument() const override { return "tfg-cf-sink" ; } |
1740 | |
1741 | ::llvm::StringRef getDescription() const override { return "Perform control-flow sink on region-based control-flow ops." ; } |
1742 | |
1743 | /// Returns the derived pass name. |
1744 | static constexpr ::llvm::StringLiteral getPassName() { |
1745 | return ::llvm::StringLiteral("ControlFlowSink" ); |
1746 | } |
1747 | ::llvm::StringRef getName() const override { return "ControlFlowSink" ; } |
1748 | |
1749 | /// Support isa/dyn_cast functionality for the derived pass class. |
1750 | static bool classof(const ::mlir::Pass *pass) { |
1751 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
1752 | } |
1753 | |
1754 | /// A clone method to create a copy of this pass. |
1755 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
1756 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
1757 | } |
1758 | |
1759 | /// Return the dialect that must be loaded in the context before this pass. |
1760 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
1761 | |
1762 | } |
1763 | |
1764 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
1765 | /// instantiation because Pass classes should only be visible by the current |
1766 | /// library. |
1767 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ControlFlowSinkBase<DerivedT>) |
1768 | |
1769 | protected: |
1770 | ::mlir::Pass::Statistic num_sunk{this, "num-sunk" , "Number of operations sunk" }; |
1771 | }; |
1772 | |
1773 | template <typename DerivedT> |
1774 | class DedupeAndHoistConstantBase : public ::mlir::OperationPass<ModuleOp> { |
1775 | public: |
1776 | using Base = DedupeAndHoistConstantBase; |
1777 | |
1778 | DedupeAndHoistConstantBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {} |
1779 | DedupeAndHoistConstantBase(const DedupeAndHoistConstantBase &other) : ::mlir::OperationPass<ModuleOp>(other) {} |
1780 | |
1781 | /// Returns the command-line argument attached to this pass. |
1782 | static constexpr ::llvm::StringLiteral getArgumentName() { |
1783 | return ::llvm::StringLiteral("tfg-dedupe-hoist-constant" ); |
1784 | } |
1785 | ::llvm::StringRef getArgument() const override { return "tfg-dedupe-hoist-constant" ; } |
1786 | |
1787 | ::llvm::StringRef getDescription() const override { return "Dedupe and hoist constants" ; } |
1788 | |
1789 | /// Returns the derived pass name. |
1790 | static constexpr ::llvm::StringLiteral getPassName() { |
1791 | return ::llvm::StringLiteral("DedupeAndHoistConstant" ); |
1792 | } |
1793 | ::llvm::StringRef getName() const override { return "DedupeAndHoistConstant" ; } |
1794 | |
1795 | /// Support isa/dyn_cast functionality for the derived pass class. |
1796 | static bool classof(const ::mlir::Pass *pass) { |
1797 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
1798 | } |
1799 | |
1800 | /// A clone method to create a copy of this pass. |
1801 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
1802 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
1803 | } |
1804 | |
1805 | /// Return the dialect that must be loaded in the context before this pass. |
1806 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
1807 | |
1808 | } |
1809 | |
1810 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
1811 | /// instantiation because Pass classes should only be visible by the current |
1812 | /// library. |
1813 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(DedupeAndHoistConstantBase<DerivedT>) |
1814 | |
1815 | protected: |
1816 | ::mlir::Pass::Option<int64_t> max_size_{*this, "max-size" , ::llvm::cl::desc("The maximum number of elements when considering whether a constant is small" ), ::llvm::cl::init(10)}; |
1817 | ::mlir::Pass::Option<bool> assume_strict_calls_{*this, "assume-strict-calls" , ::llvm::cl::desc("Assume all function calls are stricts, that is operands are evaluated prior to the call" ), ::llvm::cl::init(false)}; |
1818 | }; |
1819 | |
1820 | template <typename DerivedT> |
1821 | class DropOutputShapesAttrBase : public ::mlir::OperationPass<> { |
1822 | public: |
1823 | using Base = DropOutputShapesAttrBase; |
1824 | |
1825 | DropOutputShapesAttrBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {} |
1826 | DropOutputShapesAttrBase(const DropOutputShapesAttrBase &other) : ::mlir::OperationPass<>(other) {} |
1827 | |
1828 | /// Returns the command-line argument attached to this pass. |
1829 | static constexpr ::llvm::StringLiteral getArgumentName() { |
1830 | return ::llvm::StringLiteral("tfg-drop-unregistered-output-shapes" ); |
1831 | } |
1832 | ::llvm::StringRef getArgument() const override { return "tfg-drop-unregistered-output-shapes" ; } |
1833 | |
1834 | ::llvm::StringRef getDescription() const override { return "Drop _output_shapes attribute" ; } |
1835 | |
1836 | /// Returns the derived pass name. |
1837 | static constexpr ::llvm::StringLiteral getPassName() { |
1838 | return ::llvm::StringLiteral("DropOutputShapesAttr" ); |
1839 | } |
1840 | ::llvm::StringRef getName() const override { return "DropOutputShapesAttr" ; } |
1841 | |
1842 | /// Support isa/dyn_cast functionality for the derived pass class. |
1843 | static bool classof(const ::mlir::Pass *pass) { |
1844 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
1845 | } |
1846 | |
1847 | /// A clone method to create a copy of this pass. |
1848 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
1849 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
1850 | } |
1851 | |
1852 | /// Return the dialect that must be loaded in the context before this pass. |
1853 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
1854 | |
1855 | } |
1856 | |
1857 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
1858 | /// instantiation because Pass classes should only be visible by the current |
1859 | /// library. |
1860 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(DropOutputShapesAttrBase<DerivedT>) |
1861 | |
1862 | protected: |
1863 | ::mlir::Pass::ListOption<std::string> skip_{*this, "skip" , ::llvm::cl::desc("Comma separated list of ops that will be skipped." )}; |
1864 | }; |
1865 | |
1866 | template <typename DerivedT> |
1867 | class EliminatePassthroughIterArgsBase : public ::mlir::OperationPass<ModuleOp> { |
1868 | public: |
1869 | using Base = EliminatePassthroughIterArgsBase; |
1870 | |
1871 | EliminatePassthroughIterArgsBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {} |
1872 | EliminatePassthroughIterArgsBase(const EliminatePassthroughIterArgsBase &other) : ::mlir::OperationPass<ModuleOp>(other) {} |
1873 | |
1874 | /// Returns the command-line argument attached to this pass. |
1875 | static constexpr ::llvm::StringLiteral getArgumentName() { |
1876 | return ::llvm::StringLiteral("tfg-eliminate-passthrough-iter-args" ); |
1877 | } |
1878 | ::llvm::StringRef getArgument() const override { return "tfg-eliminate-passthrough-iter-args" ; } |
1879 | |
1880 | ::llvm::StringRef getDescription() const override { return "Eliminate passthrough loop iteration arguments." ; } |
1881 | |
1882 | /// Returns the derived pass name. |
1883 | static constexpr ::llvm::StringLiteral getPassName() { |
1884 | return ::llvm::StringLiteral("EliminatePassthroughIterArgs" ); |
1885 | } |
1886 | ::llvm::StringRef getName() const override { return "EliminatePassthroughIterArgs" ; } |
1887 | |
1888 | /// Support isa/dyn_cast functionality for the derived pass class. |
1889 | static bool classof(const ::mlir::Pass *pass) { |
1890 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
1891 | } |
1892 | |
1893 | /// A clone method to create a copy of this pass. |
1894 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
1895 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
1896 | } |
1897 | |
1898 | /// Return the dialect that must be loaded in the context before this pass. |
1899 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
1900 | |
1901 | registry.insert<tfg::TFGraphDialect>(); |
1902 | |
1903 | } |
1904 | |
1905 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
1906 | /// instantiation because Pass classes should only be visible by the current |
1907 | /// library. |
1908 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(EliminatePassthroughIterArgsBase<DerivedT>) |
1909 | |
1910 | protected: |
1911 | }; |
1912 | |
1913 | template <typename DerivedT> |
1914 | class FuncToGraphBase : public ::mlir::OperationPass<ModuleOp> { |
1915 | public: |
1916 | using Base = FuncToGraphBase; |
1917 | |
1918 | FuncToGraphBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {} |
1919 | FuncToGraphBase(const FuncToGraphBase &other) : ::mlir::OperationPass<ModuleOp>(other) {} |
1920 | |
1921 | /// Returns the command-line argument attached to this pass. |
1922 | static constexpr ::llvm::StringLiteral getArgumentName() { |
1923 | return ::llvm::StringLiteral("tfg-lower-func-to-graph" ); |
1924 | } |
1925 | ::llvm::StringRef getArgument() const override { return "tfg-lower-func-to-graph" ; } |
1926 | |
1927 | ::llvm::StringRef getDescription() const override { return "Turns a function back to a graph" ; } |
1928 | |
1929 | /// Returns the derived pass name. |
1930 | static constexpr ::llvm::StringLiteral getPassName() { |
1931 | return ::llvm::StringLiteral("FuncToGraph" ); |
1932 | } |
1933 | ::llvm::StringRef getName() const override { return "FuncToGraph" ; } |
1934 | |
1935 | /// Support isa/dyn_cast functionality for the derived pass class. |
1936 | static bool classof(const ::mlir::Pass *pass) { |
1937 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
1938 | } |
1939 | |
1940 | /// A clone method to create a copy of this pass. |
1941 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
1942 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
1943 | } |
1944 | |
1945 | /// Return the dialect that must be loaded in the context before this pass. |
1946 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
1947 | |
1948 | } |
1949 | |
1950 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
1951 | /// instantiation because Pass classes should only be visible by the current |
1952 | /// library. |
1953 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(FuncToGraphBase<DerivedT>) |
1954 | |
1955 | protected: |
1956 | }; |
1957 | |
1958 | template <typename DerivedT> |
1959 | class FunctionalToRegionBase : public ::mlir::OperationPass<ModuleOp> { |
1960 | public: |
1961 | using Base = FunctionalToRegionBase; |
1962 | |
1963 | FunctionalToRegionBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {} |
1964 | FunctionalToRegionBase(const FunctionalToRegionBase &other) : ::mlir::OperationPass<ModuleOp>(other) {} |
1965 | |
1966 | /// Returns the command-line argument attached to this pass. |
1967 | static constexpr ::llvm::StringLiteral getArgumentName() { |
1968 | return ::llvm::StringLiteral("tfg-functional-to-region" ); |
1969 | } |
1970 | ::llvm::StringRef getArgument() const override { return "tfg-functional-to-region" ; } |
1971 | |
1972 | ::llvm::StringRef getDescription() const override { return "Convert functional control-flow ops to region-based." ; } |
1973 | |
1974 | /// Returns the derived pass name. |
1975 | static constexpr ::llvm::StringLiteral getPassName() { |
1976 | return ::llvm::StringLiteral("FunctionalToRegion" ); |
1977 | } |
1978 | ::llvm::StringRef getName() const override { return "FunctionalToRegion" ; } |
1979 | |
1980 | /// Support isa/dyn_cast functionality for the derived pass class. |
1981 | static bool classof(const ::mlir::Pass *pass) { |
1982 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
1983 | } |
1984 | |
1985 | /// A clone method to create a copy of this pass. |
1986 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
1987 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
1988 | } |
1989 | |
1990 | /// Return the dialect that must be loaded in the context before this pass. |
1991 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
1992 | |
1993 | registry.insert<tfg::TFGraphDialect>(); |
1994 | |
1995 | } |
1996 | |
1997 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
1998 | /// instantiation because Pass classes should only be visible by the current |
1999 | /// library. |
2000 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(FunctionalToRegionBase<DerivedT>) |
2001 | |
2002 | protected: |
2003 | }; |
2004 | |
2005 | template <typename DerivedT> |
2006 | class GraphToFuncBase : public ::mlir::OperationPass<ModuleOp> { |
2007 | public: |
2008 | using Base = GraphToFuncBase; |
2009 | |
2010 | GraphToFuncBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {} |
2011 | GraphToFuncBase(const GraphToFuncBase &other) : ::mlir::OperationPass<ModuleOp>(other) {} |
2012 | |
2013 | /// Returns the command-line argument attached to this pass. |
2014 | static constexpr ::llvm::StringLiteral getArgumentName() { |
2015 | return ::llvm::StringLiteral("tfg-lift-graph-to-func" ); |
2016 | } |
2017 | ::llvm::StringRef getArgument() const override { return "tfg-lift-graph-to-func" ; } |
2018 | |
2019 | ::llvm::StringRef getDescription() const override { return "Turns a graph into a function." ; } |
2020 | |
2021 | /// Returns the derived pass name. |
2022 | static constexpr ::llvm::StringLiteral getPassName() { |
2023 | return ::llvm::StringLiteral("GraphToFunc" ); |
2024 | } |
2025 | ::llvm::StringRef getName() const override { return "GraphToFunc" ; } |
2026 | |
2027 | /// Support isa/dyn_cast functionality for the derived pass class. |
2028 | static bool classof(const ::mlir::Pass *pass) { |
2029 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
2030 | } |
2031 | |
2032 | /// A clone method to create a copy of this pass. |
2033 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
2034 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
2035 | } |
2036 | |
2037 | /// Return the dialect that must be loaded in the context before this pass. |
2038 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
2039 | |
2040 | } |
2041 | |
2042 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
2043 | /// instantiation because Pass classes should only be visible by the current |
2044 | /// library. |
2045 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(GraphToFuncBase<DerivedT>) |
2046 | |
2047 | protected: |
2048 | ::mlir::Pass::ListOption<std::string> feeds_{*this, "feeds" , ::llvm::cl::desc("Comma separated list of ops that will be turned into arguments." )}; |
2049 | ::mlir::Pass::ListOption<std::string> fetches_{*this, "fetches" , ::llvm::cl::desc("Comma separated list of ops that will be turned into results." )}; |
2050 | ::mlir::Pass::ListOption<std::string> control_rets_{*this, "control_rets" , ::llvm::cl::desc("Comma separated list of ops that will be turned into control returned." )}; |
2051 | }; |
2052 | |
2053 | template <typename DerivedT> |
2054 | class LiftLegacyCallBase : public ::mlir::OperationPass<ModuleOp> { |
2055 | public: |
2056 | using Base = LiftLegacyCallBase; |
2057 | |
2058 | LiftLegacyCallBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {} |
2059 | LiftLegacyCallBase(const LiftLegacyCallBase &other) : ::mlir::OperationPass<ModuleOp>(other) {} |
2060 | |
2061 | /// Returns the command-line argument attached to this pass. |
2062 | static constexpr ::llvm::StringLiteral getArgumentName() { |
2063 | return ::llvm::StringLiteral("tfg-lift-legacy-call" ); |
2064 | } |
2065 | ::llvm::StringRef getArgument() const override { return "tfg-lift-legacy-call" ; } |
2066 | |
2067 | ::llvm::StringRef getDescription() const override { return "Tag legacy calls with symbol references to add symbol uses" ; } |
2068 | |
2069 | /// Returns the derived pass name. |
2070 | static constexpr ::llvm::StringLiteral getPassName() { |
2071 | return ::llvm::StringLiteral("LiftLegacyCall" ); |
2072 | } |
2073 | ::llvm::StringRef getName() const override { return "LiftLegacyCall" ; } |
2074 | |
2075 | /// Support isa/dyn_cast functionality for the derived pass class. |
2076 | static bool classof(const ::mlir::Pass *pass) { |
2077 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
2078 | } |
2079 | |
2080 | /// A clone method to create a copy of this pass. |
2081 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
2082 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
2083 | } |
2084 | |
2085 | /// Return the dialect that must be loaded in the context before this pass. |
2086 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
2087 | |
2088 | } |
2089 | |
2090 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
2091 | /// instantiation because Pass classes should only be visible by the current |
2092 | /// library. |
2093 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(LiftLegacyCallBase<DerivedT>) |
2094 | |
2095 | protected: |
2096 | }; |
2097 | |
2098 | template <typename DerivedT> |
2099 | class NameCompressBase : public ::mlir::OperationPass<GraphFuncOp> { |
2100 | public: |
2101 | using Base = NameCompressBase; |
2102 | |
2103 | NameCompressBase() : ::mlir::OperationPass<GraphFuncOp>(::mlir::TypeID::get<DerivedT>()) {} |
2104 | NameCompressBase(const NameCompressBase &other) : ::mlir::OperationPass<GraphFuncOp>(other) {} |
2105 | |
2106 | /// Returns the command-line argument attached to this pass. |
2107 | static constexpr ::llvm::StringLiteral getArgumentName() { |
2108 | return ::llvm::StringLiteral("tfg-name-compress" ); |
2109 | } |
2110 | ::llvm::StringRef getArgument() const override { return "tfg-name-compress" ; } |
2111 | |
2112 | ::llvm::StringRef getDescription() const override { return "Compress the graph by shortening names" ; } |
2113 | |
2114 | /// Returns the derived pass name. |
2115 | static constexpr ::llvm::StringLiteral getPassName() { |
2116 | return ::llvm::StringLiteral("NameCompress" ); |
2117 | } |
2118 | ::llvm::StringRef getName() const override { return "NameCompress" ; } |
2119 | |
2120 | /// Support isa/dyn_cast functionality for the derived pass class. |
2121 | static bool classof(const ::mlir::Pass *pass) { |
2122 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
2123 | } |
2124 | |
2125 | /// A clone method to create a copy of this pass. |
2126 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
2127 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
2128 | } |
2129 | |
2130 | /// Return the dialect that must be loaded in the context before this pass. |
2131 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
2132 | |
2133 | } |
2134 | |
2135 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
2136 | /// instantiation because Pass classes should only be visible by the current |
2137 | /// library. |
2138 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(NameCompressBase<DerivedT>) |
2139 | |
2140 | protected: |
2141 | }; |
2142 | |
2143 | template <typename DerivedT> |
2144 | class PrepareAttributesForExportBase : public ::mlir::OperationPass<ModuleOp> { |
2145 | public: |
2146 | using Base = PrepareAttributesForExportBase; |
2147 | |
2148 | PrepareAttributesForExportBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {} |
2149 | PrepareAttributesForExportBase(const PrepareAttributesForExportBase &other) : ::mlir::OperationPass<ModuleOp>(other) {} |
2150 | |
2151 | /// Returns the command-line argument attached to this pass. |
2152 | static constexpr ::llvm::StringLiteral getArgumentName() { |
2153 | return ::llvm::StringLiteral("tfg-prepare-attrs-export" ); |
2154 | } |
2155 | ::llvm::StringRef getArgument() const override { return "tfg-prepare-attrs-export" ; } |
2156 | |
2157 | ::llvm::StringRef getDescription() const override { return "Legalize ops' attributes for export." ; } |
2158 | |
2159 | /// Returns the derived pass name. |
2160 | static constexpr ::llvm::StringLiteral getPassName() { |
2161 | return ::llvm::StringLiteral("PrepareAttributesForExport" ); |
2162 | } |
2163 | ::llvm::StringRef getName() const override { return "PrepareAttributesForExport" ; } |
2164 | |
2165 | /// Support isa/dyn_cast functionality for the derived pass class. |
2166 | static bool classof(const ::mlir::Pass *pass) { |
2167 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
2168 | } |
2169 | |
2170 | /// A clone method to create a copy of this pass. |
2171 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
2172 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
2173 | } |
2174 | |
2175 | /// Return the dialect that must be loaded in the context before this pass. |
2176 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
2177 | |
2178 | } |
2179 | |
2180 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
2181 | /// instantiation because Pass classes should only be visible by the current |
2182 | /// library. |
2183 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(PrepareAttributesForExportBase<DerivedT>) |
2184 | |
2185 | protected: |
2186 | }; |
2187 | |
2188 | template <typename DerivedT> |
2189 | class RegionToFunctionalBase : public ::mlir::OperationPass<ModuleOp> { |
2190 | public: |
2191 | using Base = RegionToFunctionalBase; |
2192 | |
2193 | RegionToFunctionalBase() : ::mlir::OperationPass<ModuleOp>(::mlir::TypeID::get<DerivedT>()) {} |
2194 | RegionToFunctionalBase(const RegionToFunctionalBase &other) : ::mlir::OperationPass<ModuleOp>(other) {} |
2195 | |
2196 | /// Returns the command-line argument attached to this pass. |
2197 | static constexpr ::llvm::StringLiteral getArgumentName() { |
2198 | return ::llvm::StringLiteral("tfg-region-to-functional" ); |
2199 | } |
2200 | ::llvm::StringRef getArgument() const override { return "tfg-region-to-functional" ; } |
2201 | |
2202 | ::llvm::StringRef getDescription() const override { return "Convert region-based control-flow ops to functional." ; } |
2203 | |
2204 | /// Returns the derived pass name. |
2205 | static constexpr ::llvm::StringLiteral getPassName() { |
2206 | return ::llvm::StringLiteral("RegionToFunctional" ); |
2207 | } |
2208 | ::llvm::StringRef getName() const override { return "RegionToFunctional" ; } |
2209 | |
2210 | /// Support isa/dyn_cast functionality for the derived pass class. |
2211 | static bool classof(const ::mlir::Pass *pass) { |
2212 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
2213 | } |
2214 | |
2215 | /// A clone method to create a copy of this pass. |
2216 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
2217 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
2218 | } |
2219 | |
2220 | /// Return the dialect that must be loaded in the context before this pass. |
2221 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
2222 | |
2223 | registry.insert<tfg::TFGraphDialect>(); |
2224 | |
2225 | } |
2226 | |
2227 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
2228 | /// instantiation because Pass classes should only be visible by the current |
2229 | /// library. |
2230 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(RegionToFunctionalBase<DerivedT>) |
2231 | |
2232 | protected: |
2233 | ::mlir::Pass::Option<bool> force_control_capture{*this, "force-control-capture" , ::llvm::cl::desc("Force the capture of control tokens by inserting chain `Const` ops" ), ::llvm::cl::init(false)}; |
2234 | }; |
2235 | |
2236 | template <typename DerivedT> |
2237 | class RemapperBase : public ::mlir::OperationPass<> { |
2238 | public: |
2239 | using Base = RemapperBase; |
2240 | |
2241 | RemapperBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {} |
2242 | RemapperBase(const RemapperBase &other) : ::mlir::OperationPass<>(other) {} |
2243 | |
2244 | /// Returns the command-line argument attached to this pass. |
2245 | static constexpr ::llvm::StringLiteral getArgumentName() { |
2246 | return ::llvm::StringLiteral("tfg-remapper" ); |
2247 | } |
2248 | ::llvm::StringRef getArgument() const override { return "tfg-remapper" ; } |
2249 | |
2250 | ::llvm::StringRef getDescription() const override { return "Remap operations to decrease amount of operations" ; } |
2251 | |
2252 | /// Returns the derived pass name. |
2253 | static constexpr ::llvm::StringLiteral getPassName() { |
2254 | return ::llvm::StringLiteral("Remapper" ); |
2255 | } |
2256 | ::llvm::StringRef getName() const override { return "Remapper" ; } |
2257 | |
2258 | /// Support isa/dyn_cast functionality for the derived pass class. |
2259 | static bool classof(const ::mlir::Pass *pass) { |
2260 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
2261 | } |
2262 | |
2263 | /// A clone method to create a copy of this pass. |
2264 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
2265 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
2266 | } |
2267 | |
2268 | /// Return the dialect that must be loaded in the context before this pass. |
2269 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
2270 | |
2271 | } |
2272 | |
2273 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
2274 | /// instantiation because Pass classes should only be visible by the current |
2275 | /// library. |
2276 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(RemapperBase<DerivedT>) |
2277 | |
2278 | protected: |
2279 | ::mlir::Pass::Option<bool> enable_onednn_patterns_{*this, "enable-onednn-patterns" , ::llvm::cl::desc("Enable the oneDNN related patterns." ), ::llvm::cl::init(false)}; |
2280 | ::mlir::Pass::Option<bool> verify_pdll_patterns_only_{*this, "verify-pdll-patterns-only" , ::llvm::cl::desc("Only enable PDLL patterns." ), ::llvm::cl::init(false)}; |
2281 | ::mlir::Pass::Option<bool> xla_auto_clustering_{*this, "xla-auto-clustering" , ::llvm::cl::desc("Sets XLA auto clustering flag." ), ::llvm::cl::init(false)}; |
2282 | }; |
2283 | |
2284 | template <typename DerivedT> |
2285 | class ShapeInferenceBase : public ::mlir::OperationPass<> { |
2286 | public: |
2287 | using Base = ShapeInferenceBase; |
2288 | |
2289 | ShapeInferenceBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {} |
2290 | ShapeInferenceBase(const ShapeInferenceBase &other) : ::mlir::OperationPass<>(other) {} |
2291 | |
2292 | /// Returns the command-line argument attached to this pass. |
2293 | static constexpr ::llvm::StringLiteral getArgumentName() { |
2294 | return ::llvm::StringLiteral("tfg-shape-inference" ); |
2295 | } |
2296 | ::llvm::StringRef getArgument() const override { return "tfg-shape-inference" ; } |
2297 | |
2298 | ::llvm::StringRef getDescription() const override { return "Infer the output shape of operations" ; } |
2299 | |
2300 | /// Returns the derived pass name. |
2301 | static constexpr ::llvm::StringLiteral getPassName() { |
2302 | return ::llvm::StringLiteral("ShapeInference" ); |
2303 | } |
2304 | ::llvm::StringRef getName() const override { return "ShapeInference" ; } |
2305 | |
2306 | /// Support isa/dyn_cast functionality for the derived pass class. |
2307 | static bool classof(const ::mlir::Pass *pass) { |
2308 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
2309 | } |
2310 | |
2311 | /// A clone method to create a copy of this pass. |
2312 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
2313 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
2314 | } |
2315 | |
2316 | /// Return the dialect that must be loaded in the context before this pass. |
2317 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
2318 | |
2319 | } |
2320 | |
2321 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
2322 | /// instantiation because Pass classes should only be visible by the current |
2323 | /// library. |
2324 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ShapeInferenceBase<DerivedT>) |
2325 | |
2326 | protected: |
2327 | ::mlir::Pass::Option<int> graph_version_{*this, "graph-version" , ::llvm::cl::desc("The graph producer version" )}; |
2328 | }; |
2329 | |
2330 | template <typename DerivedT> |
2331 | class StripDefaultAttrsBase : public ::mlir::OperationPass<> { |
2332 | public: |
2333 | using Base = StripDefaultAttrsBase; |
2334 | |
2335 | StripDefaultAttrsBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {} |
2336 | StripDefaultAttrsBase(const StripDefaultAttrsBase &other) : ::mlir::OperationPass<>(other) {} |
2337 | |
2338 | /// Returns the command-line argument attached to this pass. |
2339 | static constexpr ::llvm::StringLiteral getArgumentName() { |
2340 | return ::llvm::StringLiteral("tfg-strip-default-attrs" ); |
2341 | } |
2342 | ::llvm::StringRef getArgument() const override { return "tfg-strip-default-attrs" ; } |
2343 | |
2344 | ::llvm::StringRef getDescription() const override { return "Removes default-valued attributes from the graph" ; } |
2345 | |
2346 | /// Returns the derived pass name. |
2347 | static constexpr ::llvm::StringLiteral getPassName() { |
2348 | return ::llvm::StringLiteral("StripDefaultAttrs" ); |
2349 | } |
2350 | ::llvm::StringRef getName() const override { return "StripDefaultAttrs" ; } |
2351 | |
2352 | /// Support isa/dyn_cast functionality for the derived pass class. |
2353 | static bool classof(const ::mlir::Pass *pass) { |
2354 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
2355 | } |
2356 | |
2357 | /// A clone method to create a copy of this pass. |
2358 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
2359 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
2360 | } |
2361 | |
2362 | /// Return the dialect that must be loaded in the context before this pass. |
2363 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
2364 | |
2365 | } |
2366 | |
2367 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
2368 | /// instantiation because Pass classes should only be visible by the current |
2369 | /// library. |
2370 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(StripDefaultAttrsBase<DerivedT>) |
2371 | |
2372 | protected: |
2373 | }; |
2374 | |
2375 | template <typename DerivedT> |
2376 | class TopoSortBase : public ::mlir::OperationPass<> { |
2377 | public: |
2378 | using Base = TopoSortBase; |
2379 | |
2380 | TopoSortBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {} |
2381 | TopoSortBase(const TopoSortBase &other) : ::mlir::OperationPass<>(other) {} |
2382 | |
2383 | /// Returns the command-line argument attached to this pass. |
2384 | static constexpr ::llvm::StringLiteral getArgumentName() { |
2385 | return ::llvm::StringLiteral("tfg-toposort" ); |
2386 | } |
2387 | ::llvm::StringRef getArgument() const override { return "tfg-toposort" ; } |
2388 | |
2389 | ::llvm::StringRef getDescription() const override { return "Topologically sort graph and function regions" ; } |
2390 | |
2391 | /// Returns the derived pass name. |
2392 | static constexpr ::llvm::StringLiteral getPassName() { |
2393 | return ::llvm::StringLiteral("TopoSort" ); |
2394 | } |
2395 | ::llvm::StringRef getName() const override { return "TopoSort" ; } |
2396 | |
2397 | /// Support isa/dyn_cast functionality for the derived pass class. |
2398 | static bool classof(const ::mlir::Pass *pass) { |
2399 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
2400 | } |
2401 | |
2402 | /// A clone method to create a copy of this pass. |
2403 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
2404 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
2405 | } |
2406 | |
2407 | /// Return the dialect that must be loaded in the context before this pass. |
2408 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
2409 | |
2410 | } |
2411 | |
2412 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
2413 | /// instantiation because Pass classes should only be visible by the current |
2414 | /// library. |
2415 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TopoSortBase<DerivedT>) |
2416 | |
2417 | protected: |
2418 | }; |
2419 | #undef GEN_PASS_CLASSES |
2420 | #endif // GEN_PASS_CLASSES |
2421 | |