Beaver.MLIR.Rewrite (beaver v0.4.8)

Copy Markdown

This module defines functions working with MLIR rewrite patterns and pattern sets.

Summary

Types

Callback used to customize a greedy rewrite config before application.

Opaque greedy rewrite driver config handle passed to configuration callbacks.

Supported high-level rewrite config options.

Processed MLIR diagnostic tree emitted during rewrite application.

Pattern callback entries accepted by the list-based rewrite surface.

IR surfaces accepted by the rewrite driver.

Types

apply_result()

@type apply_result() :: {Beaver.MLIR.LogicalResult.t(), diagnostics()}

config_callback()

@type config_callback() :: (config_handle() -> any())

Callback used to customize a greedy rewrite config before application.

config_handle()

@type config_handle() :: term()

Opaque greedy rewrite driver config handle passed to configuration callbacks.

config_input()

@type config_input() :: config_opts() | config_callback() | nil

config_option()

@type config_option() ::
  {:max_iterations, integer()}
  | {:max_num_rewrites, integer()}
  | {:use_top_down_traversal, boolean()}
  | {:enable_folding, boolean()}
  | {:enable_constant_cse, boolean()}

Supported high-level rewrite config options.

config_opts()

@type config_opts() :: [config_option()]

diagnostic()

@type diagnostic() ::
  {severity :: atom(), location :: String.t(), message :: String.t(),
   nested :: [diagnostic()]}

Processed MLIR diagnostic tree emitted during rewrite application.

diagnostics()

@type diagnostics() :: [diagnostic()]

match_and_rewrite()

@type match_and_rewrite() :: (Beaver.MLIR.RewritePattern.t(),
                        Beaver.MLIR.Operation.t(),
                        Beaver.MLIR.PatternRewriter.t(),
                        any() ->
                          {:ok, any()} | {:error, any()})

Pattern callback entries accepted by the list-based rewrite surface.

pattern_entry()

pattern_list()

@type pattern_list() :: [pattern_entry()]

rewrite_ir()

@type rewrite_ir() :: Beaver.MLIR.Module.t() | Beaver.MLIR.Operation.t()

IR surfaces accepted by the rewrite driver.

Functions

apply_patterns(ir, pattern_set)

@spec apply_patterns(rewrite_ir(), Beaver.MLIR.FrozenRewritePatternSet.t()) ::
  apply_result()
@spec apply_patterns(rewrite_ir(), Beaver.MLIR.RewritePatternSet.t()) ::
  apply_result()
@spec apply_patterns(rewrite_ir(), pattern_list()) :: apply_result()

apply_patterns(ir, pattern_set, configure)

@spec apply_patterns(
  rewrite_ir(),
  Beaver.MLIR.FrozenRewritePatternSet.t(),
  config_input()
) :: apply_result()
@spec apply_patterns(
  rewrite_ir(),
  Beaver.MLIR.RewritePatternSet.t(),
  config_input()
) :: apply_result()
@spec apply_patterns(rewrite_ir(), pattern_list(), config_input()) :: apply_result()

apply_patterns!(ir, pattern_set)

@spec apply_patterns!(rewrite_ir(), Beaver.MLIR.FrozenRewritePatternSet.t()) ::
  rewrite_ir()
@spec apply_patterns!(rewrite_ir(), Beaver.MLIR.RewritePatternSet.t()) :: rewrite_ir()
@spec apply_patterns!(rewrite_ir(), pattern_list()) :: rewrite_ir()

apply_patterns!(ir, pattern_set, configure)

@spec apply_patterns!(
  rewrite_ir(),
  Beaver.MLIR.FrozenRewritePatternSet.t(),
  config_input()
) :: rewrite_ir()
@spec apply_patterns!(
  rewrite_ir(),
  Beaver.MLIR.RewritePatternSet.t(),
  config_input()
) :: rewrite_ir()
@spec apply_patterns!(rewrite_ir(), pattern_list(), config_input()) :: rewrite_ir()

stop_thread_pool()

@spec stop_thread_pool() :: :ok

to_config_callback(callback)

@spec to_config_callback(config_input()) :: config_callback()

with_default_config(fun)

@spec with_default_config((config_handle() -> result)) :: result when result: var

with_default_config(configure, fun)

@spec with_default_config(config_input(), (config_handle() -> result)) :: result
when result: var