原生实现注册¶
oracq.infrastructure.native
Registration of PySparQ module-level implementations; runtime capabilities do not masquerade as gate-level closure.
- class oracq.infrastructure.native.NativeSite(module, arguments, resources)[源代码]¶
基类:
objectA module call site in the execution flow taken over by a native implementation.
- 变量:
module (oracq.infrastructure.ir.Module) -- declaration of the called module.
arguments (tuple[oracq.infrastructure.ir.Ref, ...]) -- argument views corresponding one-to-one with the module registers.
resources (tuple[str, ...]) -- resource binding names corresponding one-to-one with the module resources.
- module¶
- arguments¶
- resources¶
- class oracq.infrastructure.native.NativeEntry(module, factory, label, kind)[源代码]¶
基类:
objectA native implementation registration entry under one module name.
- 变量:
module (oracq.infrastructure.ir.Module) -- module description declared at registration, used to compare against same-named modules in programs.
factory (collections.abc.Callable) -- implementation factory only called with a
NativeContextargument at execution time.label (str) -- implementation name displayed in execution reports.
kind (str) -- implementation category tag,
pysparq_customby default.
- module¶
- factory¶
- label¶
- kind¶
- class oracq.infrastructure.native.NativeRegistry[源代码]¶
基类:
objectRegister PySparQ module-level native implementations by module name and verify coverage against programs.
- entries¶
- register(operation, factory, *, label=None, kind='pysparq_custom')[源代码]¶
Register the native implementation of one module.
- 参数:
operation --
OperationorModuleproviding the module declaration.factory -- factory called with a
NativeContextargument at execution time; heavy work such as C++ compilation is deferred inside the factory as needed, not done at registration.label -- display name of the implementation in execution reports; the module name is used when omitted.
kind -- implementation category tag.
- 返回:
returns itself to support chained registration.
- 返回类型:
- 抛出:
ValidationError -- the module name is already registered with different content.
- matching(program)[源代码]¶
Compute the set of module names in a program taken over by native implementations.
- 参数:
program -- program to verify.
- 返回:
module names that match a registered entry by name and module declaration.
- 返回类型:
frozenset[str]
- 抛出:
ValidationError -- a same-named module does not match the declaration at registration.
- missing(program)[源代码]¶
List entry-reachable open declaration module names not yet covered by native implementations.
- 参数:
program -- program to check.
- 返回:
open declaration module names sorted by name; an empty tuple when there is no gap.
- 返回类型:
tuple[str, ...]
- 抛出:
ValidationError -- the program failed RIR structural validation.
- class oracq.infrastructure.native.NativeContext(ps, site, names, qrams, memories)[源代码]¶
基类:
objectExecution environment passed to native factories, bridging RIR formal parameters and PySparQ runtime objects.
- 变量:
ps (object) -- currently imported
pysparqmodule.site (oracq.infrastructure.native.NativeSite) -- native call site being executed.
names (dict) -- mapping from RIR register names to PySparQ register names.
qrams (dict) -- mapping from resource names to PySparQ QRAM objects.
memories (dict) -- mapping from resource names to sparse word data dicts.
- ps¶
- site¶
- names¶
- qrams¶
- memories¶
- register_id(parameter)[源代码]¶
Resolve a quantum formal parameter of the module to a PySparQ integer register id.
- 参数:
parameter -- module register formal parameter name.
- 返回:
id given by PySparQ
System.get_idfor the corresponding register.- 抛出:
ValidationError -- the argument is not a single view covering exactly one whole register, such as a slice or concatenation.