Skip to content

Commit

Permalink
Apply snake_case to ov::Core API (openvinotoolkit#15313)
Browse files Browse the repository at this point in the history
  • Loading branch information
vurusovs authored Jan 27, 2023
1 parent 532df18 commit ef8481d
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 157 deletions.
2 changes: 1 addition & 1 deletion src/inference/include/ie/ie_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class INFERENCE_ENGINE_API_CLASS(Core) {
* 1. (default) Use XML configuration file in case of dynamic libraries build;
* 2. Use strictly defined configuration in case of static libraries build.
*
* @param xml_config_file Path to the .xml file with plugins to load from. If the XML configuration file is not
* @param xmlConfigFile Path to the .xml file with plugins to load from. If the XML configuration file is not
* specified, default OpenVINO Runtime plugins are loaded from:
* 1. (dynamic build) default `plugins.xml` file located in the same folder as OpenVINO runtime shared library;
* 2. (static build) statically defined configuration. In this case path to the .xml file is ignored.
Expand Down
21 changes: 10 additions & 11 deletions src/inference/include/openvino/runtime/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,13 +576,13 @@ class OPENVINO_RUNTIME_API Core {
*
* @tparam T Type of a returned value.
* @tparam M Property mutability.
* @param deviceName Name of a device to get a property value.
* @param device_name Name of a device to get a property value.
* @param property Property object.
* @return Property value.
*/
template <typename T, PropertyMutability M>
T get_property(const std::string& deviceName, const ov::Property<T, M>& property) const {
return get_property(deviceName, property.name(), {}).template as<T>();
T get_property(const std::string& device_name, const ov::Property<T, M>& property) const {
return get_property(device_name, property.name(), {}).template as<T>();
}

/**
Expand All @@ -593,14 +593,14 @@ class OPENVINO_RUNTIME_API Core {
*
* @tparam T Type of a returned value.
* @tparam M Property mutability.
* @param deviceName Name of a device to get a property value.
* @param device_name Name of a device to get a property value.
* @param property Property object.
* @param arguments Additional arguments to get a 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 {
return get_property(deviceName, property.name(), arguments).template as<T>();
T get_property(const std::string& device_name, const ov::Property<T, M>& property, const AnyMap& arguments) const {
return get_property(device_name, property.name(), arguments).template as<T>();
}

/**
Expand All @@ -612,16 +612,16 @@ class OPENVINO_RUNTIME_API Core {
* @tparam T Type of a returned value.
* @tparam M Property mutability.
* @tparam Args Set of additional arguments ended with property object variable.
* @param deviceName Name of a device to get a property value.
* @param device_name Name of a device to get a property 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,
util::EnableIfAllStringAny<T, Args...> get_property(const std::string& device_name,
const ov::Property<T, M>& property,
Args&&... args) const {
return get_property(deviceName, property.name(), AnyMap{std::forward<Args>(args)...}).template as<T>();
return get_property(device_name, property.name(), AnyMap{std::forward<Args>(args)...}).template as<T>();
}

/**
Expand Down Expand Up @@ -687,8 +687,7 @@ class OPENVINO_RUNTIME_API Core {
* for different systems with different configurations.
* - `properties` are set to a plugin via the ov::Core::set_property method.
* - `extensions` are set to a plugin via the ov::Core::add_extension method.
* Notes:
* - For security purposes it suggested to specify absolute path to register plugin.
* @note For security purposes it suggested to specify absolute path to register plugin.
*
* @param xml_config_file A path to .xml file with plugins to register.
*/
Expand Down
88 changes: 43 additions & 45 deletions src/inference/src/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,38 +45,36 @@ class Core::Impl : public CoreImpl {
Impl() : ov::CoreImpl(true) {}
};

Core::Core(const std::string& xmlConfigFile) {
Core::Core(const std::string& xml_config_file) {
_impl = std::make_shared<Impl>();

#ifdef OPENVINO_STATIC_LIBRARY
OV_CORE_CALL_STATEMENT(_impl->register_plugins_in_registry(::getStaticPluginsRegistry());)
#else
OV_CORE_CALL_STATEMENT({
OV_CORE_CALL_STATEMENT(
// If XML is default, load default plugins by absolute paths
auto loadByAbsPath = xmlConfigFile.empty();
_impl->register_plugins_in_registry(findPluginXML(xmlConfigFile), loadByAbsPath);
})
_impl->register_plugins_in_registry(findPluginXML(xml_config_file), xml_config_file.empty());)
#endif
}

std::map<std::string, Version> Core::get_versions(const std::string& deviceName) const {
std::map<std::string, Version> Core::get_versions(const std::string& device_name) const {
OV_CORE_CALL_STATEMENT({
std::map<std::string, Version> versions;
for (auto&& kvp : _impl->GetVersions(deviceName)) {
for (auto&& kvp : _impl->GetVersions(device_name)) {
versions[kvp.first] = Version{kvp.second.buildNumber, kvp.second.description};
}
return versions;
})
}
#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT
std::shared_ptr<ov::Model> Core::read_model(const std::wstring& modelPath, const std::wstring& binPath) const {
std::shared_ptr<ov::Model> Core::read_model(const std::wstring& model_path, const std::wstring& bin_path) const {
OV_CORE_CALL_STATEMENT(
return _impl->read_model(ov::util::wstring_to_string(modelPath), ov::util::wstring_to_string(binPath)););
return _impl->read_model(ov::util::wstring_to_string(model_path), ov::util::wstring_to_string(bin_path)););
}
#endif

std::shared_ptr<ov::Model> Core::read_model(const std::string& modelPath, const std::string& binPath) const {
OV_CORE_CALL_STATEMENT(return _impl->read_model(modelPath, binPath););
std::shared_ptr<ov::Model> Core::read_model(const std::string& model_path, const std::string& bin_path) const {
OV_CORE_CALL_STATEMENT(return _impl->read_model(model_path, bin_path););
}

std::shared_ptr<ov::Model> Core::read_model(const std::string& model, const ov::Tensor& weights) const {
Expand All @@ -88,31 +86,31 @@ CompiledModel Core::compile_model(const std::shared_ptr<const ov::Model>& model,
}

CompiledModel Core::compile_model(const std::shared_ptr<const ov::Model>& model,
const std::string& deviceName,
const std::string& device_name,
const AnyMap& config) {
OV_CORE_CALL_STATEMENT({
auto exec = _impl->compile_model(model, deviceName, flatten_sub_properties(deviceName, config));
auto exec = _impl->compile_model(model, device_name, flatten_sub_properties(device_name, config));
return {exec._ptr, exec._so};
});
}

CompiledModel Core::compile_model(const std::string& modelPath, const AnyMap& config) {
return compile_model(modelPath, ov::DEFAULT_DEVICE_NAME, config);
CompiledModel Core::compile_model(const std::string& model_path, const AnyMap& config) {
return compile_model(model_path, ov::DEFAULT_DEVICE_NAME, config);
}

CompiledModel Core::compile_model(const std::string& modelPath, const std::string& deviceName, const AnyMap& config) {
CompiledModel Core::compile_model(const std::string& model_path, const std::string& device_name, const AnyMap& config) {
OV_CORE_CALL_STATEMENT({
auto exec = _impl->compile_model(modelPath, deviceName, flatten_sub_properties(deviceName, config));
auto exec = _impl->compile_model(model_path, device_name, flatten_sub_properties(device_name, config));
return {exec._ptr, exec._so};
});
}

CompiledModel Core::compile_model(const std::string& model,
const ov::Tensor& weights,
const std::string& deviceName,
const std::string& device_name,
const AnyMap& config) {
OV_CORE_CALL_STATEMENT({
auto exec = _impl->compile_model(model, weights, deviceName, flatten_sub_properties(deviceName, config));
auto exec = _impl->compile_model(model, weights, device_name, flatten_sub_properties(device_name, config));
return {exec._ptr, exec._so};
});
}
Expand Down Expand Up @@ -172,10 +170,10 @@ void Core::add_extension(const std::vector<std::shared_ptr<ov::Extension>>& exte
OV_CORE_CALL_STATEMENT({ _impl->add_extension(extensions); });
}

CompiledModel Core::import_model(std::istream& modelStream, const std::string& deviceName, const AnyMap& config) {
CompiledModel Core::import_model(std::istream& modelStream, const std::string& device_name, const AnyMap& config) {
OV_ITT_SCOPED_TASK(ov::itt::domains::IE, "Core::import_model");
OV_CORE_CALL_STATEMENT({
auto exec = _impl->import_model(modelStream, deviceName, flatten_sub_properties(deviceName, config));
auto exec = _impl->import_model(modelStream, device_name, flatten_sub_properties(device_name, config));
return {exec._ptr, exec._so};
});
}
Expand All @@ -191,9 +189,9 @@ CompiledModel Core::import_model(std::istream& modelStream, const RemoteContext&
}

SupportedOpsMap Core::query_model(const std::shared_ptr<const ov::Model>& model,
const std::string& deviceName,
const std::string& device_name,
const AnyMap& config) const {
OV_CORE_CALL_STATEMENT(return _impl->query_model(model, deviceName, flatten_sub_properties(deviceName, config)););
OV_CORE_CALL_STATEMENT(return _impl->query_model(model, device_name, flatten_sub_properties(device_name, config)););
}

void Core::set_property(const AnyMap& properties) {
Expand All @@ -204,56 +202,56 @@ void Core::set_property(const std::string& device_name, const AnyMap& properties
OV_CORE_CALL_STATEMENT(return _impl->set_property(device_name, properties););
}

Any Core::get_property(const std::string& deviceName, const std::string& name) const {
OV_CORE_CALL_STATEMENT(return _impl->get_property(deviceName, name, {}););
Any Core::get_property(const std::string& device_name, const std::string& name) const {
OV_CORE_CALL_STATEMENT(return _impl->get_property(device_name, name, {}););
}

Any Core::get_property(const std::string& deviceName, const std::string& name, const AnyMap& arguments) const {
OV_CORE_CALL_STATEMENT(return _impl->get_property(deviceName, name, arguments););
Any Core::get_property(const std::string& device_name, const std::string& name, const AnyMap& arguments) const {
OV_CORE_CALL_STATEMENT(return _impl->get_property(device_name, name, arguments););
}

std::vector<std::string> Core::get_available_devices() const {
OV_CORE_CALL_STATEMENT(return _impl->GetAvailableDevices(););
}

void Core::register_plugin(const std::string& pluginName, const std::string& deviceName) {
OV_CORE_CALL_STATEMENT(_impl->register_plugin(pluginName, deviceName););
void Core::register_plugin(const std::string& plugin, const std::string& device_name) {
OV_CORE_CALL_STATEMENT(_impl->register_plugin(plugin, device_name););
}

void Core::unload_plugin(const std::string& deviceName) {
void Core::unload_plugin(const std::string& device_name) {
OV_CORE_CALL_STATEMENT({
ie::DeviceIDParser parser(deviceName);
ie::DeviceIDParser parser(device_name);
std::string devName = parser.getDeviceName();

_impl->unload_plugin(devName);
});
}

void Core::register_plugins(const std::string& xmlConfigFile) {
OV_CORE_CALL_STATEMENT(_impl->register_plugins_in_registry(xmlConfigFile););
void Core::register_plugins(const std::string& xml_config_file) {
OV_CORE_CALL_STATEMENT(_impl->register_plugins_in_registry(xml_config_file););
}

RemoteContext Core::create_context(const std::string& deviceName, const AnyMap& params) {
OPENVINO_ASSERT(deviceName.find("HETERO") != 0, "HETERO device does not support remote context");
OPENVINO_ASSERT(deviceName.find("MULTI") != 0, "MULTI device does not support remote context");
OPENVINO_ASSERT(deviceName.find("AUTO") != 0, "AUTO device does not support remote context");
OPENVINO_ASSERT(deviceName.find("BATCH") != 0, "BATCH device does not support remote context");
RemoteContext Core::create_context(const std::string& device_name, const AnyMap& params) {
OPENVINO_ASSERT(device_name.find("HETERO") != 0, "HETERO device does not support remote context");
OPENVINO_ASSERT(device_name.find("MULTI") != 0, "MULTI device does not support remote context");
OPENVINO_ASSERT(device_name.find("AUTO") != 0, "AUTO device does not support remote context");
OPENVINO_ASSERT(device_name.find("BATCH") != 0, "BATCH device does not support remote context");

OV_CORE_CALL_STATEMENT({
auto parsed = parseDeviceNameIntoConfig(deviceName, flatten_sub_properties(deviceName, params));
auto parsed = parseDeviceNameIntoConfig(device_name, flatten_sub_properties(device_name, params));
auto remoteContext = _impl->get_plugin(parsed._deviceName).create_context(parsed._config);
return {remoteContext._impl, {remoteContext._so}};
});
}

RemoteContext Core::get_default_context(const std::string& deviceName) {
OPENVINO_ASSERT(deviceName.find("HETERO") != 0, "HETERO device does not support default remote context");
OPENVINO_ASSERT(deviceName.find("MULTI") != 0, "MULTI device does not support default remote context");
OPENVINO_ASSERT(deviceName.find("AUTO") != 0, "AUTO device does not support default remote context");
OPENVINO_ASSERT(deviceName.find("BATCH") != 0, "BATCH device does not support default remote context");
RemoteContext Core::get_default_context(const std::string& device_name) {
OPENVINO_ASSERT(device_name.find("HETERO") != 0, "HETERO device does not support default remote context");
OPENVINO_ASSERT(device_name.find("MULTI") != 0, "MULTI device does not support default remote context");
OPENVINO_ASSERT(device_name.find("AUTO") != 0, "AUTO device does not support default remote context");
OPENVINO_ASSERT(device_name.find("BATCH") != 0, "BATCH device does not support default remote context");

OV_CORE_CALL_STATEMENT({
auto parsed = parseDeviceNameIntoConfig(deviceName, AnyMap{});
auto parsed = parseDeviceNameIntoConfig(device_name, AnyMap{});
auto remoteContext = _impl->get_plugin(parsed._deviceName).get_default_context(parsed._config);
return {remoteContext._impl, {remoteContext._so}};
});
Expand Down
Loading

0 comments on commit ef8481d

Please sign in to comment.