qp.backline.runtime.CSignature

class CSignature(symbol, params, result=CType.VOID, library=None)[source]

Bases: object

The 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.VOID if the entry point returns nothing

  • library (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. None for 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".

caller_params

all of them, minus the out buffers.

library

out_params

Positions of the parameters the entry point writes instead of reading.

result

symbol

params

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>

check_arity(args)

Raise a TypeError if args doesn't match caller_params.

parse(symbol, spec)

Build a signature from a "(t1, t2, ...) -> tr" spec string.

check_arity(args)[source]

Raise a TypeError if args doesn’t match caller_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:

CSignature