Loading python/py-qcor.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -136,6 +136,7 @@ class PyObjectiveFunction : public qcor::ObjectiveFunction { // QJIT compile // this will be fast if already done, and we just do it once qjit.jit_compile(src, true); qjit.write_cache(); } // Evaluate this ObjectiveFunction at the dictionary of kernel args, Loading Loading @@ -196,6 +197,7 @@ class PyKernelFunctor : public qcor::KernelFunctor { auto src = py_kernel.attr("get_internal_src")().cast<std::string>(); // this will be fast if already done, and we just do it once qjit.jit_compile(src, true); qjit.write_cache(); } // Delegate to QJIT to create a CompositeInstruction representation Loading Loading @@ -282,6 +284,7 @@ PYBIND11_MODULE(_pyqcor, m) { // m.def("createObjectiveFunction", [](const std::string name, )) py::class_<qcor::QJIT, std::shared_ptr<qcor::QJIT>>(m, "QJIT", "") .def(py::init<>(), "") .def("write_cache", &qcor::QJIT::write_cache, "") .def("jit_compile", &qcor::QJIT::jit_compile, "") .def( "internal_python_jit_compile", Loading python/qcor.py +1 −0 Original line number Diff line number Diff line Loading @@ -94,6 +94,7 @@ class qjit(object): # Run the QJIT compile step to store function pointers internally self._qjit.internal_python_jit_compile(self.src) self._qjit.write_cache() return Loading runtime/jit/qcor_jit.hpp +2 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,8 @@ class QJIT { void jit_compile(const std::string &quantum_kernel_src, const bool add_het_map_kernel_ctor = false); void write_cache(); template <typename... Args> void invoke(const std::string &kernel_name, Args... args) { auto f_ptr = kernel_name_to_f_ptr[kernel_name]; Loading runtime/jit/qcor_jit.in.cpp +11 −9 Original line number Diff line number Diff line Loading @@ -6,7 +6,6 @@ #include "Accelerator.hpp" #include "CompositeInstruction.hpp" #include "xacc.hpp" #include "Utils.hpp" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/DiagnosticOptions.h" Loading Loading @@ -51,6 +50,7 @@ #include "qcor_jit.hpp" #include "qcor_syntax_handler.hpp" #include "qrt.hpp" #include "xacc.hpp" #include "xacc_internal_compiler.hpp" using namespace llvm; Loading Loading @@ -322,6 +322,7 @@ QJIT::QJIT() { std::string cache_file_contents( (std::istreambuf_iterator<char>(cache_file)), std::istreambuf_iterator<char>()); if (!cache_file_contents.empty()) { auto cache_json = nlohmann::json::parse(cache_file_contents); auto jit_cache = cache_json["jit_cache"]; for (auto &element : jit_cache) { Loading @@ -330,8 +331,8 @@ QJIT::QJIT() { } } } QJIT::~QJIT() { } void QJIT::write_cache() { std::string cache_file_loc = "@CMAKE_INSTALL_PREFIX@/tmp/qjit_cache.json"; nlohmann::json j; j["jit_cache"] = cached_kernel_codes; Loading @@ -340,6 +341,7 @@ QJIT::~QJIT() { cache << str; cache.close(); } QJIT::~QJIT() { write_cache(); } void QJIT::jit_compile(const std::string &code, const bool add_het_map_kernel_ctor) { Loading Loading
python/py-qcor.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -136,6 +136,7 @@ class PyObjectiveFunction : public qcor::ObjectiveFunction { // QJIT compile // this will be fast if already done, and we just do it once qjit.jit_compile(src, true); qjit.write_cache(); } // Evaluate this ObjectiveFunction at the dictionary of kernel args, Loading Loading @@ -196,6 +197,7 @@ class PyKernelFunctor : public qcor::KernelFunctor { auto src = py_kernel.attr("get_internal_src")().cast<std::string>(); // this will be fast if already done, and we just do it once qjit.jit_compile(src, true); qjit.write_cache(); } // Delegate to QJIT to create a CompositeInstruction representation Loading Loading @@ -282,6 +284,7 @@ PYBIND11_MODULE(_pyqcor, m) { // m.def("createObjectiveFunction", [](const std::string name, )) py::class_<qcor::QJIT, std::shared_ptr<qcor::QJIT>>(m, "QJIT", "") .def(py::init<>(), "") .def("write_cache", &qcor::QJIT::write_cache, "") .def("jit_compile", &qcor::QJIT::jit_compile, "") .def( "internal_python_jit_compile", Loading
python/qcor.py +1 −0 Original line number Diff line number Diff line Loading @@ -94,6 +94,7 @@ class qjit(object): # Run the QJIT compile step to store function pointers internally self._qjit.internal_python_jit_compile(self.src) self._qjit.write_cache() return Loading
runtime/jit/qcor_jit.hpp +2 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,8 @@ class QJIT { void jit_compile(const std::string &quantum_kernel_src, const bool add_het_map_kernel_ctor = false); void write_cache(); template <typename... Args> void invoke(const std::string &kernel_name, Args... args) { auto f_ptr = kernel_name_to_f_ptr[kernel_name]; Loading
runtime/jit/qcor_jit.in.cpp +11 −9 Original line number Diff line number Diff line Loading @@ -6,7 +6,6 @@ #include "Accelerator.hpp" #include "CompositeInstruction.hpp" #include "xacc.hpp" #include "Utils.hpp" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/DiagnosticOptions.h" Loading Loading @@ -51,6 +50,7 @@ #include "qcor_jit.hpp" #include "qcor_syntax_handler.hpp" #include "qrt.hpp" #include "xacc.hpp" #include "xacc_internal_compiler.hpp" using namespace llvm; Loading Loading @@ -322,6 +322,7 @@ QJIT::QJIT() { std::string cache_file_contents( (std::istreambuf_iterator<char>(cache_file)), std::istreambuf_iterator<char>()); if (!cache_file_contents.empty()) { auto cache_json = nlohmann::json::parse(cache_file_contents); auto jit_cache = cache_json["jit_cache"]; for (auto &element : jit_cache) { Loading @@ -330,8 +331,8 @@ QJIT::QJIT() { } } } QJIT::~QJIT() { } void QJIT::write_cache() { std::string cache_file_loc = "@CMAKE_INSTALL_PREFIX@/tmp/qjit_cache.json"; nlohmann::json j; j["jit_cache"] = cached_kernel_codes; Loading @@ -340,6 +341,7 @@ QJIT::~QJIT() { cache << str; cache.close(); } QJIT::~QJIT() { write_cache(); } void QJIT::jit_compile(const std::string &code, const bool add_het_map_kernel_ctor) { Loading