alkaid.converter package

Submodules

alkaid.converter.example module

class alkaid.converter.example.ExampleALIRTracer(model: Callable, hwconf: HWConfig, solver_options: solver_options_t | None = None, **kwargs: Any)

Bases: ALIRTracerPluginBase

Example top-level tracer for ExampleModel.

The package registers this class under the alkaid key in the alir_tracer.plugins entry-point group. It implements the two methods required by ALIRTracerPluginBase: get_input_shapes() and apply_model().

apply_model(verbose: bool, inputs: tuple[FVArray, ...]) tuple[dict[str, FVArray], list[str]]

Replay the wrapped model on symbolic inputs.

Parameters:
  • verbose – Whether to print trace details.

  • inputs – Symbolic inputs to pass to the model.

Returns:

A trace dictionary and the keys that should be treated as outputs.

Return type:

tuple

get_input_shapes()

Return input shapes when they can be inferred from the model.

Returns:

Input shapes, or None when callers must provide symbolic inputs.

Return type:

Sequence[tuple[int, …]] | None

model: ExampleModel
class alkaid.converter.example.ExampleModel(input_shape: tuple[int, ...] | None = None)

Bases: object

A simple example model class for showcasing ALIR tracer plugin usage.

alkaid.converter.example.operation(inp)

An example operation to be traced. One can use numpy-based operations along with ALIR traceable operations provided in alkaid.trace.ops.

alkaid.converter.plugin module

class alkaid.converter.plugin.ALIRTracerPluginBase(model: Callable, hwconf: HWConfig, solver_options: solver_options_t | None = None, **kwargs: Any)

Bases: object

Base class for top-level alir_tracer.plugins model tracers.

apply_model(verbose: bool, inputs: tuple[FVArray, ...]) tuple[dict[str, FVArray] | dict[str, tuple[FVArray, ...]], list[str]]

Replay the wrapped model on symbolic inputs.

Parameters:
  • verbose – Whether to print trace details.

  • inputs – Symbolic inputs to pass to the model.

Returns:

A trace dictionary and the keys that should be treated as outputs.

Return type:

tuple

get_input_shapes() Sequence[tuple[int, ...]] | None

Return input shapes when they can be inferred from the model.

Returns:

Input shapes, or None when callers must provide symbolic inputs.

Return type:

Sequence[tuple[int, …]] | None

trace(verbose: bool = False, inputs: tuple[FVArray, ...] | FVArray | None = None, inputs_kif: tuple[int, int, int] | None = None, dump: bool = False) dict[str, FVArray] | dict[str, tuple[FVArray, ...]] | tuple[FVArray, FVArray]

Trace the wrapped model into symbolic alkaid inputs and outputs.

Parameters:
  • verbose – Whether to print verbose output.

  • inputs – Optional symbolic inputs. If omitted, get_input_shapes() is used.

  • inputs_kif – Optional input KIF values used when inputs is omitted.

  • dump – Whether to return all intermediate traces instead of flattened input/output arrays.

Returns:

A trace dictionary when dump is true, otherwise flattened symbolic inputs and outputs.

Return type:

dict | tuple[FVArray, FVArray]

Module contents

alkaid.converter.get_available_plugins() dict[str, EntryPoint]
alkaid.converter.trace_model(model: Any, hwconf: HWConfig | tuple[int, int, int] = HWConfig(1, 1, -1), solver_options: solver_options_t | None = None, verbose: bool = False, inputs: tuple[FVArray, ...] | FVArray | None = None, inputs_kif: tuple[int, int, int] | None = None, dump: Literal[False] = False, framework: None | str = None, **kwargs: Any) tuple[FVArray, FVArray]
alkaid.converter.trace_model(model: Any, hwconf: HWConfig | tuple[int, int, int] = HWConfig(1, 1, -1), solver_options: solver_options_t | None = None, verbose: bool = False, inputs: tuple[FVArray, ...] | FVArray | None = None, inputs_kif: tuple[int, int, int] | None = None, dump: Literal[True] = False, framework: None | str = None, **kwargs: Any) dict[str, FVArray]