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, workers: list | None = None
)
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 |
workers
|
list[Worker] | None
|
The Workers to run on the device. Defaults to None (no workers). Workers are passed here explicitly rather than started from within the runtime sequence. |
None
|
Source code in python/iron/program.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. Lives on Program (not Runtime) because it configures both the traced Workers' tiles and the Runtime's trace-buffer sequencing.
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/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
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 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | |
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
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 | |
flat_fn_args
property
¶
fn_args with any nested lists/tuples flattened to their leaves.
Use this (not fn_args) when iterating to register/resolve individual
arguments; fn_args keeps its structure for the core_fn call.
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
set ¶
Set the barrier to value from within a runtime sequence body.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
int
|
The value to set the barrier to. |
required |
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,
tile: Tile | 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
|
tile
|
Tile | None
|
When this handle drives an ObjectFifo
from the runtime (passed in |
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,
tile: Tile | 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
|
tile
|
Tile | None
|
When this handle drains an ObjectFifo to
the runtime (passed in |
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,
tile: Tile | 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
|
tile
|
Tile | None
|
Shim tile for a runtime-driven endpoint (see prod()/cons()). Defaults to None. |
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
fill ¶
fill(
source,
tap=None,
wait: bool = False,
packet: tuple[int, int] | None = None,
offset_parameter=None,
group=None,
sizes=None,
strides=None,
offset=None,
transfer_len=None,
managed: bool = True,
)
Fill this producer ObjectFifo with data from the source runtime buffer.
Call from within a Runtime sequence body on a producer
handle. See _emit_transfer for the shared arguments; returns a
Task handle to the transfer.
Source code in python/iron/dataflow/objectfifo.py
drain ¶
drain(
dest,
tap=None,
wait: bool = False,
packet: tuple[int, int] | None = None,
offset_parameter=None,
group=None,
sizes=None,
strides=None,
offset=None,
transfer_len=None,
managed: bool = True,
)
Drain this consumer ObjectFifo, writing data to the dest runtime buffer.
Call from within a Runtime sequence body on a consumer
handle. See _emit_transfer for the shared arguments; returns a
Task handle to the transfer.
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
806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 | |
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
896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 | |
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. Its fill / drain operations
are declared in the sequence body passed to Runtime(seq, fn_args);
Workers are passed to Program(workers=...) rather than started from the body.
Runtime: orchestrates host-side data movement and worker execution for an IRON program.
The runtime sequence is written as a callback body -- a plain Python function
whose parameters are the runtime I/O buffers (and, optionally, runtime scalars).
The body runs eagerly inside @runtime_sequence at resolve time, mirroring how
Worker.core_fn runs inside @core. Because the body executes with live MLIR
values in scope, it can use native range_/if_ control flow with
fill/drain verbs nested inside -- the dynamic path lowers these to
scf.for/scf.if (EmitC C++ TXN), and the static path (Python range/int
bounds) elaborates to a flat binary sequence.
IronRuntimeError ¶
Bases: Exception
Raised by the IRON Runtime when resolution encounters an unrecoverable state.
ActiveSequence ¶
The state of a runtime sequence body while it is being emitted.
The body's data-movement verbs (fifo.fill/fifo.drain) and
TaskGroup reach this object through the active-sequence ContextVar
(see _context) rather than a threaded rt reference, so the body
signature carries only the runtime buffers.
The body runs exactly once, inside the runtime_sequence op: each verb
both binds its ObjectFifo's shim endpoint and emits the shim DMA. The DMA
references the fifo by symbol name (a legal MLIR forward reference), so it
does not require the fifo to be resolved yet -- the Program resolves fifos
and cores afterward, with every runtime endpoint already bound.
Source code in python/iron/runtime/runtime.py
note_fifo ¶
finish_task_group ¶
finish_task_group(tg: TaskGroup) -> None
Close a task group: await its waited tasks, then free the rest.
Waits are ordered before frees within the group, matching the hardware-safe order the old flat-list runtime used.
Source code in python/iron/runtime/runtime.py
emit_transfer ¶
Emit a DMA transfer and record its await/free action(s) for group close.
A waited transfer is both awaited and freed: the dynamic BD-pool pass only returns an id to the runtime free-list on an explicit free (an await is a pure TCT sync), so a waited-but-never-freed task would leak a pool slot on every rolled-loop iteration. Matches the static path's long-standing "await implies release" convention -- it just does so with an explicit free instead of folding it into the await.
Source code in python/iron/runtime/runtime.py
finalize ¶
Close bookkeeping after the body runs.
Source code in python/iron/runtime/runtime.py
Runtime ¶
Bases: Resolvable
The host-side sequence of data-movement operations that execute an IRON design.
A Runtime describes what the host does at runtime: filling input
ObjectFifos with data and draining results back to host
buffers. The sequence is the seq_fn callback passed to the
constructor; its body reads the runtime buffers as parameters and moves
data with fifo.fill(...) / fifo.drain(...).
Create a runtime from its sequence body and fn_args.
Mirrors Worker(core_fn, fn_args): seq_fn runs
inside @runtime_sequence at resolve time, called as
seq_fn(*fn_args), and can use native range_/if_ and
fifo.fill/fifo.drain. Objects in fn_args (ObjectFifoHandles,
Buffers, ...) are registered eagerly at construction -- fifo shim
endpoints bind now (from prod(tile=)/cons(tile=)) so the Program
resolves fifos and cores before the body emits, letting body verbs read
resolved worker state (e.g. barrier.set).
Each fn_args entry is one of:
- a type (a tensor type or a scalar type like
np.int32): declares a runtime input and is replaced with a live SSA value bound to a newruntime_sequenceblock arg -- a tensor type becomes aRuntimeData(fill/draintarget), a scalar type becomes the bare SSA value (scfsurvives to the dynamic EmitC path). - a concrete int value: also declares a runtime input, but is folded
into an
arith.constantinstead of a block arg (constant-boundrange_/if_unrolls to the static binary path). One body thus serves both lowerings depending on whether the caller passes a type or an int here. - any other object (ObjectFifoHandle, Buffer, Kernel, ScratchpadParameter,
WorkerRuntimeBarrier, ...): passed through to the body unchanged, as
with
Worker.fn_args.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seq_fn
|
Callable
|
The sequence body; params bound to |
required |
fn_args
|
Sequence | None
|
Types/ints (runtime inputs) and shared objects,
in the order |
None
|
strict_task_groups
|
bool
|
Disallow mixing the default and explicit task groups. Defaults to True. |
True
|
Source code in python/iron/runtime/runtime.py
fifos
property
¶
The ObjectFifoHandles driven from the runtime by fill()/drain().
add_flow ¶
Register an explicit Flow (or
PacketFlow) so the Program resolves it alongside
the ObjectFifos.
add_lock ¶
add_tile_dma ¶
resolve ¶
resolve(
loc: Location | None = None,
ip: InsertionPoint | None = None,
*,
trace_size: int | None = None,
reuse_output_buffer: bool = False,
egress_shim_col: int = 0,
load_pdi_device_ref: str | None = None
) -> None
Build the runtime_sequence op and run the sequence body inside it.
The body runs exactly once. Each fill/drain verb binds its
ObjectFifo's shim endpoint and emits the shim DMA (referencing the fifo
by symbol name, a forward reference). The Program calls this before it
resolves ObjectFifos and cores, so by the time a fifo is resolved every
runtime endpoint -- including those on link siblings -- is already bound.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace_size
|
int | None
|
Forwarded from
|
None
|
reuse_output_buffer
|
bool
|
Forwarded from
|
False
|
egress_shim_col
|
int
|
Forwarded from
|
0
|
load_pdi_device_ref
|
str | None
|
On the full-ELF path (no xclbin configures the
device), the device symbol to load via |
None
|
Source code in python/iron/runtime/runtime.py
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 375 | |
sync_parameters ¶
Emit aiex.sync_scratchpad_parameters_from_host in the sequence body.
Call after all scratchpad 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 ¶
Kernel(
name: str,
object_file_name: str,
arg_types: list[type[ndarray] | dtype] | None = None,
*,
link_with_mode: str | None = None
)
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.
link_with_mode selects how that artifact is consumed: the default
(None) object-links it, while "merge" asks aiecc to llvm-link it into
the core's LLVM module before codegen. The mode is explicit metadata --
it is never inferred from the file suffix.
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
|
link_with_mode
|
str | None
|
Optional link policy emitted alongside
|
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,
inline: 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 artifact 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
|
inline
|
bool
|
When True, compile the kernel to |
False
|
Source code in python/iron/kernel.py
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 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 | |
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])
def sequence(out):
# The compiler automatically inserts the parameter-sync preamble.
...
rt = Runtime(sequence, [output_type])
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: TaskGroup | 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 TaskGroup.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_group
|
TaskGroup | None
|
The TaskGroup associated with this task. Defaults to None. |
None
|
Source code in python/iron/runtime/task.py
TaskGroup: groups related runtime transfers so they are awaited/freed together.
TaskGroup ¶
A grouping of runtime data transfers awaited and freed together.
Construct one inside a runtime sequence body and pass it as the group=
argument to fifo.fill(...) / fifo.drain(...). Call
finish to await the group's
waited transfers and free the rest (waits are ordered before frees).
def seq(A, C):
tg = TaskGroup()
inA.prod().fill(A, group=tg)
outC.cons().drain(C, wait=True, group=tg)
tg.finish()
Construct a TaskGroup, registering it with the active runtime sequence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int | None
|
Group id, unique within a Runtime. Defaults to the active sequence's next id. Passing an explicit id is only needed for the runtime's internal default group. |
None
|
Source code in python/iron/runtime/taskgroup.py
finish ¶
DMATask: a RuntimeTask that generates a shim DMA transfer operation.
DMATask ¶
DMATask(
object_fifo: ObjectFifoHandle,
rt_data: RuntimeData,
tap: TensorAccessPattern | None = None,
task_group: TaskGroup | None = None,
wait: bool = False,
offset_parameter: str | None = None,
packet: tuple[int, int] | None = None,
sizes=None,
strides=None,
offset=None,
transfer_len=None,
)
Bases: RuntimeTask
A RuntimeTask that will resolve to a DMA Operation.
Provide the access pattern either as a static tap
(TensorAccessPattern) or as explicit sizes/strides/offset/
transfer_len lists whose entries may be runtime SSA values (for the
dynamic lowering). The two forms are mutually exclusive.
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 | None
|
The static access pattern. Mutually exclusive with sizes/strides/offset/transfer_len. |
None
|
task_group
|
TaskGroup | 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
|
sizes
|
optional
|
Explicit access-pattern sizes whose entries may be
runtime SSA values. Used instead of |
None
|
strides
|
optional
|
Explicit access-pattern strides, paired with
|
None
|
offset
|
optional
|
Explicit access-pattern offset. Used instead of
|
None
|
transfer_len
|
optional
|
Explicit access-pattern transfer length.
Used instead of |
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 TaskGroup Finish operation
Task: a handle to an in-flight shim DMA transfer.
Returned by fifo.fill/fifo.drain. Its handle is the transfer's
!index SSA value, so a Task can be carried across scf.for iterations
as a range_ iter_args entry for software-pipelined transfers -- and it
carries .free() / .await_() verbs so the loop body does not need to reach
for the raw aiex.dma_free_task / aiex.dma_await_task dialect ops.
A Task returned by an unmanaged transfer (managed=False) is not enrolled
in a TaskGroup's automatic await/free, so the caller owns its lifetime with
these verbs -- exactly what a hand-rolled ping-pong needs.
Task ¶
A handle to a submitted shim DMA transfer.
Wraps the transfer's !index SSA value (handle). Pass a Task as a
range_ iter_args entry to carry an in-flight transfer across loop
iterations; range_ unwraps it to its handle for the scf.for
iter_arg and re-wraps the block argument as a Task for the body.