support cache dir in multi/auto/batch (#13507)

* support cache dir in multi/auto

Signed-off-by: fishbell <bell.song@intel.com>

* support cache_dir in bat h

Signed-off-by: fishbell <bell.song@intel.com>

* fix case failure

Signed-off-by: fishbell <bell.song@intel.com>

* clang format

Signed-off-by: fishbell <bell.song@intel.com>

Signed-off-by: fishbell <bell.song@intel.com>
This commit is contained in:
yanlan song
2022-10-19 10:15:03 +08:00
committed by GitHub
parent 226e94aa66
commit 5e2869cd14
4 changed files with 131 additions and 17 deletions

View File

@@ -297,7 +297,8 @@ InferenceEngine::Parameter MultiDeviceInferencePlugin::GetMetric(const std::stri
RW_property(ov::auto_batch_timeout.name()),
RW_property(ov::hint::performance_mode.name()),
RW_property(ov::hint::num_requests.name()),
RW_property(ov::intel_auto::device_bind_buffer.name())
RW_property(ov::intel_auto::device_bind_buffer.name()),
RW_property(ov::cache_dir.name())
};
std::vector<ov::PropertyName> supportedProperties;
supportedProperties.reserve(roProperties.size() + rwProperties.size());
@@ -369,8 +370,10 @@ IExecutableNetworkInternal::Ptr MultiDeviceInferencePlugin::LoadNetworkImpl(cons
loadConfig.UpdateFromMap(config, GetName());
auto fullConfig = loadConfig._keyConfigMap;
// Remove the performance hint if no setting to this property from user.
if (!loadConfig.isSetPerHint)
if (!loadConfig._isSetPerHint)
fullConfig.erase(PluginConfigParams::KEY_PERFORMANCE_HINT);
if (!loadConfig._isSetCacheDir)
fullConfig.erase(CONFIG_KEY(CACHE_DIR));
// collect the settings that are applicable to the devices we are loading the network to
std::unordered_map<std::string, InferenceEngine::Parameter> multiNetworkConfig;
std::vector<DeviceInformation> metaDevices;
@@ -380,16 +383,15 @@ IExecutableNetworkInternal::Ptr MultiDeviceInferencePlugin::LoadNetworkImpl(cons
auto insertPropToConfig = [&](std::string property,
std::string& deviceName,
std::map<std::string, std::string>& deviceConfig) {
auto tmpiter =
std::find_if(fullConfig.begin(), fullConfig.end(), [&](const std::pair<std::string, std::string>& config) {
return (config.first == property);
});
if (tmpiter != fullConfig.end()) {
deviceConfig.insert({tmpiter->first, tmpiter->second});
LOG_INFO_TAG("device:%s, config:%s=%s",
deviceName.c_str(),
tmpiter->first.c_str(),
tmpiter->second.c_str());
if (deviceConfig.find(property) == deviceConfig.end()) {
auto tmpiter = fullConfig.find(property);
if (tmpiter != fullConfig.end()) {
deviceConfig.insert({tmpiter->first, tmpiter->second});
LOG_INFO_TAG("device:%s, config:%s=%s",
deviceName.c_str(),
tmpiter->first.c_str(),
tmpiter->second.c_str());
}
}
};
@@ -455,6 +457,7 @@ IExecutableNetworkInternal::Ptr MultiDeviceInferencePlugin::LoadNetworkImpl(cons
}
insertPropToConfig(CONFIG_KEY(ALLOW_AUTO_BATCHING), iter->deviceName, deviceConfig);
insertPropToConfig(CONFIG_KEY(AUTO_BATCH_TIMEOUT), iter->deviceName, deviceConfig);
insertPropToConfig(CONFIG_KEY(CACHE_DIR), iter->deviceName, deviceConfig);
iter->config = deviceConfig;
strDevices += iter->deviceName;
strDevices += ((iter + 1) == supportDevices.end()) ? "" : ",";
@@ -505,6 +508,7 @@ IExecutableNetworkInternal::Ptr MultiDeviceInferencePlugin::LoadNetworkImpl(cons
p.config.insert({tmpiter->first, tmpiter->second});
}
insertPropToConfig(CONFIG_KEY(AUTO_BATCH_TIMEOUT), p.deviceName, p.config);
insertPropToConfig(CONFIG_KEY(CACHE_DIR), p.deviceName, p.config);
const auto& deviceName = p.deviceName;
const auto& deviceConfig = p.config;
SoExecutableNetworkInternal exec_net;

View File

@@ -98,12 +98,15 @@ struct PluginConfig {
} else if (std::find(perf_hints_configs.begin(), perf_hints_configs.end(), kvp.first) != perf_hints_configs.end()) {
_perfHintsConfig.SetConfig(kvp.first, kvp.second);
if (kvp.first == ov::hint::performance_mode.name())
isSetPerHint = true;
_isSetPerHint = true;
} else if (_availableDevices.end() !=
std::find(_availableDevices.begin(), _availableDevices.end(), kvp.first)) {
_passThroughConfig.emplace(kvp.first, kvp.second);
} else if (kvp.first.find("AUTO_") == 0) {
_passThroughConfig.emplace(kvp.first, kvp.second);
} else if (kvp.first == ov::cache_dir.name()) {
_cacheDir = kvp.second;
_isSetCacheDir = true;
} else {
if (pluginName.find("AUTO") != std::string::npos)
IE_THROW(NotFound) << "Unsupported property " << kvp.first;
@@ -189,11 +192,14 @@ struct PluginConfig {
_keyConfigMap[ov::log::level.name()] = _logLevel;
_keyConfigMap[ov::cache_dir.name()] = _cacheDir;
// for 2nd properties or independent configs from multi
for (auto && kvp : _passThroughConfig) {
_keyConfigMap[kvp.first] = kvp.second;
}
}
std::string _cacheDir{};
bool _useProfiling;
bool _exclusiveAsyncRequests;
bool _disableAutoBatching;
@@ -204,7 +210,8 @@ struct PluginConfig {
std::string _logLevel;
PerfHintsConfig _perfHintsConfig;
// Add this flag to check if user app sets hint with none value that is equal to the default value of hint.
bool isSetPerHint = false;
bool _isSetPerHint = false;
bool _isSetCacheDir = false;
std::map<std::string, std::string> _passThroughConfig;
std::map<std::string, std::string> _keyConfigMap;
const std::set<std::string> _availableDevices = {"AUTO",