Deprecated ov::Any implicit cast to any types (#9409)

* Depricated Any implicit cast

* Fixed test

* fixed gna build

* Fixed warnings in benchmark_app

* Fixed test build

* ncc exception for PrintTo

* Error mesage in test

* Error mesage in test

* fixed build
This commit is contained in:
Anton Pankratov authored and GitHub committed 2022-02-03 19:10:52 +03:00
1 parent 6677079821
commit 8993c4c18a
15 files changed
+130 -180

No files matched your search

@@ -2,7 +2,7 @@
CppMethod: '^(operator\W+|[a-z_\d]+|signaling_NaN|quiet_NaN)$'
ClassName: '^([A-Z][\w]+|b?float16|numeric_limits|ngraph_error|stopwatch|unsupported_op)$'
StructName: '^([A-Z][\w]+|element_type_traits|hash|oi_pair)$'
FunctionName: '^(operator\W+|[a-z_\d]+)$'
FunctionName: '^(operator\W+|[a-z_\d]+)|PrintTo$'
Namespace: '^([a-z\d_]+|InferenceEngine)$'
NamespaceAlias: '^([a-z\d_]+|InferenceEngine)$'
UnionName: '[A-Z][\w]+$'
+7 -6
View File
@@ -632,14 +632,15 @@ int main(int argc, char* argv[]) {
next_step();
// output of the actual settings that the device selected
for (const auto& device : devices) {
auto supported_properties = core.get_property(device, ov::supported_properties);
auto supported_properties = compiledModel.get_property(ov::supported_properties);
slog::info << "Device: " << device << slog::endl;
for (const auto& cfg : supported_properties) {
try {
slog::info << " {" << cfg << " , " << compiledModel.get_property(cfg).as<std::string>();
slog::info << " }" << slog::endl;
} catch (...) {
};
slog::info << " {" << cfg << " , ";
std::stringstream strm;
compiledModel.get_property(cfg).print(strm);
strm << "";
slog::info << strm.str();
slog::info << " }" << slog::endl;
}
}
+10 -8
View File
@@ -635,20 +635,13 @@ public:
throw ov::Exception{std::string{"Bad cast from: "} + _impl->type_info().name() + " to: " + typeid(T).name()};
}
operator bool&() & = delete;
operator const bool&() const& = delete;
operator const bool() const& = delete;
operator const bool &&() && = delete;
/**
* @brief Converts to specified type
* @tparam T type
* @return casted object
*/
template <typename T>
OPENVINO_DEPRECATED("Please use as() method")
operator T&() & {
return as<T>();
}
@@ -659,6 +652,7 @@ public:
* @return casted object
*/
template <typename T>
OPENVINO_DEPRECATED("Please use as() method")
operator const T&() const& {
return as<T>();
}
@@ -669,6 +663,7 @@ public:
* @return casted object
*/
template <typename T>
OPENVINO_DEPRECATED("Please use as() method")
operator T&() const& {
return const_cast<Any*>(this)->as<T>();
}
@@ -679,6 +674,7 @@ public:
* @return casted object
*/
template <typename T>
OPENVINO_DEPRECATED("Please use as() method")
operator T &&() && {
return std::move(as<T&&>());
}
@@ -781,6 +777,12 @@ using RTMap = AnyMap;
using AnyVector = std::vector<ov::Any>;
/** @cond INTERNAL */
inline static void PrintTo(const Any& any, std::ostream* os) {
any.print(*os);
}
/** @endcond */
} // namespace ov
namespace std {
+10 -19
View File
@@ -100,20 +100,12 @@ TEST_F(AnyTests, parameter_ship) {
EXPECT_EQ(ship.x, 3);
EXPECT_EQ(ship.y, 4);
}
{
auto parameter = Any::make<Ship>("Lollipop", int16_t(3), int16_t(4));
ASSERT_TRUE(parameter.is<Ship>());
Ship ship = parameter;
EXPECT_EQ(ship.name, "Lollipop");
EXPECT_EQ(ship.x, 3);
EXPECT_EQ(ship.y, 4);
}
}
TEST_F(AnyTests, AnyAsInt) {
Any p = 4;
ASSERT_TRUE(p.is<int>());
int test = p;
int test = p.as<int>();
ASSERT_EQ(4, test);
}
@@ -121,22 +113,23 @@ TEST_F(AnyTests, AnyAsUInt) {
Any p = uint32_t(4);
ASSERT_TRUE(p.is<uint32_t>());
ASSERT_TRUE(p.is<uint32_t>());
uint32_t test = p;
uint32_t test = p.as<uint32_t>();
ASSERT_EQ(4, test);
}
TEST_F(AnyTests, AnyAsString) {
std::string ref = "test";
Any p = ref;
std::string test = p;
ASSERT_TRUE(p.is<std::string>());
std::string test = p.as<std::string>();
ASSERT_EQ(ref, test);
}
TEST_F(AnyTests, AnyAsStringInLine) {
Any p = "test";
std::string test = p;
ASSERT_TRUE(p.is<std::string>());
std::string test = p.as<std::string>();
;
ASSERT_EQ("test", test);
}
@@ -144,7 +137,6 @@ TEST_F(AnyTests, IntAnyAsString) {
Any p = 4;
ASSERT_TRUE(p.is<int>());
ASSERT_FALSE(p.is<std::string>());
ASSERT_THROW(std::string test = p, ov::Exception);
ASSERT_THROW(std::string test = p.as<std::string>(), ov::Exception);
}
@@ -152,7 +144,6 @@ TEST_F(AnyTests, StringAnyAsInt) {
Any p = "4";
ASSERT_FALSE(p.is<int>());
ASSERT_TRUE(p.is<std::string>());
ASSERT_THROW((void)static_cast<int>(p), ov::Exception);
ASSERT_THROW((void)p.as<int>(), ov::Exception);
}
@@ -160,7 +151,7 @@ TEST_F(AnyTests, AnyAsInts) {
std::vector<int> ref = {1, 2, 3, 4, 5};
Any p = ref;
ASSERT_TRUE(p.is<std::vector<int>>());
std::vector<int> test = p;
std::vector<int> test = p.as<std::vector<int>>();
ASSERT_EQ(ref.size(), test.size());
for (size_t i = 0; i < ref.size(); i++) {
ASSERT_EQ(ref[i], test[i]);
@@ -174,13 +165,13 @@ TEST_F(AnyTests, AnyAsMapOfAnys) {
Any p = refMap;
bool isMap = p.is<std::map<std::string, Any>>();
ASSERT_TRUE(isMap);
std::map<std::string, Any> testMap = p;
auto testMap = p.as<std::map<std::string, Any>>();
ASSERT_NE(testMap.find("testParamInt"), testMap.end());
ASSERT_NE(testMap.find("testParamString"), testMap.end());
int testInt = testMap["testParamInt"];
std::string testString = testMap["testParamString"];
int testInt = testMap["testParamInt"].as<int>();
std::string testString = testMap["testParamString"].as<std::string>();
ASSERT_EQ(refMap["testParamInt"].as<int>(), testInt);
ASSERT_EQ(refMap["testParamString"].as<std::string>(), testString);
@@ -304,7 +295,7 @@ TEST_F(AnyTests, AnyRemovedRealObjectPointerWithDuplication) {
ASSERT_EQ(0, DestructorTest::destructorCount);
p = t;
ASSERT_TRUE(p.is<DestructorTest*>());
DestructorTest* t2 = p;
DestructorTest* t2 = p.as<DestructorTest*>();
ASSERT_EQ(0, DestructorTest::destructorCount);
delete t;
auto* t3 = p.as<DestructorTest*>();
+3 -3
View File
@@ -225,8 +225,8 @@ MultiDeviceExecutableNetwork::MultiDeviceExecutableNetwork(const std::string&
auto& deviceName = contextPtr->deviceInfo.deviceName;
LOG_INFO("[AUTOPLUGIN]:device:%s loading Network finished",
deviceName.c_str());
std::vector<std::string> supported_config_keys =
_core->GetMetric(deviceName, METRIC_KEY(SUPPORTED_CONFIG_KEYS));
auto supported_config_keys =
_core->GetMetric(deviceName, METRIC_KEY(SUPPORTED_CONFIG_KEYS)).as<std::vector<std::string>>();
// there is log mutex in LOG_DEBUG, add _configMutex just want to print them all together
// toDo maybe neet to implement LOG_RUN(task, LOG_LEVEL) to run some debug code.
std::lock_guard<std::mutex> lock(_confMutex);
@@ -671,7 +671,7 @@ void MultiDeviceExecutableNetwork::SetConfig(const std::map<std::string, Inferen
} else {
auto multiPlugin = std::dynamic_pointer_cast<MultiDeviceInferencePlugin>(this->_plugin);
assert(multiPlugin != nullptr);
auto metaDevices = multiPlugin->ParseMetaDevices(priorities->second, {});
auto metaDevices = multiPlugin->ParseMetaDevices(priorities->second.as<std::string>(), {});
if (std::any_of(metaDevices.begin(), metaDevices.end(), [](const DeviceInformation& kvp) {
return kvp.numRequestsPerDevices != -1;
+3 -2
View File
@@ -579,7 +579,7 @@ RemoteContext::Ptr AutoBatchInferencePlugin::CreateContext(const InferenceEngine
if (it == cfg.end())
IE_THROW() << "Value for KEY_AUTO_BATCH is not set";
auto val = it->second;
auto val = it->second.as<std::string>();
auto metaDevice = ParseMetaDevice(val, std::map<std::string, std::string>());
cfg.erase(it);
return GetCore()->CreateContext(metaDevice.deviceName, cfg);
@@ -766,7 +766,8 @@ InferenceEngine::IExecutableNetworkInternal::Ptr AutoBatchInferencePlugin::LoadN
if (deviceName.find("GPU") != std::string::npos) {
batch1_footprint = report_footprint(GetCore(), deviceName) - batch1_footprint;
if (batch1_footprint) {
const uint64_t total_mem = GetCore()->GetMetric(deviceName, GPU_METRIC_KEY(DEVICE_TOTAL_MEM_SIZE));
const auto total_mem =
GetCore()->GetMetric(deviceName, GPU_METRIC_KEY(DEVICE_TOTAL_MEM_SIZE)).as<uint64_t>();
const int estimated_batch = (total_mem - batch1_footprint) / batch1_footprint;
int closest = pow(2, floor(log(estimated_batch) / log(2)));
closest = std::max(1, closest);
+2 -2
View File
@@ -199,8 +199,8 @@ std::string Engine::DeviceArchitecture(const std::string& targetFallback) const
for (const auto& device : fallbackDevices) {
InferenceEngine::DeviceIDParser parser(device);
std::vector<std::string> supportedMetricKeys =
GetCore()->GetMetric(parser.getDeviceName(), METRIC_KEY(SUPPORTED_METRICS));
auto supportedMetricKeys =
GetCore()->GetMetric(parser.getDeviceName(), METRIC_KEY(SUPPORTED_METRICS)).as<std::vector<std::string>>();
auto it = std::find(supportedMetricKeys.begin(), supportedMetricKeys.end(), METRIC_KEY(DEVICE_ARCHITECTURE));
auto arch = (it != supportedMetricKeys.end())
? GetCore()->GetMetric(device, METRIC_KEY(DEVICE_ARCHITECTURE)).as<std::string>()
@@ -95,7 +95,7 @@ class GNAExecutableNetwork : public InferenceEngine::IExecutableNetworkInternal
IE_THROW() << "The list of configuration values is empty";
}
std::vector<ov::PropertyName> supported_properties = Config::GetSupportedProperties(true);
auto supported_properties = Config::GetSupportedProperties(true).as<std::vector<ov::PropertyName>>();
for (auto&& item : config) {
auto it = std::find(supported_properties.begin(), supported_properties.end(), item.first);
if (it != supported_properties.end()) {
@@ -20,11 +20,11 @@ namespace ov {
namespace test {
namespace behavior {
#define ASSERT_EXEC_METRIC_SUPPORTED(metricName) \
#define ASSERT_EXEC_METRIC_SUPPORTED(property) \
{ \
std::vector<std::string> metrics = exeNetwork.get_property(METRIC_KEY(SUPPORTED_METRICS));\
auto it = std::find(metrics.begin(), metrics.end(), metricName); \
ASSERT_NE(metrics.end(), it); \
auto properties = compiled_model.get_property(ov::supported_properties);\
auto it = std::find(properties.begin(), properties.end(), property); \
ASSERT_NE(properties.end(), it); \
}
@@ -44,7 +44,7 @@ class OVClassExecutableNetworkGetMetricTestForSpecificConfig :
protected:
std::string deviceName;
std::string configKey;
std::string configValue;
ov::Any configValue;
public:
void SetUp() override {
@@ -90,10 +90,10 @@ TEST_P(OVClassImportExportTestP, smoke_ImportNetworkNoThrowWithDeviceName) {
ov::Core ie = createCoreWithTemplate();
std::stringstream strm;
ov::CompiledModel executableNetwork;
ASSERT_NO_THROW(executableNetwork = ie.compile_model(actualNetwork, deviceName));
ASSERT_NO_THROW(executableNetwork.export_model(strm));
ASSERT_NO_THROW(executableNetwork = ie.import_model(strm, deviceName));
ASSERT_NO_THROW(executableNetwork.create_infer_request());
OV_ASSERT_NO_THROW(executableNetwork = ie.compile_model(actualNetwork, deviceName));
OV_ASSERT_NO_THROW(executableNetwork.export_model(strm));
OV_ASSERT_NO_THROW(executableNetwork = ie.import_model(strm, deviceName));
OV_ASSERT_NO_THROW(executableNetwork.create_infer_request());
}
//
@@ -101,89 +101,83 @@ TEST_P(OVClassImportExportTestP, smoke_ImportNetworkNoThrowWithDeviceName) {
//
TEST_P(OVClassExecutableNetworkGetMetricTest_SUPPORTED_CONFIG_KEYS, GetMetricNoThrow) {
ov::Core ie = createCoreWithTemplate();
ov::Any p;
auto exeNetwork = ie.compile_model(simpleNetwork, deviceName);
auto compiled_model = ie.compile_model(simpleNetwork, deviceName);
ASSERT_NO_THROW(p = exeNetwork.get_property(METRIC_KEY(SUPPORTED_CONFIG_KEYS)));
std::vector<std::string> configValues = p;
std::vector<ov::PropertyName> supported_properties;
OV_ASSERT_NO_THROW(supported_properties = compiled_model.get_property(ov::supported_properties));
std::cout << "Supported config keys: " << std::endl;
for (auto&& conf : configValues) {
std::cout << "Supported RW keys: " << std::endl;
for (auto&& conf : supported_properties) if (conf.is_mutable()) {
std::cout << conf << std::endl;
ASSERT_LT(0, conf.size());
}
ASSERT_LE(0, configValues.size());
ASSERT_EXEC_METRIC_SUPPORTED(METRIC_KEY(SUPPORTED_CONFIG_KEYS));
ASSERT_LE(0, supported_properties.size());
ASSERT_EXEC_METRIC_SUPPORTED(ov::supported_properties);
}
TEST_P(OVClassExecutableNetworkGetMetricTest_SUPPORTED_METRICS, GetMetricNoThrow) {
ov::Core ie = createCoreWithTemplate();
ov::Any p;
auto exeNetwork = ie.compile_model(simpleNetwork, deviceName);
auto compiled_model = ie.compile_model(simpleNetwork, deviceName);
ASSERT_NO_THROW(p = exeNetwork.get_property(METRIC_KEY(SUPPORTED_METRICS)));
std::vector<std::string> metricValues = p;
std::vector<ov::PropertyName> supported_properties;
OV_ASSERT_NO_THROW(supported_properties = compiled_model.get_property(ov::supported_properties));
std::cout << "Supported metric keys: " << std::endl;
for (auto&& conf : metricValues) {
std::cout << "Supported RO keys: " << std::endl;
for (auto&& conf : supported_properties) if (!conf.is_mutable()) {
std::cout << conf << std::endl;
ASSERT_LT(0, conf.size());
}
ASSERT_LT(0, metricValues.size());
ASSERT_EXEC_METRIC_SUPPORTED(METRIC_KEY(SUPPORTED_METRICS));
ASSERT_LE(0, supported_properties.size());
ASSERT_EXEC_METRIC_SUPPORTED(ov::supported_properties);
}
TEST_P(OVClassExecutableNetworkGetMetricTest_NETWORK_NAME, GetMetricNoThrow) {
ov::Core ie = createCoreWithTemplate();
ov::Any p;
auto exeNetwork = ie.compile_model(simpleNetwork, deviceName);
auto compiled_model = ie.compile_model(simpleNetwork, deviceName);
ASSERT_NO_THROW(p = exeNetwork.get_property(EXEC_NETWORK_METRIC_KEY(NETWORK_NAME)));
std::string networkname = p;
std::string model_name;
OV_ASSERT_NO_THROW(model_name = compiled_model.get_property(ov::model_name));
std::cout << "Exe network name: " << std::endl << networkname << std::endl;
ASSERT_EQ(simpleNetwork->get_friendly_name(), networkname);
ASSERT_EXEC_METRIC_SUPPORTED(EXEC_NETWORK_METRIC_KEY(NETWORK_NAME));
std::cout << "Compiled model name: " << std::endl << model_name << std::endl;
ASSERT_EQ(simpleNetwork->get_friendly_name(), model_name);
ASSERT_EXEC_METRIC_SUPPORTED(ov::model_name);
}
TEST_P(OVClassExecutableNetworkGetMetricTest_OPTIMAL_NUMBER_OF_INFER_REQUESTS, GetMetricNoThrow) {
ov::Core ie = createCoreWithTemplate();
ov::Any p;
auto exeNetwork = ie.compile_model(simpleNetwork, deviceName);
auto compiled_model = ie.compile_model(simpleNetwork, deviceName);
ASSERT_NO_THROW(p = exeNetwork.get_property(EXEC_NETWORK_METRIC_KEY(OPTIMAL_NUMBER_OF_INFER_REQUESTS)));
unsigned int value = p;
unsigned int value = 0;
OV_ASSERT_NO_THROW(value = compiled_model.get_property(ov::optimal_number_of_infer_requests));
std::cout << "Optimal number of Inference Requests: " << value << std::endl;
ASSERT_GE(value, 1u);
ASSERT_EXEC_METRIC_SUPPORTED(EXEC_NETWORK_METRIC_KEY(OPTIMAL_NUMBER_OF_INFER_REQUESTS));
ASSERT_EXEC_METRIC_SUPPORTED(ov::optimal_number_of_infer_requests);
}
TEST_P(OVClassExecutableNetworkGetMetricTest_ThrowsUnsupported, GetMetricThrow) {
ov::Core ie = createCoreWithTemplate();
ov::Any p;
auto exeNetwork = ie.compile_model(simpleNetwork, deviceName);
auto compiled_model = ie.compile_model(simpleNetwork, deviceName);
ASSERT_THROW(p = exeNetwork.get_property("unsupported_metric"), ov::Exception);
ASSERT_THROW(compiled_model.get_property("unsupported_property"), ov::Exception);
}
TEST_P(OVClassExecutableNetworkGetConfigTest, GetConfigNoThrow) {
ov::Core ie = createCoreWithTemplate();
ov::Any p;
auto exeNetwork = ie.compile_model(simpleNetwork, deviceName);
auto compiled_model = ie.compile_model(simpleNetwork, deviceName);
ASSERT_NO_THROW(p = exeNetwork.get_property(METRIC_KEY(SUPPORTED_CONFIG_KEYS)));
std::vector<std::string> configValues = p;
std::vector<ov::PropertyName> property_names;
OV_ASSERT_NO_THROW(property_names = compiled_model.get_property(ov::supported_properties));
for (auto&& confKey : configValues) {
for (auto&& property : property_names) {
ov::Any defaultValue;
ASSERT_NO_THROW(defaultValue = ie.get_property(deviceName, confKey));
OV_ASSERT_NO_THROW(defaultValue = compiled_model.get_property(property));
ASSERT_FALSE(defaultValue.empty());
}
}
@@ -192,71 +186,58 @@ TEST_P(OVClassExecutableNetworkGetConfigTest, GetConfigThrows) {
ov::Core ie = createCoreWithTemplate();
ov::Any p;
auto exeNetwork = ie.compile_model(simpleNetwork, deviceName);
auto compiled_model = ie.compile_model(simpleNetwork, deviceName);
ASSERT_THROW(p = exeNetwork.get_property("unsupported_config"), ov::Exception);
ASSERT_THROW(compiled_model.get_property("unsupported_property"), ov::Exception);
}
TEST_P(OVClassExecutableNetworkSetConfigTest, SetConfigThrows) {
ov::Core ie = createCoreWithTemplate();
ov::Any p;
auto exeNetwork = ie.compile_model(simpleNetwork, deviceName);
auto compiled_model = ie.compile_model(simpleNetwork, deviceName);
ASSERT_THROW(exeNetwork.set_property({{"unsupported_config", "some_value"}}), ov::Exception);
ASSERT_THROW(compiled_model.set_property({{"unsupported_config", "some_value"}}), ov::Exception);
}
TEST_P(OVClassExecutableNetworkSupportedConfigTest, SupportedConfigWorks) {
ov::Core ie = createCoreWithTemplate();
ov::Any p;
auto exeNetwork = ie.compile_model(simpleNetwork, deviceName);
ASSERT_NO_THROW(exeNetwork.set_property({{configKey, configValue}}));
ASSERT_NO_THROW(p = exeNetwork.get_property(configKey));
auto compiled_model = ie.compile_model(simpleNetwork, deviceName);
OV_ASSERT_NO_THROW(compiled_model.set_property({{configKey, configValue}}));
OV_ASSERT_NO_THROW(p = compiled_model.get_property(configKey));
ASSERT_EQ(p, configValue);
}
TEST_P(OVClassExecutableNetworkUnsupportedConfigTest, UnsupportedConfigThrows) {
ov::Core ie = createCoreWithTemplate();
auto exeNetwork = ie.compile_model(simpleNetwork, deviceName);
auto compiled_model = ie.compile_model(simpleNetwork, deviceName);
ASSERT_THROW(exeNetwork.set_property({{configKey, configValue}}), ov::Exception);
ASSERT_THROW(compiled_model.set_property({{configKey, configValue}}), ov::Exception);
}
TEST_P(OVClassExecutableNetworkGetConfigTest, GetConfigNoEmptyNoThrow) {
ov::Core ie = createCoreWithTemplate();
ov::Any p;
ASSERT_NO_THROW(p = ie.get_property(deviceName, METRIC_KEY(SUPPORTED_CONFIG_KEYS)));
std::vector<std::string> devConfigValues = p;
std::vector<ov::PropertyName> dev_property_names;
OV_ASSERT_NO_THROW(dev_property_names = ie.get_property(deviceName, ov::supported_properties));
auto exeNetwork = ie.compile_model(simpleNetwork, deviceName);
auto compiled_model = ie.compile_model(simpleNetwork, deviceName);
ASSERT_NO_THROW(p = exeNetwork.get_property(METRIC_KEY(SUPPORTED_CONFIG_KEYS)));
std::vector<std::string> execConfigValues = p;
/*
for (auto && configKey : devConfigValues) {
ASSERT_NE(execConfigValues.end(), std::find(execConfigValues.begin(), execConfigValues.end(), configKey));
ov::Any configValue;
ASSERT_NO_THROW(ov::Any configValue = exeNetwork.get_property(configKey));
}
*/
std::vector<ov::PropertyName> model_property_names;
OV_ASSERT_NO_THROW(model_property_names = compiled_model.get_property(ov::supported_properties));
}
TEST_P(OVClassHeteroExecutableNetworkGetMetricTest_SUPPORTED_CONFIG_KEYS, GetMetricNoThrow) {
ov::Core ie = createCoreWithTemplate();
ov::Any pHetero, pDevice;
auto heteroExeNetwork = ie.compile_model(actualNetwork, heteroDeviceName);
auto deviceExeNetwork = ie.compile_model(actualNetwork, deviceName);
ASSERT_NO_THROW(pHetero = heteroExeNetwork.get_property(METRIC_KEY(SUPPORTED_CONFIG_KEYS)));
ASSERT_NO_THROW(pDevice = deviceExeNetwork.get_property(METRIC_KEY(SUPPORTED_CONFIG_KEYS)));
std::vector<std::string> heteroConfigValues = pHetero, deviceConfigValues = pDevice;
std::vector<ov::PropertyName> heteroConfigValues, deviceConfigValues;
OV_ASSERT_NO_THROW(heteroConfigValues = heteroExeNetwork.get_property(ov::supported_properties));
OV_ASSERT_NO_THROW(deviceConfigValues = deviceExeNetwork.get_property(ov::supported_properties));
std::cout << "Supported config keys: " << std::endl;
for (auto&& conf : heteroConfigValues) {
@@ -275,57 +256,60 @@ TEST_P(OVClassHeteroExecutableNetworkGetMetricTest_SUPPORTED_CONFIG_KEYS, GetMet
// HETERO returns EXCLUSIVE_ASYNC_REQUESTS as a boolean value
if (CONFIG_KEY(EXCLUSIVE_ASYNC_REQUESTS) != deviceConf) {
ASSERT_EQ(deviceConfigValue, heteroConfigValue);
std::stringstream strm;
deviceConfigValue.print(strm);
strm << " ";
heteroConfigValue.print(strm);
ASSERT_EQ(deviceConfigValue, heteroConfigValue) << deviceConf << " " << strm.str();
}
}
}
TEST_P(OVClassHeteroExecutableNetworkGetMetricTest_SUPPORTED_METRICS, GetMetricNoThrow) {
ov::Core ie = createCoreWithTemplate();
ov::Any pHetero, pDevice;
auto heteroExeNetwork = ie.compile_model(actualNetwork, heteroDeviceName);
auto deviceExeNetwork = ie.compile_model(actualNetwork, deviceName);
ASSERT_NO_THROW(pHetero = heteroExeNetwork.get_property(METRIC_KEY(SUPPORTED_METRICS)));
ASSERT_NO_THROW(pDevice = deviceExeNetwork.get_property(METRIC_KEY(SUPPORTED_METRICS)));
std::vector<std::string> heteroMetricValues = pHetero, deviceMetricValues = pDevice;
std::vector<ov::PropertyName> heteroConfigValues, deviceConfigValues;
OV_ASSERT_NO_THROW(heteroConfigValues = heteroExeNetwork.get_property(ov::supported_properties));
OV_ASSERT_NO_THROW(deviceConfigValues = deviceExeNetwork.get_property(ov::supported_properties));
std::cout << "Supported metric keys: " << std::endl;
for (auto&& conf : heteroMetricValues) {
std::cout << "Supported config keys: " << std::endl;
for (auto&& conf : heteroConfigValues) {
std::cout << conf << std::endl;
ASSERT_LT(0, conf.size());
}
ASSERT_LT(0, heteroMetricValues.size());
ASSERT_LE(0, heteroConfigValues.size());
const std::vector<std::string> heteroSpecificMetrics = {METRIC_KEY(SUPPORTED_METRICS),
METRIC_KEY(SUPPORTED_CONFIG_KEYS)};
// check that all device config values are present in hetero case
for (auto&& deviceConf : deviceConfigValues) {
auto it = std::find(heteroConfigValues.begin(), heteroConfigValues.end(), deviceConf);
ASSERT_TRUE(it != heteroConfigValues.end());
// check that all device metric values are present in hetero case
for (auto&& deviceMetricName : deviceMetricValues) {
auto it = std::find(heteroMetricValues.begin(), heteroMetricValues.end(), deviceMetricName);
ASSERT_TRUE(it != heteroMetricValues.end());
ov::Any heteroConfigValue = heteroExeNetwork.get_property(deviceConf);
ov::Any deviceConfigValue = deviceExeNetwork.get_property(deviceConf);
ov::Any heteroMetricValue = heteroExeNetwork.get_property(deviceMetricName);
ov::Any deviceMetricValue = deviceExeNetwork.get_property(deviceMetricName);
if (std::find(heteroSpecificMetrics.begin(), heteroSpecificMetrics.end(), deviceMetricName) ==
heteroSpecificMetrics.end()) {
ASSERT_TRUE(heteroMetricValue == deviceMetricValue);
// HETERO returns EXCLUSIVE_ASYNC_REQUESTS as a boolean value
if (CONFIG_KEY(EXCLUSIVE_ASYNC_REQUESTS) != deviceConf) {
std::stringstream strm;
deviceConfigValue.print(strm);
strm << " ";
heteroConfigValue.print(strm);
ASSERT_EQ(deviceConfigValue, heteroConfigValue) << deviceConf << " " << strm.str();
}
}
}
TEST_P(OVClassHeteroExecutableNetworkGetMetricTest_NETWORK_NAME, GetMetricNoThrow) {
ov::Core ie = createCoreWithTemplate();
ov::Any p;
auto exeNetwork = ie.compile_model(actualNetwork, heteroDeviceName);
auto compiled_model = ie.compile_model(actualNetwork, heteroDeviceName);
ASSERT_NO_THROW(p = exeNetwork.get_property(EXEC_NETWORK_METRIC_KEY(NETWORK_NAME)));
std::string networkname = p;
std::string model_name;
OV_ASSERT_NO_THROW(model_name = compiled_model.get_property(ov::model_name));
std::cout << "Exe network name: " << std::endl << networkname << std::endl;
std::cout << "Compiled model name: " << std::endl << model_name << std::endl;
}
TEST_P(OVClassHeteroExecutableNetworkGetMetricTest_TARGET_FALLBACK, GetMetricNoThrow) {
@@ -333,13 +317,13 @@ TEST_P(OVClassHeteroExecutableNetworkGetMetricTest_TARGET_FALLBACK, GetMetricNoT
setHeteroNetworkAffinity(deviceName);
auto exeNetwork = ie.compile_model(actualNetwork, heteroDeviceName);
auto compiled_model = ie.compile_model(actualNetwork, heteroDeviceName);
std::string targets;
ASSERT_NO_THROW(targets = exeNetwork.get_property(ov::device::priorities));
OV_ASSERT_NO_THROW(targets = compiled_model.get_property(ov::device::priorities));
auto expectedTargets = deviceName + "," + CommonTestUtils::DEVICE_CPU;
std::cout << "Exe network fallback targets: " << targets << std::endl;
std::cout << "Compiled model fallback targets: " << targets << std::endl;
ASSERT_EQ(expectedTargets, targets);
}
@@ -10,7 +10,6 @@
#include "openvino/runtime/compiled_model.hpp"
#include "openvino/op/parameter.hpp"
#include "functional_test_utils/ov_plugin_cache.hpp"
#include "common_test_utils/ov_common_utils.hpp"
namespace ov {
namespace test {
@@ -4,7 +4,6 @@
#include "gtest/gtest.h"
#include "common_test_utils/ov_common_utils.hpp"
#include "functional_test_utils/layer_test_utils/environment.hpp"
#include "functional_test_utils/layer_test_utils/summary.hpp"
#include "functional_test_utils/skip_tests_config.hpp"
@@ -1,26 +0,0 @@
// Copyright (C) 2018-2022 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <algorithm>
#include <string>
#include <sstream>
#include <iterator>
#include <vector>
#include <set>
#include <chrono>
#include <ostream>
#include <memory>
#include <cpp/ie_cnn_network.h>
#include <ngraph/function.hpp>
#include <openvino/core/any.hpp>
#include <openvino/runtime/common.hpp>
namespace ov {
static void PrintTo(const Any& any, std::ostream* os) {
any.print(*os);
}
} // namespace ov
@@ -8,7 +8,6 @@
#include <string>
#include "test_assertions.hpp"
#include "ov_common_utils.hpp"
namespace CommonTestUtils {
@@ -61,11 +61,11 @@ std::shared_ptr<ov::Core> PluginCache::core(const std::string &deviceToCheck) {
}
if (!deviceToCheck.empty()) {
std::vector<std::string> metrics = ov_core->get_property(deviceToCheck, METRIC_KEY(SUPPORTED_METRICS));
auto properties = ov_core->get_property(deviceToCheck, ov::supported_properties);
if (std::find(metrics.begin(), metrics.end(), METRIC_KEY(AVAILABLE_DEVICES)) != metrics.end()) {
std::vector<std::string> availableDevices =
ov_core->get_property(deviceToCheck, METRIC_KEY(AVAILABLE_DEVICES));
if (std::find(properties.begin(), properties.end(), ov::available_devices) != properties.end()) {
auto availableDevices =
ov_core->get_property(deviceToCheck, ov::available_devices);
if (availableDevices.empty()) {
std::cerr << "No available devices for " << deviceToCheck << std::endl;
@@ -39,7 +39,7 @@ protected:
Config config;
void SetAndCompare(const std::string& key, const std::string& val) {
config.UpdateFromMap({{key, val}});
EXPECT_EQ(config.GetParameter(key), val);
EXPECT_EQ(config.GetParameter(key).as<std::string>(), val);
}
void ExpectThrow(const std::string& key, const std::string& val) {
EXPECT_THROW(config.UpdateFromMap({{key, val}}),