Commit fa3e6066 authored by Nguyen, Thien Minh's avatar Nguyen, Thien Minh
Browse files

Reconstruct the tensor expansion before adding more gates so that the count is strictly respected.



Signed-off-by: default avatarThien Nguyen <nguyentm@ornl.gov>
parent 8b6700f4
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -601,7 +601,9 @@ void ExatnGenVisitor<TNQVM_COMPLEX_TYPE>::appendGateTensor(
  // Count gate layer if this is a multi-qubit gate.
  if (in_gateInstruction.nRequiredBits() > 1) {
    updateLayerCounter(in_gateInstruction);
    reconstructCircuitTensor();
  }

  const auto gateName = GetGateName(GateType);
  const GateInstanceIdentifier gateInstanceId(gateName, in_params...);
  const std::string uniqueGateName = gateInstanceId.toNameString();
@@ -676,8 +678,6 @@ void ExatnGenVisitor<TNQVM_COMPLEX_TYPE>::appendGateTensor(
    xacc::error("Failed to append tensor for gate " +
                in_gateInstruction.name() + ", pairing = " + gatePairingString);
  }

  reconstructCircuitTensor();
}

template <typename TNQVM_COMPLEX_TYPE>
@@ -1057,6 +1057,7 @@ void ExatnGenVisitor<TNQVM_COMPLEX_TYPE>::updateLayerCounter(
    } else {
      ++m_layerCounter;
      m_layerTracker.clear();
      m_layerTracker.emplace(std::make_pair(q1, q2));
    }
  }
}