mlir.dialects._async_ops_gen

Attributes

Classes

_Dialect

AddToGroupOp

The async.add_to_group adds an async token or value to the async group.

AwaitAllOp

The async.await_all operation waits until all the tokens or values in the

AwaitOp

The async.await operation waits until the argument becomes ready, and for

CallOp

The async.call operation represents a direct call to an async function

CoroBeginOp

The async.coro.begin allocates a coroutine frame and returns a handle to

CoroEndOp

The async.coro.end marks the point where a coroutine needs to return

CoroFreeOp

The async.coro.free deallocates the coroutine frame created by the

CoroIdOp

The async.coro.id returns a switched-resume coroutine identifier.

CoroSaveOp

The async.coro.saves saves the coroutine state.

CoroSuspendOp

The async.coro.suspend suspends the coroutine and transfers control to the

CreateGroupOp

The async.create_group allocates an empty async group. Async tokens or

ExecuteOp

The body region attached to the async.execute operation semantically

FuncOp

An async function is like a normal function, but supports non-blocking

ReturnOp

The async.return is a special terminator operation for Async function.

RuntimeAddRefOp

The async.runtime.add_ref operation adds a reference(s) to async value

RuntimeAddToGroupOp

The async.runtime.add_to_group adds an async token or value to the async

RuntimeAwaitAndResumeOp

The async.runtime.await_and_resume operation awaits for the operand to

RuntimeAwaitOp

The async.runtime.await operation blocks the caller thread until the

RuntimeCreateGroupOp

The async.runtime.create_group operation creates an async dialect group

RuntimeCreateOp

The async.runtime.create operation creates an async dialect token or

RuntimeDropRefOp

The async.runtime.drop_ref operation drops a reference(s) to async value

RuntimeIsErrorOp

The async.runtime.is_error operation returns true if the token, value or

RuntimeLoadOp

The async.runtime.load operation loads the value from the runtime

RuntimeNumWorkerThreadsOp

The async.runtime.num_worker_threads operation gets the number of threads

RuntimeResumeOp

The async.runtime.resume operation resumes the coroutine on a thread

RuntimeSetAvailableOp

The async.runtime.set_available operation switches async token or value

RuntimeSetErrorOp

The async.runtime.set_error operation switches async token or value

RuntimeStoreOp

The async.runtime.store operation stores the value into the runtime

YieldOp

The async.yield is a special terminator operation for the block inside

Functions

add_to_group(→ _ods_ir)

await_all(→ AwaitAllOp)

await_(→ Union[_ods_ir, _ods_ir, AwaitOp])

call(→ Union[_ods_ir, _ods_ir, CallOp])

coro_begin(→ _ods_ir)

coro_end(→ CoroEndOp)

coro_free(→ CoroFreeOp)

coro_id(→ _ods_ir)

coro_save(→ _ods_ir)

coro_suspend(→ CoroSuspendOp)

create_group(→ _ods_ir)

execute(→ Union[_ods_ir, _ods_ir, ExecuteOp])

func(→ FuncOp)

return_(→ ReturnOp)

runtime_add_ref(→ RuntimeAddRefOp)

runtime_add_to_group(→ _ods_ir)

runtime_await_and_resume(→ RuntimeAwaitAndResumeOp)

runtime_await(→ RuntimeAwaitOp)

runtime_create_group(→ _ods_ir)

runtime_create(→ _ods_ir)

runtime_drop_ref(→ RuntimeDropRefOp)

runtime_is_error(→ _ods_ir)

runtime_load(→ _ods_ir)

runtime_num_worker_threads(→ _ods_ir)

runtime_resume(→ RuntimeResumeOp)

runtime_set_available(→ RuntimeSetAvailableOp)

runtime_set_error(→ RuntimeSetErrorOp)

runtime_store(→ RuntimeStoreOp)

yield_(→ YieldOp)

Module Contents

mlir.dialects._async_ops_gen._ods_ir
class mlir.dialects._async_ops_gen._Dialect(descriptor: object)

Bases: _ods_ir

DIALECT_NAMESPACE = 'async'
class mlir.dialects._async_ops_gen.AddToGroupOp(operand, group, *, results=None, loc=None, ip=None)

Bases: _ods_ir

The async.add_to_group adds an async token or value to the async group. Returns the rank of the added element in the group. This rank is fixed for the group lifetime.

Example:

%0 = async.create_group %size : !async.group
%1 = ... : !async.token
%2 = async.add_to_group %1, %0 : !async.token
OPERATION_NAME = 'async.add_to_group'
_ODS_REGIONS = (0, True)
operand() _ods_ir
group() _ods_ir
rank() _ods_ir
mlir.dialects._async_ops_gen.add_to_group(operand, group, *, results=None, loc=None, ip=None) _ods_ir
class mlir.dialects._async_ops_gen.AwaitAllOp(operand, *, loc=None, ip=None)

Bases: _ods_ir

The async.await_all operation waits until all the tokens or values in the group become ready.

Example:

%0 = async.create_group %size : !async.group

%1 = ... : !async.token
%2 = async.add_to_group %1, %0 : !async.token

%3 = ... : !async.token
%4 = async.add_to_group %2, %0 : !async.token

async.await_all %0
OPERATION_NAME = 'async.await_all'
_ODS_REGIONS = (0, True)
operand() _ods_ir
mlir.dialects._async_ops_gen.await_all(operand, *, loc=None, ip=None) AwaitAllOp
class mlir.dialects._async_ops_gen.AwaitOp(result, operand, *, loc=None, ip=None)

Bases: _ods_ir

The async.await operation waits until the argument becomes ready, and for the async.value arguments it unwraps the underlying value

Example:

%0 = ... : !async.token
async.await %0 : !async.token

%1 = ... : !async.value<f32>
%2 = async.await %1 : !async.value<f32>
OPERATION_NAME = 'async.await'
_ODS_REGIONS = (0, True)
operand() _ods_ir
result() _ods_ir | None

Shortcut to get an op result if it has only one (throws an error otherwise).

mlir.dialects._async_ops_gen.await_(result, operand, *, loc=None, ip=None) _ods_ir | _ods_ir | AwaitOp
class mlir.dialects._async_ops_gen.CallOp(result, callee, operands_, *, arg_attrs=None, res_attrs=None, loc=None, ip=None)

Bases: _ods_ir

The async.call operation represents a direct call to an async function that is within the same symbol scope as the call. The operands and result types of the call must match the specified async function type. The callee is encoded as a symbol reference attribute named “callee”.

Example:

%2 = async.call @my_add(%0, %1) : (f32, f32) -> !async.value<f32>
OPERATION_NAME = 'async.call'
_ODS_REGIONS = (0, True)
operands_() _ods_ir
callee() _ods_ir
arg_attrs() _ods_ir | None
res_attrs() _ods_ir | None
mlir.dialects._async_ops_gen.call(result, callee, operands_, *, arg_attrs=None, res_attrs=None, loc=None, ip=None) _ods_ir | _ods_ir | CallOp
class mlir.dialects._async_ops_gen.CoroBeginOp(id, *, results=None, loc=None, ip=None)

Bases: _ods_ir

The async.coro.begin allocates a coroutine frame and returns a handle to the coroutine.

OPERATION_NAME = 'async.coro.begin'
_ODS_REGIONS = (0, True)
id() _ods_ir
handle() _ods_ir
mlir.dialects._async_ops_gen.coro_begin(id, *, results=None, loc=None, ip=None) _ods_ir
class mlir.dialects._async_ops_gen.CoroEndOp(handle, *, loc=None, ip=None)

Bases: _ods_ir

The async.coro.end marks the point where a coroutine needs to return control back to the caller if it is not an initial invocation of the coroutine. It the start part of the coroutine is is no-op.

OPERATION_NAME = 'async.coro.end'
_ODS_REGIONS = (0, True)
handle() _ods_ir
mlir.dialects._async_ops_gen.coro_end(handle, *, loc=None, ip=None) CoroEndOp
class mlir.dialects._async_ops_gen.CoroFreeOp(id, handle, *, loc=None, ip=None)

Bases: _ods_ir

The async.coro.free deallocates the coroutine frame created by the async.coro.begin operation.

OPERATION_NAME = 'async.coro.free'
_ODS_REGIONS = (0, True)
id() _ods_ir
handle() _ods_ir
mlir.dialects._async_ops_gen.coro_free(id, handle, *, loc=None, ip=None) CoroFreeOp
class mlir.dialects._async_ops_gen.CoroIdOp(*, results=None, loc=None, ip=None)

Bases: _ods_ir

The async.coro.id returns a switched-resume coroutine identifier.

OPERATION_NAME = 'async.coro.id'
_ODS_REGIONS = (0, True)
id() _ods_ir
mlir.dialects._async_ops_gen.coro_id(*, results=None, loc=None, ip=None) _ods_ir
class mlir.dialects._async_ops_gen.CoroSaveOp(handle, *, results=None, loc=None, ip=None)

Bases: _ods_ir

The async.coro.saves saves the coroutine state.

OPERATION_NAME = 'async.coro.save'
_ODS_REGIONS = (0, True)
handle() _ods_ir
state() _ods_ir
mlir.dialects._async_ops_gen.coro_save(handle, *, results=None, loc=None, ip=None) _ods_ir
class mlir.dialects._async_ops_gen.CoroSuspendOp(state, suspendDest, resumeDest, cleanupDest, *, loc=None, ip=None)

Bases: _ods_ir

The async.coro.suspend suspends the coroutine and transfers control to the suspend successor. If suspended coroutine later resumed it will transfer control to the resume successor. If it is destroyed it will transfer control to the the cleanup successor.

In switched-resume lowering coroutine can be already in resumed state when suspend operation is called, in this case control will be transferred to the resume successor skipping the suspend successor.

OPERATION_NAME = 'async.coro.suspend'
_ODS_REGIONS = (0, True)
state() _ods_ir
mlir.dialects._async_ops_gen.coro_suspend(state, suspend_dest, resume_dest, cleanup_dest, *, loc=None, ip=None) CoroSuspendOp
class mlir.dialects._async_ops_gen.CreateGroupOp(size, *, results=None, loc=None, ip=None)

Bases: _ods_ir

The async.create_group allocates an empty async group. Async tokens or values can be added to this group later. The size of the group must be specified at construction time, and await_all operation will first wait until the number of added tokens or values reaches the group size.

Example:

%size = ... : index
%group = async.create_group %size : !async.group
...
async.await_all %group
OPERATION_NAME = 'async.create_group'
_ODS_REGIONS = (0, True)
size() _ods_ir
result() _ods_ir

Shortcut to get an op result if it has only one (throws an error otherwise).

mlir.dialects._async_ops_gen.create_group(size, *, results=None, loc=None, ip=None) _ods_ir
class mlir.dialects._async_ops_gen.ExecuteOp(token, bodyResults, dependencies, bodyOperands, *, loc=None, ip=None)

Bases: _ods_ir

The body region attached to the async.execute operation semantically can be executed concurrently with the successor operation. In the followup example “compute0” can be executed concurrently with “compute1”.

The actual concurrency semantics depends on the dialect lowering to the executable format. Fully sequential execution (“compute0” completes before “compute1” starts) is a completely legal execution.

Because concurrent execution is not guaranteed, it is illegal to create an implicit dependency from “compute1” to “compute0” (e.g. via shared global state). All dependencies must be made explicit with async execute arguments (async.token or async.value).

async.execute operation takes async.token dependencies and async.value operands separately, and starts execution of the attached body region only when all tokens and values become ready.

Example:

%dependency = ... : !async.token
%value = ... : !async.value<f32>

%token, %results =
  async.execute [%dependency](%value as %unwrapped: !async.value<f32>)
             -> !async.value<!some.type>
  {
    %0 = "compute0"(%unwrapped): (f32) -> !some.type
    async.yield %0 : !some.type
  }

%1 = "compute1"(...) : !some.type

In the example above asynchronous execution starts only after dependency token and value argument become ready. Unwrapped value passed to the attached body region as an %unwrapped value of f32 type.

OPERATION_NAME = 'async.execute'
_ODS_OPERAND_SEGMENTS
_ODS_REGIONS = (1, True)
dependencies() _ods_ir
bodyOperands() _ods_ir
token() _ods_ir
bodyResults() _ods_ir
bodyRegion() _ods_ir
mlir.dialects._async_ops_gen.execute(token, body_results, dependencies, body_operands, *, loc=None, ip=None) _ods_ir | _ods_ir | ExecuteOp
class mlir.dialects._async_ops_gen.FuncOp(sym_name, function_type, *, sym_visibility=None, arg_attrs=None, res_attrs=None, loc=None, ip=None)

Bases: _ods_ir

An async function is like a normal function, but supports non-blocking await. Internally, async function is lowered to the LLVM coroutinue with async runtime intrinsic. It can return an async token and/or async values. The token represents the execution state of async function and can be used when users want to express dependencies on some side effects, e.g., the token becomes available once every thing in the func body is executed.

Example:

// Async function can't return void, it always must be some async thing.
async.func @async.0() -> !async.token {
  return
}

// Function returns only async value.
async.func @async.1() -> !async.value<i32> {
  %0 = arith.constant 42 : i32
  return %0 : i32
}

// Implicit token can be added to return types.
async.func @async.2() -> !async.token, !async.value<i32> {
  %0 = arith.constant 42 : i32
  return %0 : i32
}
OPERATION_NAME = 'async.func'
_ODS_REGIONS = (1, True)
sym_name() _ods_ir
function_type() _ods_ir
sym_visibility() _ods_ir | None
arg_attrs() _ods_ir | None
res_attrs() _ods_ir | None
body() _ods_ir
mlir.dialects._async_ops_gen.func(sym_name, function_type, *, sym_visibility=None, arg_attrs=None, res_attrs=None, loc=None, ip=None) FuncOp
class mlir.dialects._async_ops_gen.ReturnOp(operands_, *, loc=None, ip=None)

Bases: _ods_ir

The async.return is a special terminator operation for Async function.

Example:

async.func @foo() : !async.token {
  return
}
OPERATION_NAME = 'async.return'
_ODS_REGIONS = (0, True)
operands_() _ods_ir
mlir.dialects._async_ops_gen.return_(operands_, *, loc=None, ip=None) ReturnOp
class mlir.dialects._async_ops_gen.RuntimeAddRefOp(operand, count, *, loc=None, ip=None)

Bases: _ods_ir

The async.runtime.add_ref operation adds a reference(s) to async value (token, value or group).

OPERATION_NAME = 'async.runtime.add_ref'
_ODS_REGIONS = (0, True)
operand() _ods_ir
count() _ods_ir
mlir.dialects._async_ops_gen.runtime_add_ref(operand, count, *, loc=None, ip=None) RuntimeAddRefOp
class mlir.dialects._async_ops_gen.RuntimeAddToGroupOp(operand, group, *, results=None, loc=None, ip=None)

Bases: _ods_ir

The async.runtime.add_to_group adds an async token or value to the async group. Returns the rank of the added element in the group.

OPERATION_NAME = 'async.runtime.add_to_group'
_ODS_REGIONS = (0, True)
operand() _ods_ir
group() _ods_ir
rank() _ods_ir
mlir.dialects._async_ops_gen.runtime_add_to_group(operand, group, *, results=None, loc=None, ip=None) _ods_ir
class mlir.dialects._async_ops_gen.RuntimeAwaitAndResumeOp(operand, handle, *, loc=None, ip=None)

Bases: _ods_ir

The async.runtime.await_and_resume operation awaits for the operand to become available or error and resumes the coroutine on a thread managed by the runtime.

OPERATION_NAME = 'async.runtime.await_and_resume'
_ODS_REGIONS = (0, True)
operand() _ods_ir
handle() _ods_ir
mlir.dialects._async_ops_gen.runtime_await_and_resume(operand, handle, *, loc=None, ip=None) RuntimeAwaitAndResumeOp
class mlir.dialects._async_ops_gen.RuntimeAwaitOp(operand, *, loc=None, ip=None)

Bases: _ods_ir

The async.runtime.await operation blocks the caller thread until the operand becomes available or error.

OPERATION_NAME = 'async.runtime.await'
_ODS_REGIONS = (0, True)
operand() _ods_ir
mlir.dialects._async_ops_gen.runtime_await(operand, *, loc=None, ip=None) RuntimeAwaitOp
class mlir.dialects._async_ops_gen.RuntimeCreateGroupOp(size, *, results=None, loc=None, ip=None)

Bases: _ods_ir

The async.runtime.create_group operation creates an async dialect group of the given size. Group created in the empty state.

OPERATION_NAME = 'async.runtime.create_group'
_ODS_REGIONS = (0, True)
size() _ods_ir
result() _ods_ir

Shortcut to get an op result if it has only one (throws an error otherwise).

mlir.dialects._async_ops_gen.runtime_create_group(size, *, results=None, loc=None, ip=None) _ods_ir
class mlir.dialects._async_ops_gen.RuntimeCreateOp(result, *, loc=None, ip=None)

Bases: _ods_ir

The async.runtime.create operation creates an async dialect token or value. Tokens and values are created in the non-ready state.

OPERATION_NAME = 'async.runtime.create'
_ODS_REGIONS = (0, True)
result() _ods_ir

Shortcut to get an op result if it has only one (throws an error otherwise).

mlir.dialects._async_ops_gen.runtime_create(result, *, loc=None, ip=None) _ods_ir
class mlir.dialects._async_ops_gen.RuntimeDropRefOp(operand, count, *, loc=None, ip=None)

Bases: _ods_ir

The async.runtime.drop_ref operation drops a reference(s) to async value (token, value or group).

OPERATION_NAME = 'async.runtime.drop_ref'
_ODS_REGIONS = (0, True)
operand() _ods_ir
count() _ods_ir
mlir.dialects._async_ops_gen.runtime_drop_ref(operand, count, *, loc=None, ip=None) RuntimeDropRefOp
class mlir.dialects._async_ops_gen.RuntimeIsErrorOp(operand, *, results=None, loc=None, ip=None)

Bases: _ods_ir

The async.runtime.is_error operation returns true if the token, value or group (any of the async runtime values) is in the error state. It is the caller responsibility to check error state after the call to await or resuming after await_and_resume.

OPERATION_NAME = 'async.runtime.is_error'
_ODS_REGIONS = (0, True)
operand() _ods_ir
is_error() _ods_ir
mlir.dialects._async_ops_gen.runtime_is_error(operand, *, results=None, loc=None, ip=None) _ods_ir
class mlir.dialects._async_ops_gen.RuntimeLoadOp(storage, *, results=None, loc=None, ip=None)

Bases: _ods_ir

The async.runtime.load operation loads the value from the runtime async.value storage.

OPERATION_NAME = 'async.runtime.load'
_ODS_REGIONS = (0, True)
storage() _ods_ir
result() _ods_ir

Shortcut to get an op result if it has only one (throws an error otherwise).

mlir.dialects._async_ops_gen.runtime_load(storage, *, results=None, loc=None, ip=None) _ods_ir
class mlir.dialects._async_ops_gen.RuntimeNumWorkerThreadsOp(*, results=None, loc=None, ip=None)

Bases: _ods_ir

The async.runtime.num_worker_threads operation gets the number of threads in the threadpool from the runtime.

OPERATION_NAME = 'async.runtime.num_worker_threads'
_ODS_REGIONS = (0, True)
result() _ods_ir

Shortcut to get an op result if it has only one (throws an error otherwise).

mlir.dialects._async_ops_gen.runtime_num_worker_threads(*, results=None, loc=None, ip=None) _ods_ir
class mlir.dialects._async_ops_gen.RuntimeResumeOp(handle, *, loc=None, ip=None)

Bases: _ods_ir

The async.runtime.resume operation resumes the coroutine on a thread managed by the runtime.

OPERATION_NAME = 'async.runtime.resume'
_ODS_REGIONS = (0, True)
handle() _ods_ir
mlir.dialects._async_ops_gen.runtime_resume(handle, *, loc=None, ip=None) RuntimeResumeOp
class mlir.dialects._async_ops_gen.RuntimeSetAvailableOp(operand, *, loc=None, ip=None)

Bases: _ods_ir

The async.runtime.set_available operation switches async token or value state to available.

OPERATION_NAME = 'async.runtime.set_available'
_ODS_REGIONS = (0, True)
operand() _ods_ir
mlir.dialects._async_ops_gen.runtime_set_available(operand, *, loc=None, ip=None) RuntimeSetAvailableOp
class mlir.dialects._async_ops_gen.RuntimeSetErrorOp(operand, *, loc=None, ip=None)

Bases: _ods_ir

The async.runtime.set_error operation switches async token or value state to error.

OPERATION_NAME = 'async.runtime.set_error'
_ODS_REGIONS = (0, True)
operand() _ods_ir
mlir.dialects._async_ops_gen.runtime_set_error(operand, *, loc=None, ip=None) RuntimeSetErrorOp
class mlir.dialects._async_ops_gen.RuntimeStoreOp(value, storage, *, loc=None, ip=None)

Bases: _ods_ir

The async.runtime.store operation stores the value into the runtime async.value storage.

OPERATION_NAME = 'async.runtime.store'
_ODS_REGIONS = (0, True)
value() _ods_ir
storage() _ods_ir
mlir.dialects._async_ops_gen.runtime_store(value, storage, *, loc=None, ip=None) RuntimeStoreOp
class mlir.dialects._async_ops_gen.YieldOp(operands_, *, loc=None, ip=None)

Bases: _ods_ir

The async.yield is a special terminator operation for the block inside async.execute operation.

OPERATION_NAME = 'async.yield'
_ODS_REGIONS = (0, True)
operands_() _ods_ir
mlir.dialects._async_ops_gen.yield_(operands_, *, loc=None, ip=None) YieldOp