IRON 1a5eed49d3c0721a318ac369f725acc96b7c4584
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
iron.scratchpad_parameter.ScratchpadParameter Class Reference
Inheritance diagram for iron.scratchpad_parameter.ScratchpadParameter:
Inheritance graph
[legend]
Collaboration diagram for iron.scratchpad_parameter.ScratchpadParameter:
Collaboration graph
[legend]

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
 

Detailed Description

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.
        ...

Constructor & Destructor Documentation

◆ __init__()

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.

Member Function Documentation

◆ dtype()

NpuDType iron.scratchpad_parameter.ScratchpadParameter.dtype (   self)
The numpy scalar type of this parameter.

◆ name()

str iron.scratchpad_parameter.ScratchpadParameter.name (   self)
The symbol name of this parameter.

◆ read()

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.

◆ resolve()

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.

Member Data Documentation

◆ _dtype

iron.scratchpad_parameter.ScratchpadParameter._dtype
protected

◆ _name

iron.scratchpad_parameter.ScratchpadParameter._name
protected

◆ _resolved

iron.scratchpad_parameter.ScratchpadParameter._resolved
protected

The documentation for this class was generated from the following file: