[VPU] Add performance hints (#9349)
Added a new key required for benchmark_app
This commit is contained in:
parent
7ec1cc919e
commit
18c20f5766
@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2022 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "vpu/configuration/as_parameter_enabler.hpp"
|
||||
|
||||
namespace vpu {
|
||||
|
||||
namespace details {
|
||||
|
||||
enum class Access;
|
||||
enum class Category;
|
||||
|
||||
} // namespace details
|
||||
|
||||
class PluginConfiguration;
|
||||
|
||||
struct PerformanceHintOption : public AsParameterEnabler {
|
||||
using value_type = std::string;
|
||||
|
||||
static std::string key();
|
||||
static void validate(const std::string&);
|
||||
static void validate(const PluginConfiguration&);
|
||||
static std::string defaultValue();
|
||||
static value_type parse(const std::string&);
|
||||
static details::Access access();
|
||||
static details::Category category();
|
||||
};
|
||||
|
||||
} // namespace vpu
|
@ -0,0 +1,35 @@
|
||||
// Copyright (C) 2022 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
|
||||
#include "vpu/configuration/as_parameter_enabler.hpp"
|
||||
|
||||
namespace vpu {
|
||||
|
||||
namespace details {
|
||||
|
||||
enum class Access;
|
||||
enum class Category;
|
||||
|
||||
} // namespace details
|
||||
|
||||
class PluginConfiguration;
|
||||
|
||||
struct PerformanceHintNumRequestsOption : public AsParameterEnabler {
|
||||
using value_type = int;
|
||||
|
||||
static std::string key();
|
||||
static void validate(const std::string&);
|
||||
static void validate(const PluginConfiguration&);
|
||||
static std::string defaultValue();
|
||||
static value_type parse(const std::string&);
|
||||
static details::Access access();
|
||||
static details::Category category();
|
||||
};
|
||||
|
||||
} // namespace vpu
|
@ -0,0 +1,44 @@
|
||||
// Copyright (C) 2022 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "vpu/private_plugin_config.hpp"
|
||||
#include "vpu/configuration/options/performance_hint.hpp"
|
||||
#include "vpu/utils/containers.hpp"
|
||||
#include "vpu/configuration/plugin_configuration.hpp"
|
||||
#include <ie_plugin_config.hpp>
|
||||
|
||||
namespace vpu {
|
||||
|
||||
void PerformanceHintOption::validate(const std::string& value) {}
|
||||
|
||||
void PerformanceHintOption::validate(const PluginConfiguration& configuration) {
|
||||
validate(configuration[key()]);
|
||||
}
|
||||
|
||||
std::string PerformanceHintOption::key() {
|
||||
return CONFIG_KEY(PERFORMANCE_HINT);
|
||||
}
|
||||
|
||||
details::Access PerformanceHintOption::access() {
|
||||
return details::Access::Public;
|
||||
}
|
||||
|
||||
details::Category PerformanceHintOption::category() {
|
||||
return details::Category::CompileTime;
|
||||
}
|
||||
|
||||
std::string PerformanceHintOption::defaultValue() {
|
||||
return "";
|
||||
}
|
||||
|
||||
PerformanceHintOption::value_type PerformanceHintOption::parse(const std::string& value) {
|
||||
if (value == CONFIG_VALUE(LATENCY) || value == CONFIG_VALUE(THROUGHPUT) || value == "") {
|
||||
return value;
|
||||
} else {
|
||||
VPU_THROW_EXCEPTION << "Wrong value for property key " << CONFIG_KEY(PERFORMANCE_HINT) << ". Expected only "
|
||||
<< CONFIG_VALUE(LATENCY) << "/" << CONFIG_VALUE(THROUGHPUT);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace vpu
|
@ -0,0 +1,52 @@
|
||||
// Copyright (C) 2022 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "vpu/private_plugin_config.hpp"
|
||||
#include "vpu/configuration/options/performance_hint_num_requests.hpp"
|
||||
#include "vpu/utils/containers.hpp"
|
||||
#include "vpu/configuration/plugin_configuration.hpp"
|
||||
#include "vpu/utils/error.hpp"
|
||||
#include <ie_plugin_config.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace vpu {
|
||||
|
||||
void PerformanceHintNumRequestsOption::validate(const std::string& value) {}
|
||||
|
||||
void PerformanceHintNumRequestsOption::validate(const PluginConfiguration& configuration) {
|
||||
validate(configuration[key()]);
|
||||
}
|
||||
|
||||
std::string PerformanceHintNumRequestsOption::key() {
|
||||
return CONFIG_KEY(PERFORMANCE_HINT_NUM_REQUESTS);
|
||||
}
|
||||
|
||||
details::Access PerformanceHintNumRequestsOption::access() {
|
||||
return details::Access::Public;
|
||||
}
|
||||
|
||||
details::Category PerformanceHintNumRequestsOption::category() {
|
||||
return details::Category::CompileTime;
|
||||
}
|
||||
|
||||
std::string PerformanceHintNumRequestsOption::defaultValue() {
|
||||
return "-1";
|
||||
}
|
||||
|
||||
PerformanceHintNumRequestsOption::value_type PerformanceHintNumRequestsOption::parse(const std::string& value) {
|
||||
try {
|
||||
auto returnValue = std::stoi(value);
|
||||
if (returnValue > 0 || returnValue == -1) {
|
||||
return returnValue;
|
||||
} else {
|
||||
throw std::logic_error("wrong val");
|
||||
}
|
||||
} catch (...) {
|
||||
VPU_THROW_EXCEPTION << "Wrong value of " << value << " for property key "
|
||||
<< CONFIG_VALUE(KEY_PERFORMANCE_HINT_NUM_REQUESTS)
|
||||
<< ". Expected only positive integer numbers";
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace vpu
|
@ -51,6 +51,7 @@
|
||||
#include <vpu/configuration/options/throughput_streams.hpp>
|
||||
#include <vpu/configuration/options/number_of_cmx_slices.hpp>
|
||||
#include <vpu/configuration/options/vpu_scales_option.hpp>
|
||||
#include <vpu/configuration/options/performance_hint.hpp>
|
||||
|
||||
namespace vpu {
|
||||
|
||||
@ -88,8 +89,13 @@ void CompileEnv::init(const PluginConfiguration& config, const Logger::Ptr& log)
|
||||
g_compileEnv->profile.setLogger(log);
|
||||
#endif
|
||||
|
||||
const auto numExecutors = config.get<ThroughputStreamsOption>().hasValue()
|
||||
? config.get<ThroughputStreamsOption>().get() : DefaultAllocation::numStreams(config);
|
||||
int numExecutors = 0;
|
||||
if (config.get<ThroughputStreamsOption>().hasValue()) {
|
||||
numExecutors = config.get<ThroughputStreamsOption>().get();
|
||||
} else if (!config.get<PerformanceHintOption>().empty()) {
|
||||
numExecutors = config.get<PerformanceHintOption>() == CONFIG_VALUE(LATENCY) ? 1 : 2;
|
||||
}
|
||||
numExecutors = numExecutors ? numExecutors : DefaultAllocation::numStreams(config);
|
||||
VPU_THROW_UNLESS(numExecutors >= 1 && numExecutors <= DeviceResources::numStreams(),
|
||||
R"(Value of configuration option ("{}") must be in the range [{}, {}], actual is "{}")",
|
||||
ThroughputStreamsOption::key(), 1, DeviceResources::numStreams(), numExecutors);
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include <vpu/configuration/options/log_level.hpp>
|
||||
#include <vpu/configuration/options/throughput_streams.hpp>
|
||||
#include <vpu/configuration/options/exclusive_async_requests.hpp>
|
||||
#include <vpu/configuration/options/performance_hint.hpp>
|
||||
#include "vpu/configuration/options/performance_hint_num_requests.hpp"
|
||||
#include <vpu/ngraph/operations/dynamic_shape_resolver.hpp>
|
||||
#include <vpu/ngraph/transformations/dynamic_to_static_shape.hpp>
|
||||
#include <ngraph/opsets/opset3.hpp>
|
||||
@ -59,8 +61,13 @@ ExecutableNetwork::ExecutableNetwork(
|
||||
|
||||
void ExecutableNetwork::openDevice(std::vector<DevicePtr>& devicePool) {
|
||||
_device = _executor->openDevice(devicePool, _config);
|
||||
_actualNumExecutors = _config.get<ThroughputStreamsOption>().hasValue()
|
||||
? _config.get<ThroughputStreamsOption>().get() : DefaultAllocation::numStreams(_config);
|
||||
int executors = 0;
|
||||
if (_config.get<ThroughputStreamsOption>().hasValue()) {
|
||||
executors = _config.get<ThroughputStreamsOption>().get();
|
||||
} else if (!_config.get<PerformanceHintOption>().empty()) {
|
||||
executors = _config.get<PerformanceHintOption>() == CONFIG_VALUE(LATENCY) ? 1 : 2;
|
||||
}
|
||||
_actualNumExecutors = executors ? executors : DefaultAllocation::numStreams(_config);
|
||||
}
|
||||
|
||||
ExecutableNetwork::ExecutableNetwork(
|
||||
@ -229,7 +236,18 @@ InferenceEngine::Parameter ExecutableNetwork::GetMetric(const std::string &name)
|
||||
} else if (name == METRIC_KEY(SUPPORTED_CONFIG_KEYS)) {
|
||||
IE_SET_METRIC_RETURN(SUPPORTED_CONFIG_KEYS, std::vector<std::string>());
|
||||
} else if (name == METRIC_KEY(OPTIMAL_NUMBER_OF_INFER_REQUESTS)) {
|
||||
IE_SET_METRIC_RETURN(OPTIMAL_NUMBER_OF_INFER_REQUESTS, static_cast<unsigned int>(2u * _actualNumExecutors));
|
||||
unsigned int optimalNumOfInferRequests = static_cast<unsigned int>(2u * _actualNumExecutors);
|
||||
|
||||
if (!_config.get<PerformanceHintOption>().empty()) {
|
||||
optimalNumOfInferRequests =
|
||||
_config.get<PerformanceHintOption>() == CONFIG_VALUE(THROUGHPUT) ? optimalNumOfInferRequests : 1;
|
||||
}
|
||||
if (_config.get<PerformanceHintNumRequestsOption>() != -1) {
|
||||
optimalNumOfInferRequests =
|
||||
std::min(optimalNumOfInferRequests,
|
||||
static_cast<unsigned int>(_config.get<PerformanceHintNumRequestsOption>()));
|
||||
}
|
||||
IE_SET_METRIC_RETURN(OPTIMAL_NUMBER_OF_INFER_REQUESTS, optimalNumOfInferRequests);
|
||||
} else if (name == METRIC_KEY(DEVICE_THERMAL)) {
|
||||
IE_SET_METRIC_RETURN(DEVICE_THERMAL, _executor->GetThermal(_device));
|
||||
} else {
|
||||
|
@ -69,6 +69,8 @@
|
||||
#include <vpu/configuration/options/enable_mx_boot.hpp>
|
||||
|
||||
#include "myriad_plugin.h"
|
||||
#include "vpu/configuration/options/performance_hint.hpp"
|
||||
#include "vpu/configuration/options/performance_hint_num_requests.hpp"
|
||||
|
||||
using namespace InferenceEngine;
|
||||
using namespace InferenceEngine::PluginConfigParams;
|
||||
@ -235,6 +237,8 @@ Engine::Engine(std::shared_ptr<IMvnc> mvnc) :
|
||||
_parsedConfig.registerOption<NoneLayersOption>();
|
||||
_parsedConfig.registerOption<EnableAsyncDMAOption>();
|
||||
_parsedConfig.registerOption<EnableMXBootOption>();
|
||||
_parsedConfig.registerOption<PerformanceHintOption>();
|
||||
_parsedConfig.registerOption<PerformanceHintNumRequestsOption>();
|
||||
|
||||
IE_SUPPRESS_DEPRECATED_START
|
||||
_parsedConfig.registerDeprecatedOption<DisableConvertStagesOption>(InferenceEngine::MYRIAD_DISABLE_CONVERT_STAGES);
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <ie_plugin_config.hpp>
|
||||
#include "vpu/vpu_plugin_config.hpp"
|
||||
#include "vpu/private_plugin_config.hpp"
|
||||
#include "vpu/utils/optional.hpp"
|
||||
@ -194,6 +195,8 @@ std::vector<std::map<std::string, std::string>> getCorrectConfigs() {
|
||||
{InferenceEngine::MYRIAD_ENABLE_WEIGHTS_ANALYSIS, CONFIG_VALUE(NO)},
|
||||
{InferenceEngine::MYRIAD_PERF_REPORT_MODE, InferenceEngine::MYRIAD_PER_LAYER},
|
||||
{KEY_PERF_COUNT, CONFIG_VALUE(YES)},
|
||||
{KEY_PERFORMANCE_HINT, CONFIG_VALUE(LATENCY)},
|
||||
{KEY_PERFORMANCE_HINT_NUM_REQUESTS, "2"},
|
||||
{InferenceEngine::MYRIAD_PACK_DATA_IN_CMX, CONFIG_VALUE(NO)},
|
||||
{InferenceEngine::MYRIAD_TENSOR_STRIDES, "tensor[1,2,3,4]"},
|
||||
{InferenceEngine::MYRIAD_IGNORE_UNKNOWN_LAYERS, CONFIG_VALUE(NO)},
|
||||
@ -278,6 +281,8 @@ const std::vector<std::pair<std::string, InferenceEngine::Parameter>>& getDefaul
|
||||
{InferenceEngine::MYRIAD_ENABLE_RECEIVING_TENSOR_TIME, {false}},
|
||||
{InferenceEngine::MYRIAD_PERF_REPORT_MODE, {InferenceEngine::MYRIAD_PER_LAYER}},
|
||||
{KEY_PERF_COUNT, {false}},
|
||||
{KEY_PERFORMANCE_HINT, {}},
|
||||
{KEY_PERFORMANCE_HINT_NUM_REQUESTS, {}},
|
||||
{InferenceEngine::MYRIAD_PACK_DATA_IN_CMX, {true}},
|
||||
{InferenceEngine::MYRIAD_NUMBER_OF_SHAVES, {InferenceEngine::MYRIAD_NUMBER_OF_SHAVES_AUTO}},
|
||||
{InferenceEngine::MYRIAD_THROUGHPUT_STREAMS, {InferenceEngine::MYRIAD_THROUGHPUT_STREAMS_AUTO}},
|
||||
@ -580,6 +585,8 @@ const std::vector<std::string>& getPublicOptions() {
|
||||
InferenceEngine::MYRIAD_ENABLE_RECEIVING_TENSOR_TIME,
|
||||
VPU_CONFIG_KEY(PRINT_RECEIVE_TENSOR_TIME),
|
||||
KEY_PERF_COUNT,
|
||||
KEY_PERFORMANCE_HINT,
|
||||
KEY_PERFORMANCE_HINT_NUM_REQUESTS,
|
||||
InferenceEngine::MYRIAD_THROUGHPUT_STREAMS,
|
||||
KEY_EXCLUSIVE_ASYNC_REQUESTS,
|
||||
KEY_DEVICE_ID,
|
||||
|
@ -53,6 +53,8 @@
|
||||
#include <vpu/configuration/options/enable_custom_reshape_param.hpp>
|
||||
#include <vpu/configuration/options/none_layers.hpp>
|
||||
#include <vpu/configuration/options/enable_async_dma.hpp>
|
||||
#include <vpu/configuration/options/performance_hint.hpp>
|
||||
#include "vpu/configuration/options/performance_hint_num_requests.hpp"
|
||||
|
||||
#include <atomic>
|
||||
#include <iomanip>
|
||||
@ -439,6 +441,8 @@ PluginConfiguration createConfiguration() {
|
||||
configuration.registerOption<EnableCustomReshapeParamOption>();
|
||||
configuration.registerOption<NoneLayersOption>();
|
||||
configuration.registerOption<EnableAsyncDMAOption>();
|
||||
configuration.registerOption<PerformanceHintOption>();
|
||||
configuration.registerOption<PerformanceHintNumRequestsOption>();
|
||||
|
||||
IE_SUPPRESS_DEPRECATED_START
|
||||
configuration.registerDeprecatedOption<DisableConvertStagesOption>(InferenceEngine::MYRIAD_DISABLE_CONVERT_STAGES);
|
||||
|
@ -53,6 +53,8 @@
|
||||
#include <vpu/configuration/options/enable_custom_reshape_param.hpp>
|
||||
#include <vpu/configuration/options/none_layers.hpp>
|
||||
#include <vpu/configuration/options/enable_async_dma.hpp>
|
||||
#include <vpu/configuration/options/performance_hint.hpp>
|
||||
#include "vpu/configuration/options/performance_hint_num_requests.hpp"
|
||||
|
||||
using namespace InferenceEngine;
|
||||
using namespace vpu;
|
||||
@ -133,6 +135,8 @@ void graphTransformerFunctionalTests::PrepareGraphCompilation() {
|
||||
_configuration.registerOption<EnableCustomReshapeParamOption>();
|
||||
_configuration.registerOption<NoneLayersOption>();
|
||||
_configuration.registerOption<EnableAsyncDMAOption>();
|
||||
_configuration.registerOption<PerformanceHintOption>();
|
||||
_configuration.registerOption<PerformanceHintNumRequestsOption>();
|
||||
|
||||
IE_SUPPRESS_DEPRECATED_START
|
||||
_configuration.registerDeprecatedOption<DisableConvertStagesOption>(InferenceEngine::MYRIAD_DISABLE_CONVERT_STAGES);
|
||||
|
@ -55,6 +55,8 @@
|
||||
#include <vpu/configuration/options/enable_custom_reshape_param.hpp>
|
||||
#include <vpu/configuration/options/none_layers.hpp>
|
||||
#include <vpu/configuration/options/enable_async_dma.hpp>
|
||||
#include "vpu/configuration/options/performance_hint.hpp"
|
||||
#include "vpu/configuration/options/performance_hint_num_requests.hpp"
|
||||
|
||||
namespace vpu {
|
||||
|
||||
@ -251,6 +253,8 @@ PluginConfiguration createConfiguration() {
|
||||
configuration.registerOption<EnableCustomReshapeParamOption>();
|
||||
configuration.registerOption<NoneLayersOption>();
|
||||
configuration.registerOption<EnableAsyncDMAOption>();
|
||||
configuration.registerOption<PerformanceHintOption>();
|
||||
configuration.registerOption<PerformanceHintNumRequestsOption>();
|
||||
|
||||
IE_SUPPRESS_DEPRECATED_START
|
||||
configuration.registerDeprecatedOption<DisableConvertStagesOption>(InferenceEngine::MYRIAD_DISABLE_CONVERT_STAGES);
|
||||
|
Loading…
Reference in New Issue
Block a user