forked from OSchip/llvm-project
Revert "[mlir] add an option to print op stats in JSON"
There is a failure from the python pass manager.
This reverts commit 1a19abf38c
.
This commit is contained in:
parent
c67c4133ac
commit
28331c6097
|
@ -145,10 +145,6 @@ def LoopInvariantCodeMotion : Pass<"loop-invariant-code-motion"> {
|
|||
def PrintOpStats : Pass<"print-op-stats"> {
|
||||
let summary = "Print statistics of operations";
|
||||
let constructor = "mlir::createPrintOpStatsPass()";
|
||||
let options = [
|
||||
Option<"printAsJSON", "json", "bool", /*default=*/"false",
|
||||
"print the stats as JSON">
|
||||
];
|
||||
}
|
||||
|
||||
def SCCP : Pass<"sccp"> {
|
||||
|
|
|
@ -27,9 +27,6 @@ struct PrintOpStatsPass : public PrintOpStatsBase<PrintOpStatsPass> {
|
|||
// Print summary of op stats.
|
||||
void printSummary();
|
||||
|
||||
// Print symmary of op stats in JSON.
|
||||
void printSummaryInJSON();
|
||||
|
||||
private:
|
||||
llvm::StringMap<int64_t> opCount;
|
||||
raw_ostream &os;
|
||||
|
@ -40,12 +37,8 @@ void PrintOpStatsPass::runOnOperation() {
|
|||
opCount.clear();
|
||||
|
||||
// Compute the operation statistics for the currently visited operation.
|
||||
getOperation()->walk(
|
||||
[&](Operation *op) { ++opCount[op->getName().getStringRef()]; });
|
||||
if (printAsJSON) {
|
||||
printSummaryInJSON();
|
||||
} else
|
||||
printSummary();
|
||||
getOperation()->walk([&](Operation *op) { ++opCount[op->getName().getStringRef()]; });
|
||||
printSummary();
|
||||
}
|
||||
|
||||
void PrintOpStatsPass::printSummary() {
|
||||
|
@ -87,23 +80,6 @@ void PrintOpStatsPass::printSummary() {
|
|||
}
|
||||
}
|
||||
|
||||
void PrintOpStatsPass::printSummaryInJSON() {
|
||||
SmallVector<StringRef, 64> sorted(opCount.keys());
|
||||
llvm::sort(sorted);
|
||||
|
||||
os << "{\n";
|
||||
|
||||
for (unsigned i = 0, e = sorted.size(); i != e; ++i) {
|
||||
const auto &key = sorted[i];
|
||||
os << " \"" << key << "\" : " << opCount[key];
|
||||
if (i != e - 1)
|
||||
os << ",\n";
|
||||
else
|
||||
os << "\n";
|
||||
}
|
||||
os << "}\n";
|
||||
}
|
||||
|
||||
std::unique_ptr<Pass> mlir::createPrintOpStatsPass(raw_ostream &os) {
|
||||
return std::make_unique<PrintOpStatsPass>(os);
|
||||
}
|
||||
|
|
|
@ -138,14 +138,14 @@ void testPrintPassPipeline() {
|
|||
mlirOpPassManagerAddOwnedPass(nestedFuncPm, printOpStatPass);
|
||||
|
||||
// Print the top level pass manager
|
||||
// CHECK: Top-level: builtin.module(func.func(print-op-stats{json=false}))
|
||||
// CHECK: Top-level: builtin.module(func.func(print-op-stats))
|
||||
fprintf(stderr, "Top-level: ");
|
||||
mlirPrintPassPipeline(mlirPassManagerGetAsOpPassManager(pm), printToStderr,
|
||||
NULL);
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
// Print the pipeline nested one level down
|
||||
// CHECK: Nested Module: func.func(print-op-stats{json=false})
|
||||
// CHECK: Nested Module: func.func(print-op-stats)
|
||||
fprintf(stderr, "Nested Module: ");
|
||||
mlirPrintPassPipeline(nestedModulePm, printToStderr, NULL);
|
||||
fprintf(stderr, "\n");
|
||||
|
@ -166,9 +166,8 @@ void testParsePassPipeline() {
|
|||
// Try parse a pipeline.
|
||||
MlirLogicalResult status = mlirParsePassPipeline(
|
||||
mlirPassManagerGetAsOpPassManager(pm),
|
||||
mlirStringRefCreateFromCString(
|
||||
"builtin.module(func.func(print-op-stats{json=false}),"
|
||||
" func.func(print-op-stats{json=false}))"));
|
||||
mlirStringRefCreateFromCString("builtin.module(func.func(print-op-stats),"
|
||||
" func.func(print-op-stats))"));
|
||||
// Expect a failure, we haven't registered the print-op-stats pass yet.
|
||||
if (mlirLogicalResultIsSuccess(status)) {
|
||||
fprintf(
|
||||
|
@ -180,9 +179,8 @@ void testParsePassPipeline() {
|
|||
mlirRegisterTransformsPrintOpStats();
|
||||
status = mlirParsePassPipeline(
|
||||
mlirPassManagerGetAsOpPassManager(pm),
|
||||
mlirStringRefCreateFromCString(
|
||||
"builtin.module(func.func(print-op-stats{json=false}),"
|
||||
" func.func(print-op-stats{json=false}))"));
|
||||
mlirStringRefCreateFromCString("builtin.module(func.func(print-op-stats),"
|
||||
" func.func(print-op-stats))"));
|
||||
// Expect a failure, we haven't registered the print-op-stats pass yet.
|
||||
if (mlirLogicalResultIsFailure(status)) {
|
||||
fprintf(stderr,
|
||||
|
@ -190,8 +188,8 @@ void testParsePassPipeline() {
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// CHECK: Round-trip: builtin.module(func.func(print-op-stats{json=false}),
|
||||
// func.func(print-op-stats{json=false}))
|
||||
// CHECK: Round-trip: builtin.module(func.func(print-op-stats),
|
||||
// func.func(print-op-stats))
|
||||
fprintf(stderr, "Round-trip: ");
|
||||
mlirPrintPassPipeline(mlirPassManagerGetAsOpPassManager(pm), printToStderr,
|
||||
NULL);
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
// RUN: mlir-opt -allow-unregistered-dialect -print-op-stats=json %s -o=/dev/null 2>&1 | FileCheck %s
|
||||
|
||||
func.func @main(tensor<4xf32>, tensor<4xf32>) -> tensor<4xf32> {
|
||||
^bb0(%arg0: tensor<4xf32>, %arg1: tensor<4xf32>):
|
||||
%0 = arith.addf %arg0, %arg1 : tensor<4xf32>
|
||||
%1 = arith.addf %arg0, %arg1 : tensor<4xf32>
|
||||
%2 = arith.addf %arg0, %arg1 : tensor<4xf32>
|
||||
%3 = arith.addf %arg0, %arg1 : tensor<4xf32>
|
||||
%4 = arith.addf %arg0, %arg1 : tensor<4xf32>
|
||||
%5 = arith.addf %arg0, %arg1 : tensor<4xf32>
|
||||
%10 = "xla.add"(%0, %arg1) : (tensor<4xf32>,tensor<4xf32>)-> tensor<4xf32>
|
||||
%11 = "xla.add"(%0, %arg1) : (tensor<4xf32>,tensor<4xf32>)-> tensor<4xf32>
|
||||
%12 = "xla.add"(%0, %arg1) : (tensor<4xf32>,tensor<4xf32>)-> tensor<4xf32>
|
||||
%13 = "xla.add"(%0, %arg1) : (tensor<4xf32>,tensor<4xf32>)-> tensor<4xf32>
|
||||
%14 = "xla.add"(%0, %arg1) : (tensor<4xf32>,tensor<4xf32>)-> tensor<4xf32>
|
||||
%15 = "xla.add"(%0, %arg1) : (tensor<4xf32>,tensor<4xf32>)-> tensor<4xf32>
|
||||
%16 = "xla.add"(%0, %arg1) : (tensor<4xf32>,tensor<4xf32>)-> tensor<4xf32>
|
||||
%17 = "xla.add"(%0, %arg1) : (tensor<4xf32>,tensor<4xf32>)-> tensor<4xf32>
|
||||
%18 = "xla.add"(%0, %arg1) : (tensor<4xf32>,tensor<4xf32>)-> tensor<4xf32>
|
||||
%19 = "xla.add"(%0, %arg1) : (tensor<4xf32>,tensor<4xf32>)-> tensor<4xf32>
|
||||
%20 = "xla.add"(%0, %arg1) : (tensor<4xf32>,tensor<4xf32>)-> tensor<4xf32>
|
||||
%21 = "xla.add"(%0, %arg1) : (tensor<4xf32>,tensor<4xf32>)-> tensor<4xf32>
|
||||
%22 = "xla.add"(%0, %arg1) : (tensor<4xf32>,tensor<4xf32>)-> tensor<4xf32>
|
||||
%23 = "xla.add"(%0, %arg1) : (tensor<4xf32>,tensor<4xf32>)-> tensor<4xf32>
|
||||
%24 = "xla.add"(%0, %arg1) : (tensor<4xf32>,tensor<4xf32>)-> tensor<4xf32>
|
||||
%25 = "xla.add"(%0, %arg1) : (tensor<4xf32>,tensor<4xf32>)-> tensor<4xf32>
|
||||
%26 = "xla.add"(%0, %arg1) : (tensor<4xf32>,tensor<4xf32>)-> tensor<4xf32>
|
||||
%30 = "long_op_name"(%0, %arg1) : (tensor<4xf32>,tensor<4xf32>)-> tensor<4xf32>
|
||||
return %1 : tensor<4xf32>
|
||||
}
|
||||
|
||||
// CHECK: {
|
||||
// CHECK: "arith.addf" : 6,
|
||||
// CHECK: "func.return" : 1,
|
||||
// CHECK: "long_op_name" : 1,
|
||||
// CHECK: "xla.add" : 17
|
||||
// CHECK: }
|
Loading…
Reference in New Issue