iqm.cpc.compiler.compiler.compiler_pass

Contents

iqm.cpc.compiler.compiler.compiler_pass#

iqm.cpc.compiler.compiler.compiler_pass(function)#

Convenience wrapper to create a valid compiler pass.

When the wrapped function is called, the compilation data (e.g. circuits) is passed as the first argument. If function has any other arguments, the wrapper takes their values from the context dict. If no matching key is found for a required argument, an error is raised.

function` must return either a tuple of ``(data, ctx) where data is the compilation result and ctx is a dict with any new context data, or only data. The contents of ctx will be merged to the input context. Note the difference to a plain, unwrapped CompilationPass: not returning ctx is valid.

Return type:

Callable[[Any, dict[str, Any]], tuple[Any, dict[str, Any]]]