File tree Expand file tree Collapse file tree 3 files changed +17
-3
lines changed
mlir/mhlo-pass-example/Pow2 Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,9 @@ int main(int argc, char *argv[]) {
94
94
if (mlir::failed (mlir::applyPassManagerCLOptions (pm)))
95
95
return 4 ;
96
96
97
+ // Enable the statistics (only works on debug mode)
98
+ // pm.enableStatistics();
99
+
97
100
// Add a run of the canonicalizer to optimize the mlir module.
98
101
// pm.addNestedPass<mlir::func::FuncOp>(mlir::createCanonicalizerPass());
99
102
pm.addNestedPass <mlir::func::FuncOp>(
Original file line number Diff line number Diff line change @@ -89,6 +89,15 @@ namespace {
89
89
struct SubstitutePow2Pass
90
90
: public PassWrapper<SubstitutePow2Pass, OperationPass<func::FuncOp>> {
91
91
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID (SubstitutePow2Pass)
92
+ // Here we can add the statistic (the statistic is only works on debug mode)
93
+ // Since the statistic has the atomic value, we can't use the default copy
94
+ // constructor and assignment operator.
95
+ // SubstitutePow2Pass() = default;
96
+ // SubstitutePow2Pass(const SubstitutePow2Pass &other) {
97
+ // this->statistic = other.statistic.getValue();
98
+ // };
99
+ // mlir::Pass::Statistic statistic{this, "example-statistic", "An example
100
+ // statistic"};
92
101
93
102
void runOnOperation () final ;
94
103
};
@@ -100,6 +109,8 @@ void SubstitutePow2Pass::runOnOperation() {
100
109
patterns.add <Pow2OptPattern>(&getContext ());
101
110
if (failed (applyPatternsAndFoldGreedily (op, std::move (patterns))))
102
111
signalPassFailure ();
112
+ // Here we can add the statistic (the statistic is only works on debug mode)
113
+ // statistic++;
103
114
}
104
115
105
116
namespace {
Original file line number Diff line number Diff line change @@ -20,8 +20,8 @@ def Pow2Pass : Pass<"pow-2", "func::FuncOp"> {
20
20
21
21
// Specify any statistics.
22
22
let statistics = [
23
- // Statistic</*C++ variable name=*/"statistic",
24
- // /*display name*/"example-statistic",
25
- // /*description*/"An example statistic">
23
+ Statistic</*C++ variable name=*/"statistic",
24
+ /*display name*/"example-statistic",
25
+ /*description*/"An example statistic">
26
26
];
27
27
}
You can’t perform that action at this time.
0 commit comments