Op2QAllLayer#
- class torchquantum.layer.Op2QAllLayer(op, n_wires: int, has_params=False, trainable=False, wire_reverse=False, jump=1, circular=False)[source]#
Bases:
QuantumModule
Quantum layer applying the same two-qubit operation to all pairs of adjacent wires. This class represents a quantum layer that applies the same two-qubit operation to all pairs of adjacent wires in the quantum device. The pairs of wires can be determined in a circular or non-circular pattern based on the specified jump.
- Parameters:
op (tq.Operator) – Two-qubit operation to be applied.
n_wires (int) – Number of wires in the quantum device.
has_params (bool, optional) – Flag indicating if the operation has parameters. Defaults to False.
trainable (bool, optional) – Flag indicating if the operation is trainable. Defaults to False.
wire_reverse (bool, optional) – Flag indicating if the order of wires in each pair should be reversed. Defaults to False.
jump (int, optional) – Number of positions to jump between adjacent pairs of wires. Defaults to 1.
circular (bool, optional) – Flag indicating if the pattern should be circular. Defaults to False.
- __init__(op, n_wires: int, has_params=False, trainable=False, wire_reverse=False, jump=1, circular=False)[source]#
Initialize the QuantumModule.
- Returns:
None.
Examples
>>> qmodule = QuantumModule()
Methods
- forward(q_device)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
Attributes