Beaver.MLIR.Dialect.MLProgram (beaver v0.4.8)

Copy Markdown

Summary

Functions

Return op name ml_program.func as a bitstring.

ml_program.func - Function containing a single SSACFG region

Return op name ml_program.global as a bitstring.

ml_program.global - Module level declaration of a global variable

Return op name ml_program.global_load as a bitstring.

ml_program.global_load - Direct load of a mutable value from a global

Return op name ml_program.global_load_const as a bitstring.

ml_program.global_load_const - Direct load a constant value from a global

Return op name ml_program.global_load_graph as a bitstring.

ml_program.global_load_graph - Direct load of a mutable value from a global in Graph region

Return op name ml_program.global_store as a bitstring.

ml_program.global_store - Direct store of a value into a mutable global

Return op name ml_program.global_store_graph as a bitstring.

ml_program.global_store_graph - Direct store of a value into a mutable global

Return op name ml_program.output as a bitstring.

ml_program.output - Outputs values from a subgraph function

Return op name ml_program.return as a bitstring.

ml_program.return - Returns values from a func function

Return op name ml_program.subgraph as a bitstring.

ml_program.subgraph - An function containing a single Graph region

Return op name ml_program.token as a bitstring.

ml_program.token - Produces a new token value

Functions

func()

Return op name ml_program.func as a bitstring.

func(ssa)

ml_program.func - Function containing a single SSACFG region

Attributes

  • sym_name - Single, SymbolNameAttr, string attribute
  • function_type - Single, anonymous/composite constraint, type attribute of function type
  • arg_attrs - Optional, DictArrayAttr, Array of dictionary attributes
  • res_attrs - Optional, DictArrayAttr, Array of dictionary attributes
  • sym_visibility - Optional, StrAttr, string attribute

Description

This simple function container represents callables in an ML program where the body is an SSACFG region. It must be terminated by a return op which yields values with the same arity and types as the FunctionType results of the containing func.

This op is a Symbol but does not introduce a new SymbolTable. As such, it cannot represent nested symbols.

Example:

ml_program.func private @some_extern(i32) -> i32
ml_program.func @compute(%arg0 : i32) -> i32 {
  ml_program.return %arg0 : i32
}

global()

Return op name ml_program.global as a bitstring.

global(ssa)

ml_program.global - Module level declaration of a global variable

Attributes

  • sym_name - Single, SymbolNameAttr, string attribute
  • type - Single, TypeAttr, any type attribute
  • is_mutable - Optional, UnitAttr, unit attribute
  • value - Optional, AnyAttr, any attribute
  • sym_visibility - Optional, StrAttr, string attribute

Description

Declares a named global variable (or constant).

A global contains a value of a specified type which can be accessed at runtime via appropriate load/store operations. It can be mutable or constant, optionally taking an initial value or declared as extern (in which case, the initial value is found in external storage by symbol name).

Generally, the type of the global and the type of the initial value will be the same. However, for type hierarchies which can have a more generalized bounding type that can be assigned from a narrow type, this is allowed (but not verified).

Examples:

// Constant global.
ml_program.global @foobar(dense<4> : tensor<4xi32>) : tensor<?xi32>

// Constant with external linkage.
ml_program.global mutable @foobar(#ml_program.extern<tensor<4xi32>>)
  : tensor<?xi32>

// Mutable global with an undefined initial value.
ml_program.global mutable @foobar : tensor<?xi32>

global_load()

Return op name ml_program.global_load as a bitstring.

global_load(ssa)

ml_program.global_load - Direct load of a mutable value from a global

Attributes

  • global - Single, SymbolRefAttr, symbol reference attribute

Results

  • result - Single, AnyType, any non-token type

Description

Performs a non-atomic, non-volatile, non-synchronized load from a global that may be mutable.

It is fully expected that these constraints are not suitable for all situations, and alternative ops should be defined and used for more advanced cases.

This op is side effecting and may not be valid to use in graph regions without additional consideration to evaluation order constraints. See global_load_graph for op which allows for explicit ordering constraints.

Example:

%0 = ml_program.global_load @foobar : tensor<?xi32>

global_load_const()

Return op name ml_program.global_load_const as a bitstring.

global_load_const(ssa)

ml_program.global_load_const - Direct load a constant value from a global

Attributes

  • global - Single, SymbolRefAttr, symbol reference attribute

Results

  • result - Single, AnyType, any non-token type

Description

Loads a constant (immutable) value from a global directly by symbol.

This op is only legal for globals that are not mutable and exists because such a load can be considered to have no side effects.

Example:

%0 = ml_program.global_load_const @foobar : tensor<?xi32>

global_load_graph()

Return op name ml_program.global_load_graph as a bitstring.

global_load_graph(ssa)

ml_program.global_load_graph - Direct load of a mutable value from a global in Graph region

Attributes

  • global - Single, SymbolRefAttr, symbol reference attribute

Operands

  • consumeTokens - Variadic, MLProgram_TokenType, variadic of Token for establishing execution ordering in a graph

Results

  • result - Single, AnyType, any non-token type
  • produceToken - Single, MLProgram_TokenType, Token for establishing execution ordering in a graph

Description

Performs a non-atomic, non-volatile, non-synchronized load from a global that may be mutable.

It is fully expected that these constraints are not suitable for all situations, and alternative ops should be defined and used for more advanced cases.

This op is side effecting and may not be valid to use in graph regions without additional consideration to evaluation order constraints.

Example:

%0, %cstr = ml_program.global_load_graph @foobar
  ordering (%token -> !ml_program.token) : tensor<?xi32>

global_store()

Return op name ml_program.global_store as a bitstring.

global_store(ssa)

ml_program.global_store - Direct store of a value into a mutable global

Attributes

  • global - Single, SymbolRefAttr, symbol reference attribute

Operands

  • value - Single, AnyType, any non-token type

Description

Performs a non-atomic, non-volatile, non-synchronized store to a mutable global.

It is fully expected that these constraints are not suitable for all situations, and alternative ops should be defined and used for more advanced cases.

This op is side effecting and may not be valid to use in graph regions without additional consideration to evaluation order constraints. See global_store_graph for op which allows for explicit ordering constraints.

Example:

ml_program.global_store @foobar = %0 : tensor<?xi32>

global_store_graph()

Return op name ml_program.global_store_graph as a bitstring.

global_store_graph(ssa)

ml_program.global_store_graph - Direct store of a value into a mutable global

Attributes

  • global - Single, SymbolRefAttr, symbol reference attribute

Operands

  • value - Single, AnyType, any non-token type
  • consumeTokens - Variadic, MLProgram_TokenType, variadic of Token for establishing execution ordering in a graph

Results

  • produceToken - Single, MLProgram_TokenType, Token for establishing execution ordering in a graph

Description

Performs a non-atomic, non-volatile, non-synchronized store to a mutable global.

It is fully expected that these constraints are not suitable for all situations, and alternative ops should be defined and used for more advanced cases.

This op is side effecting and may not be valid to use in graph regions without additional consideration to evaluation order constraints.

Example:

%token = ml_program.global_store @foobar = %0 : tensor<?xi32>
  ordering (%in_token -> !ml_program.token) : tensor<?xi32>

output()

Return op name ml_program.output as a bitstring.

output(ssa)

ml_program.output - Outputs values from a subgraph function

Operands

  • operands - Variadic, AnyType, variadic of any non-token type

Description

The output operation terminates a subgraph by yielding values to the caller. The operation takes variable number of operands and produces no results. The operand number and types must match the signature of the function that contains the operation.

return()

Return op name ml_program.return as a bitstring.

return(ssa)

ml_program.return - Returns values from a func function

Operands

  • operands - Variadic, AnyType, variadic of any non-token type

Description

The return operation terminates a func function by yielding values to the caller. The operation takes variable number of operands and produces no results. The operand number and types must match the signature of the function that contains the operation.

subgraph()

Return op name ml_program.subgraph as a bitstring.

subgraph(ssa)

ml_program.subgraph - An function containing a single Graph region

Attributes

  • sym_name - Single, SymbolNameAttr, string attribute
  • function_type - Single, anonymous/composite constraint, type attribute of function type
  • arg_attrs - Optional, DictArrayAttr, Array of dictionary attributes
  • res_attrs - Optional, DictArrayAttr, Array of dictionary attributes
  • sym_visibility - Optional, StrAttr, string attribute

Description

This simple function container represents callables in an ML program where the body is a Graph region containing a single block. It must be terminated by an output op which yields values with the same arity and types as the FunctionType results of the containing subgraph.

This op is a Symbol but does not introduce a new SymbolTable. As such, it cannot represented nested symbols.

Example:

ml_program.subgraph private @some_extern(i32) -> i32
ml_program.subgraph @compute(%arg0 : i32) -> i32 {
  ml_program.output %arg0 : i32
}

token()

Return op name ml_program.token as a bitstring.

token(ssa)

ml_program.token - Produces a new token value

Results

  • token - Single, MLProgram_TokenType, Token for establishing execution ordering in a graph

Description

Token values are used to chain side effecting ops in a graph so as to establish an execution order. This op produces a token.