Line | Branch | Decision | Exec | Source |
---|---|---|---|---|
1 | // Copyright 2019-2022 Cambridge Quantum Computing | |||
2 | // | |||
3 | // Licensed under the Apache License, Version 2.0 (the "License"); | |||
4 | // you may not use this file except in compliance with the License. | |||
5 | // You may obtain a copy of the License at | |||
6 | // | |||
7 | // http://www.apache.org/licenses/LICENSE-2.0 | |||
8 | // | |||
9 | // Unless required by applicable law or agreed to in writing, software | |||
10 | // distributed under the License is distributed on an "AS IS" BASIS, | |||
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
12 | // See the License for the specific language governing permissions and | |||
13 | // limitations under the License. | |||
14 | ||||
15 | #include "PassLibrary.hpp" | |||
16 | ||||
17 | #include <memory> | |||
18 | ||||
19 | #include "Circuit/CircPool.hpp" | |||
20 | #include "PassGenerators.hpp" | |||
21 | #include "Predicates/CompilerPass.hpp" | |||
22 | #include "Transformations/BasicOptimisation.hpp" | |||
23 | #include "Transformations/Decomposition.hpp" | |||
24 | #include "Transformations/MeasurePass.hpp" | |||
25 | #include "Transformations/OptimisationPass.hpp" | |||
26 | #include "Transformations/Rebase.hpp" | |||
27 | #include "Transformations/Transform.hpp" | |||
28 | #include "Utils/Json.hpp" | |||
29 | ||||
30 | namespace tket { | |||
31 | ||||
32 | template <typename T> | |||
33 | 7 | static PassPtr gate_translation_pass( | ||
34 | const T &transform, OpTypeSet after_set, bool respect_connectivity, | |||
35 | const std::string &name) { | |||
36 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | after_set.insert(OpType::Measure); | |
37 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | after_set.insert(OpType::Collapse); | |
38 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | after_set.insert(OpType::Reset); | |
39 | 7 | PredicatePtrMap precons; | ||
40 | 7 | std::type_index ti = typeid(ConnectivityPredicate); | ||
41 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | PredicatePtr out_gateset = std::make_shared<GateSetPredicate>(after_set); | |
42 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | PredicatePtr max2qb = std::make_shared<MaxTwoQubitGatesPredicate>(); | |
43 |
3/6✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 7 times.
✗ Branch 9 not taken.
|
28 | PredicatePtrMap postcon_spec = { | |
44 | CompilationUnit::make_type_pair(out_gateset), | |||
45 | CompilationUnit::make_type_pair(max2qb)}; | |||
46 | 7 | PredicateClassGuarantees g_postcons; | ||
47 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6 times.
|
2/2✓ Decision 'true' taken 1 times.
✓ Decision 'false' taken 6 times.
|
7 | if (!respect_connectivity) |
48 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | g_postcons.insert({ti, Guarantee::Clear}); // synthesis passes do not in | |
49 | // general preserve connectivity | |||
50 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | PostConditions postcon{postcon_spec, g_postcons, Guarantee::Preserve}; | |
51 | // record pass config | |||
52 | 7 | nlohmann::json j; | ||
53 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
7 | j["name"] = name; | |
54 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | PassPtr ptr = std::make_shared<StandardPass>(precons, transform, postcon, j); | |
55 | 14 | return ptr; | ||
56 | 7 | } | ||
57 | ||||
58 | 15 | const PassPtr &SynthesiseTK() { | ||
59 | static const PassPtr pp(gate_translation_pass( | |||
60 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Transforms::synthesise_tk(), {OpType::TK1, OpType::TK2}, true, | |
61 |
6/12✓ Branch 0 taken 1 times.
✓ Branch 1 taken 14 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
17 | "SynthesiseTK")); | |
62 | 15 | return pp; | ||
63 | } | |||
64 | 4 | const PassPtr &SynthesiseTket() { | ||
65 | static const PassPtr pp(gate_translation_pass( | |||
66 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Transforms::synthesise_tket(), {OpType::TK1, OpType::CX}, true, | |
67 |
6/12✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
6 | "SynthesiseTket")); | |
68 | 4 | return pp; | ||
69 | } | |||
70 | 5 | const PassPtr &SynthesiseHQS() { | ||
71 | static const PassPtr pp(gate_translation_pass( | |||
72 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Transforms::synthesise_HQS(), | |
73 |
6/12✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
7 | {OpType::ZZMax, OpType::PhasedX, OpType::Rz}, false, "SynthesiseHQS")); | |
74 | 5 | return pp; | ||
75 | } | |||
76 | 5 | const PassPtr &SynthesiseOQC() { | ||
77 | static const PassPtr pp(gate_translation_pass( | |||
78 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Transforms::synthesise_OQC(), {OpType::Rz, OpType::SX, OpType::ECR}, true, | |
79 |
6/12✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
7 | "SynthesiseOQC")); | |
80 | 5 | return pp; | ||
81 | } | |||
82 | 5 | const PassPtr &SynthesiseUMD() { | ||
83 | static const PassPtr pp(gate_translation_pass( | |||
84 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Transforms::synthesise_UMD(), | |
85 |
6/12✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
7 | {OpType::XXPhase, OpType::PhasedX, OpType::Rz}, true, "SynthesiseUMD")); | |
86 | 5 | return pp; | ||
87 | } | |||
88 | 5 | const PassPtr &RebaseTket() { | ||
89 | static const PassPtr pp(gate_translation_pass( | |||
90 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Transforms::rebase_tket(), {OpType::CX, OpType::TK1}, true, | |
91 |
6/12✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
7 | "RebaseTket")); | |
92 | 5 | return pp; | ||
93 | } | |||
94 | ||||
95 | 2 | const PassPtr &RebaseUFR() { | ||
96 | static const PassPtr pp(gate_translation_pass( | |||
97 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | Transforms::rebase_UFR(), {OpType::CX, OpType::Rz, OpType::H}, true, | |
98 |
6/12✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
|
4 | "RebaseUFR")); | |
99 | 2 | return pp; | ||
100 | } | |||
101 | ||||
102 | 5 | const PassPtr &PeepholeOptimise2Q() { | ||
103 | OpTypeSet after_set = { | |||
104 | OpType::TK1, OpType::CX, OpType::Measure, OpType::Collapse, | |||
105 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | OpType::Reset}; | |
106 | 5 | PredicatePtrMap precons = {}; | ||
107 | 5 | std::type_index ti = typeid(ConnectivityPredicate); | ||
108 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | PredicatePtr out_gateset = std::make_shared<GateSetPredicate>(after_set); | |
109 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | PredicatePtr max2qb = std::make_shared<MaxTwoQubitGatesPredicate>(); | |
110 | PredicatePtrMap postcon_spec = { | |||
111 | CompilationUnit::make_type_pair(out_gateset), | |||
112 |
3/6✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 5 times.
✗ Branch 9 not taken.
|
20 | CompilationUnit::make_type_pair(max2qb)}; | |
113 | 5 | PredicateClassGuarantees g_postcons; | ||
114 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | g_postcons.insert({ti, Guarantee::Clear}); | |
115 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | PostConditions postcon{postcon_spec, g_postcons, Guarantee::Preserve}; | |
116 | // record pass config | |||
117 | 5 | nlohmann::json j; | ||
118 |
2/4✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
|
5 | j["name"] = "PeepholeOptimise2Q"; | |
119 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | static const PassPtr pp(std::make_shared<StandardPass>( | |
120 |
4/8✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
|
7 | precons, Transforms::peephole_optimise_2q(), postcon, j)); | |
121 | 5 | return pp; | ||
122 | 5 | } | ||
123 | ||||
124 | 13 | const PassPtr &RemoveRedundancies() { | ||
125 | 1 | static const PassPtr pp([]() { | ||
126 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Transform t = Transforms::remove_redundancies(); | |
127 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
2 | PostConditions postcon = {{}, {}, Guarantee::Preserve}; | |
128 | 1 | PredicatePtrMap precons; | ||
129 | // record pass config | |||
130 | 1 | nlohmann::json j; | ||
131 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | j["name"] = "RemoveRedundancies"; | |
132 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return std::make_shared<StandardPass>(precons, t, postcon, j); | |
133 |
4/8✓ Branch 0 taken 1 times.
✓ Branch 1 taken 12 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
14 | }()); | |
134 | 13 | return pp; | ||
135 | } | |||
136 | ||||
137 | 6 | const PassPtr &CommuteThroughMultis() { | ||
138 | 1 | static const PassPtr pp([]() { | ||
139 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Transform t = Transforms::commute_through_multis(); | |
140 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
2 | PostConditions postcon = {{}, {}, Guarantee::Preserve}; | |
141 | 1 | PredicatePtrMap precons; | ||
142 | // record pass config | |||
143 | 1 | nlohmann::json j; | ||
144 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | j["name"] = "CommuteThroughMultis"; | |
145 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return std::make_shared<StandardPass>(precons, t, postcon, j); | |
146 |
4/8✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
7 | }()); | |
147 | 6 | return pp; | ||
148 | } | |||
149 | ||||
150 | 3 | const PassPtr &DecomposeArbitrarilyControlledGates() { | ||
151 | 1 | static const PassPtr pp([]() { | ||
152 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Transform t = Transforms::decomp_arbitrary_controlled_gates(); | |
153 | PredicateClassGuarantees g_postcons = { | |||
154 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | {typeid(GateSetPredicate), Guarantee::Clear}}; | |
155 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | PostConditions postcon = {{}, g_postcons, Guarantee::Preserve}; | |
156 | 1 | PredicatePtrMap precons; | ||
157 | // record pass config | |||
158 | 1 | nlohmann::json j; | ||
159 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | j["name"] = "DecomposeArbitrarilyControlledGates"; | |
160 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return std::make_shared<StandardPass>(precons, t, postcon, j); | |
161 |
4/8✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
4 | }()); | |
162 | 3 | return pp; | ||
163 | } | |||
164 | ||||
165 | 2 | const PassPtr &DecomposeMultiQubitsCX() { | ||
166 | 1 | static const PassPtr pp([]() { | ||
167 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Transform t = Transforms::decompose_multi_qubits_CX(); | |
168 | /* Spits out CX + any single qb gates */ | |||
169 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | OpTypeSet ots = {OpType::CX}; | |
170 | 1 | op_signature_t noargs = {}; | ||
171 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | op_signature_t singleq = {EdgeType::Quantum}; | |
172 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
|
1 | ots.insert(all_projective_types().begin(), all_projective_types().end()); | |
173 |
3/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 8 taken 96 times.
✓ Branch 9 taken 1 times.
|
0/1? Decision couldn't be analyzed.
|
97 | for (const std::pair<const OpType, OpTypeInfo> &ott : optypeinfo()) { |
174 |
7/8✓ Branch 1 taken 69 times.
✓ Branch 2 taken 27 times.
✓ Branch 5 taken 69 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 41 times.
✓ Branch 8 taken 28 times.
✓ Branch 9 taken 59 times.
✓ Branch 10 taken 37 times.
|
2/2✓ Decision 'true' taken 59 times.
✓ Decision 'false' taken 78 times.
|
137 | if (!ott.second.signature || *ott.second.signature == singleq || |
175 |
3/4✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 37 times.
|
41 | *ott.second.signature == noargs) | |
176 |
1/2✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
|
59 | ots.insert(ott.first); | |
177 | } | |||
178 | 1 | PredicatePtrMap precons; | ||
179 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | PredicatePtr outp_gates = std::make_shared<GateSetPredicate>(ots); | |
180 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | PredicatePtr twoqbpred = std::make_shared<MaxTwoQubitGatesPredicate>(); | |
181 | PredicatePtrMap spec_postcons = { | |||
182 | CompilationUnit::make_type_pair(outp_gates), | |||
183 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
4 | CompilationUnit::make_type_pair(twoqbpred)}; | |
184 | 1 | PredicateClassGuarantees g_postcons; | ||
185 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | PostConditions postcon{spec_postcons, g_postcons, Guarantee::Preserve}; | |
186 | // record pass config | |||
187 | 1 | nlohmann::json j; | ||
188 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | j["name"] = "DecomposeMultiQubitsCX"; | |
189 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return std::make_shared<StandardPass>(precons, t, postcon, j); | |
190 |
4/8✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
3 | }()); | |
191 | 2 | return pp; | ||
192 | } | |||
193 | ||||
194 | 2 | const PassPtr &DecomposeSingleQubitsTK1() { | ||
195 | 1 | static const PassPtr pp([]() { | ||
196 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Transform t = Transforms::decompose_single_qubits_TK1(); | |
197 | /* Spits out TK1 + any multi qb gates */ | |||
198 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | OpTypeSet ots = {OpType::TK1}; | |
199 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | op_signature_t singleq = {EdgeType::Quantum}; | |
200 |
3/6✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
|
1 | ots.insert(all_projective_types().begin(), all_projective_types().end()); | |
201 |
3/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 8 taken 96 times.
✓ Branch 9 taken 1 times.
|
0/1? Decision couldn't be analyzed.
|
97 | for (const std::pair<const OpType, OpTypeInfo> &ott : optypeinfo()) { |
202 |
7/8✓ Branch 1 taken 69 times.
✓ Branch 2 taken 27 times.
✓ Branch 5 taken 69 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 41 times.
✓ Branch 8 taken 28 times.
✓ Branch 9 taken 68 times.
✓ Branch 10 taken 28 times.
|
2/2✓ Decision 'true' taken 68 times.
✓ Decision 'false' taken 28 times.
|
96 | if (!ott.second.signature || *ott.second.signature != singleq) |
203 |
1/2✓ Branch 1 taken 68 times.
✗ Branch 2 not taken.
|
68 | ots.insert(ott.first); | |
204 | } | |||
205 | 1 | PredicatePtrMap precons; | ||
206 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | PredicatePtr outp_gates = std::make_shared<GateSetPredicate>(ots); | |
207 | PredicatePtrMap spec_postcons = { | |||
208 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
3 | CompilationUnit::make_type_pair(outp_gates)}; | |
209 | 1 | PredicateClassGuarantees g_postcons; | ||
210 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | PostConditions postcon{spec_postcons, g_postcons, Guarantee::Preserve}; | |
211 | // record pass config | |||
212 | 1 | nlohmann::json j; | ||
213 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | j["name"] = "DecomposeSingleQubitsTK1"; | |
214 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return std::make_shared<StandardPass>(precons, t, postcon, j); | |
215 |
4/8✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
3 | }()); | |
216 | 2 | return pp; | ||
217 | } | |||
218 | ||||
219 | 24 | PassPtr ComposePhasePolyBoxes(const unsigned min_size) { | ||
220 | /** | |||
221 | * converts a circuit containing all possible gates to a circuit | |||
222 | * containing only phase poly boxes + H gates (and measure + reset + collapse | |||
223 | * + barrier) | |||
224 | * this pass will replace all wire swaps in the given circuit and they will be | |||
225 | * included in the last or an additional phase poly boxes | |||
226 | */ | |||
227 | ||||
228 | Transform t = | |||
229 |
1/2✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
|
24 | (Transforms::rebase_UFR() >> | |
230 |
2/4✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 24 times.
✗ Branch 5 not taken.
|
48 | Transforms::compose_phase_poly_boxes(min_size)); | |
231 | ||||
232 |
1/2✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
|
24 | PredicatePtr noclas = std::make_shared<NoClassicalControlPredicate>(); | |
233 | ||||
234 |
2/4✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 24 times.
✗ Branch 6 not taken.
|
72 | PredicatePtrMap precons{CompilationUnit::make_type_pair(noclas)}; | |
235 | ||||
236 |
1/2✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
|
24 | PredicatePtr no_wire_swap = std::make_shared<NoWireSwapsPredicate>(); | |
237 | ||||
238 | PredicatePtrMap s_postcons{ | |||
239 | CompilationUnit::make_type_pair(noclas), | |||
240 |
3/6✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 24 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 24 times.
✗ Branch 9 not taken.
|
96 | CompilationUnit::make_type_pair(no_wire_swap)}; | |
241 |
1/2✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
|
24 | PostConditions postcon{s_postcons, {}, Guarantee::Preserve}; | |
242 | ||||
243 | 24 | nlohmann::json j; | ||
244 |
2/4✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 24 times.
✗ Branch 5 not taken.
|
24 | j["name"] = "ComposePhasePolyBoxes"; | |
245 |
1/2✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
|
24 | j["min_size"] = min_size; | |
246 | ||||
247 |
1/2✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
|
48 | return std::make_shared<StandardPass>(precons, t, postcon, j); | |
248 | 24 | } | ||
249 | ||||
250 | 6 | const PassPtr &DecomposeBoxes() { | ||
251 | 1 | static const PassPtr pp([]() { | ||
252 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Transform t = Transforms::decomp_boxes(); | |
253 | 1 | PredicatePtrMap s_ps; | ||
254 | /** | |||
255 | * Preserves Max2QubitGatesPredicate since any box with >2 qubits is | |||
256 | * already invalid. | |||
257 | * Preserves ConnectivityPredicate (and DirectednessPredicate) since the | |||
258 | * verification looks inside CircBoxes and any other boxes with >2 | |||
259 | * qubits are already invalid. | |||
260 | * Most others are preserved since the predicates look within CircBoxes. | |||
261 | * | |||
262 | * Invalidates GateSetPredicate because it doesn't look inside boxes or | |||
263 | * account for the gate set of their decomposition. | |||
264 | */ | |||
265 | PredicateClassGuarantees g_postcons = { | |||
266 | ✗ | {typeid(GateSetPredicate), Guarantee::Clear}, | ||
267 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | }; | |
268 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | PostConditions postcon{s_ps, g_postcons, Guarantee::Preserve}; | |
269 | // record pass config | |||
270 | 1 | nlohmann::json j; | ||
271 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | j["name"] = "DecomposeBoxes"; | |
272 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return std::make_shared<StandardPass>(s_ps, t, postcon, j); | |
273 |
4/8✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
7 | }()); | |
274 | 6 | return pp; | ||
275 | } | |||
276 | ||||
277 | 2 | const PassPtr &SquashTK1() { | ||
278 | 1 | static const PassPtr pp([]() { | ||
279 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Transform t = Transforms::squash_1qb_to_tk1(); | |
280 | 1 | PredicatePtrMap s_ps; | ||
281 | PredicateClassGuarantees g_postcons{ | |||
282 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | {typeid(GateSetPredicate), Guarantee::Clear}}; | |
283 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | PostConditions postcon{s_ps, g_postcons, Guarantee::Preserve}; | |
284 | // record pass config | |||
285 | 1 | nlohmann::json j; | ||
286 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | j["name"] = "SquashTK1"; | |
287 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return std::make_shared<StandardPass>(s_ps, t, postcon, j); | |
288 |
4/8✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
3 | }()); | |
289 | 2 | return pp; | ||
290 | } | |||
291 | ||||
292 | 2 | const PassPtr &DecomposeBridges() { | ||
293 | 1 | static const PassPtr pp([]() { | ||
294 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Transform t = Transforms::decompose_BRIDGE_to_CX(); | |
295 | 1 | PredicatePtrMap s_ps; | ||
296 | PredicateClassGuarantees g_postcons{ | |||
297 | ✗ | {typeid(GateSetPredicate), Guarantee::Clear}, | ||
298 |
1/2✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | {typeid(DirectednessPredicate), Guarantee::Clear}}; | |
299 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | PostConditions postcon{s_ps, g_postcons, Guarantee::Preserve}; | |
300 | 1 | nlohmann::json j; | ||
301 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | j["name"] = "DecomposeBridges"; | |
302 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return std::make_shared<StandardPass>(s_ps, t, postcon, j); | |
303 |
4/8✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
3 | }()); | |
304 | 2 | return pp; | ||
305 | } | |||
306 | ||||
307 | 4 | const PassPtr &FlattenRegisters() { | ||
308 | 1 | static const PassPtr pp([]() { | ||
309 | Transform t = | |||
310 | 4 | Transform([](Circuit &circ, std::shared_ptr<unit_bimaps_t> maps) { | ||
311 |
3/4✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 1 times.
|
2/2✓ Decision 'true' taken 1 times.
✓ Decision 'false' taken 3 times.
|
4 | if (circ.is_simple()) return false; |
312 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | unit_map_t qmap = circ.flatten_registers(); | |
313 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | update_maps(maps, qmap, qmap); | |
314 | 1 | return true; | ||
315 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | }); | |
316 | 1 | PredicatePtrMap s_ps; | ||
317 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | PredicatePtr simple = std::make_shared<DefaultRegisterPredicate>(); | |
318 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
3 | PredicatePtrMap spec_postcons{CompilationUnit::make_type_pair(simple)}; | |
319 | PredicateClassGuarantees g_postcons{ | |||
320 | ✗ | {typeid(ConnectivityPredicate), Guarantee::Clear}, | ||
321 |
1/2✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | {typeid(DirectednessPredicate), Guarantee::Clear}}; | |
322 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | PostConditions postcon{spec_postcons, g_postcons, Guarantee::Preserve}; | |
323 | // record pass config | |||
324 | 1 | nlohmann::json j; | ||
325 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | j["name"] = "FlattenRegisters"; | |
326 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return std::make_shared<StandardPass>(s_ps, t, postcon, j); | |
327 |
4/8✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
5 | }()); | |
328 | 4 | return pp; | ||
329 | } | |||
330 | ||||
331 | 4 | const PassPtr &RemoveBarriers() { | ||
332 | 1 | static const PassPtr pp([]() { | ||
333 | 4 | Transform t = Transform([](Circuit &circ) { | ||
334 | 4 | VertexList barriers; | ||
335 |
7/8✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 95 times.
✓ Branch 6 taken 4 times.
✓ Branch 8 taken 95 times.
✓ Branch 9 taken 4 times.
✓ Branch 11 taken 4 times.
✓ Branch 12 taken 4 times.
|
103 | BGL_FORALL_VERTICES(v, circ.dag, DAG) { | |
336 |
3/4✓ Branch 1 taken 95 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 94 times.
|
2/2✓ Decision 'true' taken 1 times.
✓ Decision 'false' taken 94 times.
|
95 | if (circ.get_OpType_from_Vertex(v) == OpType::Barrier) { |
337 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | barriers.push_back(v); | |
338 | } | |||
339 | } | |||
340 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | circ.remove_vertices( | |
341 | barriers, Circuit::GraphRewiring::Yes, Circuit::VertexDeletion::Yes); | |||
342 | 8 | return !barriers.empty(); | ||
343 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
5 | }); | |
344 | 1 | const PredicatePtrMap no_precons; | ||
345 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | const PredicatePtr no_barriers = std::make_shared<NoBarriersPredicate>(); | |
346 | PredicatePtrMap no_barriers_con{ | |||
347 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
3 | CompilationUnit::make_type_pair(no_barriers)}; | |
348 | 1 | PredicateClassGuarantees preserve_all; | ||
349 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | PostConditions postcons{no_barriers_con, preserve_all, Guarantee::Preserve}; | |
350 | 1 | nlohmann::json j; | ||
351 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | j["name"] = "RemoveBarriers"; | |
352 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return std::make_shared<StandardPass>(no_precons, t, postcons, j); | |
353 |
4/8✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
5 | }()); | |
354 | 4 | return pp; | ||
355 | } | |||
356 | ||||
357 | 12 | const PassPtr &DelayMeasures() { | ||
358 | 1 | static const PassPtr pp([]() { | ||
359 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Transform t = Transforms::delay_measures(); | |
360 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | PredicatePtr midmeaspred = std::make_shared<NoMidMeasurePredicate>(); | |
361 | PredicatePtrMap spec_postcons = { | |||
362 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
3 | CompilationUnit::make_type_pair(midmeaspred)}; | |
363 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | PostConditions postcon = {spec_postcons, {}, Guarantee::Preserve}; | |
364 | 1 | PredicatePtrMap precons; | ||
365 | // record pass config | |||
366 | 1 | nlohmann::json j; | ||
367 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | j["name"] = "DelayMeasures"; | |
368 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return std::make_shared<StandardPass>(precons, t, postcon, j); | |
369 |
4/8✓ Branch 0 taken 1 times.
✓ Branch 1 taken 11 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
13 | }()); | |
370 | 12 | return pp; | ||
371 | } | |||
372 | ||||
373 | 6 | const PassPtr &RemoveDiscarded() { | ||
374 | 1 | static const PassPtr pp([]() { | ||
375 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Transform t = Transforms::remove_discarded_ops(); | |
376 | 1 | PredicatePtrMap no_precons; | ||
377 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
2 | PostConditions postcon = {{}, {}, Guarantee::Preserve}; | |
378 | 1 | nlohmann::json j; | ||
379 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | j["name"] = "RemoveDiscarded"; | |
380 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return std::make_shared<StandardPass>(no_precons, t, postcon, j); | |
381 |
4/8✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
7 | }()); | |
382 | 6 | return pp; | ||
383 | } | |||
384 | ||||
385 | 6 | const PassPtr &SimplifyMeasured() { | ||
386 | 1 | static const PassPtr pp([]() { | ||
387 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Transform t = Transforms::simplify_measured(); | |
388 | 1 | PredicatePtrMap no_precons; | ||
389 | ||||
390 | // GateSetPredicate not preserved because classical gates may be | |||
391 | // introduced. | |||
392 | PredicateClassGuarantees g_postcons = { | |||
393 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | {typeid(GateSetPredicate), Guarantee::Clear}}; | |
394 | ||||
395 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | PostConditions postcon = {{}, g_postcons, Guarantee::Preserve}; | |
396 | 1 | nlohmann::json j; | ||
397 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | j["name"] = "SimplifyMeasured"; | |
398 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return std::make_shared<StandardPass>(no_precons, t, postcon, j); | |
399 |
4/8✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
7 | }()); | |
400 | 6 | return pp; | ||
401 | } | |||
402 | ||||
403 | 6 | const PassPtr &NormaliseTK2() { | ||
404 | 1 | static const PassPtr pp([]() { | ||
405 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Transform t = Transforms::normalise_TK2(); | |
406 | 1 | PredicatePtrMap no_precons; | ||
407 | ||||
408 | // GateSetPredicate not preserved because single-qubit gates may be added | |||
409 | PredicateClassGuarantees g_postcons = { | |||
410 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | {typeid(GateSetPredicate), Guarantee::Clear}}; | |
411 | ||||
412 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | PredicatePtr normalisedpred = std::make_shared<NormalisedTK2Predicate>(); | |
413 | PredicatePtrMap spec_postcons = { | |||
414 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
3 | CompilationUnit::make_type_pair(normalisedpred)}; | |
415 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | PostConditions postcon = {spec_postcons, g_postcons, Guarantee::Preserve}; | |
416 | 1 | nlohmann::json j; | ||
417 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | j["name"] = "NormaliseTK2"; | |
418 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return std::make_shared<StandardPass>(no_precons, t, postcon, j); | |
419 |
4/8✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
7 | }()); | |
420 | 6 | return pp; | ||
421 | } | |||
422 | ||||
423 | 3 | const PassPtr &ZZPhaseToRz() { | ||
424 | 1 | static const PassPtr pp([]() { | ||
425 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Transform t = Transforms::ZZPhase_to_Rz(); | |
426 | // GateSetPredicate not preserved because ZZPhase gates may be converted to | |||
427 | // Rz gates | |||
428 | PredicateClassGuarantees g_postcons = { | |||
429 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | {typeid(GateSetPredicate), Guarantee::Clear}}; | |
430 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | PostConditions postcon = {{}, g_postcons, Guarantee::Preserve}; | |
431 | 1 | PredicatePtrMap precons; | ||
432 | // record pass config | |||
433 | 1 | nlohmann::json j; | ||
434 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | j["name"] = "ZZPhaseToRz"; | |
435 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return std::make_shared<StandardPass>(precons, t, postcon, j); | |
436 |
4/8✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
4 | }()); | |
437 | 3 | return pp; | ||
438 | } | |||
439 | ||||
440 | 3 | const PassPtr &SquashRzPhasedX() { | ||
441 | 1 | static const PassPtr pp([]() { | ||
442 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Transform t = Transforms::squash_1qb_to_Rz_PhasedX(); | |
443 | 1 | PredicatePtrMap s_ps; | ||
444 | PredicateClassGuarantees g_postcons{ | |||
445 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | {typeid(GateSetPredicate), Guarantee::Clear}}; | |
446 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | PostConditions postcon{s_ps, g_postcons, Guarantee::Preserve}; | |
447 | 1 | nlohmann::json j; | ||
448 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | j["name"] = "SquashRzPhasedX"; | |
449 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return std::make_shared<StandardPass>(s_ps, t, postcon, j); | |
450 |
4/8✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
4 | }()); | |
451 | 3 | return pp; | ||
452 | } | |||
453 | ||||
454 | } // namespace tket | |||
455 |