Commit 5f39537c authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

bug fixes to xacc.py


Signed-off-by: Mccaskey, Alex's avatarAlex McCaskey <mccaskeyaj@ornl.gov>
parent 0cdb6720
Pipeline #46138 passed with stages
in 8 minutes and 33 seconds
......@@ -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";
......
......@@ -17,7 +17,6 @@
#include "Accelerator.hpp"
#include "IR.hpp"
#include "IRProvider.hpp"
#include <boost/algorithm/string.hpp>
using namespace pyxacc;
......
......@@ -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):
......
......@@ -145,6 +145,8 @@ public:
return 0;
}
virtual bool validateOptions() { return false; }
DEFINE_VISITABLE();
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment