This commit is contained in:
myshevts
2021-11-25 10:35:20 +03:00
parent 65273cc0dc
commit a7e28580e6

View File

@@ -554,23 +554,25 @@ public:
const auto& batch_mode = config_with_batch.find(CONFIG_KEY(ALLOW_AUTO_BATCHING));
if (batch_mode != config_with_batch.end() && batch_mode->second == CONFIG_VALUE(YES)) {
auto deviceNameWithoutBatch = !deviceNameWithBatchSize.empty()
? DeviceIDParser::getBatchDevice(deviceNameWithBatchSize)
: deviceNameOrig;
? DeviceIDParser::getBatchDevice(deviceNameWithBatchSize)
: deviceNameOrig;
unsigned int requests = 0;
unsigned int optimalBatchSize = 0;
if (deviceNameWithBatchSize.empty()) { // batch size is not set explicitly via device name e.g. BATCH:GPU(4)
// query the optimal batch size
if (deviceNameWithBatchSize.empty()) {
// batch size is not set explicitly via device name e.g. BATCH:GPU(4)
// let's query the optimal batch size
try {
std::map<std::string, ie::Parameter> options;
options["MODEL_ADDRESS"] = &network;
optimalBatchSize = GetCPPPluginByName(DeviceIDParser(deviceNameWithoutBatch).getDeviceName())
.get_metric(METRIC_KEY(OPTIMAL_BATCH), options)
.as<unsigned int>();
auto res = GetConfig(deviceNameWithoutBatch, CONFIG_KEY(PERFORMANCE_HINT_NUM_REQUESTS)).as<std::string>();
.get_metric(METRIC_KEY(OPTIMAL_BATCH), options)
.as<unsigned int>();
auto res =
GetConfig(deviceNameWithoutBatch, CONFIG_KEY(PERFORMANCE_HINT_NUM_REQUESTS)).as<std::string>();
requests = PerfHintsConfig::CheckPerformanceHintRequestValue(res);
const auto &reqs = config.find(CONFIG_KEY(PERFORMANCE_HINT_NUM_REQUESTS));
const auto& reqs = config.find(CONFIG_KEY(PERFORMANCE_HINT_NUM_REQUESTS));
if (reqs != config.end())
requests = (unsigned int) PerfHintsConfig::CheckPerformanceHintRequestValue(reqs->second);
requests = (unsigned int)PerfHintsConfig::CheckPerformanceHintRequestValue(reqs->second);
if (requests) {
std::cout << "!!!!!!!!!!!!!!!Detected reqs_limitation: " << requests << std::endl;
optimalBatchSize = std::max(1u, std::min(requests, optimalBatchSize));
@@ -602,13 +604,13 @@ public:
}
if (optimalBatchSize > 1 || !deviceNameWithBatchSize.empty()) {
auto batchConfig = deviceNameWithBatchSize.empty()
? deviceNameWithoutBatch + "(" + std::to_string(optimalBatchSize) + ")"
: deviceNameWithBatchSize;
? deviceNameWithoutBatch + "(" + std::to_string(optimalBatchSize) + ")"
: deviceNameWithBatchSize;
if (bDetectionOutput) {
deviceName = "HETERO:BATCH," + deviceNameWithoutBatch;
std::cout << "HETERO code path!!!!" << std::endl;
// config_with_batch[CONFIG_KEY(AUTO_BATCH)] = batchConfig;
SetConfigForPlugins({{CONFIG_KEY(AUTO_BATCH), batchConfig}},"BATCH");
SetConfigForPlugins({{CONFIG_KEY(AUTO_BATCH), batchConfig}}, "BATCH");
} else {
deviceName = "BATCH:" + batchConfig;
}