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

Public Member Functions

None __init__ (self, str name, str|None object_file_name=None, str|None source_file=None, str|None source_string=None, list[type[np.ndarray]|np.dtype]|None arg_types=None, list[str]|None include_dirs=None, list[str]|None compile_flags=None, *str|None symbol_prefix=None, bool use_chess=False)
 
 __call__ (self, *args, **kwargs)
 
int __hash__ (self)
 
bool __eq__ (self, object other)
 
str __repr__ (self)
 
- Public Member Functions inherited from iron.kernel.Kernel
str object_file_name (self)
 
None resolve (self, ir.Location|None loc=None, ir.InsertionPoint|None ip=None)
 
- Public Member Functions inherited from iron.kernel.BaseKernel
tuple[int,...] arg_shape (self, int arg_index=0)
 
 arg_dtype (self, int arg_index=0)
 
int tile_size (self, int arg_index=0)
 
list arg_types (self)
 
- Public Member Functions inherited from iron.resolvable.Resolvable
list tiles (self)
 

Static Public Attributes

tuple mac_dims
 
str zero : "Kernel"
 
str get_only : "Kernel"
 
str put_only : "Kernel"
 
str put_get : "Kernel"
 

Protected Member Functions

None _validate_arg (self, int index, arg, expected_ty)
 
str _content_digest (self)
 
- Protected Member Functions inherited from iron.kernel.BaseKernel
 _resolve_arg (self, int arg_index)
 

Protected Attributes

 _original_name
 
 _symbol_prefix
 
 _source_file
 
 _source_string
 
 _include_dirs
 
 _compile_flags
 
 _use_chess
 
 _compiled
 
 _object_file_name
 
 _arg_types
 
 _name
 
 _cached_digest
 
- Protected Attributes inherited from iron.kernel.Kernel
 _object_file_name
 
 _op
 
 _name
 
- Protected Attributes inherited from iron.kernel.BaseKernel
 _name
 
 _arg_types
 
 _op
 

Static Protected Attributes

set _instances = set()
 

Detailed Description

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 :class:`Kernel` class instead when you have a pre-built
object file.

Constructor & Destructor Documentation

◆ __init__()

None iron.kernel.ExternalFunction.__init__ (   self,
str  name,
str | None   object_file_name = None,
str | None   source_file = None,
str | None   source_string = None,
list[type[np.ndarray] | np.dtype] | None   arg_types = None,
list[str] | None   include_dirs = None,
list[str] | None   compile_flags = None,
*str | None   symbol_prefix = None,
bool   use_chess = False 
)
Args:
    name: Symbol name of the function as it will appear in the object
        file.
    object_file_name: Output object file name.  Defaults to
        ``<effective_name>.o``.
    source_file: Path to a C/C++ source file on disk.  Mutually
        exclusive with ``source_string``.
    source_string: Inline C/C++ source code.  Mutually exclusive with
        ``source_file``.
    arg_types: Type signature of the function arguments.  Defaults to
        None (empty list).
    include_dirs: Additional ``-I`` directories passed to the chosen
        compiler (Peano by default; xchesscc when ``use_chess=True``).
        Defaults to None (empty list).
    compile_flags: Additional flags passed verbatim to the chosen
        compiler.  Defaults to None (empty list).
    symbol_prefix: Optional prefix for the exported symbol name.  When
        set, the effective symbol name becomes ``<symbol_prefix>_<name>``
        and the object file is named accordingly.  The original name is
        preserved in ``_original_name`` for source file naming.
    use_chess: When ``True``, this ExternalFunction's source is
        compiled with ``xchesscc_wrapper`` instead of Peano's
        ``clang++``.  The JIT compile orchestration auto-detects the
        design-level toolchain from the registered EFs and switches
        aiecc's front-end accordingly; mixing chess + peano EFs in
        one design is rejected loudly because aiecc only invokes one
        front-end per compile.

Reimplemented from iron.kernel.Kernel.

Member Function Documentation

◆ __call__()

iron.kernel.ExternalFunction.__call__ (   self,
args,
**  kwargs 
)
Call with argument count and type validation before emitting MLIR.

``**kwargs`` are forwarded to the base ``BaseKernel.__call__``
and ultimately to the MLIR ``func.call`` builder.

Reimplemented from iron.kernel.BaseKernel.

◆ __eq__()

bool iron.kernel.ExternalFunction.__eq__ (   self,
object  other 
)
Content-based equality so hash collisions never produce false cache hits.

◆ __hash__()

int iron.kernel.ExternalFunction.__hash__ (   self)
Content-based hash for use as a dict/set key and in cache signatures.

◆ __repr__()

str iron.kernel.ExternalFunction.__repr__ (   self)
Content-based repr so str(ef) is stable across GC cycles.

Default ``object.__repr__`` uses the recyclable memory address; two
distinct EFs can then alias onto the same _compute_hash cache slot.

◆ _content_digest()

str iron.kernel.ExternalFunction._content_digest (   self)
protected
Return a 64-bit hex SHA-256 digest of this instance's content.

Used by both ``__hash__`` and ``__eq__`` so the two are consistent.
Memoised on the instance: source-file reads and stat() calls would
otherwise run on every dict lookup and noticeably regress hot
compile-cache paths.  Instance state is treated as immutable after
construction; mutating ``_source_*`` / ``_include_dirs`` /
``_compile_flags`` / ``_arg_types`` afterwards is not supported.

◆ _validate_arg()

None iron.kernel.ExternalFunction._validate_arg (   self,
int  index,
  arg,
  expected_ty 
)
protected
Validate a single argument against its expected type.

Member Data Documentation

◆ _arg_types

iron.kernel.ExternalFunction._arg_types
protected

◆ _cached_digest

iron.kernel.ExternalFunction._cached_digest
protected

◆ _compile_flags

iron.kernel.ExternalFunction._compile_flags
protected

◆ _compiled

iron.kernel.ExternalFunction._compiled
protected

◆ _include_dirs

iron.kernel.ExternalFunction._include_dirs
protected

◆ _instances

set iron.kernel.ExternalFunction._instances = set()
staticprotected

◆ _name

iron.kernel.ExternalFunction._name
protected

◆ _object_file_name

iron.kernel.ExternalFunction._object_file_name
protected

◆ _original_name

iron.kernel.ExternalFunction._original_name
protected

◆ _source_file

iron.kernel.ExternalFunction._source_file
protected

◆ _source_string

iron.kernel.ExternalFunction._source_string
protected

◆ _symbol_prefix

iron.kernel.ExternalFunction._symbol_prefix
protected

◆ _use_chess

iron.kernel.ExternalFunction._use_chess
protected

◆ get_only

str iron.kernel.ExternalFunction.get_only : "Kernel"
static

◆ mac_dims

tuple iron.kernel.ExternalFunction.mac_dims
static

◆ put_get

str iron.kernel.ExternalFunction.put_get : "Kernel"
static

◆ put_only

str iron.kernel.ExternalFunction.put_only : "Kernel"
static

◆ zero

str iron.kernel.ExternalFunction.zero : "Kernel"
static

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