Commit 20e9bc57 authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

fixing comment bug in xasm compiler, adding xacc::quantum::getObservable API


Signed-off-by: Mccaskey, Alex's avatarAlex McCaskey <mccaskeyaj@ornl.gov>
parent b711000f
Pipeline #71103 passed with stage
in 4 minutes and 27 seconds
......@@ -6,10 +6,10 @@
![alt text](https://raw.githubusercontent.com/eclipse/xacc/master/docs/assets/xacc-readme.jpg)
## Language and Hardware Independent Quantum Programming Framework
XACC is an extensible compilation framework for hybrid quantum-classical computing architectures.
It provides extensible language frontend and hardware backend compilation components glued together
via a novel quantum intermediate representation. XACC currently supports quantum-classical programming
and enables the execution of quantum kernels on IBM, Rigetti, and D-Wave QPUs, as well as a number
XACC is an extensible compilation framework for hybrid quantum-classical computing architectures.
It provides extensible language frontend and hardware backend compilation components glued together
via a novel quantum intermediate representation. XACC currently supports quantum-classical programming
and enables the execution of quantum kernels on IBM, Rigetti, and D-Wave QPUs, as well as a number
of quantum computer simulators.
Documentation
......@@ -19,31 +19,31 @@ Documentation
Build from Source
-----------------
Ensure that you have installed CMake 3.2+, a C++11 compliant compiler (GCC 5+, Clang 3.8+), and
CURL development headers and libraries with OpenSSL support
(see [prerequisites](http://xacc.readthedocs.io/en/latest/install.html#pre-requisites)).
Ensure that you have installed CMake 3.2+, a C++14 compliant compiler (GCC 6+, Clang 3.4+), and
CURL development headers and libraries with OpenSSL support
(see [prerequisites](http://xacc.readthedocs.io/en/latest/install.html#pre-requisites)).
Optional dependencies include BLAS and LAPACK development libraries (for various simulators),
Optional dependencies include BLAS and LAPACK development libraries (for various simulators),
Python 3 development headers and library (for the Python API), and Libunwind (for stack trace printing).
Clone the repository recursively, configure with `cmake` and build with `make`
```bash
$ git clone --recursive https://github.com/eclipse/xacc
$ cd xacc && mkdir build && cd build
[default]
$ cmake ..
[with python api]
[default]
$ cmake ..
[with python api]
$ cmake .. -DPYTHON_INCLUDE_DIR=/path/to/python/headers
[with tests]
$ cmake .. -DXACC_BUILD_TESTS=TRUE
$ cmake .. -DXACC_BUILD_TESTS=TRUE
[or any combination of the above]
$ cmake .. -DPYTHON_INCLUDE_DIR=/path/to/python/headers -DXACC_BUILD_TESTS=TRUE
$ cmake .. -DPYTHON_INCLUDE_DIR=/path/to/python/headers -DXACC_BUILD_TESTS=TRUE
[now build xacc]
$ make install
[if you built with tests]
$ ctest
```
Your installation will be in `$HOME/.xacc`. If you built with the Python API, be sure to update your `PYTHONPATH`
Your installation will be in `$HOME/.xacc`. If you built with the Python API, be sure to update your `PYTHONPATH`
environment variable to point to the installation:
```bash
$ export PYTHONPATH=$PYTHONPATH:$HOME/.xacc
......
......@@ -79,7 +79,7 @@ public:
}
const int nInstructions() override { return instructions.size(); }
const int nChildren() override {return instructions.size();}
void mapBits(std::vector<std::size_t> bitMap) override {
xacc::error("AnnealingProgrma.mapBits not implemented");
......
add_executable(deuteron_from_qasm deuteron.cpp)
target_link_libraries(deuteron_from_qasm PRIVATE xacc xacc-pauli)
target_link_libraries(deuteron_from_qasm PRIVATE xacc xacc-quantum-gate)
add_executable(deuteron_from_qasm_vqe_algo deuteron_vqe_algo.cpp)
target_link_libraries(deuteron_from_qasm_vqe_algo PRIVATE xacc xacc-pauli)
\ No newline at end of file
target_link_libraries(deuteron_from_qasm_vqe_algo PRIVATE xacc xacc-quantum-gate)
\ No newline at end of file
#include "xacc.hpp"
#include "Optimizer.hpp"
#include "PauliOperator.hpp"
#include "xacc_service.hpp"
#include "xacc_observable.hpp"
#include <iomanip>
......@@ -16,10 +16,10 @@ int main(int argc, char **argv) {
auto buffer = xacc::qalloc(2);
// Create the N=2 deuteron Hamiltonian
auto H_N_2 =
std::make_shared<xacc::quantum::PauliOperator>("5.907 - 2.1433 X0X1 "
"- 2.1433 Y0Y1"
"+ .21829 Z0 - 6.125 Z1");
auto H_N_2 = xacc::quantum::getObservable(
"pauli", std::string("5.907 - 2.1433 X0X1 "
"- 2.1433 Y0Y1"
"+ .21829 Z0 - 6.125 Z1"));
// JIT map Quil QASM Ansatz to IR
xacc::qasm(R"(
.compiler quil
......@@ -34,8 +34,8 @@ CNOT 1 0
// Observe the Ansatz, creating measured kernels
auto kernels = H_N_2->observe(ansatz);
// Create the OptFunction to be optimized
xacc::OptFunction f(
// Create the OptFunction to be optimized
xacc::OptFunction f(
[&](const std::vector<double> &x) {
std::vector<double> coefficients;
std::vector<std::string> kernelNames;
......
#include "xacc.hpp"
#include "Optimizer.hpp"
#include "PauliOperator.hpp"
#include "xacc_observable.hpp"
#include "xacc_service.hpp"
int main(int argc, char **argv) {
......@@ -11,10 +11,10 @@ int main(int argc, char **argv) {
auto accelerator = xacc::getAccelerator();
// Create the N=2 deuteron Hamiltonian
std::shared_ptr<xacc::Observable> H_N_2 =
std::make_shared<xacc::quantum::PauliOperator>("5.907 - 2.1433 X0X1 "
"- 2.1433 Y0Y1"
"+ .21829 Z0 - 6.125 Z1");
auto H_N_2 = xacc::quantum::getObservable(
"pauli", std::string("5.907 - 2.1433 X0X1 "
"- 2.1433 Y0Y1"
"+ .21829 Z0 - 6.125 Z1"));
auto optimizer = xacc::getOptimizer("nlopt");
......@@ -42,6 +42,6 @@ CNOT(q[1],q[0]);
vqe->execute(buffer);
// Print the result
std::cout << "Energy: "
<< buffer->getInformation("opt-val").as<double>() << "\n";
std::cout << "Energy: " << buffer->getInformation("opt-val").as<double>()
<< "\n";
}
\ No newline at end of file
......@@ -30,7 +30,7 @@ add_library(${LIBRARY_NAME} SHARED ${SRC})
#add_dependencies(${LIBRARY_NAME} antlr4_shared)
target_include_directories(${LIBRARY_NAME}
PUBLIC utils
PUBLIC . utils
ir
${CMAKE_SOURCE_DIR}/tpls/rapidjson/include
PRIVATE
......@@ -53,7 +53,7 @@ usFunctionEmbedResources(TARGET
FILES
manifest.json)
target_link_libraries(${LIBRARY_NAME} PUBLIC xacc)
target_link_libraries(${LIBRARY_NAME} PUBLIC xacc PRIVATE xacc-pauli xacc-fermion)
if(APPLE)
......
......@@ -152,6 +152,18 @@ public:
void load(std::istream &inStream) override;
const int nInstructions() override { return instructions.size(); }
// int count = 0;
// InstructionIterator iter(shared_from_this());
// while (iter.hasNext()) {
// auto inst = iter.next();
// if (!inst->isComposite()) {
// count++;
// }
// }
// return count;
// }
const int nChildren() override {return instructions.size();}
InstPtr getInstruction(const std::size_t idx) override {
validateInstructionIndex(idx);
......@@ -230,7 +242,7 @@ public:
[&](const std::string var) { return var == variable; }, newVariable);
}
const std::size_t nVariables() override { return variables.size(); }
const std::size_t nVariables() override { return getVariables().size(); }
const int depth() override;
const std::string persistGraph() override;
......
/*******************************************************************************
* Copyright (c) 2017 UT-Battelle, LLC.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompanies this
* distribution. The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution
*License is available at https://eclipse.org/org/documents/edl-v10.php
*
* Contributors:
* Alexander J. McCaskey - initial API and implementation
*******************************************************************************/
#ifndef XACC_OBSERVABLE_HPP_
#define XACC_OBSERVABLE_HPP_
#include "xacc_quantum_gate_api.hpp"
#endif
\ No newline at end of file
#include "xacc_quantum_gate_api.hpp"
#include "PauliOperator.hpp"
#include "FermionOperator.hpp"
#include "xacc.hpp"
namespace xacc {
namespace quantum {
std::shared_ptr<Observable> getObservable(const std::string type,
const std::string representation) {
if (type == "pauli") {
return representation.empty()
? std::make_shared<PauliOperator>()
: std::make_shared<PauliOperator>(representation);
} else if (type == "fermion") {
return representation.empty()
? std::make_shared<FermionOperator>()
: std::make_shared<FermionOperator>(representation);
} else {
xacc::error("[xacc::getObservable()] Invalid observable type: " + type);
return std::make_shared<PauliOperator>();
}
}
std::shared_ptr<Observable> getObservable() {
return getObservable("pauli", std::string(""));
}
std::shared_ptr<Observable> getObservable(const std::string type) {
return getObservable(type, std::string(""));
}
std::shared_ptr<Observable> getObservable(const std::string type,
const HeterogeneousMap &options) {
auto observable = getObservable(type);
observable->fromOptions(options);
return observable;
}
std::shared_ptr<Observable> getObservable(const std::string type,
const HeterogeneousMap &&options) {
return getObservable(type, options);
}
} // namespace quantum
} // namespace xacc
\ No newline at end of file
/*******************************************************************************
* Copyright (c) 2017 UT-Battelle, LLC.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompanies this
* distribution. The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution
*License is available at https://eclipse.org/org/documents/edl-v10.php
*
* Contributors:
* Alexander J. McCaskey - initial API and implementation
*******************************************************************************/
#ifndef XACC_QUANTUM_GATE_API_HPP_
#define XACC_QUANTUM_GATE_API_HPP_
#include "Observable.hpp"
namespace xacc {
namespace quantum {
std::shared_ptr<Observable> getObservable();
std::shared_ptr<Observable> getObservable(const std::string type);
std::shared_ptr<Observable> getObservable(const std::string type,
const std::string repr);
std::shared_ptr<Observable> getObservable(const std::string type,
const HeterogeneousMap &options);
std::shared_ptr<Observable> getObservable(const std::string type,
const HeterogeneousMap &&options);
} // namespace quantum
} // namespace xacc
#endif
\ No newline at end of file
......@@ -125,4 +125,4 @@ mode names:
DEFAULT_MODE
atn:
[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 39, 255, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, 4, 34, 9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 4, 37, 9, 37, 4, 38, 9, 38, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 3, 14, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 18, 3, 18, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 20, 3, 20, 3, 21, 3, 21, 3, 22, 3, 22, 3, 23, 3, 23, 3, 24, 3, 24, 3, 25, 3, 25, 3, 25, 3, 26, 3, 26, 3, 26, 3, 26, 3, 27, 3, 27, 3, 27, 3, 27, 3, 28, 3, 28, 3, 28, 3, 28, 3, 29, 3, 29, 3, 29, 3, 29, 3, 30, 3, 30, 3, 30, 3, 31, 3, 31, 3, 31, 3, 31, 3, 31, 3, 32, 3, 32, 7, 32, 199, 10, 32, 12, 32, 14, 32, 202, 11, 32, 3, 32, 3, 32, 3, 33, 3, 33, 7, 33, 208, 10, 33, 12, 33, 14, 33, 211, 11, 33, 3, 33, 3, 33, 7, 33, 215, 10, 33, 12, 33, 14, 33, 218, 11, 33, 3, 33, 3, 33, 7, 33, 222, 10, 33, 12, 33, 14, 33, 225, 11, 33, 5, 33, 227, 10, 33, 3, 34, 3, 34, 3, 34, 3, 34, 3, 35, 6, 35, 234, 10, 35, 13, 35, 14, 35, 235, 3, 36, 3, 36, 7, 36, 240, 10, 36, 12, 36, 14, 36, 243, 11, 36, 3, 36, 3, 36, 3, 37, 3, 37, 3, 37, 3, 37, 3, 38, 5, 38, 252, 10, 38, 3, 38, 3, 38, 2, 2, 39, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 14, 27, 15, 29, 16, 31, 17, 33, 18, 35, 19, 37, 20, 39, 21, 41, 22, 43, 23, 45, 24, 47, 25, 49, 26, 51, 27, 53, 28, 55, 29, 57, 30, 59, 31, 61, 32, 63, 33, 65, 34, 67, 35, 69, 36, 71, 37, 73, 38, 75, 39, 3, 2, 9, 4, 2, 12, 12, 15, 15, 3, 2, 99, 124, 6, 2, 50, 59, 67, 92, 97, 97, 99, 124, 3, 2, 67, 92, 4, 2, 67, 92, 99, 124, 3, 2, 36, 36, 5, 2, 11, 12, 15, 15, 34, 34, 2, 263, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, 2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 43, 3, 2, 2, 2, 2, 45, 3, 2, 2, 2, 2, 47, 3, 2, 2, 2, 2, 49, 3, 2, 2, 2, 2, 51, 3, 2, 2, 2, 2, 53, 3, 2, 2, 2, 2, 55, 3, 2, 2, 2, 2, 57, 3, 2, 2, 2, 2, 59, 3, 2, 2, 2, 2, 61, 3, 2, 2, 2, 2, 63, 3, 2, 2, 2, 2, 65, 3, 2, 2, 2, 2, 67, 3, 2, 2, 2, 2, 69, 3, 2, 2, 2, 2, 71, 3, 2, 2, 2, 2, 73, 3, 2, 2, 2, 2, 75, 3, 2, 2, 2, 3, 77, 3, 2, 2, 2, 5, 85, 3, 2, 2, 2, 7, 90, 3, 2, 2, 2, 9, 92, 3, 2, 2, 2, 11, 97, 3, 2, 2, 2, 13, 99, 3, 2, 2, 2, 15, 101, 3, 2, 2, 2, 17, 103, 3, 2, 2, 2, 19, 105, 3, 2, 2, 2, 21, 107, 3, 2, 2, 2, 23, 109, 3, 2, 2, 2, 25, 111, 3, 2, 2, 2, 27, 113, 3, 2, 2, 2, 29, 117, 3, 2, 2, 2, 31, 124, 3, 2, 2, 2, 33, 130, 3, 2, 2, 2, 35, 150, 3, 2, 2, 2, 37, 152, 3, 2, 2, 2, 39, 159, 3, 2, 2, 2, 41, 161, 3, 2, 2, 2, 43, 163, 3, 2, 2, 2, 45, 165, 3, 2, 2, 2, 47, 167, 3, 2, 2, 2, 49, 169, 3, 2, 2, 2, 51, 172, 3, 2, 2, 2, 53, 176, 3, 2, 2, 2, 55, 180, 3, 2, 2, 2, 57, 184, 3, 2, 2, 2, 59, 188, 3, 2, 2, 2, 61, 191, 3, 2, 2, 2, 63, 196, 3, 2, 2, 2, 65, 226, 3, 2, 2, 2, 67, 228, 3, 2, 2, 2, 69, 233, 3, 2, 2, 2, 71, 237, 3, 2, 2, 2, 73, 246, 3, 2, 2, 2, 75, 251, 3, 2, 2, 2, 77, 78, 7, 97, 2, 2, 78, 79, 7, 97, 2, 2, 79, 80, 7, 115, 2, 2, 80, 81, 7, 114, 2, 2, 81, 82, 7, 119, 2, 2, 82, 83, 7, 97, 2, 2, 83, 84, 7, 97, 2, 2, 84, 4, 3, 2, 2, 2, 85, 86, 7, 120, 2, 2, 86, 87, 7, 113, 2, 2, 87, 88, 7, 107, 2, 2, 88, 89, 7, 102, 2, 2, 89, 6, 3, 2, 2, 2, 90, 91, 7, 42, 2, 2, 91, 8, 3, 2, 2, 2, 92, 93, 7, 115, 2, 2, 93, 94, 7, 100, 2, 2, 94, 95, 7, 107, 2, 2, 95, 96, 7, 118, 2, 2, 96, 10, 3, 2, 2, 2, 97, 98, 7, 46, 2, 2, 98, 12, 3, 2, 2, 2, 99, 100, 7, 43, 2, 2, 100, 14, 3, 2, 2, 2, 101, 102, 7, 125, 2, 2, 102, 16, 3, 2, 2, 2, 103, 104, 7, 127, 2, 2, 104, 18, 3, 2, 2, 2, 105, 106, 7, 93, 2, 2, 106, 20, 3, 2, 2, 2, 107, 108, 7, 40, 2, 2, 108, 22, 3, 2, 2, 2, 109, 110, 7, 63, 2, 2, 110, 24, 3, 2, 2, 2, 111, 112, 7, 95, 2, 2, 112, 26, 3, 2, 2, 2, 113, 114, 7, 107, 2, 2, 114, 115, 7, 112, 2, 2, 115, 116, 7, 118, 2, 2, 116, 28, 3, 2, 2, 2, 117, 118, 7, 102, 2, 2, 118, 119, 7, 113, 2, 2, 119, 120, 7, 119, 2, 2, 120, 121, 7, 100, 2, 2, 121, 122, 7, 110, 2, 2, 122, 123, 7, 103, 2, 2, 123, 30, 3, 2, 2, 2, 124, 125, 7, 104, 2, 2, 125, 126, 7, 110, 2, 2, 126, 127, 7, 113, 2, 2, 127, 128, 7, 99, 2, 2, 128, 129, 7, 118, 2, 2, 129, 32, 3, 2, 2, 2, 130, 131, 7, 117, 2, 2, 131, 132, 7, 118, 2, 2, 132, 133, 7, 102, 2, 2, 133, 134, 7, 60, 2, 2, 134, 135, 7, 60, 2, 2, 135, 136, 7, 120, 2, 2, 136, 137, 7, 103, 2, 2, 137, 138, 7, 101, 2, 2, 138, 139, 7, 118, 2, 2, 139, 140, 7, 113, 2, 2, 140, 141, 7, 116, 2, 2, 141, 142, 7, 62, 2, 2, 142, 143, 7, 102, 2, 2, 143, 144, 7, 113, 2, 2, 144, 145, 7, 119, 2, 2, 145, 146, 7, 100, 2, 2, 146, 147, 7, 110, 2, 2, 147, 148, 7, 103, 2, 2, 148, 149, 7, 64, 2, 2, 149, 34, 3, 2, 2, 2, 150, 151, 7, 61, 2, 2, 151, 36, 3, 2, 2, 2, 152, 153, 7, 116, 2, 2, 153, 154, 7, 103, 2, 2, 154, 155, 7, 118, 2, 2, 155, 156, 7, 119, 2, 2, 156, 157, 7, 116, 2, 2, 157, 158, 7, 112, 2, 2, 158, 38, 3, 2, 2, 2, 159, 160, 7, 45, 2, 2, 160, 40, 3, 2, 2, 2, 161, 162, 7, 47, 2, 2, 162, 42, 3, 2, 2, 2, 163, 164, 7, 44, 2, 2, 164, 44, 3, 2, 2, 2, 165, 166, 7, 49, 2, 2, 166, 46, 3, 2, 2, 2, 167, 168, 7, 96, 2, 2, 168, 48, 3, 2, 2, 2, 169, 170, 7, 114, 2, 2, 170, 171, 7, 107, 2, 2, 171, 50, 3, 2, 2, 2, 172, 173, 7, 117, 2, 2, 173, 174, 7, 107, 2, 2, 174, 175, 7, 112, 2, 2, 175, 52, 3, 2, 2, 2, 176, 177, 7, 101, 2, 2, 177, 178, 7, 113, 2, 2, 178, 179, 7, 117, 2, 2, 179, 54, 3, 2, 2, 2, 180, 181, 7, 118, 2, 2, 181, 182, 7, 99, 2, 2, 182, 183, 7, 112, 2, 2, 183, 56, 3, 2, 2, 2, 184, 185, 7, 103, 2, 2, 185, 186, 7, 122, 2, 2, 186, 187, 7, 114, 2, 2, 187, 58, 3, 2, 2, 2, 188, 189, 7, 110, 2, 2, 189, 190, 7, 112, 2, 2, 190, 60, 3, 2, 2, 2, 191, 192, 7, 117, 2, 2, 192, 193, 7, 115, 2, 2, 193, 194, 7, 116, 2, 2, 194, 195, 7, 118, 2, 2, 195, 62, 3, 2, 2, 2, 196, 200, 7, 37, 2, 2, 197, 199, 10, 2, 2, 2, 198, 197, 3, 2, 2, 2, 199, 202, 3, 2, 2, 2, 200, 198, 3, 2, 2, 2, 200, 201, 3, 2, 2, 2, 201, 203, 3, 2, 2, 2, 202, 200, 3, 2, 2, 2, 203, 204, 5, 75, 38, 2, 204, 64, 3, 2, 2, 2, 205, 209, 9, 3, 2, 2, 206, 208, 9, 4, 2, 2, 207, 206, 3, 2, 2, 2, 208, 211, 3, 2, 2, 2, 209, 207, 3, 2, 2, 2, 209, 210, 3, 2, 2, 2, 210, 227, 3, 2, 2, 2, 211, 209, 3, 2, 2, 2, 212, 216, 9, 5, 2, 2, 213, 215, 9, 4, 2, 2, 214, 213, 3, 2, 2, 2, 215, 218, 3, 2, 2, 2, 216, 214, 3, 2, 2, 2, 216, 217, 3, 2, 2, 2, 217, 227, 3, 2, 2, 2, 218, 216, 3, 2, 2, 2, 219, 223, 9, 5, 2, 2, 220, 222, 9, 6, 2, 2, 221, 220, 3, 2, 2, 2, 222, 225, 3, 2, 2, 2, 223, 221, 3, 2, 2, 2, 223, 224, 3, 2, 2, 2, 224, 227, 3, 2, 2, 2, 225, 223, 3, 2, 2, 2, 226, 205, 3, 2, 2, 2, 226, 212, 3, 2, 2, 2, 226, 219, 3, 2, 2, 2, 227, 66, 3, 2, 2, 2, 228, 229, 5, 69, 35, 2, 229, 230, 7, 48, 2, 2, 230, 231, 5, 69, 35, 2, 231, 68, 3, 2, 2, 2, 232, 234, 4, 50, 59, 2, 233, 232, 3, 2, 2, 2, 234, 235, 3, 2, 2, 2, 235, 233, 3, 2, 2, 2, 235, 236, 3, 2, 2, 2, 236, 70, 3, 2, 2, 2, 237, 241, 7, 36, 2, 2, 238, 240, 10, 7, 2, 2, 239, 238, 3, 2, 2, 2, 240, 243, 3, 2, 2, 2, 241, 239, 3, 2, 2, 2, 241, 242, 3, 2, 2, 2, 242, 244, 3, 2, 2, 2, 243, 241, 3, 2, 2, 2, 244, 245, 7, 36, 2, 2, 245, 72, 3, 2, 2, 2, 246, 247, 9, 8, 2, 2, 247, 248, 3, 2, 2, 2, 248, 249, 8, 37, 2, 2, 249, 74, 3, 2, 2, 2, 250, 252, 7, 15, 2, 2, 251, 250, 3, 2, 2, 2, 251, 252, 3, 2, 2, 2, 252, 253, 3, 2, 2, 2, 253, 254, 7, 12, 2, 2, 254, 76, 3, 2, 2, 2, 11, 2, 200, 209, 216, 223, 226, 235, 241, 251, 3, 8, 2, 2]
\ No newline at end of file
[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 39, 257, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, 4, 34, 9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 4, 37, 9, 37, 4, 38, 9, 38, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 3, 14, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 18, 3, 18, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 20, 3, 20, 3, 21, 3, 21, 3, 22, 3, 22, 3, 23, 3, 23, 3, 24, 3, 24, 3, 25, 3, 25, 3, 25, 3, 26, 3, 26, 3, 26, 3, 26, 3, 27, 3, 27, 3, 27, 3, 27, 3, 28, 3, 28, 3, 28, 3, 28, 3, 29, 3, 29, 3, 29, 3, 29, 3, 30, 3, 30, 3, 30, 3, 31, 3, 31, 3, 31, 3, 31, 3, 31, 3, 32, 3, 32, 3, 32, 3, 32, 7, 32, 201, 10, 32, 12, 32, 14, 32, 204, 11, 32, 3, 32, 3, 32, 3, 33, 3, 33, 7, 33, 210, 10, 33, 12, 33, 14, 33, 213, 11, 33, 3, 33, 3, 33, 7, 33, 217, 10, 33, 12, 33, 14, 33, 220, 11, 33, 3, 33, 3, 33, 7, 33, 224, 10, 33, 12, 33, 14, 33, 227, 11, 33, 5, 33, 229, 10, 33, 3, 34, 3, 34, 3, 34, 3, 34, 3, 35, 6, 35, 236, 10, 35, 13, 35, 14, 35, 237, 3, 36, 3, 36, 7, 36, 242, 10, 36, 12, 36, 14, 36, 245, 11, 36, 3, 36, 3, 36, 3, 37, 3, 37, 3, 37, 3, 37, 3, 38, 5, 38, 254, 10, 38, 3, 38, 3, 38, 2, 2, 39, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 14, 27, 15, 29, 16, 31, 17, 33, 18, 35, 19, 37, 20, 39, 21, 41, 22, 43, 23, 45, 24, 47, 25, 49, 26, 51, 27, 53, 28, 55, 29, 57, 30, 59, 31, 61, 32, 63, 33, 65, 34, 67, 35, 69, 36, 71, 37, 73, 38, 75, 39, 3, 2, 9, 4, 2, 12, 12, 15, 15, 3, 2, 99, 124, 6, 2, 50, 59, 67, 92, 97, 97, 99, 124, 3, 2, 67, 92, 4, 2, 67, 92, 99, 124, 3, 2, 36, 36, 5, 2, 11, 12, 15, 15, 34, 34, 2, 265, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, 2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 43, 3, 2, 2, 2, 2, 45, 3, 2, 2, 2, 2, 47, 3, 2, 2, 2, 2, 49, 3, 2, 2, 2, 2, 51, 3, 2, 2, 2, 2, 53, 3, 2, 2, 2, 2, 55, 3, 2, 2, 2, 2, 57, 3, 2, 2, 2, 2, 59, 3, 2, 2, 2, 2, 61, 3, 2, 2, 2, 2, 63, 3, 2, 2, 2, 2, 65, 3, 2, 2, 2, 2, 67, 3, 2, 2, 2, 2, 69, 3, 2, 2, 2, 2, 71, 3, 2, 2, 2, 2, 73, 3, 2, 2, 2, 2, 75, 3, 2, 2, 2, 3, 77, 3, 2, 2, 2, 5, 85, 3, 2, 2, 2, 7, 90, 3, 2, 2, 2, 9, 92, 3, 2, 2, 2, 11, 97, 3, 2, 2, 2, 13, 99, 3, 2, 2, 2, 15, 101, 3, 2, 2, 2, 17, 103, 3, 2, 2, 2, 19, 105, 3, 2, 2, 2, 21, 107, 3, 2, 2, 2, 23, 109, 3, 2, 2, 2, 25, 111, 3, 2, 2, 2, 27, 113, 3, 2, 2, 2, 29, 117, 3, 2, 2, 2, 31, 124, 3, 2, 2, 2, 33, 130, 3, 2, 2, 2, 35, 150, 3, 2, 2, 2, 37, 152, 3, 2, 2, 2, 39, 159, 3, 2, 2, 2, 41, 161, 3, 2, 2, 2, 43, 163, 3, 2, 2, 2, 45, 165, 3, 2, 2, 2, 47, 167, 3, 2, 2, 2, 49, 169, 3, 2, 2, 2, 51, 172, 3, 2, 2, 2, 53, 176, 3, 2, 2, 2, 55, 180, 3, 2, 2, 2, 57, 184, 3, 2, 2, 2, 59, 188, 3, 2, 2, 2, 61, 191, 3, 2, 2, 2, 63, 196, 3, 2, 2, 2, 65, 228, 3, 2, 2, 2, 67, 230, 3, 2, 2, 2, 69, 235, 3, 2, 2, 2, 71, 239, 3, 2, 2, 2, 73, 248, 3, 2, 2, 2, 75, 253, 3, 2, 2, 2, 77, 78, 7, 97, 2, 2, 78, 79, 7, 97, 2, 2, 79, 80, 7, 115, 2, 2, 80, 81, 7, 114, 2, 2, 81, 82, 7, 119, 2, 2, 82, 83, 7, 97, 2, 2, 83, 84, 7, 97, 2, 2, 84, 4, 3, 2, 2, 2, 85, 86, 7, 120, 2, 2, 86, 87, 7, 113, 2, 2, 87, 88, 7, 107, 2, 2, 88, 89, 7, 102, 2, 2, 89, 6, 3, 2, 2, 2, 90, 91, 7, 42, 2, 2, 91, 8, 3, 2, 2, 2, 92, 93, 7, 115, 2, 2, 93, 94, 7, 100, 2, 2, 94, 95, 7, 107, 2, 2, 95, 96, 7, 118, 2, 2, 96, 10, 3, 2, 2, 2, 97, 98, 7, 46, 2, 2, 98, 12, 3, 2, 2, 2, 99, 100, 7, 43, 2, 2, 100, 14, 3, 2, 2, 2, 101, 102, 7, 125, 2, 2, 102, 16, 3, 2, 2, 2, 103, 104, 7, 127, 2, 2, 104, 18, 3, 2, 2, 2, 105, 106, 7, 93, 2, 2, 106, 20, 3, 2, 2, 2, 107, 108, 7, 40, 2, 2, 108, 22, 3, 2, 2, 2, 109, 110, 7, 63, 2, 2, 110, 24, 3, 2, 2, 2, 111, 112, 7, 95, 2, 2, 112, 26, 3, 2, 2, 2, 113, 114, 7, 107, 2, 2, 114, 115, 7, 112, 2, 2, 115, 116, 7, 118, 2, 2, 116, 28, 3, 2, 2, 2, 117, 118, 7, 102, 2, 2, 118, 119, 7, 113, 2, 2, 119, 120, 7, 119, 2, 2, 120, 121, 7, 100, 2, 2, 121, 122, 7, 110, 2, 2, 122, 123, 7, 103, 2, 2, 123, 30, 3, 2, 2, 2, 124, 125, 7, 104, 2, 2, 125, 126, 7, 110, 2, 2, 126, 127, 7, 113, 2, 2, 127, 128, 7, 99, 2, 2, 128, 129, 7, 118, 2, 2, 129, 32, 3, 2, 2, 2, 130, 131, 7, 117, 2, 2, 131, 132, 7, 118, 2, 2, 132, 133, 7, 102, 2, 2, 133, 134, 7, 60, 2, 2, 134, 135, 7, 60, 2, 2, 135, 136, 7, 120, 2, 2, 136, 137, 7, 103, 2, 2, 137, 138, 7, 101, 2, 2, 138, 139, 7, 118, 2, 2, 139, 140, 7, 113, 2, 2, 140, 141, 7, 116, 2, 2, 141, 142, 7, 62, 2, 2, 142, 143, 7, 102, 2, 2, 143, 144, 7, 113, 2, 2, 144, 145, 7, 119, 2, 2, 145, 146, 7, 100, 2, 2, 146, 147, 7, 110, 2, 2, 147, 148, 7, 103, 2, 2, 148, 149, 7, 64, 2, 2, 149, 34, 3, 2, 2, 2, 150, 151, 7, 61, 2, 2, 151, 36, 3, 2, 2, 2, 152, 153, 7, 116, 2, 2, 153, 154, 7, 103, 2, 2, 154, 155, 7, 118, 2, 2, 155, 156, 7, 119, 2, 2, 156, 157, 7, 116, 2, 2, 157, 158, 7, 112, 2, 2, 158, 38, 3, 2, 2, 2, 159, 160, 7, 45, 2, 2, 160, 40, 3, 2, 2, 2, 161, 162, 7, 47, 2, 2, 162, 42, 3, 2, 2, 2, 163, 164, 7, 44, 2, 2, 164, 44, 3, 2, 2, 2, 165, 166, 7, 49, 2, 2, 166, 46, 3, 2, 2, 2, 167, 168, 7, 96, 2, 2, 168, 48, 3, 2, 2, 2, 169, 170, 7, 114, 2, 2, 170, 171, 7, 107, 2, 2, 171, 50, 3, 2, 2, 2, 172, 173, 7, 117, 2, 2, 173, 174, 7, 107, 2, 2, 174, 175, 7, 112, 2, 2, 175, 52, 3, 2, 2, 2, 176, 177, 7, 101, 2, 2, 177, 178, 7, 113, 2, 2, 178, 179, 7, 117, 2, 2, 179, 54, 3, 2, 2, 2, 180, 181, 7, 118, 2, 2, 181, 182, 7, 99, 2, 2, 182, 183, 7, 112, 2, 2, 183, 56, 3, 2, 2, 2, 184, 185, 7, 103, 2, 2, 185, 186, 7, 122, 2, 2, 186, 187, 7, 114, 2, 2, 187, 58, 3, 2, 2, 2, 188, 189, 7, 110, 2, 2, 189, 190, 7, 112, 2, 2, 190, 60, 3, 2, 2, 2, 191, 192, 7, 117, 2, 2, 192, 193, 7, 115, 2, 2, 193, 194, 7, 116, 2, 2, 194, 195, 7, 118, 2, 2, 195, 62, 3, 2, 2, 2, 196, 197, 7, 49, 2, 2, 197, 198, 7, 49, 2, 2, 198, 202, 3, 2, 2, 2, 199, 201, 10, 2, 2, 2, 200, 199, 3, 2, 2, 2, 201, 204, 3, 2, 2, 2, 202, 200, 3, 2, 2, 2, 202, 203, 3, 2, 2, 2, 203, 205, 3, 2, 2, 2, 204, 202, 3, 2, 2, 2, 205, 206, 5, 75, 38, 2, 206, 64, 3, 2, 2, 2, 207, 211, 9, 3, 2, 2, 208, 210, 9, 4, 2, 2, 209, 208, 3, 2, 2, 2, 210, 213, 3, 2, 2, 2, 211, 209, 3, 2, 2, 2, 211, 212, 3, 2, 2, 2, 212, 229, 3, 2, 2, 2, 213, 211, 3, 2, 2, 2, 214, 218, 9, 5, 2, 2, 215, 217, 9, 4, 2, 2, 216, 215, 3, 2, 2, 2, 217, 220, 3, 2, 2, 2, 218, 216, 3, 2, 2, 2, 218, 219, 3, 2, 2, 2, 219, 229, 3, 2, 2, 2, 220, 218, 3, 2, 2, 2, 221, 225, 9, 5, 2, 2, 222, 224, 9, 6, 2, 2, 223, 222, 3, 2, 2, 2, 224, 227, 3, 2, 2, 2, 225, 223, 3, 2, 2, 2, 225, 226, 3, 2, 2, 2, 226, 229, 3, 2, 2, 2, 227, 225, 3, 2, 2, 2, 228, 207, 3, 2, 2, 2, 228, 214, 3, 2, 2, 2, 228, 221, 3, 2, 2, 2, 229, 66, 3, 2, 2, 2, 230, 231, 5, 69, 35, 2, 231, 232, 7, 48, 2, 2, 232, 233, 5, 69, 35, 2, 233, 68, 3, 2, 2, 2, 234, 236, 4, 50, 59, 2, 235, 234, 3, 2, 2, 2, 236, 237, 3, 2, 2, 2, 237, 235, 3, 2, 2, 2, 237, 238, 3, 2, 2, 2, 238, 70, 3, 2, 2, 2, 239, 243, 7, 36, 2, 2, 240, 242, 10, 7, 2, 2, 241, 240, 3, 2, 2, 2, 242, 245, 3, 2, 2, 2, 243, 241, 3, 2, 2, 2, 243, 244, 3, 2, 2, 2, 244, 246, 3, 2, 2, 2, 245, 243, 3, 2, 2, 2, 246, 247, 7, 36, 2, 2, 247, 72, 3, 2, 2, 2, 248, 249, 9, 8, 2, 2, 249, 250, 3, 2, 2, 2, 250, 251, 8, 37, 2, 2, 251, 74, 3, 2, 2, 2, 252, 254, 7, 15, 2, 2, 253, 252, 3, 2, 2, 2, 253, 254, 3, 2, 2, 2, 254, 255, 3, 2, 2, 2, 255, 256, 7, 12, 2, 2, 256, 76, 3, 2, 2, 2, 11, 2, 202, 211, 218, 225, 228, 237, 243, 253, 3, 8, 2, 2]
\ No newline at end of file
......@@ -121,7 +121,7 @@ string
/* Comment */
COMMENT
: '#' ~ [\r\n]* EOL
: '//' ~ [\r\n]* EOL
;
/* id, ego, and super-ego */
......
......@@ -70,8 +70,14 @@ using InstPtr = std::shared_ptr<Instruction>;
class CompositeInstruction : public Instruction, public Persistable {
public:
// This should return the number
// of concrete leaves in the tree
virtual const int nInstructions() = 0;
// This should return the number of
// direct children
virtual const int nChildren() = 0;
virtual InstPtr getInstruction(const std::size_t idx) = 0;
virtual std::vector<InstPtr> getInstructions() = 0;
virtual void removeInstruction(const std::size_t idx) = 0;
......
......@@ -197,7 +197,14 @@ std::shared_ptr<Accelerator> getAccelerator() {
auto name = getOption("accelerator");
HeterogeneousMap m;
auto name_backend = split(name, ':');
auto acc = xacc::getService<Accelerator>(name_backend[0], false);
std::shared_ptr<Accelerator> acc;
if (xacc::hasService<Accelerator>(name_backend[0])) {
acc = xacc::getService<Accelerator>(name_backend[0], false);
} else if (xacc::hasContributedService<Accelerator>(name_backend[0])) {
acc = xacc::getContributedService<Accelerator>(name_backend[0], false);
}
if (name_backend.size() > 1) {
std::string b = name_backend[1];
m.insert("backend", b);
......@@ -221,7 +228,14 @@ std::shared_ptr<Accelerator> getAccelerator(const std::string &name,
}
auto name_backend = split(name, ':');
auto acc = xacc::getService<Accelerator>(name_backend[0]);
std::shared_ptr<Accelerator> acc;
if (xacc::hasService<Accelerator>(name_backend[0])) {
acc = xacc::getService<Accelerator>(name_backend[0], false);
} else if (xacc::hasContributedService<Accelerator>(name_backend[0])) {
acc = xacc::getContributedService<Accelerator>(name_backend[0], false);
}
if (name_backend.size() > 1) {
setOption(name_backend[0] + "-backend", name_backend[1]);
}
......@@ -247,7 +261,14 @@ std::shared_ptr<Accelerator> getAccelerator(const std::string &name,
}
HeterogeneousMap m = params;
auto name_backend = split(name, ':');
auto acc = xacc::getService<Accelerator>(name_backend[0], false);
std::shared_ptr<Accelerator> acc;
if (xacc::hasService<Accelerator>(name_backend[0])) {
acc = xacc::getService<Accelerator>(name_backend[0], false);
} else if (xacc::hasContributedService<Accelerator>(name_backend[0])) {
acc = xacc::getContributedService<Accelerator>(name_backend[0], false);
}
if (name_backend.size() > 1) {
std::string b = name_backend[1];
m.insert("backend", b);
......@@ -255,9 +276,6 @@ std::shared_ptr<Accelerator> getAccelerator(const std::string &name,
}
if (acc) {
// std::stringstream ss;
// m.print<std::string,int>(ss);
// std::cout << "SS:\n" << ss.str() << "\n";
acc->initialize(m);
} else {
......@@ -280,7 +298,7 @@ bool hasAccelerator(const std::string &name) {
error("XACC not initialized before use. Please execute "
"xacc::Initialize() before using API.");
}
return xacc::hasService<Accelerator>(name);
return xacc::hasService<Accelerator>(name) || xacc::hasContributedService<Accelerator>(name);
}
std::shared_ptr<Compiler> getCompiler(const std::string &name) {
......
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