Skip to content

Commit 256e64a

Browse files
committed
🚑 fix all newly broken pieces
Signed-off-by: Lukas Burgholzer <lukas.burgholzer@jku.at>
1 parent c128f66 commit 256e64a

File tree

13 files changed

+59
-63
lines changed

13 files changed

+59
-63
lines changed

include/Mapper.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ class Mapper {
184184
std::transform(extension.begin(), extension.end(), extension.begin(),
185185
[](unsigned char c) { return ::tolower(c); });
186186
if (extension == "real") {
187-
dumpResult(outputFilename, qc::Real);
187+
dumpResult(outputFilename, qc::Format::Real);
188188
} else if (extension == "qasm") {
189-
dumpResult(outputFilename, qc::OpenQASM);
189+
dumpResult(outputFilename, qc::Format::OpenQASM);
190190
} else {
191191
throw QMAPException("[dump] Extension " + extension +
192192
" not recognized/supported for dumping.");

include/cliffordsynthesis/CliffordSynthesizer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class CliffordSynthesizer {
4444
std::stringstream ss;
4545
ss << results.getResultCircuit();
4646
resultCircuit = std::make_unique<qc::QuantumComputation>();
47-
resultCircuit->import(ss, qc::OpenQASM);
47+
resultCircuit->import(ss, qc::Format::OpenQASM);
4848
return *resultCircuit;
4949
};
5050
[[nodiscard]] Tableau& getResultTableau() {

mqt/qmap/bindings.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ MappingResults map(const py::object& circ, Architecture& arch,
4242

4343
if (config.useTeleportation) {
4444
config.teleportationQubits =
45-
std::min((arch.getNqubits() - qc.getNqubits()) & ~1, 8);
45+
std::min((arch.getNqubits() - qc.getNqubits()) & ~1,
46+
static_cast<std::size_t>(8));
4647
}
4748

4849
std::unique_ptr<Mapper> mapper;
@@ -69,7 +70,7 @@ MappingResults map(const py::object& circ, Architecture& arch,
6970
auto& results = mapper->getResults();
7071

7172
std::stringstream qasm{};
72-
mapper->dumpResult(qasm, qc::OpenQASM);
73+
mapper->dumpResult(qasm, qc::Format::OpenQASM);
7374
results.mappedCircuit = qasm.str();
7475

7576
return results;

src/Mapper.cpp

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -149,31 +149,29 @@ void Mapper::finalizeMappedCircuit() {
149149
// circuit
150150
if (architecture.getNqubits() > qcMapped.getNqubits()) {
151151
for (auto logicalQubit = qcMapped.getNqubits();
152-
logicalQubit < static_cast<dd::QubitCount>(architecture.getNqubits());
153-
++logicalQubit) {
154-
dd::Qubit physicalQubit = -1;
152+
logicalQubit < architecture.getNqubits(); ++logicalQubit) {
153+
std::optional<qc::Qubit> physicalQubit = std::nullopt;
155154

156155
// check if the corresponding physical qubit is already in use
157-
if (qcMapped.initialLayout.find(static_cast<dd::Qubit>(logicalQubit)) !=
156+
if (qcMapped.initialLayout.find(static_cast<qc::Qubit>(logicalQubit)) !=
158157
qcMapped.initialLayout.end()) {
159158
// get the next unused physical qubit
160-
for (physicalQubit = 0;
161-
physicalQubit < static_cast<dd::Qubit>(architecture.getNqubits());
162-
++physicalQubit) {
163-
if (qcMapped.initialLayout.find(physicalQubit) ==
159+
for (physicalQubit = 0; *physicalQubit < architecture.getNqubits();
160+
++(*physicalQubit)) {
161+
if (qcMapped.initialLayout.find(*physicalQubit) ==
164162
qcMapped.initialLayout.end()) {
165163
break;
166164
}
167165
}
168166
} else {
169-
physicalQubit = static_cast<dd::Qubit>(logicalQubit);
167+
physicalQubit = static_cast<qc::Qubit>(logicalQubit);
170168
}
171169

172-
assert(physicalQubit != -1);
170+
assert(physicalQubit.has_value());
173171

174172
// the added logical qubits are not used in the circuit itself, so they
175173
// are regarded garbage
176-
qcMapped.addAncillaryQubit(physicalQubit, -1);
174+
qcMapped.addAncillaryQubit(*physicalQubit, std::nullopt);
177175
}
178176
}
179177
// unify quantum registers
@@ -187,31 +185,30 @@ void Mapper::finalizeMappedCircuit() {
187185

188186
void Mapper::placeRemainingArchitectureQubits() {
189187
if (qc.getNqubits() < architecture.getNqubits()) {
190-
for (auto logical = qc.getNqubits();
191-
logical < static_cast<decltype(logical)>(architecture.getNqubits());
188+
for (auto logical = qc.getNqubits(); logical < architecture.getNqubits();
192189
++logical) {
193-
dd::Qubit physical = -1;
190+
std::optional<qc::Qubit> physical = std::nullopt;
194191

195192
// check if the corresponding physical qubit is already in use
196-
if (qcMapped.initialLayout.find(static_cast<dd::Qubit>(logical)) !=
193+
if (qcMapped.initialLayout.find(static_cast<qc::Qubit>(logical)) !=
197194
qcMapped.initialLayout.end()) {
198195
// get the next unused physical qubit
199-
for (physical = 0;
200-
physical < static_cast<dd::Qubit>(architecture.getNqubits());
201-
++physical) {
202-
if (qcMapped.initialLayout.find(physical) ==
196+
for (physical = 0; *physical < architecture.getNqubits();
197+
++(*physical)) {
198+
if (qcMapped.initialLayout.find(*physical) ==
203199
qcMapped.initialLayout.end()) {
204200
break;
205201
}
206202
}
207203
} else {
208-
physical = static_cast<dd::Qubit>(logical);
204+
physical = static_cast<qc::Qubit>(logical);
209205
}
210206

211-
qubits.at(physical) = logical;
207+
assert(physical.has_value());
208+
qubits.at(*physical) = static_cast<short>(logical);
212209

213210
// mark architecture qubit as ancillary and garbage
214-
qcMapped.initialLayout[physical] = static_cast<dd::Qubit>(logical);
211+
qcMapped.initialLayout[*physical] = static_cast<qc::Qubit>(logical);
215212
qcMapped.setLogicalQubitAncillary(logical);
216213
qcMapped.setLogicalQubitGarbage(logical);
217214
}

src/cliffordsynthesis/encoding/GateEncoder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ void GateEncoder::extractTwoQubitGatesFromModel(const std::size_t pos,
129129
continue;
130130
}
131131
const auto control =
132-
dd::Control{static_cast<dd::Qubit>(ctrl), dd::Control::Type::pos};
132+
qc::Control{static_cast<qc::Qubit>(ctrl), qc::Control::Type::Pos};
133133
if (model.getBoolValue(twoQubitGates[ctrl][trgt], lb.get())) {
134134
qc.emplace_back<qc::StandardOperation>(N, control, trgt, qc::OpType::X);
135135
++nTwoQubitGates;

src/exact/ExactMapper.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,10 @@ void ExactMapper::map(const Configuration& settings) {
259259
for (const auto& [physical, logical] : *swapsIterator) {
260260
locations.at(logical) = static_cast<short>(physical);
261261
qubits.at(physical) = static_cast<short>(logical);
262-
qcMapped.initialLayout[static_cast<dd::Qubit>(physical)] =
263-
static_cast<dd::Qubit>(logical);
264-
qcMapped.outputPermutation[static_cast<dd::Qubit>(physical)] =
265-
static_cast<dd::Qubit>(logical);
262+
qcMapped.initialLayout[static_cast<qc::Qubit>(physical)] =
263+
static_cast<qc::Qubit>(logical);
264+
qcMapped.outputPermutation[static_cast<qc::Qubit>(physical)] =
265+
static_cast<qc::Qubit>(logical);
266266
}
267267

268268
// place remaining architecture qubits
@@ -317,7 +317,7 @@ void ExactMapper::map(const Configuration& settings) {
317317
qcMapped.h(reverse.first);
318318
qcMapped.h(reverse.second);
319319
qcMapped.x(reverse.second,
320-
dd::Control{static_cast<dd::Qubit>(reverse.first)});
320+
qc::Control{static_cast<qc::Qubit>(reverse.first)});
321321
qcMapped.h(reverse.second);
322322
qcMapped.h(reverse.first);
323323
} else {
@@ -327,7 +327,7 @@ void ExactMapper::map(const Configuration& settings) {
327327
<< " " << cnot.second << std::endl;
328328
}
329329
qcMapped.x(cnot.second,
330-
dd::Control{static_cast<dd::Qubit>(cnot.first)});
330+
qc::Control{static_cast<qc::Qubit>(cnot.first)});
331331
}
332332
}
333333
}

src/heuristic/HeuristicMapper.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ void HeuristicMapper::map(const Configuration& ms) {
5858
} else if (swap.op == qc::Teleportation) {
5959
qcMapped.emplace_back<qc::StandardOperation>(
6060
qcMapped.getNqubits(),
61-
qc::Targets{static_cast<dd::Qubit>(swap.first),
62-
static_cast<dd::Qubit>(swap.second),
63-
static_cast<dd::Qubit>(swap.middle_ancilla)},
61+
qc::Targets{static_cast<qc::Qubit>(swap.first),
62+
static_cast<qc::Qubit>(swap.second),
63+
static_cast<qc::Qubit>(swap.middle_ancilla)},
6464
qc::Teleportation);
6565
results.output.teleportations++;
6666
}
@@ -107,15 +107,15 @@ void HeuristicMapper::map(const Configuration& ms) {
107107
qcMapped.h(reverse.first);
108108
qcMapped.h(reverse.second);
109109
qcMapped.x(reverse.second,
110-
dd::Control{static_cast<dd::Qubit>(reverse.first)});
110+
qc::Control{static_cast<qc::Qubit>(reverse.first)});
111111
qcMapped.h(reverse.second);
112112
qcMapped.h(reverse.first);
113113

114114
results.output.directionReverse++;
115115
gateidx += 5;
116116
} else {
117117
qcMapped.x(cnot.second,
118-
dd::Control{static_cast<dd::Qubit>(cnot.first)});
118+
qc::Control{static_cast<qc::Qubit>(cnot.first)});
119119
gateidx++;
120120
}
121121
}
@@ -127,8 +127,8 @@ void HeuristicMapper::map(const Configuration& ms) {
127127
std::size_t count = 0U;
128128
for (std::size_t i = 0U; i < architecture.getNqubits(); ++i) {
129129
if (qubits[i] != -1) {
130-
qcMapped.outputPermutation[static_cast<dd::Qubit>(i)] =
131-
static_cast<dd::Qubit>(qubits[i]);
130+
qcMapped.outputPermutation[static_cast<qc::Qubit>(i)] =
131+
static_cast<qc::Qubit>(qubits[i]);
132132
} else {
133133
qcMapped.setLogicalQubitGarbage(qc.getNqubits() + count);
134134
++count;
@@ -171,10 +171,10 @@ void HeuristicMapper::map(const Configuration& ms) {
171171
++loc;
172172
}
173173
locations.at(target) = loc;
174-
op->setTargets({static_cast<dd::Qubit>(loc)});
174+
op->setTargets({static_cast<qc::Qubit>(loc)});
175175
qcMapped.initialLayout.at(target) = loc;
176176
} else {
177-
op->setTargets({static_cast<dd::Qubit>(targetLocation)});
177+
op->setTargets({static_cast<qc::Qubit>(targetLocation)});
178178
}
179179
}
180180
}

test/cliffordsynthesis/test_synthesis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class SynthesisTest : public ::testing::TestWithParam<TestConfiguration> {
6666
if (!test.initialCircuit.empty()) {
6767
std::stringstream ss(test.initialCircuit);
6868
qc::QuantumComputation qc{};
69-
qc.import(ss, qc::OpenQASM);
69+
qc.import(ss, qc::Format::OpenQASM);
7070
std::cout << "Initial circuit:\n" << qc;
7171
targetTableau = Tableau(qc);
7272
if (test.initialTableau.empty()) {

test/test_architecture.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ class TestArchitecture : public testing::TestWithParam<std::string> {
1111
protected:
1212
std::string test_architecture_dir = "./architectures/";
1313
std::string test_calibration_dir = "./calibration/";
14-
15-
void SetUp() override { using namespace dd::literals; }
1614
};
1715

1816
INSTANTIATE_TEST_SUITE_P(Architecture, TestArchitecture,

test/test_encodings.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ INSTANTIATE_TEST_SUITE_P(
3737
std::pair{Encoding::Bimander, CommanderGrouping::Fixed3}));
3838

3939
TEST_P(TestEncodings, ThreeToSevenQubits) {
40-
using namespace dd::literals;
40+
using namespace qc::literals;
4141

4242
qc = qc::QuantumComputation(3U);
4343
qc.x(2, 1_pc);
@@ -59,7 +59,7 @@ TEST_P(TestEncodings, ThreeToSevenQubits) {
5959
}
6060

6161
TEST_P(TestEncodings, FiveToSevenQubits) {
62-
using namespace dd::literals;
62+
using namespace qc::literals;
6363

6464
qc = qc::QuantumComputation(5U);
6565
qc.x(1, 0_pc);

0 commit comments

Comments
 (0)