yobx.reference.evaluator#

ExtendedReferenceEvaluator#

class yobx.reference.ExtendedReferenceEvaluator(proto: Any, opsets: Dict[str, int] | None = None, functions: List | None = None, verbose: int = 0, new_ops: List[type[NativeOpKernel]] | None = None, **kwargs)[source]#

Executes models with the onnx-light native runtime.

Operators execute through the native runtime. Project NumPy kernels, including full-precision comparison and index reductions, are explicitly registered through its custom-kernel API. Missing kernels never trigger another evaluator or runtime.

run(None, feeds) returns outputs in graph declaration order. run(feeds_list) maps positional values to graph inputs. Models, serialized models, filenames, graphs, individual nodes, functions and export artifacts are accepted.

new_ops accepts NativeOpKernel subclasses. Alternatively, register_custom_kernel(domain, op_type, fn) registers a callable with signature fn(node, *inputs) returning an array or a tuple of arrays. Registrations affect future node resolutions. Once resolved, a node retains its kernel across runs and shape changes, even after replacement or removal of the registration. A new evaluator is required to change that kernel.

static filter_ops(proto, new_ops, opsets)[source]#

Selects the highest compatible version of each custom kernel.

property input_types#

Returns the declared graph input types.

property output_types#

Returns the declared graph output types.

register_custom_kernel(domain, op_type, fn, *, with_opset: bool = False)[source]#

Registers a callback for future resolutions, not already-resolved nodes.

property rt_inits_#

Returns graph initializers as arrays.

run(output_names, feed_inputs: Dict[str, Any] | None = None, attributes=None, intermediate: Literal[False] = False) → List[ndarray | List[ndarray]][source]#
run(output_names, feed_inputs: Dict[str, Any] | None = None, attributes=None, *, intermediate: Literal[True]) → Dict[str, ndarray | List[ndarray] | None]
run(output_names, feed_inputs: Dict[str, Any] | None = None, attributes=None, intermediate: bool = False) → List[ndarray | List[ndarray]] | Dict[str, ndarray | List[ndarray] | None]

Returns requested outputs, or a dictionary including intermediate values.

unregister_custom_kernel(domain, op_type)[source]#

Removes a registration without changing already-resolved kernels.