Commit 508206aa authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

updating to run embedding for dwave qmi if not run



Signed-off-by: Mccaskey, Alex's avatarAlex McCaskey <mccaskeyaj@ornl.gov>
parent 48b893c0
......@@ -199,6 +199,27 @@ void PyXACCListener::enterUop(PyXACCIRParser::UopContext *ctx) {
xacc::error("Only permitting gates with 1 parameter for now.");
}
}
void PyXACCListener::exitXacckernel(PyXACCIRParser::XacckernelContext *ctx) {
// If this is a D-Wave kernel, then we need to check
// and see if an embedding has been set, if not, then
// lets run the D-Wave compiler to set one.
if (!std::dynamic_pointer_cast<GateFunction>(f)) {
if (!xacc::hasCompiler("dwave-qmi")) {
xacc::error(
"Cannot run decorated code for d-wave without d-wave plugins.");
}
auto acc = xacc::getAccelerator("dwave");
auto buff = acc->getBuffer(bufferName);
if (!buff->hasExtraInfoKey("embedding")) {
xacc::info("Embedding not found for this python kernel, computing embedding now.");
auto dwcompiler = xacc::getCompiler("dwave-qmi");
auto xaccKernelSrcStr = dwcompiler->translate("", f);
auto embeddedCode = dwcompiler->compile(xaccKernelSrcStr, acc);
}
}
}
} // namespace quantum
} // namespace xacc
......@@ -49,7 +49,9 @@ public:
virtual void
enterXacckernel(PyXACCIRParser::XacckernelContext * /*ctx*/) override;
virtual void
exitXacckernel(PyXACCIRParser::XacckernelContext * /*ctx*/) override;
virtual void enterUop(PyXACCIRParser::UopContext * /*ctx*/) override;
};
......
......@@ -316,6 +316,10 @@ PYBIND11_MODULE(_pyxacc, m) {
(std::map<std::string, ExtraInfo>(xacc::AcceleratorBuffer::*)()) &
xacc::AcceleratorBuffer::getInformation,
"")
.def("addExtraInfo",
(void (xacc::AcceleratorBuffer::*)(const std::string, ExtraInfo)) &
xacc::AcceleratorBuffer::addExtraInfo,
"")
.def("getInformation",
(ExtraInfo(xacc::AcceleratorBuffer::*)(const std::string)) &
xacc::AcceleratorBuffer::getInformation,
......
Supports Markdown
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