[Mlir-commits] [mlir] 85f19f9 - [mlir] add createPrintOpStatsPass() with explicit params

Okwan Kwon llvmlistbot at llvm.org
Wed Jun 15 12:10:10 PDT 2022


Author: Okwan Kwon
Date: 2022-06-15T12:09:59-07:00
New Revision: 85f19f99e4796c5e052dd6e6d3d0551b7f4a5723

URL: https://github.com/llvm/llvm-project/commit/85f19f99e4796c5e052dd6e6d3d0551b7f4a5723
DIFF: https://github.com/llvm/llvm-project/commit/85f19f99e4796c5e052dd6e6d3d0551b7f4a5723.diff

LOG: [mlir] add createPrintOpStatsPass() with explicit params

This allows to set printAsJSON through the create function.

Differential Revision: https://reviews.llvm.org/D127891

Added: 
    

Modified: 
    mlir/include/mlir/Transforms/Passes.h
    mlir/lib/Transforms/OpStats.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Transforms/Passes.h b/mlir/include/mlir/Transforms/Passes.h
index 49a6442a79d90..16862ae4fe586 100644
--- a/mlir/include/mlir/Transforms/Passes.h
+++ b/mlir/include/mlir/Transforms/Passes.h
@@ -62,6 +62,10 @@ std::unique_ptr<Pass> createStripDebugInfoPass();
 /// the module.
 std::unique_ptr<Pass> createPrintOpStatsPass(raw_ostream &os = llvm::errs());
 
+/// Creates a pass which prints the list of ops and the number of occurrences in
+/// the module with the output format option.
+std::unique_ptr<Pass> createPrintOpStatsPass(raw_ostream &os, bool printAsJSON);
+
 /// Creates a pass which inlines calls and callable operations as defined by
 /// the CallGraph.
 std::unique_ptr<Pass> createInlinerPass();

diff  --git a/mlir/lib/Transforms/OpStats.cpp b/mlir/lib/Transforms/OpStats.cpp
index e7740abb3d19f..0ee49e371b8dd 100644
--- a/mlir/lib/Transforms/OpStats.cpp
+++ b/mlir/lib/Transforms/OpStats.cpp
@@ -21,6 +21,10 @@ namespace {
 struct PrintOpStatsPass : public PrintOpStatsBase<PrintOpStatsPass> {
   explicit PrintOpStatsPass(raw_ostream &os) : os(os) {}
 
+  explicit PrintOpStatsPass(raw_ostream &os, bool printAsJSON) : os(os) {
+    this->printAsJSON = printAsJSON;
+  }
+
   // Prints the resultant operation statistics post iterating over the module.
   void runOnOperation() override;
 
@@ -107,3 +111,8 @@ void PrintOpStatsPass::printSummaryInJSON() {
 std::unique_ptr<Pass> mlir::createPrintOpStatsPass(raw_ostream &os) {
   return std::make_unique<PrintOpStatsPass>(os);
 }
+
+std::unique_ptr<Pass> mlir::createPrintOpStatsPass(raw_ostream &os,
+                                                   bool printAsJSON) {
+  return std::make_unique<PrintOpStatsPass>(os);
+}


        


More information about the Mlir-commits mailing list