Commit b0b027c6 authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

fix base visit ch in allgatevisitor, add get compiler with metadata to python api


Signed-off-by: Mccaskey, Alex's avatarAlex McCaskey <mccaskeyaj@ornl.gov>
parent 93c33074
Pipeline #147045 passed with stage
in 15 minutes and 50 seconds
......@@ -33,6 +33,11 @@ void bind_compiler(py::module &m) {
xacc::Compiler::compile,
"Compile the "
"given source code.")
.def("compile",
(std::shared_ptr<xacc::IR>(xacc::Compiler::*)()) &
xacc::Compiler::compile,
"Compile the "
"given source code.")
.def("translate",
(const std::string (xacc::Compiler::*)(
std::shared_ptr<CompositeInstruction>)) &
......
......@@ -116,8 +116,9 @@ PYBIND11_MODULE(_pyxacc, m) {
},
"Set a number of options at once.");
m.def("getAcceleratorDecorator",
[](const std::string name, std::shared_ptr<Accelerator> acc) -> std::shared_ptr<Accelerator> {
auto accd = xacc::getAcceleratorDecorator(name,acc);
[](const std::string name,
std::shared_ptr<Accelerator> acc) -> std::shared_ptr<Accelerator> {
auto accd = xacc::getAcceleratorDecorator(name, acc);
return accd;
});
m.def("getAcceleratorDecorator",
......@@ -128,7 +129,7 @@ PYBIND11_MODULE(_pyxacc, m) {
PyHeterogeneousMap2HeterogeneousMap vis(m, item.first);
mpark::visit(vis, item.second);
}
auto accd = xacc::getAcceleratorDecorator(name,acc, m);
auto accd = xacc::getAcceleratorDecorator(name, acc, m);
return accd;
});
m.def("asComposite", &xacc::ir::asComposite, "");
......@@ -179,7 +180,25 @@ PYBIND11_MODULE(_pyxacc, m) {
return xacc::getAlgorithm(algo, m);
},
"");
m.def("storeBuffer", [](std::shared_ptr<AcceleratorBuffer> buffer) { xacc::storeBuffer(buffer);},"");
m.def(
"getCompiler",
[](const std::string c, const PyHeterogeneousMap &options) {
HeterogeneousMap m;
for (auto &item : options) {
PyHeterogeneousMap2HeterogeneousMap vis(m, item.first);
mpark::visit(vis, item.second);
}
auto compiler = xacc::getCompiler(c);
compiler->setExtraOptions(m);
return compiler;
},
"");
m.def(
"storeBuffer",
[](std::shared_ptr<AcceleratorBuffer> buffer) {
xacc::storeBuffer(buffer);
},
"");
m.def("getOptimizer",
(std::shared_ptr<xacc::Optimizer>(*)(const std::string)) &
xacc::getOptimizer,
......
......@@ -56,10 +56,10 @@ public:
void visit(Ry &h) override {}
void visit(Rx &h) override {}
void visit(U1 &u1) override {
InstructionParameter p = u1.getParameter(0);
Rz rz(u1.bits());
rz.setParameter(0, p);
visit(rz);
InstructionParameter p = u1.getParameter(0);
Rz rz(u1.bits());
rz.setParameter(0, p);
visit(rz);
}
void visit(X &h) override {}
void visit(Y &h) override {}
......@@ -92,15 +92,31 @@ public:
void visit(fSim &fsim) override {}
void visit(iSwap &isw) override {}
void visit(XY& xy) override {}
void visit(XY &xy) override {}
void visit(CRZ &crz) override {}
void visit(CH &ch) override {}
void visit(CH &ch) override {
S s(ch.bits()[1]);
Hadamard h(ch.bits()[1]);
T t(ch.bits()[1]);
CNOT cn(ch.bits());
Tdg tdg(ch.bits()[1]);
Hadamard h2(ch.bits()[1]);
Sdg sdg(ch.bits()[1]);
visit(s);
visit(h);
visit(t);
visit(cn);
visit(tdg);
visit(h2);
visit(sdg);
}
void visit(S &s) override {}
void visit(CPhase& cp) override {}
void visit(Measure& cp) override {}
void visit(Identity& cp) override {}
void visit(U& cp) override {}
void visit(CPhase &cp) override {}
void visit(Measure &cp) override {}
void visit(Identity &cp) override {}
void visit(U &cp) override {}
void visit(Sdg &sdg) override {}
void visit(T &t) override {}
......
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