Skip to content

Commit

Permalink
Fix for IR printing argument updates introduced in upstream (#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackalcooper authored Sep 20, 2024
1 parent 98b8f36 commit a25dcc5
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 5 deletions.
4 changes: 2 additions & 2 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
mlir==20.0.0.2024090301+b6597f52; sys_platform != "linux"
mlir==20.0.0.2024090301+cuda.b6597f52; sys_platform == "linux"
mlir==20.0.0.2024091901+009398b3; sys_platform != "linux"
mlir==20.0.0.2024091901+cuda.009398b3; sys_platform == "linux"
--find-links https://github.com/makslevental/mlir-wheels/releases/expanded_assets/latest
1 change: 0 additions & 1 deletion lib/beaver/mlir/capi_kinds.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ mlir_mods = [
DiagnosticHandler,
Diagnostic,
DiagnosticSeverity,
PassManager,
RewritePatternSet,
SymbolTable,
ExternalPassCallbacks,
Expand Down
3 changes: 1 addition & 2 deletions lib/beaver/mlir/pass/composer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ defmodule Beaver.MLIR.Pass.Composer do

if print do
mlirContextEnableMultithreading(ctx, false)
mlirPassManagerEnableIRPrinting(pm)
Logger.info("[Beaver] IR printing enabled")
MLIR.PassManager.enable_ir_printing(pm)
end

if debug do
Expand Down
25 changes: 25 additions & 0 deletions lib/beaver/mlir/pass_manager.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
defmodule Beaver.MLIR.PassManager do
use Kinda.ResourceKind,
forward_module: Beaver.Native

alias Beaver.MLIR

@type print_opt ::
{:before_all, boolean()}
| {:after_all, boolean()}
| {:module_scope, boolean()}
| {:after_only_on_change, boolean()}
| {:after_only_on_failure, boolean()}
@type print_opts :: [print_opt()]
@spec enable_ir_printing(MLIR.PassManager.t(), print_opts()) :: :ok
def enable_ir_printing(%MLIR.PassManager{} = pm, opts \\ []) do
MLIR.CAPI.mlirPassManagerEnableIRPrinting(
pm,
!!Keyword.get(opts, :before_all, false),
!!Keyword.get(opts, :after_all, true),
!!Keyword.get(opts, :module_scope, false),
!!Keyword.get(opts, :after_only_on_change, false),
!!Keyword.get(opts, :after_only_on_failure, false)
)
end
end
6 changes: 6 additions & 0 deletions test/debug_output_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,10 @@ defmodule DebugOutputTest do
|> MLIR.Transforms.canonicalize()
|> MLIR.Pass.Composer.run!(timing: true)
end

test "pass manager enable print ir", test_context do
ir(test_context[:ctx])
|> MLIR.Transforms.canonicalize()
|> MLIR.Pass.Composer.run!(print: true)
end
end

0 comments on commit a25dcc5

Please sign in to comment.