Writing an operator¶
What an operator is declared with. The declaration itself (param,
tunable, per_call) is mlir-aie's, in aie.utils.compile.jit; the
contributing guide walks through adding one.
Declaration¶
IRON's half of an operator: building, graphs and tuning.
The declaration itself (param, tunable, per_call, Select
and the base operator) is mlir-aie's, in aie.utils.compile.jit.
Operand
¶
An operand as one operator holds it (op.x).
The resolved In, Out or InOut, read through on use (a shape
may follow a tunable), and its bound lane_handles. An InOut
keeps what its stream does not drain.
Source code in iron/common/declare/operand.py
flat_type
property
¶
The runtime-sequence argument type: this buffer flattened to 1-D.
In its own element units (blocks, for block float).
l1_depth
property
¶
l1_depth: int
The depth a core-side fifo of this operand's tiles can have: two, or one.
One when a tile spans more than a hardware bank of the bound device's core memory.
batch_axes
property
¶
batch_axes: int
1 if a leading T | None dimension is present on this instance, else 0.
bounded
property
¶
(extent, axis, word) when a bound extent sizes an axis.
word is the per-call tiles per lane.
bind
¶
Bind each lane, in lane order, to the fifo end build() built for it.
A one-lane operand may take its handle bare.
Raises:
| Type | Description |
|---|---|
ValueError
|
Not one handle per lane, or the operand is bound already. |
Source code in iron/common/declare/operand.py
pin
¶
pin(endpoints: list[DmaEndpoint]) -> None
Pin each lane, in order, to a shim DmaEndpoint built elsewhere.
DmaEndpoint is MM2S for an input, S2MM for an output, so its
transfers are shim DMA tasks; build() returns the endpoints
among its objects.
Raises:
| Type | Description |
|---|---|
ValueError
|
An endpoint moves the other way or names no channel,
or |
Source code in iron/common/declare/operand.py
fill
¶
fill(tap: TensorAccessPattern | None = None, *, lane: int | None = None, group: TaskGroup | None = None, wait: bool = False, source: Operand | None = None, offset_parameter: Value | None = None, length_parameter: Value | None = None, length_unit: int | None = None, repeat_parameter: Value | None = None, managed: bool = True)
Fill lane of this operand's stream from the host in sequence(rt).
Returns the Task. A per-call Value is patched into the
descriptor on a full ELF; on an xclbin it regenerates the
instruction stream every call.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tap
|
TensorAccessPattern | None
|
The walk over |
None
|
lane
|
int | None
|
Required unless the operand has one lane. |
None
|
group
|
TaskGroup | None
|
The |
None
|
wait
|
bool
|
End with an await rather than a free. |
False
|
source
|
Operand | None
|
Another input whose data rides this operand's lane. |
None
|
offset_parameter
|
Value | None
|
A per-call element offset of |
None
|
length_parameter
|
Value | None
|
A per-call count of |
None
|
length_unit
|
int | None
|
The element count one |
None
|
repeat_parameter
|
Value | None
|
A per-call count of extra runs of |
None
|
managed
|
bool
|
False hands the queue slot and descriptors to the compiler, which frees them after a later wait; joins no group. |
True
|
Source code in iron/common/declare/operand.py
drain
¶
drain(tap: TensorAccessPattern | None = None, *, lane: int | None = None, group: TaskGroup | None = None, wait: bool = False, offset_parameter: Value | None = None, length_parameter: Value | None = None, length_unit: int | None = None, repeat_parameter: Value | None = None, managed: bool = True)
Drain lane lane of this operand's stream to the host.
The arguments are fill's, and a drain the sequence must see
finish before it ends passes wait=True.
Source code in iron/common/declare/operand.py
extent_axis
¶
extent_axis(extent: PerCallMember) -> int | None
Return the axis of the resolved shape that extent bounds sizes.
None where no axis matches, or extent bounds no parameter.
Source code in iron/common/declare/operand.py
fits
¶
fits(tap: TensorAccessPattern) -> bool
Whether one buffer descriptor of a lane's shim tile holds tap.
tap is a pattern over this operand.
Source code in iron/common/declare/operand.py
split
¶
Return a contiguous run of elements of this operand as (d1, d0).
d0 is the largest a lane's shim descriptor holds as its
innermost dimension with d1 beside it, or None where no d0 does.
Source code in iron/common/declare/operand.py
extent_unit
¶
Return the rows along axis of one round-robin unit under a bound.
Operator.extent_unit's, else the stream tile's.
Source code in iron/common/declare/operand.py
transfers
¶
Return the derived (lane, tap, length_parameter, length_unit) transfers.
The whole buffer (one lane or replicated) or one block of the first non-batch axis per lane; under a bound, round-robin by tile instead.
Raises:
| Type | Description |
|---|---|
ValueError
|
No |
Source code in iron/common/declare/operand.py
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 | |
Built
dataclass
¶
What build() made: the array's objects and each core's Rtp.
The objects are what the array declares (Workers, Flows, PacketFlows,
Locks, TileDmas, Buffers, pinned DmaEndpoints). A sequence needing
more reads a subclass via rt.built.
Operator
¶
Operator(*, bound_values: dict[str, Affine | None] | None = None, pinned: frozenset[str] | None = None, **given: Any)
Bases: Operator
An operator, whose subclass body is its declaration.
The declaration is mlir-aie's param(), tunable(), per_call();
aie.iron's In/Out/InOut.
Attributes:
| Name | Type | Description |
|---|---|---|
bound_values |
dict[str, Affine | None]
|
The graph expression bound to each per-call value, by name. |
pinned |
frozenset[str]
|
The tunables its caller gave, which the tuner holds; it may
move a profile's and |
Source code in iron/common/declare/operator.py
step
classmethod
¶
Record a step inside a graph's body: GEMV.step(w, h, **kw).
Raises:
| Type | Description |
|---|---|
TypeError
|
Called outside a graph's body. |
Source code in iron/common/declare/operator.py
build
¶
build() -> Built
Build the array for the bound device on layout().
Bind every operand's lanes to fifo ends and give each core reading
Values an Rtp.
Source code in iron/common/declare/operator.py
tolerance
¶
tolerance() -> Tolerance | None
Return what each output of the resolved operator is judged by.
None where nothing bounds it, which check mode refuses.
array_device
¶
Return the device the array's Program is built for.
The bound device unless the array takes a part of it.
exported_design
¶
shim_columns
classmethod
¶
How many of dev's columns fit its streams in the shim DMA budget.
A replicate stream costs once per channel, one with no per=
once, and a when= flag flags leaves out is its default.
Raises:
| Type | Description |
|---|---|
Unresolvable
|
Not even one column's streams fit. |
Source code in iron/common/declare/operator.py
call_operands
classmethod
¶
Split a call into inputs by name, outputs and other keywords.
As (x, ..., [outputs...], *, weight=None, ...) would: inputs are
in declaration order, and an optional input is a keyword, so never
taken for an output.
Source code in iron/common/declare/operator.py
resolve_columns
¶
resolve_columns(dev, given: int | None, num_channels: int = 1, *, fits: Callable[[int], bool] | None = None) -> int
given, checked against the shim budget, or the most columns that fits.
When no count fits, one column is returned and compatible names the rule.
Source code in iron/common/declare/operator.py
addressed_inputs
¶
Return the content of each input that names a device address.
For a run alone: addresses is every buffer's device address, by
buffer name; random bytes there would steer the DMA anywhere. Other
inputs are filled at random.
Source code in iron/common/declare/operator.py
judge
¶
judge(inputs: Mapping[str, ndarray], written: Mapping[str, ndarray], tolerance: Tolerance, expected: Mapping[str, ndarray] | None = None) -> dict[str, Verdict]
Each written buffer's verdict against its reference result.
Every mapping is by buffer name. expected defaults to
reference on inputs, which a bound tolerance is also
evaluated on.
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Source code in iron/common/declare/operator.py
sequence
¶
design_key
¶
Identity for sharing a build: equal keys generate byte-identical MLIR.
A graph's bound per-call values add their names.
Source code in iron/common/declare/operator.py
resolved
¶
Return this operator resolved for dev, the bound device unless given.
Source code in iron/common/declare/operator.py
replace
¶
Return a copy with changes, checked against the device once complete.
changes may name any parameter, the bound_values or the
pinned tunables.
Source code in iron/common/declare/operator.py
derived_at
¶
Return the word the host writes for name.
With the extents at the given bounds (an Affine form where the
caller evaluates it symbolically rather than at one number).
Source code in iron/common/declare/operator.py
extent_unit
¶
Return the rows of buffer one lane takes at a time under a bound.
None for the stream tile's rows; 0 when a bound does not shorten it.
value
¶
Return the device word of value name.
An extent attribute reads as an integer.
Source code in iron/common/declare/operator.py
use_value
¶
Record that a graph binds the per-call value name to its expression bound_to.
Source code in iron/common/declare/operator.py
compile
¶
Build, once, the image this operator runs on outside a graph.
Returns its artifacts (the xclbin, the instruction stream and their cache entry).
Source code in iron/common/declare/operator.py
layout
¶
layout() -> Self
Return this operator as its cores see it.
Each operand is bound to the view and its values this operator's; an extent reads as its number only where the key holds its bound.
Source code in iron/common/declare/operator.py
Precision
¶
Bases: StrEnum
The roundings a matmul may make beyond its reference's.
Named as torch.set_float32_matmul_precision names them; each level
allows the one above's and more, and a matmul takes the fastest kernel
its level allows.
HIGHEST: f32 partial sums, rounded once to the output's type.HIGH: partial sums rounded to the output's type per K tile.MEDIUM: A and B rounded to bfp16 for the multiplies, where the device has bfp16 macs.
Profile
¶
Tunable values by operator shape, as (cls, dims, tunables) entries.
An open tunable comes from the most specific match (a dimension left out matches any, a subclass its base's); equally specific ones that disagree raise.
Source code in iron/common/declare/profile.py
make
¶
Build cls(**kwargs) with its open tunables filled from this profile.
Standalone use of what a graph's recorder applies implicitly to every step it constructs.
Source code in iron/common/declare/profile.py
add
¶
Add an entry for cls.
param() values to match (one left out matches any value) and
tunable() values to give.
Source code in iron/common/declare/profile.py
tunables_for
¶
Resolve the tunables for the cls a call with given keywords makes.
Each comes from the most specific entry naming it.
Source code in iron/common/declare/profile.py
dims
staticmethod
¶
Collect every dimension (param()) a kind call with given makes.
This is what an entry is matched against: one it leaves out is its
default, None where a function computes it.
Source code in iron/common/declare/profile.py
matches
staticmethod
¶
Whether an entry's matched dimensions cover dims.
load
classmethod
¶
Load the profile save wrote to path.
Source code in iron/common/declare/profile.py
save
¶
Write the profile as JSON, one entry to a line.
Raises:
| Type | Description |
|---|---|
ValueError
|
An entry's operator is not in |
Source code in iron/common/declare/profile.py
Block
¶
Bases: PerCallMember
A block of words words a core reads, written once per build.
derive computes them from the operator. A shipped image's parameters
are one.
Source code in iron/common/declare/rtp.py
Rtp
¶
Bases: tuple
The words one core reads per call: a buffer and scratchpad words.
The sequence writes the buffer, then opens barrier on it. A tuple,
so a Worker takes it as one argument whose leaves mlir-aie registers;
the core calls read.
Attributes:
| Name | Type | Description |
|---|---|---|
slots |
dict[Value, int]
|
Each value the buffer holds and its first word there. |
buffer |
Buffer | None
|
None when every value is a scratchpad word. |
Raises:
| Type | Description |
|---|---|
ValueError
|
A value of several words is read from the scratchpad, whose parameters are one word each. |
read
¶
Read each value's word (a list of them for a block), keyed by the value.
In a core: wait for the sequence, read, re-arm.
Source code in iron/common/declare/rtp.py
write
¶
Write the words of each value the buffer holds, by value name.
Called in the preamble: a resident's number, or an xclbin's per-call scalar.
Raises:
| Type | Description |
|---|---|
ValueError
|
A value is given another number of words than it declares. |
Source code in iron/common/declare/rtp.py
Value
¶
Value(op: Operator, name: str, *, dtype: Any = int32, derive: Callable[[Any], Any] | None = None, bounds: OperatorParam | None = None, words: int = 1)
Bases: PerCallMember
A per_call() member bound to one operator (op.value("count")).
Or op.count unless an extent. Per call when a graph binds it, else
written once per build before the first DMA. A core reads it through
its Rtp.
Attributes:
| Name | Type | Description |
|---|---|---|
derive |
The once-per-build word, or |
|
bounds |
For an extent, the |
|
param |
Any
|
The build's parameter: a |
ssa |
Any
|
Its value in the sequence body, on an xclbin. |
Source code in iron/common/declare/value.py
per_call
property
¶
per_call: bool
A graph binds this value, or derive reads a bound extent.
A value with no derive and no bounds is always per call.
dispatch
property
¶
dispatch: bool
The instruction stream is regenerated around this value every call.
One every call gives, on an operator with an exported design. A full ELF cannot carry it.
Xclbin
¶
Bases: NPUKernel
A downloaded xclbin pinned by sha256.
Fetched over https into the JIT cache's prebuilt/<filename> on
first read of xclbin_path. As an image= it has no
instructions; a build runs it with_instructions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kernel
|
Any
|
|
{}
|
Source code in iron/common/declare/xclbin.py
with_instructions
¶
with_instructions(insts_path, **kernel) -> Xclbin
Return this image running insts_path.
With kernel (as NPUKernel takes it) over the declared
settings.
Source code in iron/common/declare/xclbin.py
fetch
¶
fetch(directory=None) -> Path
Return the downloaded file in directory.
NPU_CACHE_HOME's prebuilt/ by default, fetched unless
the pinned content is there.
Raises:
| Type | Description |
|---|---|
ValueError
|
The URL is not https. |
RuntimeError
|
The download has another digest. |
Source code in iron/common/declare/xclbin.py
Elementwise templates¶
The shared elementwise array.
One core per (column, channel), each streaming fixed-size lines of
every operand through the kernel a subclass's kernel() names, with
the scalars scalars() supplies; a parameter either reads is
declared array=True unless a stream names it. A replicate=True
input is one line each core holds for the whole call and every line
meets (RowwiseMul's row).
Sweep
¶
Sweep(lengths: Iterable[int] = LENGTHS, *, channels: Iterable[int] | None = (1, 2), tile_cap: int | None = None, regular: int | None = 2048, rows: bool = False, bench: int | None = BENCH_ELEMENTS, lower: bool = False, **extra: Any)
The cases of an elementwise operator.
At the regular length, one core and the most its shim budget allows (the grids between run the same loop); at the other lengths, in the extensive suite, the smallest and the largest tile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channels
|
Iterable[int] | None
|
None leaves the count to the operator (a binary one). |
(1, 2)
|
tile_cap
|
int | None
|
Else the class's |
None
|
regular
|
int | None
|
The one length in the default suite; None for all. |
2048
|
rows
|
bool
|
A length is that many elements in rows of |
False
|
bench
|
int | None
|
The length of one CI-tracked case at the widest grid; None adds none. |
BENCH_ELEMENTS
|
lower
|
bool
|
Flags its first default case |
False
|
**extra
|
Any
|
Given to every case. |
{}
|
Source code in iron/common/elementwise.py
KernelCall
dataclass
¶
KernelCall(kernel: ExternalFunction, scalars: tuple = (), operands: tuple[Operand | None, ...] = ())
One kernel call an elementwise operator's core makes over a line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scalars
|
tuple
|
The scalar arguments its contract leaves unbound, in order. |
()
|
operands
|
tuple[Operand | None, ...]
|
Each input tile, in the kernel's order: an input of the
operator ( |
()
|
Elementwise
¶
Bases: Operator
The array for an elementwise kernel over lines of tile_size elements.
Subclasses declare operands with the line as their tile, most split
over every core (per=CORES), and implement kernel;
tile_cap is the longest line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_aie_columns
|
int
|
Tunable: the call's, else the profile's, else |
None
|
num_channels
|
int
|
Tunable: the call's, else the profile's, else |
None
|
tile_size
|
int
|
Tunable: the call's, else the profile's, else |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
count |
Per call. |
Source code in iron/common/elementwise.py
valid_elements
property
¶
valid_elements: int
The elements a call processes, the bounded extent's worth if bound.
chain
¶
chain() -> tuple[KernelCall, ...]
Return the kernel calls a core makes over one line, in order.
reference and judge follow them; more than kernel()
only with an array of its own.
Source code in iron/common/elementwise.py
over
¶
Return this operator over elements elements in lines of line, on one core.
Raises:
| Type | Description |
|---|---|
ValueError
|
Its shape is not a run of lines. |
Source code in iron/common/elementwise.py
reference
¶
Run the kernel contract's reference, line by line, what the cores compute.
A bounded call's elements short of a whole line are zero-padded to whole lines, as the device runs whole tiles.
Source code in iron/common/elementwise.py
judge
¶
judge(inputs: Mapping[str, ndarray], written: Mapping[str, ndarray], tolerance: Tolerance, expected: Mapping[str, ndarray] | None = None) -> dict[str, Verdict]
Its output held to its reference by its kernel's judge, line by line.
Where a core makes one kernel call; as any operator's where it makes more.
Source code in iron/common/elementwise.py
kernel
¶
kernel() -> ExternalFunction
held_segments
¶
held_segments() -> int
Return the lines each held input is cut into.
A core holds all of them and meets, in turn, with that many lines of every other input.
arguments
¶
Return where each tile goes in a call of kernel, and its scalar arguments.
n_in inputs and n_out outputs; given fills the
scalars the contract leaves unbound.
Returns:
| Type | Description |
|---|---|
list[int]
|
The argument positions of the inputs then the outputs, in the |
dict
|
order a core acquires them, and the scalar values by position. |
Source code in iron/common/elementwise.py
UnaryElementwise
¶
UnaryElementwise(*, num_aie_columns: int = None, num_channels: int = None, tile_size: int = None, size: int)
Bases: Elementwise
A flat buffer in, a flat buffer of the same size out.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_aie_columns
|
int
|
Tunable: the call's, else the profile's, else |
None
|
num_channels
|
int
|
Tunable: the call's, else the profile's, else |
None
|
tile_size
|
int
|
Tunable: the call's, else the profile's, else |
None
|
size
|
int
|
|
required |
Attributes:
| Name | Type | Description |
|---|---|---|
count |
Per call. |
|
valid |
Per call. |
|
x |
|
|
y |
|
Source code in iron/common/elementwise.py
BinaryElementwise
¶
BinaryElementwise(*, num_aie_columns: int = None, num_channels: int = None, tile_size: int = None, size: int)
Bases: Elementwise
Two flat buffers in, one of the same size out.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_aie_columns
|
int
|
Tunable: the call's, else the profile's, else |
None
|
num_channels
|
int
|
Tunable: the call's, else the profile's, else |
None
|
tile_size
|
int
|
Tunable: the call's, else the profile's, else |
None
|
size
|
int
|
|
required |
Attributes:
| Name | Type | Description |
|---|---|---|
count |
Per call. |
|
valid |
Per call. |
|
a |
|
|
b |
|
|
y |
|
Source code in iron/common/elementwise.py
Rowwise
¶
Bases: Elementwise
rows rows of tile_size elements in, the same out, one kernel call per row.
For a kernel that reduces over its line, so the line is a
param() the cores read: another line would compute something
else.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_aie_columns
|
int
|
Tunable: the call's, else the profile's, else |
None
|
num_channels
|
int
|
Tunable: the call's, else the profile's, else |
None
|
tile_size
|
int
|
|
required |
rows
|
int
|
|
required |
Attributes:
| Name | Type | Description |
|---|---|---|
count |
Per call. |
|
valid |
Per call. |
|
x |
|
|
y |
|
Source code in iron/common/elementwise.py
WeightedRowwise
¶
WeightedRowwise(*, num_aie_columns: int = None, num_channels: int = None, tile_size: int, rows: int, weighted: bool = False)
Bases: Rowwise
A Rowwise kernel's rows, optionally times a learned weight row.
Weighted, two cores per (column, channel) are pipelined, the second multiplying by the row, which halves the line a core holds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_aie_columns
|
int
|
Tunable: the call's, else the profile's, else |
None
|
num_channels
|
int
|
Tunable: the call's, else the profile's, else |
None
|
tile_size
|
int
|
|
required |
rows
|
int
|
|
required |
weighted
|
bool
|
|
False
|
Attributes:
| Name | Type | Description |
|---|---|---|
count |
Per call. |
|
valid |
Per call. |
|
x |
|
|
y |
|
|
weight |
|
Source code in iron/common/elementwise.py
reference
¶
Run the kernels' references in turn, the kernel's row rounded to bf16.
Source code in iron/common/elementwise.py
RowBroadcast
¶
Bases: Rowwise
rows rows of tile_size elements, each met elementwise by one row.
A core holds row whole; past tile_cap a row is cut into
segments lines of line elements, each met by its own
segment: the same sums, in more calls.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_aie_columns
|
int
|
Tunable: the call's, else the profile's, else |
None
|
num_channels
|
int
|
Tunable: the call's, else the profile's, else |
None
|
tile_size
|
int
|
|
required |
rows
|
int
|
|
required |
Attributes:
| Name | Type | Description |
|---|---|---|
count |
Per call. |
|
valid |
Per call. |
|
x |
|
|
y |
|
|
row |
|
Source code in iron/common/elementwise.py
segments_for
classmethod
¶
Return the fewest lines a width-element row is cut into for a core.
A core holds it beside two lines each of x and y, as much as a row at the cap takes; None where no cut does.
Source code in iron/common/elementwise.py
Design and runtime sequence¶
The library-owned build of a declared operator.
OperatorDesign.module builds aie.iron's Program from the operator's
build() and an OperatorRuntime. For a full ELF, configuration puts
each BuiltArray and its sequences into one DeviceConfiguration.
BuiltArray
¶
BuiltArray(design: OperatorDesign, words: Mapping[str, str] | None = None, dispatch: Mapping[str, object] | None = None)
One design's array, built on a resolved copy of its operator (op).
Its operands' lanes are bound. Designs of one array (identities)
build it once, each running its own sequence over it (runtime).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
words
|
Mapping[str, str] | None
|
On a full ELF, design symbol -> the scratchpad word it shares with others that always hold the same number. |
None
|
dispatch
|
Mapping[str, object] | None
|
On an xclbin, each per-call value's dispatch-time scalar, by device symbol. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
A full ELF is asked to carry a |
Source code in iron/common/design/design.py
reads
cached
property
¶
Return the scratchpad words this design's cores read.
Beside its array_key, all its array depends on. Read off the
design built anew and resolved alone, since a core reads a word
through the parameter its function closes over.
runtime
¶
runtime(other: BuiltArray, name: str | None) -> OperatorRuntime
other's runtime sequence over this array, named name.
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Source code in iron/common/design/design.py
OperatorDesign
¶
One operator's design (module, or Operator.exported_design).
CompilableDesign compiles and caches it; identity adds to the
cache key the fields the operator's repr leaves out.
Source code in iron/common/design/design.py
module
¶
Return the operator's MLIR module on the bound device.
On an xclbin, which has no parameter scratchpad, dispatch is each
per-call value's scalar by symbol.
Source code in iron/common/design/design.py
compilable
¶
Return the CompilableDesign given options.
The operator's aiecc_flags are added to theirs.
Source code in iron/common/design/design.py
compile
¶
Compile the design, or find it in the cache.
image, for an insts_only stream, is the design it runs on: the
compile fails, naming each resource laid out otherwise than there,
rather than run against it.
Source code in iron/common/design/design.py
OperatorRuntime
¶
Bases: Runtime
The rt an operator's sequence(rt) receives.
aie.iron's Runtime running the preamble, then that sequence or the
one its declaration derives. A managed transfer on a pinned lane keeps
at most the operand's depth in flight, all awaited at the
sequence's end.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
op
|
Operator
|
The resolved operator, its array built and its operands' lanes bound or pinned. |
required |
name
|
str | None
|
The sequence's symbol; the Program names it when None. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
built |
What the operator's |
|
pins |
Each pinned lane this runtime declares, by its symbol. |
|
buffers |
Buffers no worker places: a shipped image's parameter blocks, or a pool only descriptors address. |
Source code in iron/common/design/runtime.py
body
¶
Record the sequence body, given the operator's runtime tensors, its lanes' handles.
Then each per-call value not in the scratchpad as its scalar.
Source code in iron/common/design/runtime.py
declare
¶
Its pins and buffers, at device scope ahead of the sequence.
aie.iron names a shim channel by its route and places a buffer by the worker that reads it, and these have neither.
Source code in iron/common/design/runtime.py
transfer
¶
transfer(verb: str, operand: Operand, tap: TensorAccessPattern | None, *, lane: int | None, group, wait: bool, source: Operand | None = None, offset_parameter: Value | None = None, length_parameter: Value | None = None, length_unit: int | None = None, repeat_parameter: Value | None = None, managed: bool = True)
Operand.fill/drain (verb): source's (else operand's) tap.
Through lane of operand's stream, its per-call words a
scratchpad parameter on a full ELF, the pattern's sizes and offset
on an xclbin.
Source code in iron/common/design/runtime.py
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 276 277 278 279 280 281 282 283 284 285 286 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 | |
preamble
¶
Write each core's runtime parameters, the parameter sync, then each core's barrier, before any DMA.
A shipped image's parameter blocks (buffers) get the residents'
words in declaration order, for its sequence to release. An
own_preamble operator's sequence calls it, values overriding
residents.
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Source code in iron/common/design/runtime.py
configuration
¶
configuration(name: str, arrays: Mapping[str, BuiltArray], steps: Sequence[str] = ()) -> DeviceConfiguration
Build arrays as one device configuration name.
One array per identity, and each entry's sequence over it, sequence
if it is alone, else named for its key. Given steps (keys of
arrays), one sequence runs theirs in order.
Raises:
| Type | Description |
|---|---|
ValueError
|
The arrays are built for different devices, or traced with different trace sizes. |
Source code in iron/common/design/design.py
identities
¶
Return what each of arrays is, equal where two are one array.
Its array_key, and where another shares that, the words its cores
read (BuiltArray.reads).