IRON API (aie.iron)¶
IRON is the high-level Python interface for programming AMD Ryzen™ AI NPUs.
You describe a design as Python objects — tiles, workers, data movement, and a
host runtime — and IRON compiles it to an optimized xclbin + instruction
stream via the MLIR-AIE toolchain.
Every object on this page is resolvable: it lowers to one or more MLIR operations when the design is compiled. That is what makes it the high-level layer. For the direct MLIR op wrappers that IRON lowers to, see the Dialect op wrappers page.
All symbols documented here are importable directly from the iron
namespace (e.g. from iron import Worker, ObjectFifo, Runtime).
Core design abstractions¶
The objects most designs are built from.
Program¶
Program ¶
Program(device: Device, rt: Runtime)
A Program represents all design information needed to run the design on a device.
Note
MLIR verification (ctx.module.operation.verify()) is performed inside
resolve_program, not during construction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device
|
Device
|
The device used to generate the final MLIR for the design. |
required |
rt
|
Runtime
|
The runtime object for the design. |
required |
Source code in python/iron/program.py
resolve_program ¶
This method resolves the program components in order to generate MLIR.
Tiles are emitted as aie.logical_tile ops. The --aie-place-tiles pass in the compilation pipeline converts them to aie.tile ops.
Returns:
| Name | Type | Description |
|---|---|---|
module |
Module
|
The module containing the MLIR context information. |
Source code in python/iron/program.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
Worker¶
Worker and WorkerRuntimeBarrier: compute-core tasks and runtime synchronization primitives.
Worker ¶
Worker(
core_fn: Callable | None,
fn_args: list | None = None,
tile: Tile = AnyComputeTile,
while_true: bool = True,
stack_size: int | None = None,
allocation_scheme: str | None = None,
trace: int | None = None,
trace_events: list | None = None,
dynamic_objfifo_lowering: bool | None = None,
)
Bases: ObjectFifoEndpoint
A task to be run on an AIE compute core.
A Worker takes a core_fn callable and the arguments it needs (ObjectFIFO handles,
Buffers, Kernels, etc.). Each Worker is placed on a single compute tile, either
explicitly via tile or automatically by the --aie-place-tiles compiler pass.
Construct a Worker
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
core_fn
|
Callable | None
|
The task to run on a core. If None, a busy-loop ( |
required |
fn_args
|
list | None
|
Pointers to arguments, which should include all context the core_fn needs to run. Defaults to None (empty list). |
None
|
tile
|
Tile
|
The compute tile for the Worker. Also accepts None (treated as AnyComputeTile). Defaults to AnyComputeTile. |
AnyComputeTile
|
while_true
|
bool
|
If true, will wrap the core_fn in a while(true) loop to ensure it runs until reconfiguration. Defaults to True. |
True
|
stack_size
|
int
|
The stack_size in bytes to be allocated for the worker. Defaults to 1024 bytes. |
None
|
allocation_scheme
|
str
|
The memory allocation scheme to use for the Worker, either 'basic-sequential' or 'bank-aware'. If None, defaults to bank-aware. Will override any allocation scheme set on the tile. |
None
|
trace
|
int
|
If >0, enable tracing for this worker. |
None
|
trace_events
|
list | None
|
Custom list of trace events for this worker. Defaults to None. |
None
|
dynamic_objfifo_lowering
|
bool | None
|
Per-core override for the
|
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Parameters are validated. |
Source code in python/iron/worker.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
fifos
property
¶
fifos: list[ObjectFifoHandle]
Returns a list of ObjectFifoHandles given to the Worker via fn_args.
Returns:
| Type | Description |
|---|---|
list[ObjectFifoHandle]
|
list[ObjectFifoHandle]: ObjectFifoHandles used by the Worker. |
buffers
property
¶
buffers: list[Buffer]
Returns a list of Buffers given to the Worker via fn_args.
Returns:
| Type | Description |
|---|---|
list[Buffer]
|
list[Buffer]: Buffer used by the Worker. |
grid
staticmethod
¶
Build a 2D grid of Workers; factory(r, c) returns one Worker.
Replaces the common pattern::
ws = [Worker(...) for i in range(R) for j in range(C)]
ws[i * C + j] # 1-D index arithmetic
with::
ws = Worker.grid(R, C, lambda r, c: Worker(...))
ws[i][j] # natural 2-D access
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rows
|
int
|
Outer-dimension count (e.g. column index). |
required |
cols
|
int
|
Inner-dimension count (e.g. channel index). |
required |
factory
|
Callable[[int, int], Worker]
|
Called once per cell with |
required |
Returns:
| Type | Description |
|---|---|
list[list[Worker]]
|
|
Source code in python/iron/worker.py
WorkerRuntimeBarrier ¶
A barrier allowing individual workers to synchronize with the runtime sequence.
Initialize a WorkerRuntimeBarrier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
initial_value
|
int
|
The initial lock value. Defaults to 0. |
0
|
Source code in python/iron/worker.py
wait_for_value ¶
Should be called from inside a core function.
Wait for the barrier to be set to value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
int
|
The value to wait for. |
required |
Source code in python/iron/worker.py
release_with_value ¶
Release and decrement the barrier by value inside the core.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
int
|
The value to decrement by in Release. |
required |
Source code in python/iron/worker.py
ObjectFifo¶
ObjectFifo ¶
ObjectFifo(
obj_type: type[ndarray],
*,
depth: int | None = 2,
name: str | None = None,
dims_to_stream: StreamDims | None = None,
dims_from_stream_per_cons: StreamDims | None = None,
plio: bool = False,
pad_dimensions: PadDims | None = None,
disable_synchronization: bool = False,
repeat_count: int | None = None,
delegate_tile: Tile | None = None,
via_DMA: bool = False,
init_values: list[ndarray] | None = None,
consumer_obj_type: type[ndarray] | None = None,
aie_stream: tuple[int, int] | None = None
)
Bases: Resolvable
A synchronized, explicit dataflow channel between IRON program
components such as Workers and the Runtime.
Internally, an ObjectFifo is a circular buffer with a given depth and
element type. Its users are explicitly either a producer or a
consumer, and each user holds an ObjectFifoHandle
carrying its (possibly unplaced) tile.
Example
Construct an ObjectFifo.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj_type
|
type[ndarray]
|
The type of each buffer in the ObjectFifo |
required |
depth
|
int | None
|
The default depth of the ObjectFifo endpoints. Defaults to 2. |
2
|
name
|
str | None
|
The name of the ObjectFifo. If None is given, a unique name will be generated. Defaults to None. |
None
|
dims_to_stream
|
StreamDims | None
|
Data layout transformations applied when data is pushed onto the AXI stream, described as pairs of (size, stride) from highest to lowest dimension. Defaults to None. |
None
|
dims_from_stream_per_cons
|
StreamDims | None
|
List of data layout transformations applied by each consumer when data is read from the AXI stream, described as pairs of (size, stride) from highest to lowest dimension. Defaults to None. |
None
|
plio
|
bool
|
Whether the ObjectFifo uses PLIO connections. Defaults to False. |
False
|
disable_synchronization
|
bool
|
When True, disables lock-based synchronization on the ObjectFifo. Defaults to False. |
False
|
repeat_count
|
int | None
|
If set, causes the MemTile DMA to replay the buffer descriptor this many times without a new DMA transfer from L3. Distinct from |
None
|
delegate_tile
|
Tile | None
|
Shared-memory delegate tile. When set, the ObjectFifo's underlying buffer pool is allocated on this tile's memory module instead of the default placement. Lowers to |
None
|
init_values
|
list[ndarray] | None
|
Per-buffer static initial values for the producer endpoint. One ndarray per producer-side buffer; the producer tile must be able to hold static data at design startup (e.g. a MemTile). Lowers to the |
None
|
consumer_obj_type
|
type[ndarray] | None
|
Consumer element type for asymmetric transfer granularity. When set, the producer sends obj_type-sized transfers and the consumer receives consumer_obj_type-sized transfers. Producer element count must be an integer multiple of consumer element count. Defaults to None. |
None
|
aie_stream
|
tuple[int, int] | None
|
Mark the fifo as a direct AIE-stream connection by stamping the |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in python/iron/dataflow/objectfifo.py
depth
property
¶
The default depth of the ObjectFifo. This may be overridden by an ObjectFifoHandle upon construction.
dims_from_stream_per_cons
property
¶
The default dimensions from stream per consumer value. This may be overridden by an ObjectFifoHandle of type consumer.
dims_to_stream
property
¶
The dimensions to stream value. This will be shared by the ObjectFifoHandle of type producer.
dtype
property
¶
The per-element data type of each element in each buffer belonging to the ObjectFifo
obj_type
property
¶
The tensor type of each buffer belonging to the ObjectFifo
set_iter_count ¶
Set iteration count for DMA BD (Buffer Descriptor) chaining on MemTile for the ObjectFifo.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iter_count
|
int
|
Number of forward chain iterations. - Must be in range [1, 256]: Forward chain with specified number of iterations |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If iter_count is outside the valid range [1, 256] |
Source code in python/iron/dataflow/objectfifo.py
prod ¶
prod(
depth: int | None = None, channel: int | None = None
) -> ObjectFifoHandle
Returns an ObjectFifoHandle of type producer. Each ObjectFifo may have only one producer handle, so if one already exists, a new reference to this handle will be returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
depth
|
int | None
|
The depth of the buffers at the endpoint corresponding to the producer handle. Defaults to None. |
None
|
channel
|
int | None
|
Pin the producer endpoint's DMA channel instead of first-free assignment. Defaults to None (auto-assign). |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Arguments are validated |
ValueError
|
If depth was not specified on ObjectFifo construction, depth must be specified here. |
Returns:
| Name | Type | Description |
|---|---|---|
ObjectFifoHandle |
ObjectFifoHandle
|
The producer handle to this ObjectFifo. |
Source code in python/iron/dataflow/objectfifo.py
cons ¶
cons(
depth: int | None = None,
dims_from_stream: StreamDims | None = None,
channel: int | None = None,
) -> ObjectFifoHandle
Returns an ObjectFifoHandle of type consumer. Each ObjectFifo may have multiple consumers, so this will return a new consumer handle every time it is called.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
depth
|
int | None
|
The depth of the buffers at the endpoint corresponding to this consumer handle. Defaults to None. |
None
|
dims_from_stream
|
StreamDims | None
|
Dimensions from stream for this consumer. Defaults to None. |
None
|
channel
|
int | None
|
Pin this consumer endpoint's DMA channel instead of first-free assignment. Defaults to None (auto-assign). |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Arguments are validated |
Returns:
| Name | Type | Description |
|---|---|---|
ObjectFifoHandle |
ObjectFifoHandle
|
A consumer handle to this ObjectFifo. |
Source code in python/iron/dataflow/objectfifo.py
tiles ¶
The list of placement tiles corresponding to the endpoints of all handles of this ObjectFifo
Raises:
| Type | Description |
|---|---|
ValueError
|
A producer handle must be constructed. |
ValueError
|
At least one consumer handle must be constructed. |
Returns:
| Type | Description |
|---|---|
list[Tile]
|
list[Tile]: A list of tiles of the endpoints of this ObjectFifo. |
Source code in python/iron/dataflow/objectfifo.py
ObjectFifoHandle ¶
ObjectFifoHandle(
of: ObjectFifo,
is_prod: bool,
depth: int | None = None,
dims_from_stream: StreamDims | None = None,
channel: int | None = None,
)
Bases: Resolvable
A handle to an ObjectFifo, of type producer or consumer.
Producer and consumer handles are what Worker core
functions call acquire
and release on to
move data through the fifo. Obtain them via
ObjectFifo.prod() and
ObjectFifo.cons().
Construct an ObjectFifoHandle
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
of
|
ObjectFifo
|
The ObjectFifo to construct the handle for. |
required |
is_prod
|
bool
|
Whether the handle should be producer or consumer handle. |
required |
depth
|
int | None
|
The depth of the ObjectFifo at this endpoint. Defaults to None. |
None
|
dims_from_stream
|
StreamDims | None
|
A unique dimensions from stream. This is only valid for consumer handles. Defaults to None. |
None
|
channel
|
int | None
|
Pin this endpoint's DMA channel instead of first-free assignment. Defaults to None (auto-assign). |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Arguments are validated. |
Source code in python/iron/dataflow/objectfifo.py
channel
property
¶
The pinned DMA channel for this handle's endpoint, or None to auto-assign.
dims_from_stream
property
¶
The dimensions from stream of a consumer ObjectFifoHandle
endpoint
property
writable
¶
The endpoint of this ObjectFifoHandle
acquire ¶
Acquire access to some elements of the ObjectFifo, using ObjectFifo synchronization to moderate access.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_elem
|
int
|
Number of elements to acquire. If some elements are already acquired, only the additional elements needed to reach a total of |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
Number of elements cannot exceed ObjectFifo depth. |
Returns:
| Type | Description |
|---|---|
list
|
An indexable handle to the acquired elements: a single element when |
Source code in python/iron/dataflow/objectfifo.py
release ¶
Release access to some elements of the ObjectFifo, allowing the other endpoint of the ObjectFifo to acquire them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_elem
|
int
|
Number of elements to release. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
Number of elements cannot exceed ObjectFifo depth. |
Source code in python/iron/dataflow/objectfifo.py
all_of_endpoints ¶
All endpoints belonging to an ObjectFifo
join ¶
join(
offsets: list[int],
tile: Tile = AnyMemTile,
depths: list[int] | None = None,
obj_types: list[type[ndarray]] | None = None,
names: list[str] | None = None,
dims_to_stream: list[StreamDims] | None = None,
dims_from_stream: list[StreamDims] | None = None,
plio: bool = False,
repeat_counts: list[int | None] | None = None,
) -> list[ObjectFifo]
Construct multiple ObjectFifos which feed data into a ObjectFifoHandle. Note that this function is only valid for producer ObjectFifoHandles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offsets
|
list[int]
|
Offsets into the current producer, each corresponding to a new consumer. |
required |
tile
|
Tile
|
The tile where the Join operation occurs. Defaults to AnyMemTile. |
AnyMemTile
|
depths
|
list[int] | None
|
The depth of each new ObjectFifo. Defaults to None. |
None
|
obj_types
|
list[type[ndarray]]
|
The type of the buffers corresponding to each new ObjectFifo. Defaults to None. |
None
|
names
|
list[str] | None
|
The name of each new ObjectFifo. If not given, unique names will be generated. Defaults to None. |
None
|
dims_to_stream
|
list[list[Sequence[int] | None]] | None
|
The dimensionsToStream to assign to each new ObjectFifo. Defaults to None. |
None
|
dims_from_stream
|
list[list[Sequence[int] | None]] | None
|
The dimensionsFromStream to assign to each new ObjectFifo consumer. Defaults to None. |
None
|
plio
|
bool
|
Set plio on each new ObjectFifo. Defaults to False. |
False
|
repeat_counts
|
list[int | None] | None
|
Per-sub-fifo MemTile DMA repeat count (see ObjectFifo.repeat_count). Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Arguments are validated |
Returns:
| Type | Description |
|---|---|
list[ObjectFifo]
|
list[ObjectFifo]: A list of newly constructed ObjectFifos whose consumers are used in this join() operation. |
Source code in python/iron/dataflow/objectfifo.py
599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 | |
split ¶
split(
offsets: list[int],
tile: Tile = AnyMemTile,
depths: list[int] | None = None,
obj_types: list[type[ndarray]] | None = None,
names: list[str] | None = None,
dims_to_stream: list[StreamDims] | None = None,
dims_from_stream: list[StreamDims] | None = None,
plio: bool = False,
repeat_counts: list[int | None] | None = None,
) -> list[ObjectFifo]
Split the data from an ObjectFifoConsumer handle by sending it to producers in N newly constructed ObjectFifos. Note this operation is only valid for ObjectFifoHandles of type consumer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offsets
|
list[int]
|
The offset into the current consumer for each new ObjectFifo producer. |
required |
tile
|
Tile
|
The tile where the Split operation takes place. Defaults to AnyMemTile. |
AnyMemTile
|
depths
|
list[int] | None
|
The depth of each new ObjectFifo. Defaults to None. |
None
|
obj_types
|
list[type[ndarray]]
|
The buffer type of each new ObjectFifo. Defaults to None. |
None
|
names
|
list[str] | None
|
The name of each new ObjectFifo. If not given, a unique name will be generated. Defaults to None. |
None
|
dims_to_stream
|
list[StreamDims] | None
|
The dimensions to stream for each new ObjectFifo. Defaults to None. |
None
|
dims_from_stream
|
list[StreamDims] | None
|
The dimensions from stream for each new ObjectFifo. Defaults to None. |
None
|
plio
|
bool
|
Set plio on each new ObjectFifo. Defaults to False. |
False
|
repeat_counts
|
list[int | None] | None
|
Per-sub-fifo MemTile DMA repeat count (see ObjectFifo.repeat_count). Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Arguments are validated. |
Returns:
| Type | Description |
|---|---|
list[ObjectFifo]
|
list[ObjectFifo]: A list of newly constructed ObjectFifos whose producers are used in this split() operation. |
Source code in python/iron/dataflow/objectfifo.py
689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 | |
forward ¶
forward(
tile: Tile = AnyMemTile,
obj_type: type[ndarray] | None = None,
depth: int | None = None,
name: str | None = None,
dims_to_stream: StreamDims | None = None,
dims_from_stream: StreamDims | None = None,
plio: bool = False,
repeat_count: int | None = None,
) -> ObjectFifo
This is a special case of the split() operation where an ObjectFifoHandle of type consumer is forwarded to the producer of a newly-constructed ObjectFifo.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tile
|
Tile
|
The tile for the Forward operation. Defaults to AnyMemTile. |
AnyMemTile
|
obj_type
|
type[ndarray] | None
|
The object type of the new ObjectFifo. Defaults to None. |
None
|
depth
|
int | None
|
The depth of the new ObjectFifo. Defaults to None. |
None
|
name
|
str | None
|
The name of the new ObjectFifo. If None is given, a unique name will be generated. Defaults to None. |
None
|
dims_to_stream
|
StreamDims | None
|
The dimensions to stream for the new ObjectFifo. Defaults to None. |
None
|
dims_from_stream
|
StreamDims | None
|
The dimensions from stream for the new ObjectFifo. Defaults to None. |
None
|
plio
|
bool
|
Set plio on each new ObjectFifo. Defaults to False. |
False
|
repeat_count
|
int | None
|
MemTile DMA repeat count for the new ObjectFifo (see ObjectFifo.repeat_count). Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Arguments are Validated |
Returns:
| Name | Type | Description |
|---|---|---|
ObjectFifo |
ObjectFifo
|
A newly constructed ObjectFifo whose producer used in this forward() operation. |
Source code in python/iron/dataflow/objectfifo.py
ObjectFifoLink ¶
ObjectFifoLink(
srcs: list[ObjectFifoHandle] | ObjectFifoHandle,
dsts: list[ObjectFifoHandle] | ObjectFifoHandle,
tile: Tile = AnyMemTile,
src_offsets: list[int] | None = None,
dst_offsets: list[int] | None = None,
)
Bases: ObjectFifoEndpoint, Resolvable
This is an object used internally by split(), join() and forward() operations.
Construct an ObjectFifoLink. This is either a many-to-one, one-to-many, or one-to-one operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
srcs
|
list[ObjectFifoHandle] | ObjectFifoHandle
|
A list of consumer ObjectFifoHandles to link. |
required |
dsts
|
list[ObjectFifoHandle] | ObjectFifoHandle
|
A list of producer ObjectFifoHandles to link. |
required |
tile
|
Tile
|
The tile where the link occurs. Also accepts None (treated as AnyMemTile). Defaults to AnyMemTile. |
AnyMemTile
|
src_offsets
|
list[int] | None
|
If many sources, one offset per source is required to split the destination. Defaults to None (empty list). |
None
|
dst_offsets
|
list[int] | None
|
If many destinations, one offset per destination is required to split the source. Defaults to None (empty list). |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Arguments are validated. |
Source code in python/iron/dataflow/objectfifo.py
Runtime¶
The host-side orchestration entry point that declares fill / drain /
start operations via rt.sequence(...).
Runtime: orchestrates host-side data movement and worker execution for an IRON program.
IronRuntimeError ¶
Bases: Exception
Raised by the IRON Runtime when resolution encounters an unrecoverable state.
Runtime ¶
Bases: Resolvable
The host-side sequence of data-movement and worker-start operations that execute an IRON design.
A Runtime describes what the host does at runtime: filling input
ObjectFifos with data, starting
Workers, and draining results back to host buffers.
Operations are declared inside a sequence
context.
Initialize a runtime object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strict_task_groups
|
bool
|
Disallows mixing the default group and explicit task groups during resolution. This can catch common errors, but can be set to False to disable the checks. |
True
|
Source code in python/iron/runtime/runtime.py
workers
property
¶
workers: list[Worker]
The workers associated with the Runtime by calls to start()
fifos
property
¶
The ObjectFifoHandles associated with the Runtime by calls to fill() and drain()
add_flow ¶
Register an explicit Flow (or
PacketFlow) so the Program resolves it alongside
the ObjectFifos.
add_lock ¶
add_tile_dma ¶
sequence ¶
A RuntimeSequence is a sequence of operations that are performed in support of a program. Common operations include input and output data movement.
Raises:
| Type | Description |
|---|---|
ValueError
|
Arguments are validated. |
ValueError
|
If task groups are not finished within the sequence() context, and error will be raised. |
Yields:
| Type | Description |
|---|---|
RuntimeData | tuple[RuntimeData, ...]
|
RuntimeData | tuple[RuntimeData, ...]: Handles to the runtime buffers matching the declared input types. |
Source code in python/iron/runtime/runtime.py
task_group ¶
task_group() -> RuntimeTaskGroup
Generate a handle to a RuntimeTaskGroup. This should be called within a Runtime.sequence() context.
Returns:
| Name | Type | Description |
|---|---|---|
RuntimeTaskGroup |
RuntimeTaskGroup
|
The new RuntimeTaskGroup |
Source code in python/iron/runtime/runtime.py
finish_task_group ¶
finish_task_group(task_group: RuntimeTaskGroup)
Close out a RuntimeTaskGroup. This should be called within a Runtime.sequence() context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_group
|
RuntimeTaskGroup
|
The task group to close. All associated tasks will be awaited or freed. |
required |
Source code in python/iron/runtime/runtime.py
fill ¶
fill(
in_fifo: ObjectFifoHandle,
source: RuntimeData,
tap: TensorAccessPattern | None = None,
task_group: RuntimeTaskGroup | None = None,
wait: bool = False,
tile: Tile = AnyShimTile,
packet: tuple[int, int] | None = None,
offset_parameter: "ScratchpadParameter | str | None" = None,
) -> None
Conceptually fill an ObjectFifoHandle (of type producer) with data from a runtime buffer. This should be called within a Runtime.sequence() context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_fifo
|
ObjectFifoHandle
|
The producer ObjectFifoHandle. |
required |
source
|
RuntimeData
|
The input Runtime data buffer. |
required |
tap
|
TensorAccessPattern | None
|
A way of specifying how data in the buffer is accessed when sending it to the in_fifo. If None is given, this will default to a linear transfer containing all data in the source buffer. Defaults to None. |
None
|
task_group
|
RuntimeTaskGroup | None
|
A TaskGroup to associate this task with. Defaults to None. |
None
|
wait
|
bool
|
Whether this Task should be awaited on or not. If not, it will be freed when the task group is finished. Defaults to False. |
False
|
tile
|
Tile | None
|
The Shim tile to associate the data transfer with. Defaults to AnyShimTile. |
AnyShimTile
|
packet
|
tuple[int, int] | None
|
Stamp the shim DMA's BD
with a packet header |
None
|
offset_parameter
|
ScratchpadParameter | str | None
|
A ScratchpadParameter (or its name) whose value is used as the element offset for this DMA transfer. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Arguments are validated. |
Source code in python/iron/runtime/runtime.py
drain ¶
drain(
out_fifo: ObjectFifoHandle,
dest: RuntimeData,
tap: TensorAccessPattern | None = None,
task_group: RuntimeTaskGroup | None = None,
wait: bool = False,
tile: Tile = AnyShimTile,
packet: tuple[int, int] | None = None,
offset_parameter: "ScratchpadParameter | str | None" = None,
) -> None
Conceptually drain an ObjectFifoHandle (of type consumer): read data from the ObjectFifo and write it to a runtime buffer. This should be called within a Runtime.sequence() context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
out_fifo
|
ObjectFifoHandle
|
The consumer ObjectFifoHandle. |
required |
dest
|
RuntimeData
|
The output Runtime data buffer. |
required |
tap
|
TensorAccessPattern | None
|
A way of specifying how data in the buffer is accessed when reading from the out_fifo. If None is given, this will default to a linear transfer containing all data in the destination buffer. Defaults to None. |
None
|
task_group
|
RuntimeTaskGroup | None
|
A TaskGroup to associate this task with. Defaults to None. |
None
|
wait
|
bool
|
Whether this Task should be awaited on or not. If not, it will be freed when the task group is finished. Defaults to False. |
False
|
tile
|
Tile | None
|
The Shim tile to associate the data transfer with. Defaults to AnyShimTile. |
AnyShimTile
|
packet
|
tuple[int, int] | None
|
Stamp the shim DMA's BD
with a packet header |
None
|
offset_parameter
|
ScratchpadParameter | str | None
|
A ScratchpadParameter (or its name) whose value is used as the element offset for this DMA transfer. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Arguments are validated. |
Source code in python/iron/runtime/runtime.py
start ¶
start(*args: Worker)
A placeholder operation to indicate that one or more Worker should be started on the device. This should be called within a Runtime.sequence() context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Worker
|
One or more Workers. If more than one is given, they will be started in order. |
()
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Arguments are validated. |
Source code in python/iron/runtime/runtime.py
inline_ops ¶
Insert an InlineOpRuntimeTask into the runtime. This should be called within a Runtime.sequence() context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inline_func
|
Callable
|
The function to execute within an MLIR context. |
required |
inline_args
|
list
|
The state the function needs to execute. Any ObjectFifoHandle passed here is registered with the Runtime (so the Program resolves its shim allocation) and, if it has no endpoint yet, is bound to a shim tile -- an inline op driving a fifo from the runtime sequence is a host-side (shim) endpoint. This mirrors how InlineOpRuntimeTask resolves Buffer args. |
required |
Source code in python/iron/runtime/runtime.py
enable_trace ¶
enable_trace(
trace_size: int | None = None,
workers: list | None = None,
reuse_output_buffer: bool = False,
coretile_events: list | None = None,
coremem_events: list | None = None,
memtile_events: list | None = None,
shimtile_events: list | None = None,
egress_shim_col: int = 0,
)
Enable hardware tracing for this program.
Configures the AIE trace units and routes trace packets to DDR via the shim DMA.
Should be called within a sequence context before data movement operations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace_size
|
int
|
Size of the trace buffer in bytes. |
None
|
workers
|
list[Worker] | None
|
Specific workers to trace. If None,
all workers with |
None
|
reuse_output_buffer
|
bool
|
When False (default), trace lowering appends a dedicated trace-buffer argument to the runtime_sequence; it lands at the tail so enabling trace never perturbs the data arguments' indices. When True, trace data is written into the tail of the last output buffer, saving a host buffer. Defaults to False. |
False
|
coretile_events
|
list | None
|
List of up to 8 core tile trace events. See the AIEX dialect reference for available events under (type)EventAIE such as CoreEventAIE. Defaults to None (uses hardware defaults). |
None
|
coremem_events
|
list | None
|
List of up to 8 core memory trace events. Defaults to None (uses hardware defaults). |
None
|
memtile_events
|
list | None
|
List of up to 8 mem tile trace events. Defaults to None (uses hardware defaults). |
None
|
shimtile_events
|
list | None
|
List of up to 8 shim tile trace events. Defaults to None (uses hardware defaults). |
None
|
egress_shim_col
|
int
|
Column of the shim tile used to egress trace packets to DDR. Defaults to 0. |
0
|
Source code in python/iron/runtime/runtime.py
set_barrier ¶
set_barrier(barrier: WorkerRuntimeBarrier, value: int)
Set the value of a worker barrier. This should be called within a Runtime.sequence() context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
barrier
|
WorkerRuntimeBarrier
|
The WorkerRuntimeBarrier to set. |
required |
value
|
int
|
The value to set the barrier to. |
required |
Source code in python/iron/runtime/runtime.py
sync_parameters ¶
Emit aiex.sync_scratchpad_parameters_from_host in the runtime sequence.
Call this within a sequence context after all
parameters have been written on the host side and before starting
workers that read them.
Source code in python/iron/runtime/runtime.py
Buffer¶
Named memory region accessible by both Workers and the Runtime.
Buffer ¶
Buffer(
type: type[ndarray] | None = None,
initial_value: ndarray | None = None,
name: str | None = None,
tile: Tile | None = None,
use_write_rtp: bool = False,
address: int | None = None,
)
Bases: Resolvable
A buffer that is available both to Workers and to the Runtime for operations. This is often used for Runtime Parameters.
A Buffer is a memory region declared at the top-level of the design, allowing it to be accessed by both Workers and the Runtime.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type
|
type[ndarray] | None
|
The type of the buffer. Defaults to None. |
None
|
initial_value
|
ndarray | None
|
An initial value to set the buffer to. Should be of same datatype and shape as the buffer. Defaults to None. |
None
|
name
|
str | None
|
The name of the buffer. If none is given, a unique name will be generated. Defaults to None. |
None
|
tile
|
Tile | None
|
The tile for the buffer. Automatically set to the Worker's tile when the buffer is passed in the Worker's fn_args list. Defaults to None. |
None
|
use_write_rtp
|
bool
|
If use_write_rtp, write_rtp/read_rtp operations will be generated. Otherwise, traditional write/read operations will be used. Defaults to False. |
False
|
address
|
int | None
|
Pin the buffer to a fixed L1 address. Needed for host-written RTP buffers the runtime pokes at a hardcoded address. Defaults to None (compiler-assigned). |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither |
Source code in python/iron/buffer.py
tiles ¶
Tile dependency for Program.resolve tile discovery.
Pinned Buffers (e.g. a compute Worker reading a
neighbor tile's L1 directly) need their tile registered with the
Device before resolve runs. Worker-attached Buffers without an
explicit placement get pinned to the Worker's tile in
Worker's constructor, which is already discoverable
via Worker.tile; this method just exposes any extra (cross-tile)
placements.
Source code in python/iron/buffer.py
Kernels¶
Kernel and ExternalFunction: wrappers for pre-compiled and C++ AIE compute kernels.
BaseKernel ¶
Bases: Resolvable
Base class for AIE core functions that resolve to a func.func declaration.
Subclasses
Kernel: wraps a pre-compiled object file. ExternalFunction: compiles C/C++ source at JIT time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Symbol name of the function. |
required |
arg_types
|
list[type[ndarray] | dtype] | None
|
Type signature of the function arguments. Defaults to None (empty list). |
None
|
Source code in python/iron/kernel.py
arg_shape ¶
Return the shape tuple of the array argument at arg_index.
Works for both np.ndarray[(...,), np.dtype[T]] parameterized
types (the canonical IRON kernel signature) and MLIR MemRefType
operands.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
arg_index
|
int
|
Index into |
0
|
Raises:
| Type | Description |
|---|---|
ValueError
|
When |
Source code in python/iron/kernel.py
arg_dtype ¶
Return the numpy dtype of the array argument at arg_index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
arg_index
|
int
|
Index into |
0
|
Raises:
| Type | Description |
|---|---|
ValueError
|
When |
Source code in python/iron/kernel.py
tile_size ¶
Return the first dimension of the array argument at arg_index.
Convenience wrapper over
arg_shape for the common case of
a 1-D buffer argument. tile_size(i) is equivalent to
arg_shape(i)[0].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
arg_index
|
int
|
Index into |
0
|
Source code in python/iron/kernel.py
Kernel ¶
Bases: BaseKernel
An AIE core function backed by a pre-compiled object file.
Use ExternalFunction instead when you want to
compile from C/C++ source at JIT time.
resolve() emits a func.func private declaration with a
link_with attribute naming object_file_name. The
aie-assign-core-link-files pass propagates this into the CoreOp's
link_files attribute so the linker knows which file to include.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Symbol name of the function as it appears in the object file. |
required |
object_file_name
|
str
|
Filename of the pre-compiled object file
(e.g. |
required |
arg_types
|
list[type[ndarray] | dtype] | None
|
Type signature of the function arguments. Defaults to None (empty list). |
None
|
Source code in python/iron/kernel.py
ExternalFunction ¶
ExternalFunction(
name: str,
object_file_name: str | None = None,
source_file: str | None = None,
source_string: str | None = None,
arg_types: list[type[ndarray] | dtype] | None = None,
include_dirs: list[str] | None = None,
compile_flags: list[str] | None = None,
*,
symbol_prefix: str | None = None,
use_chess: bool = False
)
Bases: Kernel
An AIE core function compiled from C/C++ source at JIT time.
Each instance is registered in _instances at construction time so that
the @jit decorator can discover and compile all source files before
invoking the MLIR compilation pipeline. _instances is cleared at the
start of each @jit call to prevent stale registrations from a previous
(possibly failed) run.
Use the base Kernel class instead when you have a
pre-built object file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Symbol name of the function as it will appear in the object file. |
required |
object_file_name
|
str | None
|
Output object file name. Defaults to
|
None
|
source_file
|
str | None
|
Path to a C/C++ source file on disk. Mutually
exclusive with |
None
|
source_string
|
str | None
|
Inline C/C++ source code. Mutually exclusive with
|
None
|
arg_types
|
list[type[ndarray] | dtype] | None
|
Type signature of the function arguments. Defaults to None (empty list). |
None
|
include_dirs
|
list[str] | None
|
Additional |
None
|
compile_flags
|
list[str] | None
|
Additional flags passed verbatim to the chosen compiler. Defaults to None (empty list). |
None
|
symbol_prefix
|
str | None
|
Optional prefix for the exported symbol name. When
set, the effective symbol name becomes |
None
|
use_chess
|
bool
|
When |
False
|
Source code in python/iron/kernel.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | |
ScratchpadParameter¶
ScratchpadParameter: a named runtime value set from the host and read by Workers.
ScratchpadParameter ¶
Bases: Resolvable
A named runtime parameter communicated from host to AIE cores via the scratchpad mechanism.
Declare a ScratchpadParameter at design time. Pass it to a
Worker via fn_args and call
read inside the
core_fn to obtain its current value. The
--aie-lower-scratchpad-parameters pass automatically inserts the
necessary lock and scratchpad-sync preamble ops.
Example
import numpy as np
from aie.iron import ScratchpadParameter, Worker, Runtime, Program
seq_len = ScratchpadParameter("seq_len", np.int32)
def core_body(p):
v = p.read()
...
worker = Worker(core_body, [seq_len])
rt = Runtime()
with rt.sequence(output_type) as out:
# The compiler automatically inserts the parameter-sync preamble.
...
Create a ScratchpadParameter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Symbol name for the parameter (must be unique within the device). |
required |
dtype
|
NpuDType
|
The numpy scalar type (e.g. |
required |
Source code in python/iron/scratchpad_parameter.py
read ¶
Emit aiex.read_scratchpad_parameter inside a core body.
Must be called within an active MLIR insertion point (i.e. inside a
Worker's core_fn).
Returns:
| Type | Description |
|---|---|
Value
|
An MLIR SSA value of the parameter's type. |
Source code in python/iron/scratchpad_parameter.py
resolve ¶
Emit aiex.scratchpad_parameter @name : type at module scope.
Source code in python/iron/scratchpad_parameter.py
Compile-time & JIT¶
Decorators and markers for JIT-compiling a design and injecting compile-time
constants. These are re-exported into iron from aie.utils.
Note
The JIT entry point and tensor factories below are thin re-exports from
the compiled aie.utils package. Their full signatures and source are
available in the running package; the summaries here describe the public
contract.
| Symbol | Kind | Summary |
|---|---|---|
iron.jit |
decorator | JIT-compile a design and run it on the attached NPU (Triton-style). The first call compiles to an xclbin + instruction stream; later calls hit a cache. |
iron.CompilableDesign |
class | Bundle a design generator with its compile-time configuration. |
iron.CallableDesign |
class | A compiled, callable design produced from a CompilableDesign. |
iron.compileconfig |
decorator | Attach compile-time configuration to a design generator. |
iron.get_compile_arg |
function | Dynamically inject a compile-time argument (advanced). |
iron.In / iron.Out / iron.InOut |
markers | Type-annotation markers for design inputs/outputs. |
iron.CompileTime |
marker | Type-annotation marker for a compile-time constant argument. |
See the Programming Guide for worked
examples of @iron.jit.
Tensor factories¶
NumPy-like helpers that allocate NPU-accessible host tensors. Re-exported
into iron from aie.utils.
| Symbol | Summary |
|---|---|
iron.tensor |
Wrap existing data as an NPU-accessible tensor. |
iron.arange |
NPU-accessible analogue of numpy.arange. |
iron.zeros / iron.ones / iron.full |
Allocate a tensor filled with 0, 1, or a constant. |
iron.zeros_like |
Allocate a zero tensor matching another's shape/dtype. |
iron.rand / iron.randint |
Allocate a tensor of random floats / integers. |
Device management¶
| Symbol | Summary |
|---|---|
iron.get_current_device |
Return the currently selected NPU device. |
iron.set_current_device |
Select the NPU device for subsequent allocations. |
iron.ensure_current_device |
Raise if no device is currently selected. |
Data type helpers¶
Utilities for converting between short string names and numpy dtype objects.
str_to_dtype ¶
Convert a string representation of a data type to its corresponding dtype object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dtype_str
|
str
|
The string representation of the data type. |
required |
Returns:
| Type | Description |
|---|---|
type
|
The corresponding numpy/ml_dtypes type object. |
Source code in python/iron/dtype.py
dtype_to_str ¶
Convert a dtype object to its string representation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dtype
|
type
|
The dtype object to convert. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The string representation of the dtype. |
Source code in python/iron/dtype.py
Advanced primitives¶
Still part of the high-level aie.iron API — every object here is resolvable —
but reach for these only when the managed ObjectFifo
abstraction is not enough and you need explicit control over routing, DMA
descriptors, and locks.
Flow / PacketFlow¶
Circuit-switched (Flow) and packet-switched
(PacketFlow) stream connections, plus the
PacketDest endpoint descriptor.
IRON-level circuit- and packet-switched route primitives.
Two classes live here: Flow (circuit-switched) and
PacketFlow (packet-switched, with explicit packet IDs),
plus the small PacketDest dataclass PacketFlow uses for
its destination list. They share a private _emit_shim_dma_alloc
helper and are treated as a sibling pair by dataflow/__init__.py;
splitting them across two modules would either duplicate the helper
or require a third file to hold it.
Both are peers of ObjectFifo in the dataflow namespace.
ObjectFifo wraps route + buffers + locks + DMA into one
circular-buffer abstraction; Flow / PacketFlow are the
lower-level "just declare the route" primitives, paired with explicit
TileDma programs (and Buffer /
Lock shared state) for designs that need direct control.
Flow ¶
Flow(
src: Tile,
dst: Tile,
*,
src_port: WireBundle = DMA,
src_channel: int = 0,
dst_port: WireBundle = DMA,
dst_channel: int = 0,
shim_symbol: str | None = None
)
Bases: Resolvable
An explicit AXI-stream route between (src_tile, src_port, src_channel) and (dst_tile, dst_port, dst_channel).
Lowers to a single aie.flow op. The user is responsible for
arranging matching TileDma channels on the producer and
consumer ends.
Construct a Flow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
Tile
|
The source tile. |
required |
dst
|
Tile
|
The destination tile. |
required |
src_port
|
WireBundle
|
The source port bundle. Defaults to DMA. |
DMA
|
src_channel
|
int
|
The source channel. Defaults to 0. |
0
|
dst_port
|
WireBundle
|
The destination port bundle. Defaults to DMA. |
DMA
|
dst_channel
|
int
|
The destination channel. Defaults to 0. |
0
|
shim_symbol
|
str | None
|
When this Flow has a shim endpoint that
will be driven from the runtime sequence (via
|
None
|
Source code in python/iron/dataflow/flow.py
PacketDest
dataclass
¶
One destination endpoint of a PacketFlow. Held as a
small dataclass so the PacketFlow constructor's destination list reads
cleanly when there are multiple sinks (uncommon, but the underlying op
supports it).
PacketFlow ¶
PacketFlow(
pkt_id: int,
src: Tile,
dst: Tile,
*,
src_port: WireBundle = DMA,
src_channel: int = 0,
dst_port: WireBundle = DMA,
dst_channel: int = 0,
extra_dsts: Sequence[PacketDest] = (),
keep_pkt_header: bool = False,
shim_symbol: str | None = None
)
Bases: Resolvable
An explicit packet-switched route with caller-controlled pkt_id.
Peer of Flow for the packet-switched case. Unlike the
--packet-sw-objFifos global lowering (which auto-assigns sequential
packet IDs to every ObjectFifo in the design), PacketFlow
exposes the packet ID directly so the same ID can be reused across
stages and used as a routing decision (e.g. memtile dispatch by
pkt_id to one of several compute cores).
Lowers to a single aie.packetflow op containing one
aie.packet_source and one or more aie.packet_dest ops in its
region.
Construct a PacketFlow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pkt_id
|
int
|
The packet ID — the same byte the routing fabric uses to dispatch. Caller controls the value (often reused across stages so a memtile can re-emit packets keeping the original ID for downstream routing). |
required |
src
|
Tile
|
Source tile. |
required |
dst
|
Tile
|
Primary destination tile. |
required |
src_port
|
WireBundle
|
Source port bundle (as for |
DMA
|
src_channel
|
int
|
Source channel (as for |
0
|
dst_port
|
WireBundle
|
Destination port bundle (as for |
DMA
|
dst_channel
|
int
|
Destination channel (as for |
0
|
extra_dsts
|
Sequence[PacketDest]
|
Additional destination endpoints if this packet needs
to fan out. Each is a |
()
|
keep_pkt_header
|
bool
|
If |
False
|
shim_symbol
|
str | None
|
Same meaning as on |
None
|
Source code in python/iron/dataflow/flow.py
CascadeFlow¶
Directed cascade-stream connection between two adjacent Workers.
CascadeFlow: a directed cascade stream connection between two Workers.
CascadeFlow ¶
Bases: Resolvable
A directed cascade stream connection from one Worker to another.
Construct one of these for each cascade edge in your design::
CascadeFlow(producer_worker, consumer_worker)
Lowers to aie.cascade_flow(producer.tile, consumer.tile) after both
Workers are placed. The kernel functions are responsible for using the
put_mcd / get_scd intrinsics to actually drive/read the cascade
stream — this object only declares the directed topology edge.
Hardware constraints (enforced by the underlying op verifier):
- Source and destination tiles must be cardinal-adjacent.
- Each compute tile has at most one cascade input (from N or W) and one cascade output (to S or E). Multiple cascade outputs from the same tile will fail at lowering, not at construction.
- ShimTiles and MemTiles do not have cascade interfaces.
Discovery: each newly-constructed CascadeFlow registers itself on its
source Worker's _outgoing_cascades list. Program.resolve()
walks the runtime's workers and resolves each worker's outgoing
cascades after placement — no global registry, no drain step.
Construct a CascadeFlow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
'Worker'
|
Source |
required |
dst
|
'Worker'
|
Destination |
required |
Source code in python/iron/dataflow/cascadeflow.py
resolve ¶
TileDma / DmaChannel / Bd¶
Explicit tile DMA programs: TileDma,
DmaChannel, buffer descriptors (Bd), and the
Acquire / Release lock actions.
IRON-level explicit per-tile DMA program.
Peer of Worker (which describes the compute body of a tile).
A TileDma describes the DMA engine program for the same (or
a different) tile — what each hardware DMA channel does, which buffers
it reads/writes, and how it synchronizes with the compute side via
locks.
Used together with Flow / PacketFlow
(which describe the AXI-stream routes) and explicit Buffer
+ Lock declarations, for designs where
ObjectFifo would hide too much to be useful.
Acquire
dataclass
¶
Acquire(
lock: Lock, value: int = 1, greater_equal: bool = True
)
An aie.use_lock(..., AcquireGreaterEqual|Acquire) op at the start of a BD.
Release
dataclass
¶
Release(lock: Lock, value: int = 1)
An aie.use_lock(..., Release) op at the end of a BD.
Bd
dataclass
¶
Bd(
buffer: Buffer,
offset: int = 0,
length: int | None = None,
acquires: list[Acquire] = list(),
releases: list[Release] = list(),
next: int | str | None = "self",
packet: tuple[int, int] | None = None,
sizes: list = list(),
strides: list = list(),
)
A single buffer-descriptor entry in a DmaChannel's chain.
Lowers to one basic block containing acquires + aie.dma_bd +
releases + an aie.next_bd. The next field selects what the
next_bd points at:
"self"(default) — the BD loops to itself (the common "keep streaming" pattern).- an
inti— point at the i-th BD in this channel'sbdslist (zero-based). Useful for explicit cycles in a multi-BD chain. None— emit nonext_bd(rarely useful; this leaves the basic block without a terminator).
DmaChannel
dataclass
¶
DmaChannel(
direction: DMAChannelDir, channel: int, bds: list[Bd]
)
One hardware DMA channel on a tile, with its BD chain.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
direction
|
DMAChannelDir
|
|
required |
channel
|
int
|
hardware channel index. |
required |
bds
|
list[Bd]
|
ordered list of |
required |
TileDma ¶
TileDma(tile: Tile, channels: Iterable[DmaChannel])
Bases: Resolvable
Per-tile DMA program — lowers to an aie.mem (compute tile),
aie.memtile_dma (memtile), or aie.shim_dma (shim tile) region
based on the tile's type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tile
|
Tile
|
the tile whose DMA hardware this program targets. |
required |
channels
|
Iterable[DmaChannel]
|
ordered list of |
required |
Source code in python/iron/dataflow/tile_dma.py
all_buffers_and_locks ¶
Iterate every Buffer + Lock this program touches — Program uses this to make sure they're all resolved before us.
Source code in python/iron/dataflow/tile_dma.py
Lock¶
IRON-level Lock primitive — a named aie.lock on a specific tile.
Pairs with Buffer for designs that wire DMA / compute
synchronization explicitly (via TileDma and
Flow) instead of letting ObjectFifo
manage it.
Lock ¶
Bases: Resolvable
A named hardware lock on a specific tile.
Construct a Lock.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tile
|
Tile
|
The tile that owns this lock. |
required |
lock_id
|
int | None
|
Hardware lock ID; passed straight through to
the underlying |
None
|
init
|
int
|
Initial lock value at design startup. Defaults to 0. |
0
|
name
|
str | None
|
Symbol name for the lock. A unique name is generated if not provided. |
None
|
Source code in python/iron/lock.py
acquire ¶
Emit aie.use_lock(self, AcquireGreaterEqual, value=value).
The default AcquireGreaterEqual mode matches what almost every
ObjectFifo / DMA-driven design wants; use
acquire_exact for the rarer
Acquire (exact-equality) mode.
Source code in python/iron/lock.py
acquire_exact ¶
Runtime tasks¶
Lower-level runtime task types scheduled by the
Runtime.
RuntimeTask ¶
RuntimeTask(task_group: RuntimeTaskGroup | None = None)
Bases: Resolvable
A RuntimeTask is a task to be performed during runtime. A task may be synchronous or asynchronous.
Construct a RuntimeTask. It may be associated with a RuntimeTaskGroup.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_group
|
RuntimeTaskGroup | None
|
The TaskGroup associated with this task. Defaults to None. |
None
|
Source code in python/iron/runtime/task.py
task_group
property
¶
task_group: RuntimeTaskGroup | None
The RuntimeTaskGroup associated with this task.
FinishTaskGroupTask ¶
FinishTaskGroupTask(task_group: RuntimeTaskGroup)
Bases: RuntimeTask
A Task indicating the task_group should be finished(), which generally means it's tasks should be waited on and freed.
Source code in python/iron/runtime/task.py
RuntimeStartTask ¶
RuntimeStartTask(
worker: Worker,
task_group: RuntimeTaskGroup | None = None,
)
Bases: RuntimeTask
A StartTask is a placeholder to indicated that a Worker should be started
Source code in python/iron/runtime/task.py
InlineOpRuntimeTask ¶
InlineOpRuntimeTask(
fn: Callable,
args: list,
task_group: RuntimeTaskGroup | None = None,
)
Bases: RuntimeTask
An InlineOpRuntimeTask is a way of submitting arbitrary operations to a runtime that are defined in a lower-level style of IRON. This can be especially useful for tracing.
Construct an InlineOpRuntimeTask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fn
|
Callable
|
The function that will generate ops. It will be run within an MLIR module context. |
required |
args
|
list
|
The arguments for the task: this should included objects such as Buffers used by the function. |
required |
task_group
|
RuntimeTaskGroup | None
|
The TaskGroup to associated these operation with. Defaults to None. |
None
|
Source code in python/iron/runtime/task.py
RuntimeTaskGroup: a tag for grouping related RuntimeTasks for concurrent execution.
RuntimeTaskGroup ¶
A RuntimeTaskGroup is a structured tag to indicate groupings of RuntimeTasks.
Construct a RuntimeTaskGroup
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
The id of the task group. The id should be unique to tasks groups within a Runtime. |
required |
Source code in python/iron/runtime/taskgroup.py
DMATask: a RuntimeTask that generates a shim DMA transfer operation.
DMATask ¶
DMATask(
object_fifo: ObjectFifoHandle,
rt_data: RuntimeData,
tap: TensorAccessPattern,
task_group: RuntimeTaskGroup | None = None,
wait: bool = False,
offset_parameter: str | None = None,
packet: tuple[int, int] | None = None,
)
Bases: RuntimeTask
A RuntimeTask that will resolve to a DMA Operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
object_fifo
|
ObjectFifoHandle
|
The ObjectFifoHandle associated with the operation |
required |
rt_data
|
RuntimeData
|
The Runtime buffer associated with the operation. |
required |
tap
|
TensorAccessPattern
|
The access pattern associated with the operation. |
required |
task_group
|
RuntimeTaskGroup | None
|
The task group associated with the operation. Defaults to None. |
None
|
wait
|
bool
|
Whether this task should conclude with a call to await or a call to free. Defaults to False. |
False
|
offset_parameter
|
str | None
|
Name of a ScratchpadParameter whose value is used as the element offset for this DMA transfer. Defaults to None. |
None
|
packet
|
tuple[int, int] | None
|
Stamp the shim DMA's
BD with a packet header |
None
|
Source code in python/iron/runtime/dmatask.py
task
property
¶
The MLIR op generated by resolve(). This handle is used after resolution for await or free operations as dictated by a RuntimeTaskGroup Finish operation