From aa23fbb9d30846bb7aff66f67b3d959a251c247a Mon Sep 17 00:00:00 2001 From: Artemy Skrebkov Date: Thu, 11 Feb 2021 15:53:19 +0300 Subject: [PATCH] Update benchmark_app to pass precision and layout via command line (#4167) * Move processing ins and outs into samples/common - To re-use it in compile_tool and benchmark_app * Extract common into samples_utils lib - To re-use it in samples and tools * Move processLayout into samples_utils * Clean up * Enable warning as errors for samples_utils * Cannot set precision or layout for compiled network * Remove layout setting for benchmark_app - It requires further discussion * Fix compilation of samples * Fix one more sample * Fix windows build * Update README.md * One more fix for windows * Fix OpenVino ONNX CI build * More build fixes * Move os and vpu common into utils * Fix build for myriad tools * Fix windows build * Export gflags --- inference-engine/CMakeLists.txt | 2 + inference-engine/samples/CMakeLists.txt | 4 + .../samples/benchmark_app/CMakeLists.txt | 3 +- .../samples/benchmark_app/README.md | 3 + .../samples/benchmark_app/benchmark_app.hpp | 28 ++ .../samples/benchmark_app/main.cpp | 12 + .../CMakeLists.txt | 2 +- .../common/format_reader/CMakeLists.txt | 2 +- .../samples/common/samples/args_helper.hpp | 87 ----- .../samples/common/utils/CMakeLists.txt | 19 ++ .../utils/include/samples/args_helper.hpp | 36 ++ .../include}/samples/classification_results.h | 2 + .../{ => utils/include}/samples/common.hpp | 10 + .../include}/samples/console_progress.hpp | 0 .../include}/samples/csv_dumper.hpp | 0 .../include}/samples/ocv_common.hpp | 0 .../include/samples}/os/windows/w_dirent.h | 0 .../{ => utils/include}/samples/slog.hpp | 0 .../include/samples}/vpu/vpu_tools_common.hpp | 0 .../samples/common/utils/src/args_helper.cpp | 307 ++++++++++++++++++ .../samples/common/utils/src/common.cpp | 24 ++ .../hello_classification/CMakeLists.txt | 1 + .../CMakeLists.txt | 3 +- .../hello_nv12_input_classification/main.cpp | 2 +- .../samples/hello_query_device/CMakeLists.txt | 3 +- .../samples/hello_reshape_ssd/CMakeLists.txt | 1 + .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../object_detection_sample_ssd/main.cpp | 1 - .../samples/speech_sample/CMakeLists.txt | 3 +- .../style_transfer_sample/CMakeLists.txt | 2 +- .../tests_deprecated/helpers/CMakeLists.txt | 2 +- .../tools/compile_tool/CMakeLists.txt | 2 +- inference-engine/tools/compile_tool/main.cpp | 214 +----------- .../tools/vpu/common/vpu_tools_common.cpp | 24 +- .../tools/vpu/common/vpu_tools_common.hpp | 2 - .../tools/vpu/vpu_compile/CMakeLists.txt | 5 +- .../tools/vpu/vpu_perfcheck/CMakeLists.txt | 4 +- .../tools/vpu/vpu_perfcheck/main.cpp | 5 +- 39 files changed, 481 insertions(+), 338 deletions(-) delete mode 100644 inference-engine/samples/common/samples/args_helper.hpp create mode 100644 inference-engine/samples/common/utils/CMakeLists.txt create mode 100644 inference-engine/samples/common/utils/include/samples/args_helper.hpp rename inference-engine/samples/common/{ => utils/include}/samples/classification_results.h (99%) rename inference-engine/samples/common/{ => utils/include}/samples/common.hpp (99%) rename inference-engine/samples/common/{ => utils/include}/samples/console_progress.hpp (100%) rename inference-engine/samples/common/{ => utils/include}/samples/csv_dumper.hpp (100%) rename inference-engine/samples/common/{ => utils/include}/samples/ocv_common.hpp (100%) rename inference-engine/samples/common/{ => utils/include/samples}/os/windows/w_dirent.h (100%) rename inference-engine/samples/common/{ => utils/include}/samples/slog.hpp (100%) rename inference-engine/samples/common/{ => utils/include/samples}/vpu/vpu_tools_common.hpp (100%) create mode 100644 inference-engine/samples/common/utils/src/args_helper.cpp create mode 100644 inference-engine/samples/common/utils/src/common.cpp diff --git a/inference-engine/CMakeLists.txt b/inference-engine/CMakeLists.txt index a3e4f74c40f..32060a9eefe 100644 --- a/inference-engine/CMakeLists.txt +++ b/inference-engine/CMakeLists.txt @@ -180,6 +180,8 @@ endif() # ie_developer_export_targets(format_reader) +ie_developer_export_targets(ie_samples_utils) +ie_developer_export_targets(gflags) ie_developer_export_targets(${NGRAPH_LIBRARIES}) # for Template plugin diff --git a/inference-engine/samples/CMakeLists.txt b/inference-engine/samples/CMakeLists.txt index 236c17e6af3..83f3cec1e38 100644 --- a/inference-engine/samples/CMakeLists.txt +++ b/inference-engine/samples/CMakeLists.txt @@ -137,6 +137,10 @@ else() find_package(InferenceEngine 2.1 REQUIRED) endif() +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/common/utils") + add_subdirectory(common/utils) +endif() + # format reader must be added after find_package(InferenceEngine) to get # exactly the same OpenCV_DIR path which was used for the InferenceEngine build if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/common/format_reader") diff --git a/inference-engine/samples/benchmark_app/CMakeLists.txt b/inference-engine/samples/benchmark_app/CMakeLists.txt index a74294a0fbb..173731b9e64 100644 --- a/inference-engine/samples/benchmark_app/CMakeLists.txt +++ b/inference-engine/samples/benchmark_app/CMakeLists.txt @@ -8,5 +8,6 @@ file (GLOB HDR ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp) ie_add_sample(NAME benchmark_app SOURCES ${SRC} HEADERS ${HDR} - DEPENDENCIES format_reader + DEPENDENCIES format_reader ie_samples_utils OPENCV_DEPENDENCIES imgcodecs) + diff --git a/inference-engine/samples/benchmark_app/README.md b/inference-engine/samples/benchmark_app/README.md index d6aa9544e2c..c08a9ed2c1e 100644 --- a/inference-engine/samples/benchmark_app/README.md +++ b/inference-engine/samples/benchmark_app/README.md @@ -95,6 +95,9 @@ Options: -nthreads "" Optional. Number of threads to use for inference on the CPU (including HETERO and MULTI cases). -enforcebf16 Optional. Enforcing of floating point operations execution in bfloat16 precision on platforms with native bfloat16 support. By default, this key sets "true" on platforms with native bfloat16 support and "false" for other platforms. Use "-enforcebf16=false" to disable this feature. -pin "YES"/"NO"/"NUMA" Optional. Enable threads->cores ("YES", default), threads->(NUMA)nodes ("NUMA") or completely disable ("NO") CPU threads pinning for CPU-involved inference. + -ip "U8"/"FP16"/"FP32" Optional. Specifies precision for all input layers of the network. + -op "U8"/"FP16"/"FP32" Optional. Specifies precision for all output layers of the network. + -iop Optional. Specifies precision for input and output layers by name. Example: -iop "input:FP16, output:FP16". Notice that quotes are required. Overwrites precision from ip and op options for specified layers. Statistics dumping options: diff --git a/inference-engine/samples/benchmark_app/benchmark_app.hpp b/inference-engine/samples/benchmark_app/benchmark_app.hpp index 1a5a5299a02..34ee3e49a82 100644 --- a/inference-engine/samples/benchmark_app/benchmark_app.hpp +++ b/inference-engine/samples/benchmark_app/benchmark_app.hpp @@ -103,6 +103,19 @@ static const char shape_message[] = "Optional. Set shape for input. For example, // @brief message for quantization bits static const char gna_qb_message[] = "Optional. Weight bits for quantization: 8 or 16 (default)"; +// TODO: duplicate options from compile_tool +static constexpr char inputs_precision_message[] = + "Optional. Specifies precision for all input layers of the network."; + +static constexpr char outputs_precision_message[] = + "Optional. Specifies precision for all output layers of the network."; + +static constexpr char iop_message[] = + "Optional. Specifies precision for input and output layers by name.\n" +" Example: -iop \"input:FP16, output:FP16\".\n" +" Notice that quotes are required.\n" +" Overwrites precision from ip and op options for specified layers."; + /// @brief Define flag for showing help message
DEFINE_bool(h, false, help_message); @@ -190,6 +203,18 @@ DEFINE_string(shape, "", shape_message); /// @brief Define flag for quantization bits (default 16) DEFINE_int32(qb, 16, gna_qb_message); +/// @brief Specify precision for all input layers of the network +DEFINE_string(ip, "", inputs_precision_message); + +/// @brief Specify precision for all ouput layers of the network +DEFINE_string(op, "", outputs_precision_message); + +/// @brief Specify precision for input and output layers by name.\n" +/// Example: -iop \"input:FP16, output:FP16\".\n" +/// Notice that quotes are required.\n" +/// Overwrites layout from ip and op options for specified layers."; +DEFINE_string(iop, "", iop_message); + /** * @brief This function show a help message */ @@ -228,4 +253,7 @@ static void showUsage() { std::cout << " -load_config " << load_config_message << std::endl; #endif std::cout << " -qb " << gna_qb_message << std::endl; + std::cout << " -ip " << inputs_precision_message << std::endl; + std::cout << " -op " << outputs_precision_message << std::endl; + std::cout << " -iop \"\" " << iop_message << std::endl; } diff --git a/inference-engine/samples/benchmark_app/main.cpp b/inference-engine/samples/benchmark_app/main.cpp index 223212fc9c4..eed7f253006 100644 --- a/inference-engine/samples/benchmark_app/main.cpp +++ b/inference-engine/samples/benchmark_app/main.cpp @@ -67,6 +67,14 @@ bool ParseAndCheckCommandLine(int argc, char *argv[]) { throw std::logic_error("only " + std::string(detailedCntReport) + " report type is supported for MULTI device"); } + bool isNetworkCompiled = fileExt(FLAGS_m) == "blob"; + bool isPrecisionSet = !(FLAGS_ip.empty() && FLAGS_op.empty() && FLAGS_iop.empty()); + if (isNetworkCompiled && isPrecisionSet) { + std::string err = std::string("Cannot set precision for a compiled network. ") + + std::string("Please re-compile your network with required precision using compile_tool"); + + throw std::logic_error(err); + } return true; } @@ -376,6 +384,10 @@ int main(int argc, char *argv[]) { item.second->setPrecision(Precision::U8); } } + + processPrecision(cnnNetwork, FLAGS_ip, FLAGS_op, FLAGS_iop); + + printInputAndOutputsInfo(cnnNetwork); // ----------------- 7. Loading the model to the device -------------------------------------------------------- next_step(); startTime = Time::now(); diff --git a/inference-engine/samples/classification_sample_async/CMakeLists.txt b/inference-engine/samples/classification_sample_async/CMakeLists.txt index dd7aa6b9f31..710c642664a 100644 --- a/inference-engine/samples/classification_sample_async/CMakeLists.txt +++ b/inference-engine/samples/classification_sample_async/CMakeLists.txt @@ -5,4 +5,4 @@ ie_add_sample(NAME classification_sample_async SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp" HEADERS classification_sample_async.h - DEPENDENCIES format_reader) + DEPENDENCIES format_reader ie_samples_utils) diff --git a/inference-engine/samples/common/format_reader/CMakeLists.txt b/inference-engine/samples/common/format_reader/CMakeLists.txt index 48dbed9f2b5..d77e61d69dc 100644 --- a/inference-engine/samples/common/format_reader/CMakeLists.txt +++ b/inference-engine/samples/common/format_reader/CMakeLists.txt @@ -25,7 +25,7 @@ find_package(OpenCV COMPONENTS imgcodecs videoio imgproc QUIET) if(NOT OpenCV_FOUND) message(WARNING "OPENCV is disabled or not found, " ${TARGET_NAME} " will be built without OPENCV support") else() - target_link_libraries(${TARGET_NAME} PRIVATE ${OpenCV_LIBRARIES}) + target_link_libraries(${TARGET_NAME} PRIVATE ${OpenCV_LIBRARIES} ie_samples_utils) if(UNIX AND NOT APPLE) # Workaround issue that rpath-link is missing for PRIVATE dependencies # Fixed in cmake 3.16.0 https://gitlab.kitware.com/cmake/cmake/issues/19556 diff --git a/inference-engine/samples/common/samples/args_helper.hpp b/inference-engine/samples/common/samples/args_helper.hpp deleted file mode 100644 index fa2e34aa5e7..00000000000 --- a/inference-engine/samples/common/samples/args_helper.hpp +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (C) 2018-2020 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/** - * @brief a header file with common samples functionality - * @file args_helper.hpp - */ - -#pragma once - -#include -#include -#include -#include -#include - -#include - -#ifdef _WIN32 -#include -#else -#include -#endif - -/** -* @brief This function checks input args and existence of specified files in a given folder -* @param arg path to a file to be checked for existence -* @return files updated vector of verified input files -*/ -void readInputFilesArguments(std::vector &files, const std::string& arg) { - struct stat sb; - if (stat(arg.c_str(), &sb) != 0) { - slog::warn << "File " << arg << " cannot be opened!" << slog::endl; - return; - } - if (S_ISDIR(sb.st_mode)) { - DIR *dp; - dp = opendir(arg.c_str()); - if (dp == nullptr) { - slog::warn << "Directory " << arg << " cannot be opened!" << slog::endl; - return; - } - - struct dirent *ep; - while (nullptr != (ep = readdir(dp))) { - std::string fileName = ep->d_name; - if (fileName == "." || fileName == "..") continue; - files.push_back(arg + "/" + ep->d_name); - } - closedir(dp); - } else { - files.push_back(arg); - } - - if (files.size() < 20) { - slog::info << "Files were added: " << files.size() << slog::endl; - for (std::string filePath : files) { - slog::info << " " << filePath << slog::endl; - } - } else { - slog::info << "Files were added: " << files.size() << ". Too many to display each of them." << slog::endl; - } -} - -/** -* @brief This function find -i/--images key in input args -* It's necessary to process multiple values for single key -* @return files updated vector of verified input files -*/ -void parseInputFilesArguments(std::vector &files) { - std::vector args = gflags::GetArgvs(); - bool readArguments = false; - for (size_t i = 0; i < args.size(); i++) { - if (args.at(i) == "-i" || args.at(i) == "--images") { - readArguments = true; - continue; - } - if (!readArguments) { - continue; - } - if (args.at(i).c_str()[0] == '-') { - break; - } - readInputFilesArguments(files, args.at(i)); - } -} diff --git a/inference-engine/samples/common/utils/CMakeLists.txt b/inference-engine/samples/common/utils/CMakeLists.txt new file mode 100644 index 00000000000..fb5d462a2f2 --- /dev/null +++ b/inference-engine/samples/common/utils/CMakeLists.txt @@ -0,0 +1,19 @@ +# Copyright (C) Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# +set(TARGET_NAME "ie_samples_utils") + +file(GLOB_RECURSE SOURCES "*.cpp" "*.hpp") +source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCES}) + +add_library(${TARGET_NAME} STATIC ${SOURCES}) +set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "src") + +target_include_directories(${TARGET_NAME} + PUBLIC + "${CMAKE_CURRENT_SOURCE_DIR}/include") + +target_link_libraries(${TARGET_NAME} + PUBLIC + IE::inference_engine + gflags) diff --git a/inference-engine/samples/common/utils/include/samples/args_helper.hpp b/inference-engine/samples/common/utils/include/samples/args_helper.hpp new file mode 100644 index 00000000000..0b4d5da3c29 --- /dev/null +++ b/inference-engine/samples/common/utils/include/samples/args_helper.hpp @@ -0,0 +1,36 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +/** + * @brief a header file with common samples functionality + * @file args_helper.hpp + */ + +#pragma once + +#include +#include + +#include + +/** +* @brief This function checks input args and existence of specified files in a given folder +* @param arg path to a file to be checked for existence +* @return files updated vector of verified input files +*/ +void readInputFilesArguments(std::vector &files, const std::string& arg); + +/** +* @brief This function find -i/--images key in input args +* It's necessary to process multiple values for single key +* @return files updated vector of verified input files +*/ +void parseInputFilesArguments(std::vector &files); + +void processPrecision(InferenceEngine::CNNNetwork& network, const std::string &ip, const std::string &op, const std::string &iop); + +void processLayout(InferenceEngine::CNNNetwork& network, const std::string& il, const std::string& ol, const std::string& iol); + +void printInputAndOutputsInfo(const InferenceEngine::CNNNetwork& network); + diff --git a/inference-engine/samples/common/samples/classification_results.h b/inference-engine/samples/common/utils/include/samples/classification_results.h similarity index 99% rename from inference-engine/samples/common/samples/classification_results.h rename to inference-engine/samples/common/utils/include/samples/classification_results.h index 98ea8135b45..42f48e08c77 100644 --- a/inference-engine/samples/common/samples/classification_results.h +++ b/inference-engine/samples/common/utils/include/samples/classification_results.h @@ -6,6 +6,8 @@ * @brief a header file with output classification results * @file classification_results.hpp */ +#pragma once + #include #include #include diff --git a/inference-engine/samples/common/samples/common.hpp b/inference-engine/samples/common/utils/include/samples/common.hpp similarity index 99% rename from inference-engine/samples/common/samples/common.hpp rename to inference-engine/samples/common/utils/include/samples/common.hpp index cd6948e1e1c..9f18892b9f5 100644 --- a/inference-engine/samples/common/samples/common.hpp +++ b/inference-engine/samples/common/utils/include/samples/common.hpp @@ -1129,3 +1129,13 @@ inline void showAvailableDevices() { } std::cout << std::endl; } + +/** +* @brief Parse text config file. The file must have the following format (with space a delimeter): +* CONFIG_NAME1 CONFIG_VALUE1 +* CONFIG_NAME2 CONFIG_VALUE2 +* +* @param configName - filename for a file with config options +* @param comment - lines starting with symbol `comment` are skipped +*/ +std::map parseConfig(const std::string &configName, char comment = '#'); diff --git a/inference-engine/samples/common/samples/console_progress.hpp b/inference-engine/samples/common/utils/include/samples/console_progress.hpp similarity index 100% rename from inference-engine/samples/common/samples/console_progress.hpp rename to inference-engine/samples/common/utils/include/samples/console_progress.hpp diff --git a/inference-engine/samples/common/samples/csv_dumper.hpp b/inference-engine/samples/common/utils/include/samples/csv_dumper.hpp similarity index 100% rename from inference-engine/samples/common/samples/csv_dumper.hpp rename to inference-engine/samples/common/utils/include/samples/csv_dumper.hpp diff --git a/inference-engine/samples/common/samples/ocv_common.hpp b/inference-engine/samples/common/utils/include/samples/ocv_common.hpp similarity index 100% rename from inference-engine/samples/common/samples/ocv_common.hpp rename to inference-engine/samples/common/utils/include/samples/ocv_common.hpp diff --git a/inference-engine/samples/common/os/windows/w_dirent.h b/inference-engine/samples/common/utils/include/samples/os/windows/w_dirent.h similarity index 100% rename from inference-engine/samples/common/os/windows/w_dirent.h rename to inference-engine/samples/common/utils/include/samples/os/windows/w_dirent.h diff --git a/inference-engine/samples/common/samples/slog.hpp b/inference-engine/samples/common/utils/include/samples/slog.hpp similarity index 100% rename from inference-engine/samples/common/samples/slog.hpp rename to inference-engine/samples/common/utils/include/samples/slog.hpp diff --git a/inference-engine/samples/common/vpu/vpu_tools_common.hpp b/inference-engine/samples/common/utils/include/samples/vpu/vpu_tools_common.hpp similarity index 100% rename from inference-engine/samples/common/vpu/vpu_tools_common.hpp rename to inference-engine/samples/common/utils/include/samples/vpu/vpu_tools_common.hpp diff --git a/inference-engine/samples/common/utils/src/args_helper.cpp b/inference-engine/samples/common/utils/src/args_helper.cpp new file mode 100644 index 00000000000..5379d720af4 --- /dev/null +++ b/inference-engine/samples/common/utils/src/args_helper.cpp @@ -0,0 +1,307 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "samples/args_helper.hpp" + +#include +#include +#include + +#include + +#ifdef _WIN32 +#include +#else +#include +#endif + +void readInputFilesArguments(std::vector &files, const std::string& arg) { + struct stat sb; + if (stat(arg.c_str(), &sb) != 0) { + slog::warn << "File " << arg << " cannot be opened!" << slog::endl; + return; + } + if (S_ISDIR(sb.st_mode)) { + DIR *dp; + dp = opendir(arg.c_str()); + if (dp == nullptr) { + slog::warn << "Directory " << arg << " cannot be opened!" << slog::endl; + return; + } + + struct dirent *ep; + while (nullptr != (ep = readdir(dp))) { + std::string fileName = ep->d_name; + if (fileName == "." || fileName == "..") continue; + files.push_back(arg + "/" + ep->d_name); + } + closedir(dp); + } else { + files.push_back(arg); + } + + if (files.size() < 20) { + slog::info << "Files were added: " << files.size() << slog::endl; + for (std::string filePath : files) { + slog::info << " " << filePath << slog::endl; + } + } else { + slog::info << "Files were added: " << files.size() << ". Too many to display each of them." << slog::endl; + } +} + +void parseInputFilesArguments(std::vector &files) { + std::vector args = gflags::GetArgvs(); + bool readArguments = false; + for (size_t i = 0; i < args.size(); i++) { + if (args.at(i) == "-i" || args.at(i) == "--images") { + readArguments = true; + continue; + } + if (!readArguments) { + continue; + } + if (args.at(i).c_str()[0] == '-') { + break; + } + readInputFilesArguments(files, args.at(i)); + } +} + +namespace { + +void splitStringList(const std::string& str, std::vector& out, char delim) { + out.clear(); + + if (str.empty()) + return; + + std::istringstream istr(str); + + std::string elem; + while (std::getline(istr, elem, delim)) { + if (elem.empty()) { + continue; + } + out.emplace_back(std::move(elem)); + } +} + +std::map parseArgMap(std::string argMap) { + argMap.erase(std::remove_if(argMap.begin(), argMap.end(), ::isspace), argMap.end()); + + std::vector pairs; + splitStringList(argMap, pairs, ','); + + std::map parsedMap; + for (auto&& pair : pairs) { + std::vector keyValue; + splitStringList(pair, keyValue, ':'); + if (keyValue.size() != 2) { + throw std::invalid_argument("Invalid key/value pair " + pair + ". Expected :"); + } + + parsedMap[keyValue[0]] = keyValue[1]; + } + + return parsedMap; +} + + +using supported_precisions_t = std::unordered_map; + +InferenceEngine::Precision getPrecision(std::string value, + const supported_precisions_t& supported_precisions) { + std::transform(value.begin(), value.end(), value.begin(), ::toupper); + + const auto precision = supported_precisions.find(value); + if (precision == supported_precisions.end()) { + throw std::logic_error("\"" + value + "\"" + " is not a valid precision"); + } + + return precision->second; +} + +InferenceEngine::Precision getPrecision(const std::string& value) { + static const supported_precisions_t supported_precisions = { + { "FP32", InferenceEngine::Precision::FP32 }, + { "FP16", InferenceEngine::Precision::FP16 }, + { "BF16", InferenceEngine::Precision::BF16 }, + { "U64", InferenceEngine::Precision::U64 }, + { "I64", InferenceEngine::Precision::I64 }, + { "U32", InferenceEngine::Precision::U32 }, + { "I32", InferenceEngine::Precision::I32 }, + { "U16", InferenceEngine::Precision::U16 }, + { "I16", InferenceEngine::Precision::I16 }, + { "U8", InferenceEngine::Precision::U8 }, + { "I8", InferenceEngine::Precision::I8 }, + { "BOOL", InferenceEngine::Precision::BOOL }, + }; + + return getPrecision(value, supported_precisions); +} + +void setPrecisions(const InferenceEngine::CNNNetwork& network, const std::string &iop) { + const auto user_precisions_map = parseArgMap(iop); + + auto inputs = network.getInputsInfo(); + auto outputs = network.getOutputsInfo(); + + for (auto&& item : user_precisions_map) { + const auto& layer_name = item.first; + const auto& user_precision = item.second; + + const auto input = inputs.find(layer_name); + const auto output = outputs.find(layer_name); + + if (input != inputs.end()) { + input->second->setPrecision(getPrecision(user_precision)); + } else if (output != outputs.end()) { + output->second->setPrecision(getPrecision(user_precision)); + } else { + throw std::logic_error(layer_name + " is not an input neither output"); + } + } +} + +} // namespace + +void processPrecision(InferenceEngine::CNNNetwork& network, const std::string &ip, const std::string &op, + const std::string &iop) { + if (!ip.empty()) { + const auto user_precision = getPrecision(ip); + for (auto&& layer : network.getInputsInfo()) { + layer.second->setPrecision(user_precision); + } + } + + if (!op.empty()) { + auto user_precision = getPrecision(op); + for (auto&& layer : network.getOutputsInfo()) { + layer.second->setPrecision(user_precision); + } + } + + if (!iop.empty()) { + setPrecisions(network, iop); + } +} + +namespace { + +using supported_layouts_t = std::unordered_map; +using matchLayoutToDims_t = std::unordered_map; + +InferenceEngine::Layout getLayout(std::string value, + const supported_layouts_t& supported_layouts) { + std::transform(value.begin(), value.end(), value.begin(), ::toupper); + + const auto layout = supported_layouts.find(value); + if (layout == supported_layouts.end()) { + throw std::logic_error("\"" + value + "\"" + " is not a valid layout"); + } + + return layout->second; +} + +InferenceEngine::Layout getLayout(const std::string& value) { + static const supported_layouts_t supported_layouts = { + { "NCDHW", InferenceEngine::Layout::NCDHW }, + { "NDHWC", InferenceEngine::Layout::NDHWC }, + { "NCHW", InferenceEngine::Layout::NCHW }, + { "NHWC", InferenceEngine::Layout::NHWC }, + { "CHW", InferenceEngine::Layout::CHW }, + { "NC", InferenceEngine::Layout::NC }, + { "C", InferenceEngine::Layout::C }, + }; + + return getLayout(value, supported_layouts); +} + +bool isMatchLayoutToDims(InferenceEngine::Layout layout, size_t dimension) { + static const matchLayoutToDims_t matchLayoutToDims = { + {static_cast(InferenceEngine::Layout::NCDHW), 5 }, + {static_cast(InferenceEngine::Layout::NDHWC), 5 }, + {static_cast(InferenceEngine::Layout::NCHW), 4 }, + {static_cast(InferenceEngine::Layout::NHWC), 4 }, + {static_cast(InferenceEngine::Layout::CHW), 3 }, + {static_cast(InferenceEngine::Layout::NC), 2 }, + {static_cast(InferenceEngine::Layout::C), 1 } + }; + + const auto dims = matchLayoutToDims.find(static_cast(layout)); + if (dims == matchLayoutToDims.end()) { + throw std::logic_error("Layout is not valid."); + } + + return dimension == dims->second; +} + +void setLayouts(const InferenceEngine::CNNNetwork& network, const std::string iol) { + const auto user_layouts_map = parseArgMap(iol); + + auto inputs = network.getInputsInfo(); + auto outputs = network.getOutputsInfo(); + + for (auto&& item : user_layouts_map) { + const auto& layer_name = item.first; + const auto& user_layout = getLayout(item.second); + + const auto input = inputs.find(layer_name); + const auto output = outputs.find(layer_name); + + if (input != inputs.end()) { + if (!isMatchLayoutToDims(user_layout, input->second->getTensorDesc().getDims().size())) { + throw std::logic_error(item.second + " layout is not applicable to " + layer_name); + } + + input->second->setLayout(user_layout); + } else if (output != outputs.end()) { + if (!isMatchLayoutToDims(user_layout, output->second->getTensorDesc().getDims().size())) { + throw std::logic_error(item.second + " layout is not applicable to " + layer_name); + } + + output->second->setLayout(user_layout); + } else { + throw std::logic_error(layer_name + " is not an input neither output"); + } + } +} + +} // namespace + +void processLayout(InferenceEngine::CNNNetwork& network, const std::string& il, const std::string& ol, const std::string& iol) { + if (!il.empty()) { + const auto layout = getLayout(il); + for (auto&& layer : network.getInputsInfo()) { + if (isMatchLayoutToDims(layout, layer.second->getTensorDesc().getDims().size())) { + layer.second->setLayout(layout); + } + } + } + + if (!ol.empty()) { + const auto layout = getLayout(ol); + for (auto&& layer : network.getOutputsInfo()) { + if (isMatchLayoutToDims(layout, layer.second->getTensorDesc().getDims().size())) { + layer.second->setLayout(layout); + } + } + } + + if (!iol.empty()) { + setLayouts(network, iol); + } +} + +void printInputAndOutputsInfo(const InferenceEngine::CNNNetwork& network) { + std::cout << "Network inputs:" << std::endl; + for (auto&& layer : network.getInputsInfo()) { + std::cout << " " << layer.first << " : " << layer.second->getPrecision() << " / " << layer.second->getLayout() << std::endl; + } + std::cout << "Network outputs:" << std::endl; + for (auto&& layer : network.getOutputsInfo()) { + std::cout << " " << layer.first << " : " << layer.second->getPrecision() << " / " << layer.second->getLayout() << std::endl; + } +} diff --git a/inference-engine/samples/common/utils/src/common.cpp b/inference-engine/samples/common/utils/src/common.cpp new file mode 100644 index 00000000000..e434c53a460 --- /dev/null +++ b/inference-engine/samples/common/utils/src/common.cpp @@ -0,0 +1,24 @@ +// Copyright (C) Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "samples/common.hpp" + +std::map parseConfig(const std::string &configName, char comment) { + std::map config = {}; + + std::ifstream file(configName); + if (!file.is_open()) { + return config; + } + + std::string key, value; + while (file >> key >> value) { + if (key.empty() || key[0] == comment) { + continue; + } + config[key] = value; + } + + return config; +} diff --git a/inference-engine/samples/hello_classification/CMakeLists.txt b/inference-engine/samples/hello_classification/CMakeLists.txt index 303f54bb8b1..a7a3c690972 100644 --- a/inference-engine/samples/hello_classification/CMakeLists.txt +++ b/inference-engine/samples/hello_classification/CMakeLists.txt @@ -4,4 +4,5 @@ ie_add_sample(NAME hello_classification SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp" + DEPENDENCIES ie_samples_utils OPENCV_DEPENDENCIES imgcodecs) diff --git a/inference-engine/samples/hello_nv12_input_classification/CMakeLists.txt b/inference-engine/samples/hello_nv12_input_classification/CMakeLists.txt index 287797ae420..14ebe770759 100644 --- a/inference-engine/samples/hello_nv12_input_classification/CMakeLists.txt +++ b/inference-engine/samples/hello_nv12_input_classification/CMakeLists.txt @@ -3,4 +3,5 @@ # ie_add_sample(NAME hello_nv12_input_classification - SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp") + SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp" + DEPENDENCIES ie_samples_utils) diff --git a/inference-engine/samples/hello_nv12_input_classification/main.cpp b/inference-engine/samples/hello_nv12_input_classification/main.cpp index 5276d5618af..8dc5e08005f 100644 --- a/inference-engine/samples/hello_nv12_input_classification/main.cpp +++ b/inference-engine/samples/hello_nv12_input_classification/main.cpp @@ -18,7 +18,7 @@ #include #ifdef _WIN32 -#include +#include #else #include #endif diff --git a/inference-engine/samples/hello_query_device/CMakeLists.txt b/inference-engine/samples/hello_query_device/CMakeLists.txt index eafbd30b082..2b11cce1f76 100644 --- a/inference-engine/samples/hello_query_device/CMakeLists.txt +++ b/inference-engine/samples/hello_query_device/CMakeLists.txt @@ -3,4 +3,5 @@ # ie_add_sample(NAME hello_query_device - SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp") + SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp" + DEPENDENCIES ie_samples_utils) diff --git a/inference-engine/samples/hello_reshape_ssd/CMakeLists.txt b/inference-engine/samples/hello_reshape_ssd/CMakeLists.txt index f87718c7d5a..c67b7ae5008 100644 --- a/inference-engine/samples/hello_reshape_ssd/CMakeLists.txt +++ b/inference-engine/samples/hello_reshape_ssd/CMakeLists.txt @@ -15,6 +15,7 @@ ie_add_sample(NAME hello_reshape_ssd SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp" HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/reshape_ssd_extension.hpp" + DEPENDENCIES ie_samples_utils OPENCV_DEPENDENCIES imgcodecs) find_package(ngraph REQUIRED) diff --git a/inference-engine/samples/ngraph_function_creation_sample/CMakeLists.txt b/inference-engine/samples/ngraph_function_creation_sample/CMakeLists.txt index 3f63e9d1848..fa187cc42bd 100644 --- a/inference-engine/samples/ngraph_function_creation_sample/CMakeLists.txt +++ b/inference-engine/samples/ngraph_function_creation_sample/CMakeLists.txt @@ -10,7 +10,7 @@ file (GLOB MAIN_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.h) ie_add_sample(NAME ngraph_function_creation_sample SOURCES ${MAIN_SRC} HEADERS ${MAIN_HEADERS} - DEPENDENCIES format_reader) + DEPENDENCIES format_reader ie_samples_utils) find_package(ngraph REQUIRED) target_link_libraries(${TARGET_NAME} PRIVATE ${NGRAPH_LIBRARIES}) diff --git a/inference-engine/samples/object_detection_sample_ssd/CMakeLists.txt b/inference-engine/samples/object_detection_sample_ssd/CMakeLists.txt index 5eec67b4aba..ba387ed9c5b 100644 --- a/inference-engine/samples/object_detection_sample_ssd/CMakeLists.txt +++ b/inference-engine/samples/object_detection_sample_ssd/CMakeLists.txt @@ -5,7 +5,7 @@ ie_add_sample(NAME object_detection_sample_ssd SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp" HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/object_detection_sample_ssd.h" - DEPENDENCIES format_reader) + DEPENDENCIES format_reader ie_samples_utils) find_package(ngraph REQUIRED) target_link_libraries(object_detection_sample_ssd PRIVATE ${NGRAPH_LIBRARIES}) diff --git a/inference-engine/samples/object_detection_sample_ssd/main.cpp b/inference-engine/samples/object_detection_sample_ssd/main.cpp index 233caa7f881..d4d13cb3e12 100644 --- a/inference-engine/samples/object_detection_sample_ssd/main.cpp +++ b/inference-engine/samples/object_detection_sample_ssd/main.cpp @@ -18,7 +18,6 @@ #include #include -#include #include #include "object_detection_sample_ssd.h" diff --git a/inference-engine/samples/speech_sample/CMakeLists.txt b/inference-engine/samples/speech_sample/CMakeLists.txt index 400d6286065..e7671f43f20 100644 --- a/inference-engine/samples/speech_sample/CMakeLists.txt +++ b/inference-engine/samples/speech_sample/CMakeLists.txt @@ -4,4 +4,5 @@ ie_add_sample(NAME speech_sample SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp" - HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/speech_sample.hpp") + HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/speech_sample.hpp" + DEPENDENCIES ie_samples_utils) diff --git a/inference-engine/samples/style_transfer_sample/CMakeLists.txt b/inference-engine/samples/style_transfer_sample/CMakeLists.txt index d73e8f9e35d..ef42a2dea95 100644 --- a/inference-engine/samples/style_transfer_sample/CMakeLists.txt +++ b/inference-engine/samples/style_transfer_sample/CMakeLists.txt @@ -5,4 +5,4 @@ ie_add_sample(NAME style_transfer_sample SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp" HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/style_transfer_sample.h" - DEPENDENCIES format_reader) + DEPENDENCIES format_reader ie_samples_utils) diff --git a/inference-engine/tests_deprecated/helpers/CMakeLists.txt b/inference-engine/tests_deprecated/helpers/CMakeLists.txt index 140c2d1a586..926c20676b0 100644 --- a/inference-engine/tests_deprecated/helpers/CMakeLists.txt +++ b/inference-engine/tests_deprecated/helpers/CMakeLists.txt @@ -29,7 +29,7 @@ function(add_helpers target_name) # TODO: eliminate dependency on samples target_include_directories(${target_name} PUBLIC - "${IE_MAIN_SOURCE_DIR}/samples/common/os/windows") + "${IE_MAIN_SOURCE_DIR}/samples/common/utils/include/samples/os/windows") set_property(TARGET ${target_name} PROPERTY COMPILE_PDB_NAME ${target_name}) diff --git a/inference-engine/tools/compile_tool/CMakeLists.txt b/inference-engine/tools/compile_tool/CMakeLists.txt index 58614d3ced5..7af051119f8 100644 --- a/inference-engine/tools/compile_tool/CMakeLists.txt +++ b/inference-engine/tools/compile_tool/CMakeLists.txt @@ -21,7 +21,6 @@ file(GLOB SRCS add_executable(${TARGET_NAME} ${SRCS}) target_include_directories(${TARGET_NAME} SYSTEM PRIVATE - ${IE_MAIN_SOURCE_DIR}/samples/common ${IE_MAIN_SOURCE_DIR}/include ${IE_MAIN_SOURCE_DIR}/src/vpu/graph_transformer/include ${IE_MAIN_SOURCE_DIR}/src/vpu/common/include @@ -37,6 +36,7 @@ endif() target_link_libraries(${TARGET_NAME} PRIVATE inference_engine gflags + ie_samples_utils ) set_target_properties(${TARGET_NAME} PROPERTIES diff --git a/inference-engine/tools/compile_tool/main.cpp b/inference-engine/tools/compile_tool/main.cpp index fbd98f8cd14..192c1a9f538 100644 --- a/inference-engine/tools/compile_tool/main.cpp +++ b/inference-engine/tools/compile_tool/main.cpp @@ -18,7 +18,9 @@ #include #include #include + #include "samples/common.hpp" +#include "samples/args_helper.hpp" static constexpr char help_message[] = "Optional. Print the usage message."; @@ -204,106 +206,6 @@ IE_SUPPRESS_DEPRECATED_END return config; } -static std::map parseArgMap(std::string argMap) { - argMap.erase(std::remove_if(argMap.begin(), argMap.end(), ::isspace), argMap.end()); - - std::vector pairs; - vpu::splitStringList(argMap, pairs, ','); - - std::map parsedMap; - for (auto&& pair : pairs) { - std::vector keyValue; - vpu::splitStringList(pair, keyValue, ':'); - if (keyValue.size() != 2) { - throw std::invalid_argument("Invalid key/value pair " + pair + ". Expected :"); - } - - parsedMap[keyValue[0]] = keyValue[1]; - } - - return parsedMap; -} - -using supported_precisions_t = std::unordered_map; -using supported_layouts_t = std::unordered_map; -using matchLayoutToDims_t = std::unordered_map; - -static InferenceEngine::Layout getLayout(std::string value, - const supported_layouts_t& supported_layouts) { - std::transform(value.begin(), value.end(), value.begin(), ::toupper); - - const auto layout = supported_layouts.find(value); - if (layout == supported_layouts.end()) { - throw std::logic_error("\"" + value + "\"" + " is not a valid layout"); - } - - return layout->second; -} - -static InferenceEngine::Layout getLayout(const std::string& value) { - static const supported_layouts_t supported_layouts = { - { "NCDHW", InferenceEngine::Layout::NCDHW }, - { "NDHWC", InferenceEngine::Layout::NDHWC }, - { "NCHW", InferenceEngine::Layout::NCHW }, - { "NHWC", InferenceEngine::Layout::NHWC }, - { "CHW", InferenceEngine::Layout::CHW }, - { "NC", InferenceEngine::Layout::NC }, - { "C", InferenceEngine::Layout::C }, - }; - - return getLayout(value, supported_layouts); -} - -static bool isMatchLayoutToDims(InferenceEngine::Layout layout, size_t dimension) { - static const matchLayoutToDims_t matchLayoutToDims = { - {static_cast(InferenceEngine::Layout::NCDHW), 5 }, - {static_cast(InferenceEngine::Layout::NDHWC), 5 }, - {static_cast(InferenceEngine::Layout::NCHW), 4 }, - {static_cast(InferenceEngine::Layout::NHWC), 4 }, - {static_cast(InferenceEngine::Layout::CHW), 3 }, - {static_cast(InferenceEngine::Layout::NC), 2 }, - {static_cast(InferenceEngine::Layout::C), 1 } - }; - - const auto dims = matchLayoutToDims.find(static_cast(layout)); - if (dims == matchLayoutToDims.end()) { - throw std::logic_error("Layout is not valid."); - } - - return dimension == dims->second; -} - -static InferenceEngine::Precision getPrecision(std::string value, - const supported_precisions_t& supported_precisions) { - std::transform(value.begin(), value.end(), value.begin(), ::toupper); - - const auto precision = supported_precisions.find(value); - if (precision == supported_precisions.end()) { - throw std::logic_error("\"" + value + "\"" + " is not a valid precision"); - } - - return precision->second; -} - -static InferenceEngine::Precision getPrecision(const std::string& value) { - static const supported_precisions_t supported_precisions = { - { "FP32", InferenceEngine::Precision::FP32 }, - { "FP16", InferenceEngine::Precision::FP16 }, - { "BF16", InferenceEngine::Precision::BF16 }, - { "U64", InferenceEngine::Precision::U64 }, - { "I64", InferenceEngine::Precision::I64 }, - { "U32", InferenceEngine::Precision::U32 }, - { "I32", InferenceEngine::Precision::I32 }, - { "U16", InferenceEngine::Precision::U16 }, - { "I16", InferenceEngine::Precision::I16 }, - { "U8", InferenceEngine::Precision::U8 }, - { "I8", InferenceEngine::Precision::I8 }, - { "BOOL", InferenceEngine::Precision::BOOL }, - }; - - return getPrecision(value, supported_precisions); -} - bool isFP16(InferenceEngine::Precision precision) { return precision == InferenceEngine::Precision::FP16; } @@ -316,29 +218,6 @@ bool isFloat(InferenceEngine::Precision precision) { return isFP16(precision) || isFP32(precision); } -static void setPrecisions(const InferenceEngine::CNNNetwork& network) { - const auto user_precisions_map = parseArgMap(FLAGS_iop); - - auto inputs = network.getInputsInfo(); - auto outputs = network.getOutputsInfo(); - - for (auto&& item : user_precisions_map) { - const auto& layer_name = item.first; - const auto& user_precision = item.second; - - const auto input = inputs.find(layer_name); - const auto output = outputs.find(layer_name); - - if (input != inputs.end()) { - input->second->setPrecision(getPrecision(user_precision)); - } else if (output != outputs.end()) { - output->second->setPrecision(getPrecision(user_precision)); - } else { - throw std::logic_error(layer_name + " is not an input neither output"); - } - } -} - static void setDefaultIO(InferenceEngine::CNNNetwork& network) { const bool isMYRIAD = FLAGS_d.find("MYRIAD") != std::string::npos; const bool isVPUX = FLAGS_d.find("VPUX") != std::string::npos; @@ -373,81 +252,6 @@ static void setDefaultIO(InferenceEngine::CNNNetwork& network) { } } -static void processPrecisions(InferenceEngine::CNNNetwork& network) { - if (!FLAGS_ip.empty()) { - const auto user_precision = getPrecision(FLAGS_ip); - for (auto&& layer : network.getInputsInfo()) { - layer.second->setPrecision(user_precision); - } - } - - if (!FLAGS_op.empty()) { - auto user_precision = getPrecision(FLAGS_op); - for (auto&& layer : network.getOutputsInfo()) { - layer.second->setPrecision(user_precision); - } - } - - if (!FLAGS_iop.empty()) { - setPrecisions(network); - } -} - -static void setLayouts(const InferenceEngine::CNNNetwork& network) { - const auto user_layouts_map = parseArgMap(FLAGS_iol); - - auto inputs = network.getInputsInfo(); - auto outputs = network.getOutputsInfo(); - - for (auto&& item : user_layouts_map) { - const auto& layer_name = item.first; - const auto& user_layout = getLayout(item.second); - - const auto input = inputs.find(layer_name); - const auto output = outputs.find(layer_name); - - if (input != inputs.end()) { - if (!isMatchLayoutToDims(user_layout, input->second->getTensorDesc().getDims().size())) { - throw std::logic_error(item.second + " layout is not applicable to " + layer_name); - } - - input->second->setLayout(user_layout); - } else if (output != outputs.end()) { - if (!isMatchLayoutToDims(user_layout, output->second->getTensorDesc().getDims().size())) { - throw std::logic_error(item.second + " layout is not applicable to " + layer_name); - } - - output->second->setLayout(user_layout); - } else { - throw std::logic_error(layer_name + " is not an input neither output"); - } - } -} - -static void processLayout(InferenceEngine::CNNNetwork& network) { - if (!FLAGS_il.empty()) { - const auto layout = getLayout(FLAGS_il); - for (auto&& layer : network.getInputsInfo()) { - if (isMatchLayoutToDims(layout, layer.second->getTensorDesc().getDims().size())) { - layer.second->setLayout(layout); - } - } - } - - if (!FLAGS_ol.empty()) { - const auto layout = getLayout(FLAGS_ol); - for (auto&& layer : network.getOutputsInfo()) { - if (isMatchLayoutToDims(layout, layer.second->getTensorDesc().getDims().size())) { - layer.second->setLayout(layout); - } - } - } - - if (!FLAGS_iol.empty()) { - setLayouts(network); - } -} - std::string getFileNameFromPath(const std::string& path, #if defined(_WIN32) const std::string& sep = "\\") { @@ -480,18 +284,10 @@ int main(int argc, char* argv[]) { auto network = ie.ReadNetwork(FLAGS_m); setDefaultIO(network); - processPrecisions(network); - processLayout(network); + processPrecision(network, FLAGS_ip, FLAGS_op, FLAGS_iop); + processLayout(network, FLAGS_il, FLAGS_ol, FLAGS_iol); - std::cout << "Network inputs:" << std::endl; - for (auto&& layer : network.getInputsInfo()) { - std::cout << " " << layer.first << " : " << layer.second->getPrecision() << " / " << layer.second->getLayout() << std::endl; - } - std::cout << "Network outputs:" << std::endl; - for (auto&& layer : network.getOutputsInfo()) { - std::cout << " " << layer.first << " : " << layer.second->getPrecision() << " / " << layer.second->getLayout() << std::endl; - } - std::cout << std::endl; + printInputAndOutputsInfo(network); auto timeBeforeLoadNetwork = std::chrono::steady_clock::now(); auto executableNetwork = ie.LoadNetwork(network, FLAGS_d, configure()); diff --git a/inference-engine/tools/vpu/common/vpu_tools_common.cpp b/inference-engine/tools/vpu/common/vpu_tools_common.cpp index 0fda2b33518..8024d61c221 100644 --- a/inference-engine/tools/vpu/common/vpu_tools_common.cpp +++ b/inference-engine/tools/vpu/common/vpu_tools_common.cpp @@ -8,7 +8,6 @@ #endif #include -#include #include #include @@ -20,7 +19,9 @@ #include "vpu_tools_common.hpp" #include -#include "samples/common.hpp" + +#include +#include #include "precision_utils.h" @@ -58,25 +59,6 @@ void setPrecisions(const InferenceEngine::CNNNetwork &network) { } } -std::map parseConfig(const std::string &configName, char comment) { - std::map config = {}; - - std::ifstream file(configName); - if (!file.is_open()) { - return config; - } - - std::string key, value; - while (file >> key >> value) { - if (key.empty() || key[0] == comment) { - continue; - } - config[key] = value; - } - - return config; -} - BitMap::BitMap(const std::string &filename) { BmpHeader header; BmpInfoHeader infoHeader; diff --git a/inference-engine/tools/vpu/common/vpu_tools_common.hpp b/inference-engine/tools/vpu/common/vpu_tools_common.hpp index e5f7b6911c2..65570eb2ee2 100644 --- a/inference-engine/tools/vpu/common/vpu_tools_common.hpp +++ b/inference-engine/tools/vpu/common/vpu_tools_common.hpp @@ -20,8 +20,6 @@ bool isFloat(InferenceEngine::Precision precision); /* Set FP32 to FP16, all others without changes */ void setPrecisions(const InferenceEngine::CNNNetwork &network); -std::map parseConfig(const std::string &configName, char comment = '#'); - class BitMap { private: typedef struct { diff --git a/inference-engine/tools/vpu/vpu_compile/CMakeLists.txt b/inference-engine/tools/vpu/vpu_compile/CMakeLists.txt index b8861dad9a8..0445d5a17dc 100644 --- a/inference-engine/tools/vpu/vpu_compile/CMakeLists.txt +++ b/inference-engine/tools/vpu/vpu_compile/CMakeLists.txt @@ -28,13 +28,14 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") endif() target_include_directories(${TARGET_NAME} SYSTEM PRIVATE - ${IE_MAIN_SOURCE_DIR}/samples/common ${IE_MAIN_SOURCE_DIR}/tools/vpu/common + ${IE_MAIN_SOURCE_DIR}/samples/common ) target_link_libraries(${TARGET_NAME} PRIVATE inference_engine vpu_graph_transformer gflags + ie_samples_utils ) add_dependencies(${TARGET_NAME} myriadPlugin) @@ -50,4 +51,4 @@ add_cpplint_target(${TARGET_NAME}_cpplint FOR_TARGETS ${TARGET_NAME}) install(TARGETS ${TARGET_NAME} RUNTIME DESTINATION ${IE_CPACK_RUNTIME_PATH} - COMPONENT myriad) \ No newline at end of file + COMPONENT myriad) diff --git a/inference-engine/tools/vpu/vpu_perfcheck/CMakeLists.txt b/inference-engine/tools/vpu/vpu_perfcheck/CMakeLists.txt index c098e04c396..9fe463393dd 100644 --- a/inference-engine/tools/vpu/vpu_perfcheck/CMakeLists.txt +++ b/inference-engine/tools/vpu/vpu_perfcheck/CMakeLists.txt @@ -33,13 +33,13 @@ function(add_perfcheck_target TARGET_NAME PLUGIN_NAME) target_include_directories(${TARGET_NAME} SYSTEM PRIVATE "${IE_MAIN_SOURCE_DIR}/src/vpu/graph_transformer/include" - "${IE_MAIN_SOURCE_DIR}/samples/common/samples" "${IE_MAIN_SOURCE_DIR}/samples/common/format_reader") target_link_libraries(${TARGET_NAME} PRIVATE inference_engine format_reader - Threads::Threads) + Threads::Threads + ie_samples_utils) add_dependencies(${TARGET_NAME} ${PLUGIN_NAME} ${ARGN}) diff --git a/inference-engine/tools/vpu/vpu_perfcheck/main.cpp b/inference-engine/tools/vpu/vpu_perfcheck/main.cpp index 97261e8e794..ee7cb412692 100644 --- a/inference-engine/tools/vpu/vpu_perfcheck/main.cpp +++ b/inference-engine/tools/vpu/vpu_perfcheck/main.cpp @@ -29,10 +29,11 @@ #include #include #include -#include + +#include #include -#include +#include #include static char* m_exename = nullptr;