Beaver.MLIR.Transform.Schedule.DSL (beaver v0.4.8)

Copy Markdown

An Elixir authoring frontend for upstream Transform dialect schedules.

The DSL creates a verified Beaver.MLIR.Module in a caller-owned context. Its helpers create ordinary Transform dialect operations immediately; there is no second schedule graph to synchronize with the IR.

A schedule module can mix the focused helpers in this module with Beaver's normal SSA syntax:

defmodule MySchedule do
  use Beaver.MLIR.Transform.Schedule.DSL

  defschedule search do
    sequence "__transform_main", [root >>> any_op()] do
      _tile = knob("tile", [8, 16], type: param(MLIR.Type.i64()))
      # Any existing Beaver SSA operation may be emitted here.
      yield()
    end
  end
end

schedule = MySchedule.search(ctx: context)

The caller owns both context and the returned module.

Summary

Functions

Imports defschedule and the schedule authoring helpers.

Creates transform.tune.alternatives from explicit branch blocks.

Returns a deferred !transform.any_op type.

Returns a deferred !transform.any_param type.

Returns a deferred !transform.any_value type.

Defines a zero-arity schedule builder with an optional keyword argument.

Creates transform.tune.knob and returns its parameter handle.

Returns a deferred operation-specific Transform handle type.

Returns a Transform parameter type wrapping an MLIR type.

Declares the default __transform_main sequence with one any_op root handle.

Declares a named sequence with one default any_op root handle.

Declares a named sequence with typed handle arguments.

Creates transform.yield with zero or more yielded handles.

Functions

__using__(opts)

(macro)

Imports defschedule and the schedule authoring helpers.

alternatives(name, branches_or_block)

(macro)

Creates transform.tune.alternatives from explicit branch blocks.

alternatives "vectorize" do
  branch do
    # Transform SSA operations
  end

  branch do
    # A second alternative
  end
end

Each branch receives an implicit transform.yield when it does not already end in one.

any_op(opts \\ [])

Returns a deferred !transform.any_op type.

any_param(opts \\ [])

Returns a deferred !transform.any_param type.

any_value(opts \\ [])

Returns a deferred !transform.any_value type.

defschedule(call, list)

(macro)

Defines a zero-arity schedule builder with an optional keyword argument.

The generated function requires :ctx to be a caller-owned Beaver.MLIR.Context. It returns a verified Beaver.MLIR.Module; the caller must destroy the module before destroying the context.

knob(name, options, opts \\ [])

(macro)

Creates transform.tune.knob and returns its parameter handle.

Integer, float, boolean, string, :unit, MLIR.Attribute, and deferred attribute values are accepted. Integer-only knobs default to !transform.param<i64>; other domains default to !transform.any_param. Pass :type to select an explicit Transform parameter type.

operation(name, opts \\ [])

Returns a deferred operation-specific Transform handle type.

param(type)

Returns a Transform parameter type wrapping an MLIR type.

sequence(list)

(macro)

Declares the default __transform_main sequence with one any_op root handle.

sequence(name, list)

(macro)

Declares a named sequence with one default any_op root handle.

sequence(name, arguments, list)

(macro)

Declares a named sequence with typed handle arguments.

Arguments use Beaver's >>> spelling, for example [root >>> any_op(), function >>> operation("func.func")]. Sequence results are intentionally expressed by ordinary Transform SSA operations and yield/1; this helper currently declares result-free entry points.

yield(operands \\ [])

(macro)

Creates transform.yield with zero or more yielded handles.