Beaver.MLIR.CompilationPlan (beaver v0.4.8)

Copy Markdown

A reusable, inspectable, cache-stable MLIR compiler declaration.

A plan closes Composer-compatible pass data, a Transform schedule, target and schema configuration, bytecode version, context options, and telemetry metadata into one value. It owns no MLIR context or native resource.

Pipeline strings and nested pipeline strings are deterministic data. Module and callback passes contain executable behavior, so each such step must be wrapped with an explicit stable version through add_pass/3 or versioned/2. Function bodies, processes, references, and native handles are never hashed.

declaration/1 projects the executable plan to deterministic data, while identity/1 hashes that projection. Both are computed from the current struct; no cached identity can drift from a modified plan.

Summary

Functions

Appends one Composer-compatible pass, optionally with :version.

Returns the deterministic, callback-free declaration represented by a plan.

Defines a zero-arity function that returns a validated compilation plan.

Returns the stable SHA-256 identity of declaration/1.

Appends a nested Composer pass scope.

Creates and validates a compilation plan without constructing native resources.

Sets the desired MLIR bytecode emission version.

Sets options used when the compilation runtime creates an MLIR context.

Sets the dynamic dialect/schema identity.

Sets the target configuration included in the plan identity.

Sets deterministic metadata attached to compilation and artifact telemetry.

Sets the Transform schedule and its execution options.

Validates a plan and returns it unchanged.

Wraps one Composer pass payload with an explicit stable version.

Types

pass_step()

@type pass_step() ::
  binary()
  | module()
  | {binary(), [pass_step()]}
  | {binary(), binary(), function()}
  | {:beaver_compilation_plan_versioned_step, term(), term()}

t()

@type t() :: %Beaver.MLIR.CompilationPlan{
  context_options: keyword(),
  desired_emit_version: integer() | nil,
  pipeline: [pass_step()],
  schema_version: term(),
  target: term(),
  telemetry_metadata: map(),
  transform_options: keyword(),
  transform_schedule:
    Beaver.MLIR.Transform.Schedule.Resolved.t() | binary() | nil
}

Functions

add_pass(plan, pass, opts \\ [])

@spec add_pass(t(), term(), keyword()) :: t()

Appends one Composer-compatible pass, optionally with :version.

declaration(plan)

@spec declaration(t()) :: map()

Returns the deterministic, callback-free declaration represented by a plan.

defcompiler(call, opts_or_block)

(macro)

Defines a zero-arity function that returns a validated compilation plan.

identity(plan)

@spec identity(t()) :: binary()

Returns the stable SHA-256 identity of declaration/1.

nested(plan, operation_name, passes)

@spec nested(t(), binary(), [pass_step()]) :: t()

Appends a nested Composer pass scope.

new(opts \\ [])

@spec new(keyword()) :: t()

Creates and validates a compilation plan without constructing native resources.

set_bytecode_version(plan, version)

@spec set_bytecode_version(t(), integer() | :current | nil) :: t()

Sets the desired MLIR bytecode emission version.

set_context_options(plan, opts)

@spec set_context_options(
  t(),
  keyword()
) :: t()

Sets options used when the compilation runtime creates an MLIR context.

set_schema_version(plan, version)

@spec set_schema_version(t(), term()) :: t()

Sets the dynamic dialect/schema identity.

set_target(plan, target)

@spec set_target(t(), term()) :: t()

Sets the target configuration included in the plan identity.

set_telemetry_metadata(plan, metadata)

@spec set_telemetry_metadata(t(), map() | keyword()) :: t()

Sets deterministic metadata attached to compilation and artifact telemetry.

set_transform_schedule(plan, schedule, opts \\ [])

@spec set_transform_schedule(
  t(),
  Beaver.MLIR.Transform.Schedule.Resolved.t() | binary() | nil,
  keyword()
) :: t()

Sets the Transform schedule and its execution options.

validate!(plan)

@spec validate!(t()) :: t()

Validates a plan and returns it unchanged.

versioned(pass, version)

@spec versioned(term(), term()) :: pass_step()

Wraps one Composer pass payload with an explicit stable version.