|
IRON 1a5eed49d3c0721a318ac369f725acc96b7c4584
|


Public Member Functions | |
| __init__ (self, str name, NpuDType dtype) | |
| str | name (self) |
| NpuDType | dtype (self) |
| read (self) | |
| None | resolve (self, ir.Location|None loc=None, ir.InsertionPoint|None ip=None) |
Public Member Functions inherited from iron.resolvable.Resolvable | |
| list | tiles (self) |
Protected Attributes | |
| _name | |
| _dtype | |
| _resolved | |
A named runtime parameter communicated from host to AIE cores via the
scratchpad mechanism.
Declare a ``ScratchpadParameter`` at design time. Pass it to a
:class:`Worker` via ``fn_args`` and call :meth:`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.
...
| iron.scratchpad_parameter.ScratchpadParameter.__init__ | ( | self, | |
| str | name, | ||
| NpuDType | dtype | ||
| ) |
Create a ScratchpadParameter.
Args:
name: Symbol name for the parameter (must be unique within the
device).
dtype: The numpy scalar type (e.g. ``np.int32``, ``np.int16``,
``bfloat16``). ``np.float32`` is not supported -- the
scratchpad encoding zeroes the top 2 bits of the value,
which clobbers the sign and top exponent bits of an f32.
| NpuDType iron.scratchpad_parameter.ScratchpadParameter.dtype | ( | self | ) |
The numpy scalar type of this parameter.
| str iron.scratchpad_parameter.ScratchpadParameter.name | ( | self | ) |
The symbol name of this parameter.
| iron.scratchpad_parameter.ScratchpadParameter.read | ( | self | ) |
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:
An MLIR SSA value of the parameter's type.
| None iron.scratchpad_parameter.ScratchpadParameter.resolve | ( | self, | |
| ir.Location | None | loc = None, |
||
| ir.InsertionPoint | None | ip = None |
||
| ) |
Emit ``aiex.scratchpad_parameter @name : type`` at module scope.
Reimplemented from iron.resolvable.Resolvable.
|
protected |
|
protected |
|
protected |