OV2.0 c++ configuration API (#9829)

* New configuration API

* Review fix

* review coments

* fixed device name map

* fixed header

* code stile

* fixed optimization capabilities

* flatten properties

* dox fix

* doc

* merge conflicts

* fixed merge conflicts

* Fixed subobject linkage warning

* foramt fix
This commit is contained in:
Anton Pankratov
2022-01-21 18:44:41 +03:00
committed by GitHub
parent cf84f43b78
commit 50da8c4aed
154 changed files with 2038 additions and 873 deletions

View File

@@ -647,7 +647,7 @@ std::vector<benchmark_app::InputsInfo> get_inputs_info(const std::string& shape_
}
#ifdef USE_OPENCV
void dump_config(const std::string& filename, const std::map<std::string, std::map<std::string, std::string>>& config) {
void dump_config(const std::string& filename, const std::map<std::string, ov::AnyMap>& config) {
slog::warn << "YAML and XML formats for config file won't be supported soon." << slog::endl;
auto plugin_to_opencv_format = [](const std::string& str) -> std::string {
if (str.find("_") != std::string::npos) {
@@ -668,14 +668,18 @@ void dump_config(const std::string& filename, const std::map<std::string, std::m
throw std::runtime_error("Error: Can't open config file : " + filename);
for (auto device_it = config.begin(); device_it != config.end(); ++device_it) {
fs << plugin_to_opencv_format(device_it->first) << "{:";
for (auto param_it = device_it->second.begin(); param_it != device_it->second.end(); ++param_it)
fs << param_it->first << param_it->second;
std::stringstream strm;
for (auto param_it = device_it->second.begin(); param_it != device_it->second.end(); ++param_it) {
strm << param_it->first;
param_it->second.print(strm);
}
fs << strm.str();
fs << "}";
}
fs.release();
}
void load_config(const std::string& filename, std::map<std::string, std::map<std::string, std::string>>& config) {
void load_config(const std::string& filename, std::map<std::string, ov::AnyMap>& config) {
slog::warn << "YAML and XML formats for config file won't be supported soon." << slog::endl;
auto opencv_to_plugin_format = [](const std::string& str) -> std::string {
std::string new_str(str);
@@ -701,12 +705,14 @@ void load_config(const std::string& filename, std::map<std::string, std::map<std
}
}
#else
void dump_config(const std::string& filename, const std::map<std::string, std::map<std::string, std::string>>& config) {
void dump_config(const std::string& filename, const std::map<std::string, ov::AnyMap>& config) {
nlohmann::json jsonConfig;
for (const auto& item : config) {
std::string deviceName = item.first;
for (const auto& option : item.second) {
jsonConfig[deviceName][option.first] = option.second;
std::stringstream strm;
option.second.print(strm);
jsonConfig[deviceName][option.first] = strm.str();
}
}
@@ -718,7 +724,7 @@ void dump_config(const std::string& filename, const std::map<std::string, std::m
ofs << jsonConfig;
}
void load_config(const std::string& filename, std::map<std::string, std::map<std::string, std::string>>& config) {
void load_config(const std::string& filename, std::map<std::string, ov::AnyMap>& config) {
std::ifstream ifs(filename);
if (!ifs.is_open()) {
throw std::runtime_error("Can't load config file \"" + filename + "\".");