diff --git a/ivsr_sdk/CMakeLists.txt b/ivsr_sdk/CMakeLists.txt index a2729cd..4f19a39 100644 --- a/ivsr_sdk/CMakeLists.txt +++ b/ivsr_sdk/CMakeLists.txt @@ -3,13 +3,16 @@ # cmake_minimum_required(VERSION 3.10) -project(IVSR DESCRIPTION "Intel Video Super Resolution SDK") +project(IVSR DESCRIPTION "Intel IVSR SDK") include(GNUInstallDirs) set(OUTPUT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_FOLDER}/bin) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_FOLDER}/lib) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_FOLDER}/lib) +SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g2 -ggdb") +SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall") + set(SDK_PRIVATE_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/privates/include) add_subdirectory(src) @@ -28,4 +31,4 @@ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" FILES_MATCHING PATTERN "*.h" ) -install(TARGETS ivsr LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") \ No newline at end of file +install(TARGETS ivsr LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") diff --git a/ivsr_sdk/samples/CMakeLists.txt b/ivsr_sdk/samples/CMakeLists.txt index d7506b4..67af763 100644 --- a/ivsr_sdk/samples/CMakeLists.txt +++ b/ivsr_sdk/samples/CMakeLists.txt @@ -7,7 +7,6 @@ set (TARGET_NAME "vsr_sample") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib) -SET(CMAKE_BUILD_TYPE "Debug") SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g2 -ggdb") SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall") diff --git a/ivsr_sdk/src/include/InferTask.hpp b/ivsr_sdk/src/include/InferTask.hpp index 43355b3..6a2b462 100644 --- a/ivsr_sdk/src/include/InferTask.hpp +++ b/ivsr_sdk/src/include/InferTask.hpp @@ -39,10 +39,10 @@ class InferTask { using QueueCallbackFunction = std::function; // construct function InferTask(char* inBuf, char* outBuf, QueueCallbackFunction callbackQueue, InferFlag flag, ivsr_cb_t* ivsr_cb) - : inputPtr_(inBuf), - outputPtr_(outBuf), - _callbackFunction(callbackQueue), + : _callbackFunction(callbackQueue), flag_(flag), + inputPtr_(inBuf), + outputPtr_(outBuf), cb(ivsr_cb) {} InferFlag getInferFlag() { diff --git a/ivsr_sdk/src/include/engine.hpp b/ivsr_sdk/src/include/engine.hpp index 5732fec..e2a3272 100644 --- a/ivsr_sdk/src/include/engine.hpp +++ b/ivsr_sdk/src/include/engine.hpp @@ -52,8 +52,7 @@ class engine { public: engine(Derived* derived) - : _derived(derived), - init_func([=]() -> IVSRStatus { + : init_func([=]() -> IVSRStatus { return _derived->init_impl(); }), run_func([=](InferTask::Ptr task) -> IVSRStatus { @@ -70,7 +69,8 @@ class engine { }), get_infer_requests_size_func([=]() -> size_t { return _derived->get_infer_requests_size_impl(); - }) {} + }), + _derived(derived) {} // Default constructor engine() = default; diff --git a/ivsr_sdk/src/include/ivsr_smart_patch.hpp b/ivsr_sdk/src/include/ivsr_smart_patch.hpp index ab0e17b..8886eb0 100644 --- a/ivsr_sdk/src/include/ivsr_smart_patch.hpp +++ b/ivsr_sdk/src/include/ivsr_smart_patch.hpp @@ -35,9 +35,9 @@ struct PatchConfig{ int nif; int dims; PatchConfig(int w = 1920, int h = 1080, int pw = 1920, int ph = 1080, int b_w = 1,int b_h = 1,int s = 2,int n = 3,int d = 5)\ - :patchWidth(pw),patchHeight(ph), - block_h(b_h),block_w(b_w),scale(s), - nif(n),dims(d){} + :patchWidth(pw), patchHeight(ph), + block_w(b_w), block_h(b_h), scale(s), + nif(n), dims(d){} friend std::ostream& operator<<(std::ostream& os, const PatchConfig& cfg) { return os << "PatchConfig [width]:" << cfg.patchWidth << " [height]:" << cfg.patchHeight diff --git a/ivsr_sdk/src/include/ov_engine.hpp b/ivsr_sdk/src/include/ov_engine.hpp index 5feeb5f..147e5d5 100644 --- a/ivsr_sdk/src/include/ov_engine.hpp +++ b/ivsr_sdk/src/include/ov_engine.hpp @@ -35,8 +35,8 @@ class inferReqWrap final { public: using Ptr = std::shared_ptr; explicit inferReqWrap(ov::CompiledModel& model, size_t id, CallbackFunction callback) - : id_(id), - request_(model.create_infer_request()), + : request_(model.create_infer_request()), + id_(id), callback_(callback) {} void start_async() { @@ -107,12 +107,12 @@ class ov_engine : public engine { const tensor_desc_t output_tensor_desc) : engine(this), device_(device), - model_path_(model_path), - custom_lib_(custom_lib), configs_(configs), reshape_settings_(reshape_settings), input_tensor_desc_(input_tensor_desc), - output_tensor_desc_(output_tensor_desc) { + output_tensor_desc_(output_tensor_desc), + custom_lib_(custom_lib), + model_path_(model_path) { // init(); } @@ -127,11 +127,13 @@ class ov_engine : public engine { static_assert(std::is_same::value || std::is_same::value || std::is_same::value, "get_attr() is only supported for 'ov::Shape' and 'size_t' types"); +/* auto extend_shape = [](ov::Shape& shape, size_t dims) { if (shape.size() < dims) for (size_t i = shape.size(); i < dims; i++) shape.insert(shape.begin(), 1); }; +*/ if constexpr (std::is_same::value) { ov::Shape shape; @@ -152,7 +154,7 @@ class ov_engine : public engine { memcpy((char*)value.precision, element_type.c_str(), element_type.size()); memcpy((char*)value.layout, layout.c_str(), layout.size()); value.dimension = shape.size(); - for (int i = 0; i < shape.size(); ++i) { + for (auto i = 0u; i < shape.size(); ++i) { value.shape[i] = shape[i]; } } else if constexpr (std::is_same::value) { diff --git a/ivsr_sdk/src/ivsr.cpp b/ivsr_sdk/src/ivsr.cpp index f271007..a38a252 100644 --- a/ivsr_sdk/src/ivsr.cpp +++ b/ivsr_sdk/src/ivsr.cpp @@ -77,7 +77,7 @@ void parse_engine_config(std::map& config, // remove the hardware devices if MULTI appears in the devices list. auto hardware_devices = devices; if (if_multi) { - ivsr_version_t version; + //ivsr_version_t version; ov::Version ov_version = ov::get_openvino_version(); std::string ov_buildNumber = std::string(ov_version.buildNumber); // Parse out the currect virtual device as the target device. @@ -211,8 +211,8 @@ struct ivsr { threadExecutor(executor), vsr_config(config), patchConfig(patch), - input_data_shape(std::move(shape)), - patchSolution(sol) {} + patchSolution(sol), + input_data_shape(std::move(shape)) {} }; IVSRStatus ivsr_init(ivsr_config_t *configs, ivsr_handle *handle) { @@ -464,7 +464,7 @@ IVSRStatus ivsr_process(ivsr_handle handle, char* input_data, char* output_data, } // Get data into infer task - for (int idx = 0; idx < patchList.size(); ++idx) { + for (auto idx = 0u; idx < patchList.size(); ++idx) { #ifdef ENABLE_LOG std::cout << "[Trace]: ivsr_process on patch: " << idx << std::endl; #endif @@ -582,7 +582,7 @@ IVSRStatus ivsr_reconfig(ivsr_handle handle, ivsr_config_t* configs){ // reconfig ov_engine ? - }catch(exception e){ + } catch (const std::exception& e) { // std::cout << "Error in ivsr_reconfig" << std::endl; ivsr_status_log(IVSRStatus::EXCEPTION_ERROR, e.what()); return IVSRStatus::UNKNOWN_ERROR; @@ -653,7 +653,7 @@ IVSRStatus ivsr_deinit(ivsr_handle handle) { delete handle->threadExecutor; handle->threadExecutor = nullptr; } - } catch (exception e) { + } catch (const std::exception& e) { ivsr_status_log(IVSRStatus::EXCEPTION_ERROR, e.what()); return IVSRStatus::UNKNOWN_ERROR; } diff --git a/ivsr_sdk/src/ivsr_thread_executor.cpp b/ivsr_sdk/src/ivsr_thread_executor.cpp index 482c270..6f63f35 100644 --- a/ivsr_sdk/src/ivsr_thread_executor.cpp +++ b/ivsr_sdk/src/ivsr_thread_executor.cpp @@ -57,10 +57,10 @@ struct IVSRThreadExecutor::Impl { explicit Impl(const Config& config, engine* engine) : _config{config}, - _engine(engine), _streams([this] { return std::make_shared(this); - }) { + }), + _engine(engine) { for (auto streamId = 0; streamId < _config._threads; ++streamId) { _threads.emplace_back([this, streamId] { for (bool stopped = false; !stopped;) { diff --git a/ivsr_sdk/src/ov_engine.cpp b/ivsr_sdk/src/ov_engine.cpp index 4126980..284d6cc 100644 --- a/ivsr_sdk/src/ov_engine.cpp +++ b/ivsr_sdk/src/ov_engine.cpp @@ -139,7 +139,7 @@ IVSRStatus ov_engine::init_impl() { hidden_tensor_shape[h_index] = input_shape[h_index].get_length() / 4; hidden_tensor_shape[w_index] = input_shape[w_index].get_length() / 4; - for (int i = 1; i < model->inputs().size(); ++i) + for (auto i = 1u; i < model->inputs().size(); ++i) model->reshape({{model->inputs()[i].get_any_name(), hidden_tensor_shape}}); } } @@ -150,7 +150,7 @@ IVSRStatus ov_engine::init_impl() { std::map tensor_names; const auto& inputs = model->inputs(); const auto& outputs = model->outputs(); - for (int i = 1; i < inputs.size(); ++i) { + for (auto i = 1u; i < inputs.size(); ++i) { std::string hidden_inp_name = inputs[i].get_any_name(); std::string hidden_out_name = outputs[i].get_any_name(); tensor_names[hidden_inp_name] = hidden_out_name; @@ -362,7 +362,7 @@ IVSRStatus ov_engine::create_infer_requests_impl(size_t requests_num) { return GENERAL_ERROR; } - for (int id = requests_.size(); id < requests_num; ++id) { + for (auto id = requests_.size(); id < requests_num; ++id) { requests_.push_back( std::make_shared(compiled_model_, id, diff --git a/ivsr_sdk/src/smart_patch.cpp b/ivsr_sdk/src/smart_patch.cpp index d058594..5bc433e 100644 --- a/ivsr_sdk/src/smart_patch.cpp +++ b/ivsr_sdk/src/smart_patch.cpp @@ -51,7 +51,7 @@ float* fill_patch(std::vector patchCorners, float* inputBuf, std::vector> patchCorners, char* imgBuf, \ std::vector patchDims, std::vector imgDims, std::vector patchList){ int pB = patchDims[0], pN = patchDims[1], pC = patchDims[2], pH = patchDims[3], pW = patchDims[4]; int iB = imgDims[0], iN = imgDims[1], iC = imgDims[2], iH = imgDims[3], iW = imgDims[4]; // imgDims? - int patch_sW = 1; + //int patch_sW = 1; int patch_sH = pW; int patch_sC = pH * pW; int patch_sN = pC * pH * pW; int patch_sB = pN * pC * pH * pW; - int img_sW = 1; + //int img_sW = 1; int img_sH = iW; int img_sC = iH * iW; int img_sN = iC * iH * iW; @@ -107,7 +107,7 @@ void fill_image(std::vector> patchCorners, char* imgBuf, \ float * img_ptr =(float *)imgBuf; // for each patch - for (int idx = 0; idx < patchCorners.size(); ++idx){ + for (auto idx = 0u; idx < patchCorners.size(); ++idx){ float* patchPtr = (float*)patchList[idx]; auto patchCorner = patchCorners[idx]; @@ -140,7 +140,7 @@ void fill_image(std::vector> patchCorners, char* imgBuf, \ } // average each pixel - for(int id = 0; id < outputpixels; id++){ + for(size_t id = 0; id < outputpixels; id++){ *(img_ptr + id) /= *(pixelCounter + id); } @@ -150,8 +150,8 @@ void fill_image(std::vector> patchCorners, char* imgBuf, \ SmartPatch::SmartPatch(PatchConfig config, char* inBuf, char* outBuf, std::vector inputShape, bool flag) :_inputPtr(inBuf), _outputPtr(outBuf), - _config(config), _inputShape(inputShape), + _config(config), flag(flag) { if (flag){