Added get property additional arguments (#9993)
* Added get property additional arguments * Fixed build * Fixed error * Added api wiht property and map * Fixed gna build * reverted available_devices
This commit is contained in:
parent
c715fde8f0
commit
4cbcf4b4e3
@ -175,7 +175,7 @@ public:
|
|||||||
* @return nothing
|
* @return nothing
|
||||||
*/
|
*/
|
||||||
template <typename... Properties>
|
template <typename... Properties>
|
||||||
util::EnableIfAllProperties<void, Properties...> set_property(Properties&&... properties) {
|
util::EnableIfAllStringAny<void, Properties...> set_property(Properties&&... properties) {
|
||||||
set_property(AnyMap{std::forward<Properties>(properties)...});
|
set_property(AnyMap{std::forward<Properties>(properties)...});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class OPENVINO_RUNTIME_API Core {
|
|||||||
class Impl;
|
class Impl;
|
||||||
std::shared_ptr<Impl> _impl;
|
std::shared_ptr<Impl> _impl;
|
||||||
|
|
||||||
void get_property(const std::string& device_name, const std::string& name, ov::Any& to) const;
|
void get_property(const std::string& device_name, const std::string& name, const AnyMap& arguments, Any& to) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** @brief Constructs OpenVINO Core instance using XML configuration file with
|
/** @brief Constructs OpenVINO Core instance using XML configuration file with
|
||||||
@ -139,7 +139,7 @@ public:
|
|||||||
* @return A compiled model
|
* @return A compiled model
|
||||||
*/
|
*/
|
||||||
template <typename... Properties>
|
template <typename... Properties>
|
||||||
util::EnableIfAllProperties<CompiledModel, Properties...> compile_model(
|
util::EnableIfAllStringAny<CompiledModel, Properties...> compile_model(
|
||||||
const std::shared_ptr<const ov::Model>& model,
|
const std::shared_ptr<const ov::Model>& model,
|
||||||
Properties&&... properties) {
|
Properties&&... properties) {
|
||||||
return compile_model(model, AnyMap{std::forward<Properties>(properties)...});
|
return compile_model(model, AnyMap{std::forward<Properties>(properties)...});
|
||||||
@ -174,7 +174,7 @@ public:
|
|||||||
* @return A compiled model
|
* @return A compiled model
|
||||||
*/
|
*/
|
||||||
template <typename... Properties>
|
template <typename... Properties>
|
||||||
util::EnableIfAllProperties<CompiledModel, Properties...> compile_model(
|
util::EnableIfAllStringAny<CompiledModel, Properties...> compile_model(
|
||||||
const std::shared_ptr<const ov::Model>& model,
|
const std::shared_ptr<const ov::Model>& model,
|
||||||
const std::string& device_name,
|
const std::string& device_name,
|
||||||
Properties&&... properties) {
|
Properties&&... properties) {
|
||||||
@ -211,8 +211,8 @@ public:
|
|||||||
* @return A compiled model
|
* @return A compiled model
|
||||||
*/
|
*/
|
||||||
template <typename... Properties>
|
template <typename... Properties>
|
||||||
util::EnableIfAllProperties<CompiledModel, Properties...> compile_model(const std::string& model_path,
|
util::EnableIfAllStringAny<CompiledModel, Properties...> compile_model(const std::string& model_path,
|
||||||
Properties&&... properties) {
|
Properties&&... properties) {
|
||||||
return compile_model(model_path, AnyMap{std::forward<Properties>(properties)...});
|
return compile_model(model_path, AnyMap{std::forward<Properties>(properties)...});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,9 +248,9 @@ public:
|
|||||||
* @return A compiled model
|
* @return A compiled model
|
||||||
*/
|
*/
|
||||||
template <typename... Properties>
|
template <typename... Properties>
|
||||||
util::EnableIfAllProperties<CompiledModel, Properties...> compile_model(const std::string& model_path,
|
util::EnableIfAllStringAny<CompiledModel, Properties...> compile_model(const std::string& model_path,
|
||||||
const std::string& device_name,
|
const std::string& device_name,
|
||||||
Properties&&... properties) {
|
Properties&&... properties) {
|
||||||
return compile_model(model_path, device_name, AnyMap{std::forward<Properties>(properties)...});
|
return compile_model(model_path, device_name, AnyMap{std::forward<Properties>(properties)...});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,7 +276,7 @@ public:
|
|||||||
* @return A compiled model object
|
* @return A compiled model object
|
||||||
*/
|
*/
|
||||||
template <typename... Properties>
|
template <typename... Properties>
|
||||||
util::EnableIfAllProperties<CompiledModel, Properties...> compile_model(
|
util::EnableIfAllStringAny<CompiledModel, Properties...> compile_model(
|
||||||
const std::shared_ptr<const ov::Model>& model,
|
const std::shared_ptr<const ov::Model>& model,
|
||||||
const RemoteContext& context,
|
const RemoteContext& context,
|
||||||
Properties&&... properties) {
|
Properties&&... properties) {
|
||||||
@ -388,9 +388,9 @@ public:
|
|||||||
* @return A compiled model
|
* @return A compiled model
|
||||||
*/
|
*/
|
||||||
template <typename... Properties>
|
template <typename... Properties>
|
||||||
util::EnableIfAllProperties<CompiledModel, Properties...> import_model(std::istream& model_stream,
|
util::EnableIfAllStringAny<CompiledModel, Properties...> import_model(std::istream& model_stream,
|
||||||
const std::string& device_name,
|
const std::string& device_name,
|
||||||
Properties&&... properties) {
|
Properties&&... properties) {
|
||||||
return import_model(model_stream, device_name, AnyMap{std::forward<Properties>(properties)...});
|
return import_model(model_stream, device_name, AnyMap{std::forward<Properties>(properties)...});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,9 +416,9 @@ public:
|
|||||||
* @return A compiled model
|
* @return A compiled model
|
||||||
*/
|
*/
|
||||||
template <typename... Properties>
|
template <typename... Properties>
|
||||||
util::EnableIfAllProperties<CompiledModel, Properties...> import_model(std::istream& model_stream,
|
util::EnableIfAllStringAny<CompiledModel, Properties...> import_model(std::istream& model_stream,
|
||||||
const RemoteContext& context,
|
const RemoteContext& context,
|
||||||
Properties&&... properties) {
|
Properties&&... properties) {
|
||||||
return import_model(model_stream, context, AnyMap{std::forward<Properties>(properties)...});
|
return import_model(model_stream, context, AnyMap{std::forward<Properties>(properties)...});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,7 +445,7 @@ public:
|
|||||||
* @return An object containing a map of pairs a operation name -> a device name supporting this operation.
|
* @return An object containing a map of pairs a operation name -> a device name supporting this operation.
|
||||||
*/
|
*/
|
||||||
template <typename... Properties>
|
template <typename... Properties>
|
||||||
util::EnableIfAllProperties<SupportedOpsMap, Properties...> query_model(
|
util::EnableIfAllStringAny<SupportedOpsMap, Properties...> query_model(
|
||||||
const std::shared_ptr<const ov::Model>& model,
|
const std::shared_ptr<const ov::Model>& model,
|
||||||
const std::string& device_name,
|
const std::string& device_name,
|
||||||
Properties&&... properties) const {
|
Properties&&... properties) const {
|
||||||
@ -469,7 +469,7 @@ public:
|
|||||||
* @return nothing
|
* @return nothing
|
||||||
*/
|
*/
|
||||||
template <typename... Properties>
|
template <typename... Properties>
|
||||||
util::EnableIfAllProperties<void, Properties...> set_property(Properties&&... properties) {
|
util::EnableIfAllStringAny<void, Properties...> set_property(Properties&&... properties) {
|
||||||
set_property(AnyMap{std::forward<Properties>(properties)...});
|
set_property(AnyMap{std::forward<Properties>(properties)...});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -491,8 +491,8 @@ public:
|
|||||||
* @return nothing
|
* @return nothing
|
||||||
*/
|
*/
|
||||||
template <typename... Properties>
|
template <typename... Properties>
|
||||||
util::EnableIfAllProperties<void, Properties...> set_property(const std::string& device_name,
|
util::EnableIfAllStringAny<void, Properties...> set_property(const std::string& device_name,
|
||||||
Properties&&... properties) {
|
Properties&&... properties) {
|
||||||
set_property(device_name, AnyMap{std::forward<Properties>(properties)...});
|
set_property(device_name, AnyMap{std::forward<Properties>(properties)...});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -507,6 +507,18 @@ public:
|
|||||||
*/
|
*/
|
||||||
Any get_property(const std::string& device_name, const std::string& name) const;
|
Any get_property(const std::string& device_name, const std::string& name) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets properties dedicated to device behaviour.
|
||||||
|
*
|
||||||
|
* The method is targeted to extract information which can be set via set_property method.
|
||||||
|
*
|
||||||
|
* @param device_name - A name of a device to get a properties value.
|
||||||
|
* @param name - property name.
|
||||||
|
* @param arguments - additional arguments to get property
|
||||||
|
* @return Value of property corresponding to property name.
|
||||||
|
*/
|
||||||
|
Any get_property(const std::string& device_name, const std::string& name, const AnyMap& arguments) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gets properties dedicated to device behaviour.
|
* @brief Gets properties dedicated to device behaviour.
|
||||||
*
|
*
|
||||||
@ -514,6 +526,7 @@ public:
|
|||||||
* It can be device name, temperature, other devices-specific values.
|
* It can be device name, temperature, other devices-specific values.
|
||||||
*
|
*
|
||||||
* @tparam T - type of returned value
|
* @tparam T - type of returned value
|
||||||
|
* @tparam M - property mutability
|
||||||
* @param deviceName - A name of a device to get a properties value.
|
* @param deviceName - A name of a device to get a properties value.
|
||||||
* @param property - property object.
|
* @param property - property object.
|
||||||
* @return Property value.
|
* @return Property value.
|
||||||
@ -521,7 +534,50 @@ public:
|
|||||||
template <typename T, PropertyMutability M>
|
template <typename T, PropertyMutability M>
|
||||||
T get_property(const std::string& deviceName, const ov::Property<T, M>& property) const {
|
T get_property(const std::string& deviceName, const ov::Property<T, M>& property) const {
|
||||||
auto to = Any::make<T>();
|
auto to = Any::make<T>();
|
||||||
get_property(deviceName, property.name(), to);
|
get_property(deviceName, property.name(), {}, to);
|
||||||
|
return to.template as<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets properties dedicated to device behaviour.
|
||||||
|
*
|
||||||
|
* The method is needed to request common device or system properties.
|
||||||
|
* It can be device name, temperature, other devices-specific values.
|
||||||
|
*
|
||||||
|
* @tparam T - type of returned value
|
||||||
|
* @tparam M - property mutability
|
||||||
|
* @param deviceName - A name of a device to get a properties value.
|
||||||
|
* @param property - property object.
|
||||||
|
* @param arguments - additional arguments to get property
|
||||||
|
* @return Property value.
|
||||||
|
*/
|
||||||
|
template <typename T, PropertyMutability M>
|
||||||
|
T get_property(const std::string& deviceName, const ov::Property<T, M>& property, const AnyMap& arguments) const {
|
||||||
|
auto to = Any::make<T>();
|
||||||
|
get_property(deviceName, property.name(), arguments, to);
|
||||||
|
return to.template as<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets properties dedicated to device behaviour.
|
||||||
|
*
|
||||||
|
* The method is needed to request common device or system properties.
|
||||||
|
* It can be device name, temperature, other devices-specific values.
|
||||||
|
*
|
||||||
|
* @tparam T - type of returned value
|
||||||
|
* @tparam M - property mutability
|
||||||
|
* @tparam Args - set of additional arguments ended with property object variable
|
||||||
|
* @param deviceName - A name of a device to get a properties value.
|
||||||
|
* @param property - property object.
|
||||||
|
* @param args - Optional pack of pairs: (argument name, argument value) ended with property object
|
||||||
|
* @return Property value.
|
||||||
|
*/
|
||||||
|
template <typename T, PropertyMutability M, typename... Args>
|
||||||
|
util::EnableIfAllStringAny<T, Args...> get_property(const std::string& deviceName,
|
||||||
|
const ov::Property<T, M>& property,
|
||||||
|
Args&&... args) const {
|
||||||
|
auto to = Any::make<T>();
|
||||||
|
get_property(deviceName, property.name(), AnyMap{std::forward<Args>(args)...}, to);
|
||||||
return to.template as<T>();
|
return to.template as<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -609,8 +665,8 @@ public:
|
|||||||
* @return A shared pointer to a created remote context.
|
* @return A shared pointer to a created remote context.
|
||||||
*/
|
*/
|
||||||
template <typename... Properties>
|
template <typename... Properties>
|
||||||
util::EnableIfAllProperties<RemoteContext, Properties...> create_context(const std::string& device_name,
|
util::EnableIfAllStringAny<RemoteContext, Properties...> create_context(const std::string& device_name,
|
||||||
Properties&&... properties) {
|
Properties&&... properties) {
|
||||||
return create_context(device_name, AnyMap{std::forward<Properties>(properties)...});
|
return create_context(device_name, AnyMap{std::forward<Properties>(properties)...});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,29 +59,31 @@ private:
|
|||||||
|
|
||||||
/** @cond INTERNAL */
|
/** @cond INTERNAL */
|
||||||
namespace util {
|
namespace util {
|
||||||
|
struct PropertyTag {};
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
struct AllProperties;
|
struct StringAny;
|
||||||
|
|
||||||
template <typename T, typename... Args>
|
template <typename T, typename... Args>
|
||||||
struct AllProperties<T, Args...> {
|
struct StringAny<T, Args...> {
|
||||||
constexpr static const bool value =
|
constexpr static const bool value =
|
||||||
std::is_convertible<T, std::pair<std::string, ov::Any>>::value && AllProperties<Args...>::value;
|
std::is_convertible<T, std::pair<std::string, ov::Any>>::value && StringAny<Args...>::value;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct AllProperties<T> {
|
struct StringAny<T> {
|
||||||
constexpr static const bool value = std::is_convertible<T, std::pair<std::string, ov::Any>>::value;
|
constexpr static const bool value = std::is_convertible<T, std::pair<std::string, ov::Any>>::value;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T, typename... Args>
|
template <typename T, typename... Args>
|
||||||
using EnableIfAllProperties = typename std::enable_if<AllProperties<Args...>::value, T>::type;
|
using EnableIfAllStringAny = typename std::enable_if<StringAny<Args...>::value, T>::type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This class is used to bind property name with property type
|
* @brief This class is used to bind property name with property type
|
||||||
* @tparam T type of value used to pass or get property
|
* @tparam T type of value used to pass or get property
|
||||||
*/
|
*/
|
||||||
template <typename T, PropertyMutability mutability_ = PropertyMutability::RW>
|
template <typename T, PropertyMutability mutability_ = PropertyMutability::RW>
|
||||||
struct BaseProperty {
|
struct BaseProperty : public PropertyTag {
|
||||||
using value_type = T; //!< Property type
|
using value_type = T; //!< Property type
|
||||||
constexpr static const auto mutability = mutability_; //!< Property readability
|
constexpr static const auto mutability = mutability_; //!< Property readability
|
||||||
|
|
||||||
@ -468,7 +470,7 @@ struct Properties {
|
|||||||
* @return Pair of string key representation and type erased property value.
|
* @return Pair of string key representation and type erased property value.
|
||||||
*/
|
*/
|
||||||
template <typename... Properties>
|
template <typename... Properties>
|
||||||
inline util::EnableIfAllProperties<std::pair<std::string, Any>, Properties...> operator()(
|
inline util::EnableIfAllStringAny<std::pair<std::string, Any>, Properties...> operator()(
|
||||||
const std::string& device_name,
|
const std::string& device_name,
|
||||||
Properties&&... configs) const {
|
Properties&&... configs) const {
|
||||||
return {device_name, AnyMap{std::pair<std::string, Any>{configs}...}};
|
return {device_name, AnyMap{std::pair<std::string, Any>{configs}...}};
|
||||||
|
@ -1784,6 +1784,10 @@ void Core::set_property(const std::string& deviceName, const AnyMap& config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Any Core::get_property(const std::string& deviceName, const std::string& name) const {
|
Any Core::get_property(const std::string& deviceName, const std::string& name) const {
|
||||||
|
return get_property(deviceName, name, AnyMap{});
|
||||||
|
}
|
||||||
|
|
||||||
|
Any Core::get_property(const std::string& deviceName, const std::string& name, const AnyMap& arguments) const {
|
||||||
OPENVINO_ASSERT(deviceName.find("HETERO:") != 0,
|
OPENVINO_ASSERT(deviceName.find("HETERO:") != 0,
|
||||||
"You can only get_config of the HETERO itself (without devices). "
|
"You can only get_config of the HETERO itself (without devices). "
|
||||||
"get_config is also possible for the individual devices before creating the HETERO on top.");
|
"get_config is also possible for the individual devices before creating the HETERO on top.");
|
||||||
@ -1795,7 +1799,7 @@ Any Core::get_property(const std::string& deviceName, const std::string& name) c
|
|||||||
"get_config is also possible for the individual devices before creating the AUTO on top.");
|
"get_config is also possible for the individual devices before creating the AUTO on top.");
|
||||||
|
|
||||||
OV_CORE_CALL_STATEMENT({
|
OV_CORE_CALL_STATEMENT({
|
||||||
auto parsed = parseDeviceNameIntoConfig(deviceName);
|
auto parsed = parseDeviceNameIntoConfig(deviceName, arguments);
|
||||||
if (ov::supported_properties == name) {
|
if (ov::supported_properties == name) {
|
||||||
try {
|
try {
|
||||||
return _impl->GetCPPPluginByName(parsed._deviceName).get_metric(name, parsed._config);
|
return _impl->GetCPPPluginByName(parsed._deviceName).get_metric(name, parsed._config);
|
||||||
@ -1828,8 +1832,11 @@ Any Core::get_property(const std::string& deviceName, const std::string& name) c
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::get_property(const std::string& deviceName, const std::string& name, ov::Any& to) const {
|
void Core::get_property(const std::string& deviceName,
|
||||||
any_lexical_cast(get_property(deviceName, name), to);
|
const std::string& name,
|
||||||
|
const AnyMap& arguments,
|
||||||
|
ov::Any& to) const {
|
||||||
|
any_lexical_cast(get_property(deviceName, name, arguments), to);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> Core::get_available_devices() const {
|
std::vector<std::string> Core::get_available_devices() const {
|
||||||
|
@ -61,6 +61,7 @@ using OVClassGetMetricTest_SUPPORTED_METRICS = OVClassBaseTestP;
|
|||||||
using OVClassGetMetricTest_SUPPORTED_CONFIG_KEYS = OVClassBaseTestP;
|
using OVClassGetMetricTest_SUPPORTED_CONFIG_KEYS = OVClassBaseTestP;
|
||||||
using OVClassGetMetricTest_AVAILABLE_DEVICES = OVClassBaseTestP;
|
using OVClassGetMetricTest_AVAILABLE_DEVICES = OVClassBaseTestP;
|
||||||
using OVClassGetMetricTest_FULL_DEVICE_NAME = OVClassBaseTestP;
|
using OVClassGetMetricTest_FULL_DEVICE_NAME = OVClassBaseTestP;
|
||||||
|
using OVClassGetMetricTest_FULL_DEVICE_NAME_with_DEVICE_ID = OVClassBaseTestP;
|
||||||
using OVClassGetMetricTest_OPTIMIZATION_CAPABILITIES = OVClassBaseTestP;
|
using OVClassGetMetricTest_OPTIMIZATION_CAPABILITIES = OVClassBaseTestP;
|
||||||
using OVClassGetMetricTest_DEVICE_GOPS = OVClassBaseTestP;
|
using OVClassGetMetricTest_DEVICE_GOPS = OVClassBaseTestP;
|
||||||
using OVClassGetMetricTest_DEVICE_TYPE = OVClassBaseTestP;
|
using OVClassGetMetricTest_DEVICE_TYPE = OVClassBaseTestP;
|
||||||
@ -551,6 +552,21 @@ TEST_P(OVClassGetMetricTest_FULL_DEVICE_NAME, GetMetricAndPrintNoThrow) {
|
|||||||
OV_ASSERT_PROPERTY_SUPPORTED(ov::device::full_name);
|
OV_ASSERT_PROPERTY_SUPPORTED(ov::device::full_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_P(OVClassGetMetricTest_FULL_DEVICE_NAME_with_DEVICE_ID, GetMetricAndPrintNoThrow) {
|
||||||
|
ov::Core ie = createCoreWithTemplate();
|
||||||
|
std::string t;
|
||||||
|
|
||||||
|
if (supportsDeviceID(ie, deviceName)) {
|
||||||
|
auto device_ids = ie.get_property(deviceName, ov::available_devices);
|
||||||
|
ASSERT_GT(device_ids.size(), 0);
|
||||||
|
OV_ASSERT_NO_THROW(t = ie.get_property(deviceName, ov::device::full_name, ov::device::id(device_ids.front())));
|
||||||
|
std::cout << "Device " << device_ids.front() << " " << ", Full device name: " << std::endl << t << std::endl;
|
||||||
|
OV_ASSERT_PROPERTY_SUPPORTED(ov::device::full_name);
|
||||||
|
} else {
|
||||||
|
GTEST_SKIP() << "Device id is not supported";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TEST_P(OVClassGetMetricTest_OPTIMIZATION_CAPABILITIES, GetMetricAndPrintNoThrow) {
|
TEST_P(OVClassGetMetricTest_OPTIMIZATION_CAPABILITIES, GetMetricAndPrintNoThrow) {
|
||||||
ov::Core ie = createCoreWithTemplate();
|
ov::Core ie = createCoreWithTemplate();
|
||||||
std::vector<std::string> t;
|
std::vector<std::string> t;
|
||||||
|
Loading…
Reference in New Issue
Block a user