Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ORNL Quantum Computing Institute
xacc
Commits
a8b8bf5d
Commit
a8b8bf5d
authored
Jun 17, 2020
by
Mccaskey, Alex
Browse files
restructure on commongates to remove xacc.hpp inclusion, fix gate clone to clone buffernames
Signed-off-by:
Alex McCaskey
<
mccaskeyaj@ornl.gov
>
parent
de6c5ce7
Pipeline
#107455
passed with stage
in 22 minutes and 55 seconds
Changes
17
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
quantum/gate/ir/Circuit.cpp
View file @
a8b8bf5d
...
...
@@ -20,6 +20,7 @@ using namespace rapidjson;
#include
"JsonVisitor.hpp"
#include
"IRProvider.hpp"
#include
"IRToGraphVisitor.hpp"
#include
"xacc_service.hpp"
namespace
xacc
{
namespace
quantum
{
...
...
quantum/gate/ir/Circuit.hpp
View file @
a8b8bf5d
...
...
@@ -18,7 +18,6 @@
#include
"InstructionIterator.hpp"
#include
"Utils.hpp"
#include
"expression_parsing_util.hpp"
#include
"xacc_service.hpp"
#include
<limits>
#include
<memory>
#include
<stdexcept>
...
...
quantum/gate/ir/CommonGates.cpp
0 → 100644
View file @
a8b8bf5d
#include
"CommonGates.hpp"
#include
"xacc.hpp"
namespace
xacc
{
namespace
quantum
{
bool
IfStmt
::
expand
(
const
HeterogeneousMap
&
runtimeOptions
)
{
auto
buffer
=
xacc
::
getBuffer
(
bufferName
);
if
((
*
buffer
)[
bitIdx
])
{
for
(
auto
&
i
:
instructions
)
{
i
->
enable
();
}
}
else
{
// Note: although sub-instructions are initially disabled,
// we need to disable here as well just in case we run multiple shots
// and they may be enabled in the previous run.
disable
();
}
return
true
;
}
}
// namespace quantum
}
// namespace xacc
\ No newline at end of file
quantum/gate/ir/CommonGates.hpp
View file @
a8b8bf5d
...
...
@@ -15,7 +15,6 @@
#include
"Gate.hpp"
#include
"Circuit.hpp"
#include
"xacc.hpp"
namespace
xacc
{
namespace
quantum
{
...
...
@@ -86,21 +85,8 @@ public:
Circuit
::
addInstruction
(
instruction
);
}
bool
expand
(
const
HeterogeneousMap
&
runtimeOptions
)
override
{
auto
buffer
=
xacc
::
getBuffer
(
bufferName
);
if
((
*
buffer
)[
bitIdx
])
{
for
(
auto
&
i
:
instructions
)
{
i
->
enable
();
}
}
else
{
// Note: although sub-instructions are initially disabled,
// we need to disable here as well just in case we run multiple shots
// and they may be enabled in the previous run.
disable
();
}
return
true
;
}
bool
expand
(
const
HeterogeneousMap
&
runtimeOptions
)
override
;
void
disable
()
override
{
for
(
auto
&
i
:
instructions
)
{
i
->
disable
();
...
...
quantum/gate/ir/Gate.cpp
View file @
a8b8bf5d
...
...
@@ -29,7 +29,7 @@ Gate::Gate(std::string name, std::vector<std::size_t> qubts,
:
gateName
(
name
),
qbits
(
qubts
),
parameters
(
params
)
{}
Gate
::
Gate
(
const
Gate
&
inst
)
:
gateName
(
inst
.
gateName
),
qbits
(
inst
.
qbits
),
parameters
(
inst
.
parameters
),
arguments
(
inst
.
arguments
),
enabled
(
inst
.
enabled
)
{}
arguments
(
inst
.
arguments
),
enabled
(
inst
.
enabled
)
,
buffer_names
(
inst
.
buffer_names
)
{}
const
std
::
string
Gate
::
name
()
const
{
return
gateName
;
}
const
std
::
string
Gate
::
description
()
const
{
...
...
quantum/observable/fermion/FermionOperator.cpp
View file @
a8b8bf5d
...
...
@@ -17,6 +17,7 @@
#include
"ObservableTransform.hpp"
#include
"xacc_service.hpp"
#include
<Utils.hpp>
namespace
xacc
{
namespace
quantum
{
...
...
@@ -97,7 +98,7 @@ void FermionOperator::clear() { terms.clear(); }
std
::
vector
<
std
::
shared_ptr
<
CompositeInstruction
>>
FermionOperator
::
observe
(
std
::
shared_ptr
<
CompositeInstruction
>
function
)
{
auto
transform
=
xacc
::
getService
<
ObservableTransform
>
(
"jw"
);
return
transform
->
transform
(
shared_
from_
this
(
))
->
observe
(
function
);
return
transform
->
transform
(
xacc
::
as_
shared_
ptr
(
this
))
->
observe
(
function
);
}
const
std
::
string
FermionOperator
::
toString
()
{
...
...
quantum/plugins/algorithms/qaoa/qaoa_circuit.hpp
View file @
a8b8bf5d
...
...
@@ -14,6 +14,8 @@
#include
"Circuit.hpp"
#include
"IRProvider.hpp"
#include
"Observable.hpp"
#include
"xacc_service.hpp"
namespace
xacc
{
namespace
circuits
{
...
...
quantum/plugins/algorithms/qpe/ControlledGateApplicator.cpp
View file @
a8b8bf5d
...
...
@@ -11,6 +11,7 @@
* Thien Nguyen - initial API and implementation
*******************************************************************************/
#include
"ControlledGateApplicator.hpp"
#include
"xacc_service.hpp"
namespace
xacc
{
namespace
circuits
{
...
...
quantum/plugins/algorithms/qpe/ControlledGateApplicator.hpp
View file @
a8b8bf5d
...
...
@@ -11,7 +11,7 @@
* Thien Nguyen - initial API and implementation
*******************************************************************************/
#pragma once
#include
"xacc.hpp"
#include
"AllGateVisitor.hpp"
using
namespace
xacc
::
quantum
;
...
...
quantum/plugins/algorithms/vqe/vqe.cpp
View file @
a8b8bf5d
...
...
@@ -208,6 +208,7 @@ VQE::execute(const std::shared_ptr<AcceleratorBuffer> buffer,
for
(
auto
&
f
:
kernels
)
{
kernelNames
.
push_back
(
f
->
name
());
std
::
complex
<
double
>
coeff
=
f
->
getCoefficient
();
// std::cout << f->name() << "\n" << f->toString() <<"\n";
int
nFunctionInstructions
=
0
;
if
(
f
->
getInstruction
(
0
)
->
isComposite
())
{
...
...
quantum/plugins/circuits/exp/tests/ExpTester.cpp
View file @
a8b8bf5d
...
...
@@ -13,6 +13,8 @@
#include
"xacc.hpp"
#include
<gtest/gtest.h>
#include
"Circuit.hpp"
#include
"xacc_service.hpp"
using
namespace
xacc
;
TEST
(
ExpTester
,
checkSimple
)
{
...
...
quantum/plugins/circuits/hwe/tests/HWETester.cpp
View file @
a8b8bf5d
...
...
@@ -13,6 +13,7 @@
#include
"xacc.hpp"
#include
<gtest/gtest.h>
#include
"Circuit.hpp"
#include
"xacc_service.hpp"
using
namespace
xacc
;
...
...
quantum/plugins/circuits/qft/InverseQFT.cpp
View file @
a8b8bf5d
...
...
@@ -12,6 +12,7 @@
*******************************************************************************/
#include
"InverseQFT.hpp"
#include
<memory>
#include
"xacc_service.hpp"
namespace
xacc
{
...
...
quantum/plugins/circuits/ucc1/tests/UCC1Tester.cpp
View file @
a8b8bf5d
...
...
@@ -13,6 +13,7 @@
#include
"xacc.hpp"
#include
<gtest/gtest.h>
#include
"Circuit.hpp"
#include
"xacc_service.hpp"
using
namespace
xacc
;
...
...
quantum/plugins/circuits/ucc3/tests/UCC3Tester.cpp
View file @
a8b8bf5d
...
...
@@ -13,6 +13,7 @@
#include
"xacc.hpp"
#include
<gtest/gtest.h>
#include
"Circuit.hpp"
#include
"xacc_service.hpp"
using
namespace
xacc
;
...
...
xacc/compiler/qalloc.cpp
View file @
a8b8bf5d
...
...
@@ -13,10 +13,17 @@ qreg::qreg(const qreg &other) : buffer(other.buffer) {}
qubit
qreg
::
operator
[](
const
std
::
size_t
i
)
{
return
std
::
make_pair
(
buffer
->
name
(),
i
);
}
qreg
&
qreg
::
operator
=
(
const
qreg
&
q
)
{
buffer
=
q
.
buffer
;
return
*
this
;
}
AcceleratorBuffer
*
qreg
::
results
()
{
return
buffer
;
}
std
::
map
<
std
::
string
,
int
>
qreg
::
counts
()
{
return
buffer
->
getMeasurementCounts
();
}
std
::
string
qreg
::
name
()
{
return
buffer
->
name
();
}
double
qreg
::
exp_val_z
()
{
return
buffer
->
getExpectationValueZ
();
}
void
qreg
::
reset
()
{
buffer
->
resetBuffer
();
}
void
qreg
::
setName
(
const
char
*
name
)
{
buffer
->
setName
(
name
);
}
...
...
xacc/compiler/qalloc.hpp
View file @
a8b8bf5d
...
...
@@ -30,6 +30,7 @@ public:
qreg
(
const
int
n
);
qreg
(
const
qreg
&
other
);
qubit
operator
[](
const
std
::
size_t
i
);
qreg
&
operator
=
(
const
qreg
&
q
);
AcceleratorBuffer
*
results
();
std
::
map
<
std
::
string
,
int
>
counts
();
double
exp_val_z
();
...
...
@@ -38,6 +39,7 @@ public:
void
addChild
(
qreg
&
q
);
void
setName
(
const
char
*
name
);
void
setNameAndStore
(
const
char
*
name
);
std
::
string
name
();
void
store
();
void
print
();
double
weighted_sum
(
Observable
*
obs
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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