From e763d3877fd7a4cf97e0cd0ce25527be6ba122bd Mon Sep 17 00:00:00 2001 From: GenericP3rson Date: Fri, 4 Aug 2023 12:39:25 -0300 Subject: [PATCH] [minor] change swap param name and fix bug --- torchquantum/layer/layers.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/torchquantum/layer/layers.py b/torchquantum/layer/layers.py index 73cf792f..ad34d3f4 100644 --- a/torchquantum/layer/layers.py +++ b/torchquantum/layer/layers.py @@ -921,7 +921,7 @@ def __init__( self, n_wires: int = None, wires: Iterable = None, - add_swaps: bool = True, + do_swaps: bool = True, inverse: bool = False, ): """ @@ -930,7 +930,7 @@ def __init__( Args: n_wires (int): Number of wires for the QFT as an integer wires (Iterable): Wires to perform the QFT as an Iterable - add_swaps (bool): Whether or not to add the final swaps in a boolean format + do_swaps (bool): Whether or not to add the final swaps in a boolean format inverse (bool): Whether to create an inverse QFT layer in a boolean format """ super().__init__() @@ -945,7 +945,7 @@ def __init__( self.n_wires = n_wires self.wires = wires - self.add_swaps = add_swaps + self.do_swaps = do_swaps if inverse: self.gates_all = self.build_inverse_circuit() @@ -955,7 +955,7 @@ def __init__( def build_circuit(self): """Construct a QFT circuit.""" - operation_list = nn.ModuleList() + operation_list = [] # add the H and CU1 gates for top_wire in range(self.n_wires): @@ -971,7 +971,7 @@ def build_circuit(self): ) # add swaps if specified - if self.add_swaps: + if self.do_swaps: for wire in range(self.n_wires // 2): operation_list.append( { @@ -991,7 +991,7 @@ def build_inverse_circuit(self): operation_list = [] # add swaps if specified - if self.add_swaps: + if self.do_swaps: for wire in range(self.n_wires // 2): operation_list.append( {