Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ORNL Quantum Computing Institute
xacc
Commits
60c35f1c
Commit
60c35f1c
authored
Jul 16, 2020
by
Nguyen, Thien Minh
Browse files
Fixed an edge case
Optimized block == rest of circuit. Signed-off-by:
Thien Nguyen
<
nguyentm@ornl.gov
>
parent
6213a433
Changes
1
Hide whitespace changes
Inline
Side-by-side
quantum/plugins/optimizers/gate_merge/GateMergeOptimizer.cpp
View file @
60c35f1c
...
...
@@ -46,12 +46,24 @@ void MergeSingleQubitGatesOptimizer::apply(std::shared_ptr<CompositeInstruction>
instrPtr
->
disable
();
}
program
->
removeDisabled
();
const
auto
locationToInsert
=
sequence
[
0
];
for
(
auto
&
newInst
:
zyz
->
getInstructions
())
if
(
program
->
nInstructions
()
==
sequence
[
0
])
{
newInst
->
setBits
({
bitIdx
});
program
->
insertInstruction
(
locationToInsert
,
newInst
->
clone
());
for
(
auto
&
newInst
:
zyz
->
getInstructions
())
{
newInst
->
setBits
({
bitIdx
});
program
->
addInstruction
(
newInst
->
clone
());
}
}
else
{
const
auto
locationToInsert
=
sequence
[
0
];
for
(
auto
&
newInst
:
zyz
->
getInstructions
())
{
newInst
->
setBits
({
bitIdx
});
program
->
insertInstruction
(
locationToInsert
,
newInst
->
clone
());
}
}
const
auto
programLengthAfter
=
program
->
nInstructions
();
assert
(
programLengthAfter
<
programLengthBefore
);
}
...
...
@@ -196,13 +208,25 @@ void MergeTwoQubitBlockOptimizer::apply(std::shared_ptr<CompositeInstruction> pr
instrPtr
->
disable
();
}
program
->
removeDisabled
();
const
auto
locationToInsert
=
sequence
[
0
];
for
(
auto
&
newInst
:
kak
->
getInstructions
())
if
(
program
->
nInstructions
()
==
sequence
[
0
])
{
newInst
->
setBits
(
remapBits
(
newInst
->
bits
()));
program
->
insertInstruction
(
locationToInsert
,
newInst
->
clone
());
for
(
auto
&
newInst
:
kak
->
getInstructions
())
{
newInst
->
setBits
(
remapBits
(
newInst
->
bits
()));
program
->
addInstruction
(
newInst
->
clone
());
}
}
else
{
const
auto
locationToInsert
=
sequence
[
0
];
for
(
auto
&
newInst
:
kak
->
getInstructions
())
{
newInst
->
setBits
(
remapBits
(
newInst
->
bits
()));
program
->
insertInstruction
(
locationToInsert
,
newInst
->
clone
());
}
}
// Jump forward since we don't want to re-analyze this block.
instIdx
+=
nbInstructionsAfter
;
const
auto
programLengthAfter
=
program
->
nInstructions
();
assert
(
programLengthAfter
<
programLengthBefore
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment