-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge RoutingMethod::check_method
and RoutingMethod::routing_method
#244
Changes from 157 commits
3c84f72
39f46d3
8ba7968
5b50029
4c92d8d
edba555
6592cfd
b3cda73
a61e1fb
af08810
24be612
8295443
ad98c38
d46a49c
1f71597
1319c0e
b31c2c0
b18a8db
0941f74
d9aa114
eba680a
89a3dfe
c9cf8b2
b2b0680
7b6289b
05c3908
548e52e
edeaf70
8b5f108
c1f3e53
e0d7dee
568283f
33436f1
66ce863
3aab473
a9f7478
0516423
7e37426
25bf193
df0c739
c4f427e
389fc2a
991b85d
df99fbf
8fbe2f4
719498a
fd09f42
fc6bbe8
3e4ee20
2d3a1ab
740cfc6
04efd72
1b667a5
7fede77
ca40c43
5991a8c
032f64e
52f221c
7d7ba1f
dc761e0
d805b0b
e3f2b68
e8f23dc
4a210cc
bac8cc2
2d2d25d
20404bf
3cffd1f
7c092f2
9a9007d
849c7c5
8ed2f2b
2b20d2f
86fb61e
4d2dbce
0202c30
a112236
650a189
0e742a8
ca30a50
3366e22
b67528c
db33a86
3e518df
8719249
07aa0ed
f065447
34507b6
7e08c8c
067782d
efeb704
c88e949
ef57306
192171a
61a7b7e
51cabf0
fff97a9
96a8aa6
890180b
b460561
97b1efa
f7878df
3a1ce49
f1e2c0b
281e70a
de2f963
d7bbd01
c6259aa
7533f90
220a7b0
1bd2dfd
770ac41
9fbbd95
f7452df
f10be47
b75e7f9
abe3445
a1b5a49
f24e76b
7eaf6fe
904bd16
8fe485f
ecd9b51
329f223
05661f6
53fef17
2d56e46
f9394eb
4f2ded6
517c883
a53b7ee
4999115
8575f32
ac29545
222fee6
e3ae6bc
5245c1f
3435365
237e23e
042ab9b
d40c098
080a878
61dde34
8820c92
6809f96
587780a
c7a830a
efeeca3
ac4d57c
b704bb1
ea540e8
6ebf1cc
1a6d41a
b2f0c58
fbbab7a
1e7afaa
957c382
53baa75
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,32 +17,15 @@ | |
namespace tket { | ||
|
||
RoutingMethodCircuit::RoutingMethodCircuit( | ||
const std::function<std::tuple<Circuit, unit_map_t, unit_map_t>( | ||
const std::function<std::tuple<bool, Circuit, unit_map_t, unit_map_t>( | ||
const Circuit&, const ArchitecturePtr&)> | ||
_route_subcircuit, | ||
const std::function<bool(const Circuit&, const ArchitecturePtr&)> | ||
_check_subcircuit, | ||
unsigned _max_size, unsigned _max_depth) | ||
: route_subcircuit_(_route_subcircuit), | ||
check_subcircuit_(_check_subcircuit), | ||
max_size_(_max_size), | ||
max_depth_(_max_depth){}; | ||
|
||
bool RoutingMethodCircuit::check_method( | ||
const std::shared_ptr<MappingFrontier>& mapping_frontier, | ||
const ArchitecturePtr& architecture) const { | ||
// Get circuit, pass to held check method | ||
Subcircuit frontier_subcircuit = mapping_frontier->get_frontier_subcircuit( | ||
this->max_depth_, this->max_size_); | ||
Circuit frontier_circuit = | ||
mapping_frontier->circuit_.subcircuit(frontier_subcircuit); | ||
frontier_circuit.rename_units( | ||
mapping_frontier->get_default_to_quantum_boundary_unit_map()); | ||
|
||
return this->check_subcircuit_(frontier_circuit, architecture); | ||
} | ||
|
||
unit_map_t RoutingMethodCircuit::routing_method( | ||
std::pair<bool, unit_map_t> RoutingMethodCircuit::routing_method( | ||
std::shared_ptr<MappingFrontier>& mapping_frontier, | ||
const ArchitecturePtr& architecture) const { | ||
// Produce subcircuit and circuit | ||
|
@@ -54,30 +37,33 @@ unit_map_t RoutingMethodCircuit::routing_method( | |
mapping_frontier->get_default_to_quantum_boundary_unit_map()); | ||
|
||
// get routed subcircuit | ||
std::tuple<Circuit, unit_map_t, unit_map_t> routed_subcircuit = | ||
std::tuple<bool, Circuit, unit_map_t, unit_map_t> routed_subcircuit = | ||
this->route_subcircuit_(frontier_circuit, architecture); | ||
unit_map_t new_labelling = std::get<1>(routed_subcircuit); | ||
|
||
if (!get<0>(routed_subcircuit)) { | ||
return {false, {}}; | ||
} | ||
|
||
// update unit id at boundary in case of relabelling | ||
mapping_frontier->update_quantum_boundary_uids(new_labelling); | ||
mapping_frontier->update_quantum_boundary_uids(get<2>(routed_subcircuit)); | ||
|
||
unit_map_t swap_permutation; | ||
for (const auto& pair : new_labelling) { | ||
for (const auto& pair : get<2>(routed_subcircuit)) { | ||
if (pair.first != pair.second && | ||
architecture->node_exists(Node(pair.first))) { | ||
swap_permutation.insert(pair); | ||
} | ||
} | ||
// permute edges held by unitid at out boundary due to swaps | ||
mapping_frontier->permute_subcircuit_q_out_hole( | ||
std::get<2>(routed_subcircuit), frontier_subcircuit); | ||
get<3>(routed_subcircuit), frontier_subcircuit); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure how this builds: I couldn't find a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed |
||
|
||
// substitute old boundary with new cirucit | ||
std::get<0>(routed_subcircuit).flatten_registers(); | ||
get<1>(routed_subcircuit).flatten_registers(); | ||
mapping_frontier->circuit_.substitute( | ||
std::get<0>(routed_subcircuit), frontier_subcircuit); | ||
get<1>(routed_subcircuit), frontier_subcircuit); | ||
// return initial unit_map_t incase swap network required | ||
return swap_permutation; | ||
return {true, swap_permutation}; | ||
} | ||
|
||
} // namespace tket |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done