Loading compiler/fuzzy_parsing.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -78,7 +78,7 @@ bool FuzzyParsingExternalSemaSource::LookupUnqualified(clang::LookupResult &R, quantumInstructionASTs.push_back(std::move(ast)); R.addDecl(D0); D0->dump(); // D0->dump(); } else if (std::find(compositeInstructions.begin(), compositeInstructions.end(), unknownName + "__qcor_instruction") != Loading Loading @@ -137,7 +137,7 @@ bool FuzzyParsingExternalSemaSource::LookupUnqualified(clang::LookupResult &R, auto cmp = CompoundStmt::Create(ci.getASTContext(), stmts, SourceLocation(), SourceLocation()); fdecl->setBody(cmp); fdecl->dump(); // fdecl->dump(); R.addDecl(fdecl); return true; Loading compiler/qcor_ast_visitor.cpp +15 −19 Original line number Diff line number Diff line Loading @@ -108,11 +108,21 @@ bool QCORASTVisitor::VisitLambdaExpr(LambdaExpr *LE) { .str(); std::shared_ptr<Accelerator> targetAccelerator; if (xacc::optionExists("accelerator")) { targetAccelerator = xacc::getAccelerator(); if (!xacc::optionExists("accelerator")) { if (xacc::hasAccelerator("tnqvm")) { xacc::setOption("accelerator", "tnqvm"); } else if (xacc::hasAccelerator("local-ibm")) { xacc::setOption("accelerator", "local-ibm"); } else { xacc::error("No Accelerator specified for compilation. Compile with " "--accelerator and ensure you have the desired Accelerator " "installed."); } } std::cout << "LAMBDA STR:\n" << xaccKernelLambdaStr << "\n"; auto acceleratorName = xacc::getAccelerator()->name(); // std::cout << "LAMBDA STR:\n" << xaccKernelLambdaStr << "\n"; auto compiler = xacc::getCompiler("xasm"); auto ir = compiler->compile(xaccKernelLambdaStr, targetAccelerator); Loading @@ -138,23 +148,9 @@ bool QCORASTVisitor::VisitLambdaExpr(LambdaExpr *LE) { } } std::cout << "HELLO: " << function->getVariables() << "\n"; std::cout << "\n\nXACC IR:\n" << function->toString() << "\n"; // std::cout << "\n\nXACC IR:\n" << function->toString() << "\n"; auto sr = LE->getBody()->getSourceRange(); if (!xacc::optionExists("accelerator")) { if (xacc::hasAccelerator("tnqvm")) { xacc::setOption("accelerator", "tnqvm"); } else if (xacc::hasAccelerator("local-ibm")) { xacc::setOption("accelerator", "local-ibm"); } else { xacc::error("No Accelerator specified for compilation. Compile with " "--accelerator and ensure you have the desired Accelerator " "installed."); } } auto acceleratorName = xacc::getAccelerator()->name(); // Argument analysis // can be (qbit q, double t, double tt, double ttt, ...) Loading examples/deuteron_H2_expgen.cpp +13 −10 Original line number Diff line number Diff line Loading @@ -4,22 +4,25 @@ int main(int argc, char **argv) { qcor::Initialize(argc, argv); auto optimizer = qcor::getOptimizer( "nlopt", {{"nlopt-optimizer", "cobyla"}, {"nlopt-maxeval", 20}}); auto op = qcor::getObservable( "pauli", "5.907 - 2.1433 X0X1 - 2.1433 Y0Y1 + .21829 Z0 - 6.125 Z1"); auto optimizer = qcor::getOptimizer("nlopt", {std::make_pair("nlopt-optimizer", "cobyla"), std::make_pair("nlopt-maxeval", 2000)}); auto observable = qcor::getObservable("pauli", std::string("5.907 - 2.1433 X0X1 " "- 2.1433 Y0Y1" "+ .21829 Z0 - 6.125 Z1")); auto future = qcor::submit([&](qcor::qpu_handler &qh) { qh.vqe( [&](double x) { X(0); exp_i_theta(x, {{"pauli", "X0 Y1 - Y0 X1"}}); [&](qbit q, double x) { X(q[0]); exp_i_theta(q, x, {{"pauli", "X0 Y1 - Y0 X1"}}); }, op, optimizer); observable, optimizer, 0.0); }); auto results = future.get(); auto energy = mpark::get<double>(results->getInformation("opt-val")); auto energy = results->getInformation("opt-val").as<double>(); std::cout << "Results: " << energy << "\n"; } scripts/qcor.in +0 −1 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ import argparse, sys, os, subprocess, mimetypes, re def main(argv=None): print(sys.argv) compiler = '@CMAKE_CXX_COMPILER@' baseLibs = ['-rdynamic', '-Wl,-rpath,@CMAKE_INSTALL_PREFIX@/lib', Loading Loading
compiler/fuzzy_parsing.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -78,7 +78,7 @@ bool FuzzyParsingExternalSemaSource::LookupUnqualified(clang::LookupResult &R, quantumInstructionASTs.push_back(std::move(ast)); R.addDecl(D0); D0->dump(); // D0->dump(); } else if (std::find(compositeInstructions.begin(), compositeInstructions.end(), unknownName + "__qcor_instruction") != Loading Loading @@ -137,7 +137,7 @@ bool FuzzyParsingExternalSemaSource::LookupUnqualified(clang::LookupResult &R, auto cmp = CompoundStmt::Create(ci.getASTContext(), stmts, SourceLocation(), SourceLocation()); fdecl->setBody(cmp); fdecl->dump(); // fdecl->dump(); R.addDecl(fdecl); return true; Loading
compiler/qcor_ast_visitor.cpp +15 −19 Original line number Diff line number Diff line Loading @@ -108,11 +108,21 @@ bool QCORASTVisitor::VisitLambdaExpr(LambdaExpr *LE) { .str(); std::shared_ptr<Accelerator> targetAccelerator; if (xacc::optionExists("accelerator")) { targetAccelerator = xacc::getAccelerator(); if (!xacc::optionExists("accelerator")) { if (xacc::hasAccelerator("tnqvm")) { xacc::setOption("accelerator", "tnqvm"); } else if (xacc::hasAccelerator("local-ibm")) { xacc::setOption("accelerator", "local-ibm"); } else { xacc::error("No Accelerator specified for compilation. Compile with " "--accelerator and ensure you have the desired Accelerator " "installed."); } } std::cout << "LAMBDA STR:\n" << xaccKernelLambdaStr << "\n"; auto acceleratorName = xacc::getAccelerator()->name(); // std::cout << "LAMBDA STR:\n" << xaccKernelLambdaStr << "\n"; auto compiler = xacc::getCompiler("xasm"); auto ir = compiler->compile(xaccKernelLambdaStr, targetAccelerator); Loading @@ -138,23 +148,9 @@ bool QCORASTVisitor::VisitLambdaExpr(LambdaExpr *LE) { } } std::cout << "HELLO: " << function->getVariables() << "\n"; std::cout << "\n\nXACC IR:\n" << function->toString() << "\n"; // std::cout << "\n\nXACC IR:\n" << function->toString() << "\n"; auto sr = LE->getBody()->getSourceRange(); if (!xacc::optionExists("accelerator")) { if (xacc::hasAccelerator("tnqvm")) { xacc::setOption("accelerator", "tnqvm"); } else if (xacc::hasAccelerator("local-ibm")) { xacc::setOption("accelerator", "local-ibm"); } else { xacc::error("No Accelerator specified for compilation. Compile with " "--accelerator and ensure you have the desired Accelerator " "installed."); } } auto acceleratorName = xacc::getAccelerator()->name(); // Argument analysis // can be (qbit q, double t, double tt, double ttt, ...) Loading
examples/deuteron_H2_expgen.cpp +13 −10 Original line number Diff line number Diff line Loading @@ -4,22 +4,25 @@ int main(int argc, char **argv) { qcor::Initialize(argc, argv); auto optimizer = qcor::getOptimizer( "nlopt", {{"nlopt-optimizer", "cobyla"}, {"nlopt-maxeval", 20}}); auto op = qcor::getObservable( "pauli", "5.907 - 2.1433 X0X1 - 2.1433 Y0Y1 + .21829 Z0 - 6.125 Z1"); auto optimizer = qcor::getOptimizer("nlopt", {std::make_pair("nlopt-optimizer", "cobyla"), std::make_pair("nlopt-maxeval", 2000)}); auto observable = qcor::getObservable("pauli", std::string("5.907 - 2.1433 X0X1 " "- 2.1433 Y0Y1" "+ .21829 Z0 - 6.125 Z1")); auto future = qcor::submit([&](qcor::qpu_handler &qh) { qh.vqe( [&](double x) { X(0); exp_i_theta(x, {{"pauli", "X0 Y1 - Y0 X1"}}); [&](qbit q, double x) { X(q[0]); exp_i_theta(q, x, {{"pauli", "X0 Y1 - Y0 X1"}}); }, op, optimizer); observable, optimizer, 0.0); }); auto results = future.get(); auto energy = mpark::get<double>(results->getInformation("opt-val")); auto energy = results->getInformation("opt-val").as<double>(); std::cout << "Results: " << energy << "\n"; }
scripts/qcor.in +0 −1 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ import argparse, sys, os, subprocess, mimetypes, re def main(argv=None): print(sys.argv) compiler = '@CMAKE_CXX_COMPILER@' baseLibs = ['-rdynamic', '-Wl,-rpath,@CMAKE_INSTALL_PREFIX@/lib', Loading