Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tpp-run] Print IR options #992

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions test/Integration/tpp-run-print-ir.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// RUN: tpp-run %s -e entry -entry-point-result=void -mlir-print-ir-before=bufferize 2>&1 | FileCheck %s --check-prefix=BEFORE
// RUN: tpp-run %s -e entry -entry-point-result=void -mlir-print-ir-after=bufferize 2>&1 | FileCheck %s --check-prefix=AFTER

func.func @entry(%arg0: tensor<128x512xf32>, %arg1: tensor<512x256xf32>, %arg2: tensor<128x256xf32>)
-> tensor<128x256xf32> {
%0 = linalg.matmul ins(%arg0, %arg1: tensor<128x512xf32>, tensor<512x256xf32>)
outs(%arg2: tensor<128x256xf32>) -> tensor<128x256xf32>
return %0 : tensor<128x256xf32>
}

// BEFORE: IR Dump Before Bufferize (bufferize)
// BEFORE-LABEL: @_entry(
// BEFORE: linalg.batch_reduce_matmul{{.*}}tensor<

// AFTER: IR Dump After Bufferize (bufferize)
// AFTER-LABEL: @_entry(
// AFTER: linalg.batch_reduce_matmul{{.*}}memref<
13 changes: 13 additions & 0 deletions tools/tpp-run/tpp-run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ static LogicalResult prepareMLIRKernel(Operation *op,
// A set of default passes that lower any input IR to LLVM
PassManager passManager(module.getContext());

// Propagate pass manager's command-line options.
if (failed(applyPassManagerCLOptions(passManager)))
return failure();

tpp::TppRunnerWrapperOptions wrapperOpts;
wrapperOpts.kernelName = options.mainFuncName;
wrapperOpts.kernelType = options.mainFuncType;
Expand Down Expand Up @@ -275,6 +279,11 @@ int main(int argc, char **argv) {
// Initialize GPU-related LLVM machinery
tpp::initializeGpuTargets();

// Register all passes to expose them for debugging
mlir::registerAllPasses();
mlir::tpp::registerTppCompilerPasses();
mlir::tpp::registerTppPassBundlePasses();

// Add the following to include *all* MLIR Core dialects, or selectively
// include what you need like above. You only need to register dialects that
// will be *parsed* by the tool, not the one generated
Expand All @@ -288,6 +297,10 @@ int main(int argc, char **argv) {
mlir::linalg::registerTransformDialectExtension(registry);
mlir::tensor::registerTransformDialectExtension(registry);

// Add pass manager CLI debug options - exposes IR printing capabilities
// same as in opt tool
mlir::registerPassManagerCLOptions();

// This is how we integrate with the pipeline
JitRunnerConfig config;
config.mlirTransformer = prepareMLIRKernel;
Expand Down