qp.backline.runtime.CSignature¶
- class CSignature(symbol, params, result=CType.VOID, library=None)[source]¶
Bases:
objectThe C signature of a runtime symbol.
- Parameters:
symbol (str) – the C symbol name, as exported by the runtime library
params (tuple[CType]) – parameter types, in the order the C entry point takes them
result (CType) – the return type;
CType.VOIDif the entry point returns nothinglibrary (str | None) – the shared library exporting this symbol, for a direct local C ABI call. It is recorded on the compiled module so the driver links against it.
Nonefor a dispatched symbol, or one already loaded in the calling process.
Example
>>> from pennylane.backline.runtime import CSignature, CType >>> CSignature("example_run", (CType.PTR, CType.U32), result=CType.I32) CSignature('example_run', (ptr, u32) -> i32)
Alternatively,
parse()builds the same object from"(ptr, u32) -> i32".Attributes
all of them, minus the out buffers.
Positions of the parameters the entry point writes instead of reading.
- caller_params¶
all of them, minus the out buffers.
- Type:
The parameters a caller passes
- library = None¶
- out_params¶
Positions of the parameters the entry point writes instead of reading.
- result = 'void'¶
- symbol = <dataclasses._MISSING_TYPE object>¶
- params = <dataclasses._MISSING_TYPE object>¶
Methods
check_arity(args)Raise a
TypeErrorifargsdoesn't matchcaller_params.parse(symbol, spec)Build a signature from a
"(t1, t2, ...) -> tr"spec string.- check_arity(args)[source]¶
Raise a
TypeErrorifargsdoesn’t matchcaller_params.
- classmethod parse(symbol, spec)[source]¶
Build a signature from a
"(t1, t2, ...) -> tr"spec string.The arrow and result are optional; without them the result is
void.- Parameters:
symbol (str) – the C symbol name
spec (str) – the signature spec, e.g.
"(ptr, buf, u64) -> i32"
- Returns:
the parsed signature
- Return type: