[GNA] Support caching properties for model cache (#14731)
* [GNA] Enable model caching * [GNA] Enable model caching tests * Fix: Use 'removeDir' instead of 'std::remove', on Windows std::remove has no effect * Extract properties impacting model compilation into a separate method * Add caching prop for supprted prop list
This commit is contained in:
1 parent
141646ddc0
commit
e1d3f26489
7 files changed
+42
-19
No files matched your search
@@ -268,6 +268,8 @@ OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
} else if (key == CONFIG_KEY(LOG_LEVEL) || key == ov::log::level) {
|
||||
gnaFlags.log_level = ov::util::from_string(value, ov::log::level);
|
||||
} else if (key == ov::cache_dir) {
|
||||
cacheDir = value;
|
||||
} else {
|
||||
IE_THROW(NotFound)
|
||||
<< "[GNAPlugin] in function " << __PRETTY_FUNCTION__<< ": "
|
||||
@@ -350,6 +352,7 @@ OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
keyConfigMap[ov::enable_profiling.name()] =
|
||||
gnaFlags.performance_counting ? PluginConfigParams::YES: PluginConfigParams::NO;
|
||||
keyConfigMap[ov::log::level.name()] = ov::util::to_string(gnaFlags.log_level);
|
||||
keyConfigMap[ov::cache_dir.name()] = cacheDir;
|
||||
}
|
||||
|
||||
Parameter Config::GetParameter(const std::string& name) const {
|
||||
@@ -381,9 +384,23 @@ Parameter Config::GetParameter(const std::string& name) const {
|
||||
}
|
||||
}
|
||||
|
||||
const Parameter Config::GetSupportedProperties(bool compiled) {
|
||||
const Parameter Config::GetImpactingModelCompilationProperties(bool compiled) {
|
||||
ov::PropertyMutability model_mutability = compiled ? ov::PropertyMutability::RO : ov::PropertyMutability::RW;
|
||||
const std::vector<ov::PropertyName> supported_properties = {
|
||||
{ov::intel_gna::scale_factors_per_input.name(), model_mutability},
|
||||
{ov::intel_gna::firmware_model_image_path.name(), model_mutability},
|
||||
{ov::intel_gna::execution_target.name(), model_mutability},
|
||||
{ov::intel_gna::compile_target.name(), model_mutability},
|
||||
{ov::intel_gna::pwl_design_algorithm.name(), model_mutability},
|
||||
{ov::intel_gna::pwl_max_error_percent.name(), model_mutability},
|
||||
{ov::inference_precision.name(), model_mutability},
|
||||
{ov::hint::num_requests.name(), model_mutability},
|
||||
};
|
||||
return supported_properties;
|
||||
}
|
||||
|
||||
const Parameter Config::GetSupportedProperties(bool compiled) {
|
||||
std::vector<ov::PropertyName> supported_properties = {
|
||||
{ ov::supported_properties.name(), ov::PropertyMutability::RO },
|
||||
{ ov::available_devices.name(), ov::PropertyMutability::RO },
|
||||
{ ov::optimal_number_of_infer_requests.name(), ov::PropertyMutability::RO },
|
||||
@@ -391,19 +408,20 @@ const Parameter Config::GetSupportedProperties(bool compiled) {
|
||||
{ ov::device::capabilities.name(), ov::PropertyMutability::RO },
|
||||
{ ov::device::full_name.name(), ov::PropertyMutability::RO },
|
||||
{ ov::intel_gna::library_full_version.name(), ov::PropertyMutability::RO },
|
||||
{ ov::intel_gna::scale_factors_per_input.name(), model_mutability },
|
||||
{ ov::intel_gna::firmware_model_image_path.name(), model_mutability },
|
||||
{ ov::caching_properties.name(), ov::PropertyMutability::RO},
|
||||
{ ov::intel_gna::execution_mode.name(), ov::PropertyMutability::RW },
|
||||
{ ov::intel_gna::execution_target.name(), model_mutability },
|
||||
{ ov::intel_gna::compile_target.name(), model_mutability },
|
||||
{ ov::intel_gna::pwl_design_algorithm.name(), model_mutability },
|
||||
{ ov::intel_gna::pwl_max_error_percent.name(), model_mutability },
|
||||
{ ov::hint::performance_mode.name(), ov::PropertyMutability::RW },
|
||||
{ ov::inference_precision.name(), model_mutability },
|
||||
{ ov::hint::num_requests.name(), model_mutability },
|
||||
{ ov::log::level.name(), ov::PropertyMutability::RW },
|
||||
{ ov::execution_devices.name(), ov::PropertyMutability::RO },
|
||||
{ ov::cache_dir.name(), ov::PropertyMutability::RW },
|
||||
};
|
||||
|
||||
const std::vector<ov::PropertyName> impacting_model_compilation_properties =
|
||||
GetImpactingModelCompilationProperties(compiled);
|
||||
|
||||
supported_properties.insert(supported_properties.end(),
|
||||
impacting_model_compilation_properties.begin(),
|
||||
impacting_model_compilation_properties.end());
|
||||
return supported_properties;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,11 +45,13 @@ struct Config {
|
||||
gnaFlags = r.gnaFlags;
|
||||
std::lock_guard<std::mutex> lock(r.mtx4keyConfigMap);
|
||||
keyConfigMap = r.keyConfigMap;
|
||||
cacheDir = r.cacheDir;
|
||||
}
|
||||
void UpdateFromMap(const std::map<std::string, std::string>& configMap);
|
||||
void AdjustKeyMapValues();
|
||||
InferenceEngine::Parameter GetParameter(const std::string& name) const;
|
||||
std::vector<std::string> GetSupportedKeys() const;
|
||||
static const InferenceEngine::Parameter GetImpactingModelCompilationProperties(bool compiled);
|
||||
static const InferenceEngine::Parameter GetSupportedProperties(bool compiled = false);
|
||||
|
||||
ov::hint::PerformanceMode performance_mode = ov::hint::PerformanceMode::UNDEFINED;
|
||||
@@ -73,8 +75,8 @@ struct Config {
|
||||
|
||||
mutable std::mutex mtx4keyConfigMap;
|
||||
std::map<std::string, std::string> keyConfigMap;
|
||||
|
||||
static const uint8_t max_num_requests = 127;
|
||||
std::string cacheDir;
|
||||
};
|
||||
|
||||
} // namespace intel_gna
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "gna_plugin.hpp"
|
||||
#include "gna/gna_config.hpp"
|
||||
#include "openvino/runtime/intel_gna/properties.hpp"
|
||||
#include <cpp_interfaces/interface/ie_internal_plugin_config.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
@@ -61,6 +62,10 @@ Parameter GNAPlugin::GetMetric(const std::string& name, const std::map<std::stri
|
||||
return decltype(ov::execution_devices)::value_type {GetName()};
|
||||
} else if (ov::model_name == name) {
|
||||
return _network_name;
|
||||
} else if (name == ov::caching_properties) {
|
||||
std::vector<ov::PropertyName> cachingProperties = Config::GetImpactingModelCompilationProperties(true);
|
||||
cachingProperties.push_back(ov::PropertyName(ov::log::level.name(), ov::PropertyMutability::RO));
|
||||
return decltype(ov::caching_properties)::value_type(cachingProperties);
|
||||
} else {
|
||||
const std::unordered_map<std::string, std::function<Parameter()>> queryApiSupported = {
|
||||
{METRIC_KEY(AVAILABLE_DEVICES), [this]() {return GetAvailableDevices();}},
|
||||
|
||||
@@ -94,12 +94,9 @@ std::vector<std::string> disabledTestPatterns() {
|
||||
R"(.*CompileModelCacheTestBase.*(SingleConv|NestedSplitConvConcat).*)",
|
||||
R"(.*CompileModelCacheTestBase.*(Bias|ReadConcatSplitAssign).*)",
|
||||
R"(.*OVClassLoadNetworkTest.*LoadNetwork.*)",
|
||||
// TODO: Issue: 95234
|
||||
R"(.*smoke_CachingSupportCase_GNA.*)",
|
||||
// does not work due to GNA 3.0 convolution and other primitives limitations, partially can be resolved by switching GNA library to GNA3.5
|
||||
R"(.*CachingSupportCase.*LoadNet.*(Bias|Split|Concat|KSO|SingleConv).*)",
|
||||
R"(.*CachingSupportCase.*LoadNet.*(ConvPoolRelu|TIwithLSTMcell1)_f32_batch2.*)",
|
||||
// TODO: Issue: 95234
|
||||
R"(.*CachingSupportCase_GNA.*)",
|
||||
R"(.*IEClassLoadNetworkTest.*LoadNetwork(HETERO|MULTI|WithDeviceIDNoThrow|WithInvalidDeviceIDThrows).*)",
|
||||
};
|
||||
}
|
||||
@@ -61,9 +61,9 @@ TEST_F(GnaExecutableNetworkMetricsTest, TestNetworkName) {
|
||||
TEST_F(GnaExecutableNetworkMetricsTest, TestSupportedProperties) {
|
||||
std::string supportedProperties =
|
||||
"SUPPORTED_PROPERTIES AVAILABLE_DEVICES OPTIMAL_NUMBER_OF_INFER_REQUESTS RANGE_FOR_ASYNC_INFER_REQUESTS "
|
||||
"OPTIMIZATION_CAPABILITIES FULL_DEVICE_NAME GNA_LIBRARY_FULL_VERSION GNA_SCALE_FACTOR_PER_INPUT "
|
||||
"GNA_FIRMWARE_MODEL_IMAGE GNA_DEVICE_MODE GNA_HW_EXECUTION_TARGET GNA_HW_COMPILE_TARGET "
|
||||
"GNA_PWL_DESIGN_ALGORITHM GNA_PWL_MAX_ERROR_PERCENT PERFORMANCE_HINT INFERENCE_PRECISION_HINT "
|
||||
"PERFORMANCE_HINT_NUM_REQUESTS LOG_LEVEL EXECUTION_DEVICES";
|
||||
"OPTIMIZATION_CAPABILITIES FULL_DEVICE_NAME GNA_LIBRARY_FULL_VERSION CACHING_PROPERTIES "
|
||||
"GNA_DEVICE_MODE PERFORMANCE_HINT LOG_LEVEL EXECUTION_DEVICES CACHE_DIR "
|
||||
"GNA_SCALE_FACTOR_PER_INPUT GNA_FIRMWARE_MODEL_IMAGE GNA_HW_EXECUTION_TARGET GNA_HW_COMPILE_TARGET "
|
||||
"GNA_PWL_DESIGN_ALGORITHM GNA_PWL_MAX_ERROR_PERCENT INFERENCE_PRECISION_HINT PERFORMANCE_HINT_NUM_REQUESTS";
|
||||
Run(ov::supported_properties.name(), supportedProperties);
|
||||
}
|
||||
@@ -13,6 +13,7 @@ using namespace ov::intel_gna;
|
||||
|
||||
IE_SUPPRESS_DEPRECATED_START
|
||||
const std::map<std::string, std::string> supportedConfigKeysWithDefaults = {
|
||||
{CONFIG_KEY(CACHE_DIR), ""},
|
||||
{GNA_CONFIG_KEY(SCALE_FACTOR), "1.000000"},
|
||||
{GNA_CONFIG_KEY(SCALE_FACTOR) + std::string("_0"), "1.000000"},
|
||||
{GNA_CONFIG_KEY(FIRMWARE_MODEL_IMAGE), ""},
|
||||
|
||||
@@ -176,7 +176,7 @@ void LoadNetworkCacheTestBase::SetUp() {
|
||||
|
||||
void LoadNetworkCacheTestBase::TearDown() {
|
||||
CommonTestUtils::removeFilesWithExt(m_cacheFolderName, "blob");
|
||||
std::remove(m_cacheFolderName.c_str());
|
||||
CommonTestUtils::removeDir(m_cacheFolderName);
|
||||
core->SetConfig({{CONFIG_KEY(CACHE_DIR), {}}});
|
||||
APIBaseTest::TearDown();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user