diff --git a/src/plugins/hetero/internal_properties.hpp b/src/plugins/hetero/internal_properties.hpp new file mode 100644 index 00000000000..799d07dbe7b --- /dev/null +++ b/src/plugins/hetero/internal_properties.hpp @@ -0,0 +1,17 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "openvino/runtime/properties.hpp" + +namespace ov { +namespace hetero { +/** + * @brief Read-only property to get device caching properties + */ +static constexpr Property caching_device_properties{"CACHING_DEVICE_PROPERTIES"}; + +} // namespace hetero +} // namespace ov diff --git a/src/plugins/hetero/plugin.cpp b/src/plugins/hetero/plugin.cpp index 10edbe72fe7..78b3c78eb3b 100644 --- a/src/plugins/hetero/plugin.cpp +++ b/src/plugins/hetero/plugin.cpp @@ -17,6 +17,8 @@ #include "executable_network.hpp" #include "cpp_interfaces/interface/ie_internal_plugin_config.hpp" #include "openvino/runtime/properties.hpp" +#include "internal_properties.hpp" +#include "openvino/util/common_util.hpp" // clang-format on using namespace InferenceEngine; @@ -159,16 +161,21 @@ Parameter Engine::GetMetric(const std::string& name, const std::map{METRIC_KEY(SUPPORTED_METRICS), ov::device::full_name.name(), METRIC_KEY(SUPPORTED_CONFIG_KEYS), - ov::device::architecture.name(), METRIC_KEY(IMPORT_EXPORT_SUPPORT), ov::device::capabilities.name()}); } else if (METRIC_KEY(SUPPORTED_CONFIG_KEYS) == name) { @@ -179,30 +186,39 @@ Parameter Engine::GetMetric(const std::string& name, const std::map result = {}; for (const auto& device : fallbackDevices) { ov::DeviceIDParser parser(device); - - auto supportedMetricKeys = GetCore() - ->GetMetric(parser.get_device_name(), METRIC_KEY(SUPPORTED_METRICS)) - .as>(); - 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() - : parser.get_device_name(); - resArch += " " + arch; + ov::AnyMap properties = {}; + // Use name without id + auto device_name = parser.get_device_name(); + auto supported_properties = + GetCore()->GetMetric(device, ov::supported_properties.name()).as>(); + if (ov::util::contains(supported_properties, ov::caching_properties.name())) { + auto caching_properties = + GetCore()->GetMetric(device, ov::caching_properties.name()).as>(); + for (auto& property_name : caching_properties) { + properties[property_name] = GetCore()->GetMetric(device, property_name); + } + // If caching properties are not supported by device, try to add at least device architecture + } else if (ov::util::contains(supported_properties, ov::device::architecture.name())) { + auto device_architecture = GetCore()->GetMetric(device, ov::device::architecture.name()); + properties = ov::AnyMap{{ov::device::architecture.name(), device_architecture}}; + // Device architecture is not supported, add device name as achitecture + } else { + properties = ov::AnyMap{{ov::device::architecture.name(), device_name}}; + } + result.emplace_back(properties); } - return resArch; + return result.empty() ? "" : ov::Any(result).as(); } Parameter Engine::GetConfig(const std::string& name, const std::map& /*options*/) const { diff --git a/src/plugins/hetero/plugin.hpp b/src/plugins/hetero/plugin.hpp index 296793c243b..23f9f299f94 100644 --- a/src/plugins/hetero/plugin.hpp +++ b/src/plugins/hetero/plugin.hpp @@ -49,6 +49,6 @@ public: std::string GetTargetFallback(const Engine::Configs& config, bool raise_exception = true) const; private: - std::string DeviceArchitecture(const std::string& targetFallback) const; + std::string DeviceCachingProperties(const std::string& targetFallback) const; }; } // namespace HeteroPlugin