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
5f39537c
Commit
5f39537c
authored
Apr 05, 2019
by
Mccaskey, Alex
Browse files
bug fixes to xacc.py
Signed-off-by:
Alex McCaskey
<
mccaskeyaj@ornl.gov
>
parent
0cdb6720
Pipeline
#46138
passed with stages
in 8 minutes and 33 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
python/compiler/PyXACCListener.cpp
View file @
5f39537c
...
...
@@ -29,8 +29,11 @@ void DWorGateListener::enterGate(PyXACCIRParser::GateContext *ctx) {
// Until we see a qmi or anneal instruction, keep checking
// the incoming gate name
if
(
!
isDW
)
isDW
=
boost
::
contains
(
gate
,
"qmi"
)
||
boost
::
contains
(
gate
,
"anneal"
);
if
(
!
isDW
)
{
if
(
gate
.
find
(
"qmi"
)
!=
std
::
string
::
npos
||
gate
.
find
(
"anneal"
)
!=
std
::
string
::
npos
)
{
isDW
=
true
;
}
}
// Once we have seen qmi or anneal, ensure that we
// don't see any gate model instructions
...
...
@@ -64,7 +67,8 @@ void PyXACCListener::enterXacckernel(PyXACCIRParser::XacckernelContext *ctx) {
std
::
vector
<
InstructionParameter
>
params
;
for
(
int
i
=
1
;
i
<
ctx
->
param
().
size
();
i
++
)
{
if
(
!
boost
::
contains
(
ctx
->
param
(
i
)
->
getText
(),
"*"
))
{
if
(
ctx
->
param
(
i
)
->
getText
().
find
(
"*"
)
==
std
::
string
::
npos
)
{
// if (!boost::contains(ctx->param(i)->getText(), "*")) {
params
.
push_back
(
InstructionParameter
(
ctx
->
param
(
i
)
->
getText
()));
functionVariableNames
.
push_back
(
ctx
->
param
(
i
)
->
getText
());
}
...
...
@@ -96,7 +100,7 @@ void PyXACCListener::enterUop(PyXACCIRParser::UopContext *ctx) {
};
auto
gateName
=
ctx
->
gatename
->
getText
();
boost
::
trim
(
gateName
);
xacc
::
trim
(
gateName
);
if
(
gateName
==
"CX"
)
{
gateName
=
"CNOT"
;
...
...
@@ -299,7 +303,7 @@ void PyXACCListener::enterUop(PyXACCIRParser::UopContext *ctx) {
void
PyXACCListener
::
enterAllbitsOp
(
PyXACCIRParser
::
AllbitsOpContext
*
ctx
)
{
auto
gateName
=
ctx
->
gatename
->
getText
();
boost
::
trim
(
gateName
);
xacc
::
trim
(
gateName
);
if
(
gateName
==
"CX"
)
{
gateName
=
"CNOT"
;
...
...
python/compiler/PyXACCListener.hpp
View file @
5f39537c
...
...
@@ -17,7 +17,6 @@
#include "Accelerator.hpp"
#include "IR.hpp"
#include "IRProvider.hpp"
#include <boost/algorithm/string.hpp>
using
namespace
pyxacc
;
...
...
python/xacc.py
View file @
5f39537c
...
...
@@ -185,8 +185,7 @@ class DecoratorFunction(ABC):
self
.
qpu
=
self
.
accelerator
ir
=
compiler
.
compile
(
self
.
src
,
self
.
qpu
)
program
=
Program
(
self
.
qpu
,
ir
)
self
.
compiledKernel
=
program
.
getKernels
()[
0
]
self
.
compiledKernel
=
ir
.
getKernels
()[
0
]
def
overrideAccelerator
(
self
,
acc
):
self
.
accelerator
=
acc
...
...
@@ -207,7 +206,7 @@ class DecoratorFunction(ABC):
return
self
.
getFunction
().
nParameters
()
def
getFunction
(
self
):
return
self
.
compiledKernel
.
getIRFunction
()
return
self
.
compiledKernel
@
abstractmethod
def
__call__
(
self
,
*
args
,
**
kwargs
):
...
...
@@ -232,7 +231,9 @@ class WrappedF(DecoratorFunction):
#functionBufferName = inspect.getargspec(self.function)[0][0]
# Replace function arg0 name with buffer.name()
#self.src = self.src.replace(functionBufferName, buffer.name())
self
.
compiledKernel
.
execute
(
argsList
[
0
],
argsList
[
1
:])
fevaled
=
self
.
compiledKernel
.
eval
(
argsList
[
1
:])
self
.
qpu
.
execute
(
argsList
[
0
],
fevaled
)
# self.compiledKernel.execute(argsList[0], argsList[1:])
return
class
qpu
(
object
):
...
...
xacc/ir/IRGenerator.hpp
View file @
5f39537c
...
...
@@ -145,6 +145,8 @@ public:
return
0
;
}
virtual
bool
validateOptions
()
{
return
false
;
}
DEFINE_VISITABLE
();
/**
...
...
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