Loading ir/transformations/NoiseAware/CMakeLists.txt +2 −3 Original line number Diff line number Diff line Loading @@ -5,9 +5,9 @@ usfunctiongeneratebundleinit(TARGET ${LIBRARY_NAME} OUT SRC) add_library(${LIBRARY_NAME} SHARED ${SRC}) target_include_directories(${LIBRARY_NAME} PUBLIC . ../.. libint-wrapper/src) target_include_directories(${LIBRARY_NAME} PUBLIC . target_link_libraries(${LIBRARY_NAME} PUBLIC CppMicroServices PRIVATE xacc libint-wrapper) target_link_libraries(${LIBRARY_NAME} PUBLIC xacc PRIVATE CppMicroServices) set(_bundle_name qcor_noiseaware_transformation) set_target_properties(${LIBRARY_NAME} Loading @@ -30,4 +30,3 @@ if(QCOR_BUILD_TESTS) endif() install(TARGETS ${LIBRARY_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/plugins) endif() ir/transformations/NoiseAware/NoiseAwareTransformation.cpp +11 −9 Original line number Diff line number Diff line #include noiseAwareTransformation.hpp //#include SWAP.hpp?? //#include "LibIntWrapper.hpp" //#include "xacc_service.hpp" #include <iostream> Loading @@ -13,25 +12,28 @@ namespace qcor { // TODO: expand to handle more than 1 function auto function = ir->getKernels()[0]; // check that there is a kernel if (!kernelExists(allKernels)) return; // do stuff with that function // TODO:FIX: check that function is not null if (function == NULL) return; // check that function is not null if (function == nullptr) return; // iterate to get instructions in the function for (int i = 0; i < function->nInstructions(); i++) { auto inst = function->getInstruction(i); // Get index of qubit involved - vector<int> auto param = inst->bits() auto bitIdx = inst->bits() //increase index by 1 for (int j = 0; j < param.size(); j++) { param[j]++; for (int j = 0; j < bitIdx.size(); j++) { bitIdx[j]++; } //set the new bits setBits(param); inst->setBits(bitIdx); } return ir; Loading ir/transformations/NoiseAware/noiseAwareTransformation.hpp +1 −10 Original line number Diff line number Diff line Loading @@ -3,23 +3,14 @@ #include "IRTransformation.hpp" //#include <thread> using namespace xacc; /* namespace xacc { namespace quantum { class NoiseAwareTransform; } } */ namespace qcor { namespace transformations { class NoiseAwareTransform : public IRTransformation { public: std::shared_ptr<IR> transform(std::shared_ptr<IR> ir) transform; std::shared_ptr<IR> transform(std::shared_ptr<IR> ir) override; } } } Loading Loading
ir/transformations/NoiseAware/CMakeLists.txt +2 −3 Original line number Diff line number Diff line Loading @@ -5,9 +5,9 @@ usfunctiongeneratebundleinit(TARGET ${LIBRARY_NAME} OUT SRC) add_library(${LIBRARY_NAME} SHARED ${SRC}) target_include_directories(${LIBRARY_NAME} PUBLIC . ../.. libint-wrapper/src) target_include_directories(${LIBRARY_NAME} PUBLIC . target_link_libraries(${LIBRARY_NAME} PUBLIC CppMicroServices PRIVATE xacc libint-wrapper) target_link_libraries(${LIBRARY_NAME} PUBLIC xacc PRIVATE CppMicroServices) set(_bundle_name qcor_noiseaware_transformation) set_target_properties(${LIBRARY_NAME} Loading @@ -30,4 +30,3 @@ if(QCOR_BUILD_TESTS) endif() install(TARGETS ${LIBRARY_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/plugins) endif()
ir/transformations/NoiseAware/NoiseAwareTransformation.cpp +11 −9 Original line number Diff line number Diff line #include noiseAwareTransformation.hpp //#include SWAP.hpp?? //#include "LibIntWrapper.hpp" //#include "xacc_service.hpp" #include <iostream> Loading @@ -13,25 +12,28 @@ namespace qcor { // TODO: expand to handle more than 1 function auto function = ir->getKernels()[0]; // check that there is a kernel if (!kernelExists(allKernels)) return; // do stuff with that function // TODO:FIX: check that function is not null if (function == NULL) return; // check that function is not null if (function == nullptr) return; // iterate to get instructions in the function for (int i = 0; i < function->nInstructions(); i++) { auto inst = function->getInstruction(i); // Get index of qubit involved - vector<int> auto param = inst->bits() auto bitIdx = inst->bits() //increase index by 1 for (int j = 0; j < param.size(); j++) { param[j]++; for (int j = 0; j < bitIdx.size(); j++) { bitIdx[j]++; } //set the new bits setBits(param); inst->setBits(bitIdx); } return ir; Loading
ir/transformations/NoiseAware/noiseAwareTransformation.hpp +1 −10 Original line number Diff line number Diff line Loading @@ -3,23 +3,14 @@ #include "IRTransformation.hpp" //#include <thread> using namespace xacc; /* namespace xacc { namespace quantum { class NoiseAwareTransform; } } */ namespace qcor { namespace transformations { class NoiseAwareTransform : public IRTransformation { public: std::shared_ptr<IR> transform(std::shared_ptr<IR> ir) transform; std::shared_ptr<IR> transform(std::shared_ptr<IR> ir) override; } } } Loading