fhelium.compile._callable
Own callable specialization and reuse of linked execution programs.
CompiledCallable
class View source
CompiledCallable(source: Program | Compilation | Callable[_P, _R], *, backend: OperationBackend | None=None, resources: CkksDeviceResources | RnsContext | NttContext | Iterable[CkksDeviceResources | RnsContext | NttContext]=(), keys: Mapping[object, object] | Iterable[object] | EvaluationKeySet=(), pipeline: Pipeline | Callable[[CallSignature], Pipeline] | None=None, on_miss: Literal['compile', 'error']='compile', workspace: CompileWorkspace | None=None, inputs: Mapping[str, InputSpec] | None=None, material_names: Mapping[str, object] | None=None)Bases: Generic[_P, _R]
A callable that caches input-specialized executables for one source computation.
prepare creates and links a specialization for given arguments. Calls reuse a matching executable; a cache miss prepares a new specialization by default, or raises SpecializationMiss when on_miss='error'. clear releases the cached specializations.
specializations
property
specializations: tuple[Specialization, ...]Return successfully linked variants in preparation order.
prepare
method
def prepare(*args: _P.args, **kwargs: _P.kwargs) -> Specialization: ...Prepare and return the specialization matching these arguments.
Preparation captures the source when needed, runs its selected pipeline, and links the resulting Program. A matching cached specialization is returned directly. This method populates the cache under either on_miss policy.
Device-kernel compilation may occur on first execution after linking. Warm representative calls before measuring steady-state execution or capturing device launches.
with_backend
method
def with_backend(backend: OperationBackend) -> CompiledCallable[_P, _R]: ...Relink a snapshot of compiled variants against another Backend.
Call prepare to link the returned callable before execution when on_miss='error'. Existing compilations retain their selected implementations and target/ABI requirements, which the new Backend must satisfy. Each callable prepares new input signatures independently.
clear
method
def clear() -> None: ...Release this callable's specialization cache.
Call this after changing captured Python constants so the next preparation captures their new values. Changes to input Tensor contents reuse the existing specialization while its recorded input conditions hold. Caller resources and compiled results retained by peers made with with_backend remain live.