[mlir] add createPrintOpStatsPass() with explicit params
authorOkwan Kwon <okwan@google.com>
Wed, 15 Jun 2022 18:48:57 +0000 (11:48 -0700)
committerOkwan Kwon <okwan@google.com>
Wed, 15 Jun 2022 19:09:59 +0000 (12:09 -0700)
This allows to set printAsJSON through the create function.

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

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

index 49a6442..16862ae 100644 (file)
@@ -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();
index e7740ab..0ee49e3 100644 (file)
@@ -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);
+}