Beaver.MLIR.MemoryEffects behaviour (beaver v0.4.8)

Copy Markdown

Implements MLIR's MemoryEffectsOpInterface for dynamic operations.

A callback returns :pure or a list of effect specifications. An effect is one of :allocate, :free, :read, or :write, optionally associated with an operand, result, block argument, or symbol:

[
  {:read, {:operand, 0}},
  {:write, {:result, 0}},
  {:read, {:symbol, symbol_ref}, stage: 1}
]

A bare effect such as :write is not associated with a particular IR entity. Options are :parameters, :stage, :effect_on_full_region, and :resource. The default resource and a null parameters attribute are used when omitted.

The effects list passed to a two-argument callback is borrowed and valid only until that callback returns. Prefer returning declarative specifications. Callback exceptions are diagnosed and native code adds a conservative unknown write effect.

Summary

Functions

Attaches a callback-backed memory effects interface model.

Adds the standard transform-dialect effects for consumed handle operands.

Marks a transform operation as potentially modifying payload IR.

Adds the standard transform-dialect effects for read-only handle operands.

Marks a transform operation as only reading payload IR.

Adds the standard transform-dialect effects for produced handle results.

Types

effect()

@type effect() :: :allocate | :free | :read | :write

effect_spec()

@type effect_spec() ::
  effect() | {effect(), target()} | {effect(), target(), keyword()}

target()

@type target() ::
  nil
  | :operation
  | {:operand, non_neg_integer() | Beaver.MLIR.OpOperand.t()}
  | {:result, non_neg_integer() | Beaver.MLIR.Value.t()}
  | {:block_argument, Beaver.MLIR.Value.t()}
  | {:symbol, Beaver.MLIR.Attribute.t()}
  | Beaver.MLIR.OpOperand.t()
  | Beaver.MLIR.Value.t()
  | Beaver.MLIR.Attribute.t()

Callbacks

memory_effects(t)

@callback memory_effects(Beaver.MLIR.Operation.t()) ::
  :pure | [effect_spec()] | {:ok, [effect_spec()]}

Functions

attach(context, operation_name, implementation, opts \\ [])

Attaches a callback-backed memory effects interface model.

consumes_handle(effects, operands)

Adds the standard transform-dialect effects for consumed handle operands.

modifies_payload(effects)

Marks a transform operation as potentially modifying payload IR.

only_reads_handle(effects, operands)

Adds the standard transform-dialect effects for read-only handle operands.

only_reads_payload(effects)

Marks a transform operation as only reading payload IR.

produces_handle(effects, results)

Adds the standard transform-dialect effects for produced handle results.