Skip to content

Commit

Permalink
Warning and instructions that --onnx-op-stats needs more than EmitONN…
Browse files Browse the repository at this point in the history
…XIR (#1719)

Signed-off-by: Alexandre Eichenberger <[email protected]>
Co-authored-by: chentong319 <[email protected]>
  • Loading branch information
AlexandreEichenberger and chentong319 authored Sep 30, 2022
1 parent b685ab7 commit 562adae
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/Compiler/CompilerOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,10 @@ llvm::cl::opt<bool> instrumentONNXSignature("instrument-onnx-signature",
llvm::cl::opt<std::string> ONNXOpStats("onnx-op-stats",
llvm::cl::desc(
"Report the occurrence frequency of ONNX ops in JSON or TXT format:\n"
"\"TXT\" for report as text, \n"
"\"JSON\" for report as JSON."),
"\"TXT\" for report as text,\n"
"\"JSON\" for report as JSON.\n"
"Requires targets like --EmitMLIR, --EmitLLVMIR, or binary-generating "
"commands."),
llvm::cl::init(""), llvm::cl::cat(OnnxMlirOptions));

llvm::cl::opt<bool> enableMemoryBundling("enable-memory-bundling",
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/CompilerPasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void addONNXToKrnlPasses(mlir::PassManager &pm, int optLevel, bool enableCSE,
// TODO: we should write the output of this pass in a file but I was not
// able to use raw_fd_ostream of a file without it crashing.
pm.addNestedPass<func::FuncOp>(
mlir::createPrintOpStatsPass(llvm::errs(), printAsJSON));
mlir::createPrintOpStatsPass(llvm::outs(), printAsJSON));
} else {
llvm::errs() << "Skip onnx-ops-stats: expected JSON or TXT format, got \""
<< ONNXOpsStatFormat << "\"\n";
Expand Down
5 changes: 5 additions & 0 deletions src/onnx-mlir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ int main(int argc, char *argv[]) {
llvm::errs() << "Failed to parse options\n";
return 1;
}
// Test option requirements.
if (!ONNXOpStats.empty() && emissionTarget <= EmitONNXIR)
llvm::errs()
<< "Warning: --onnx-op-stats requires targets like --EmitMLIR, "
"--EmitLLVMIR, or binary-generating emit commands.\n";

mlir::OwningOpRef<mlir::ModuleOp> module;
std::string errorMessage;
Expand Down

0 comments on commit 562adae

Please sign in to comment.