diff --git a/cmake/developer_package/version.cmake b/cmake/developer_package/version.cmake index 799912b4619..e8d4fdb3d3d 100644 --- a/cmake/developer_package/version.cmake +++ b/cmake/developer_package/version.cmake @@ -49,14 +49,28 @@ macro(ie_parse_ci_build_number) message(FATAL_ERROR "File ie_version.hpp with IE_VERSION definitions is not found") endif() - file(STRINGS "${ie_version_hpp}" IE_VERSION_PARTS REGEX "#define IE_VERSION_[A-Z]+[ ]+" ) + set(ov_version_hpp "${OpenVINO_SOURCE_DIR}/ngraph/core/include/openvino/core/version.hpp") + if(NOT EXISTS ${ov_version_hpp}) + message(FATAL_ERROR "File openvino/core/version.hpp with OPENVINO_VERSION definitions is not found") + endif() - string(REGEX REPLACE ".+IE_VERSION_MAJOR[ ]+([0-9]+).*" "\\1" - IE_VERSION_MAJOR_HPP "${IE_VERSION_PARTS}") - string(REGEX REPLACE ".+IE_VERSION_MINOR[ ]+([0-9]+).*" "\\1" - IE_VERSION_MINOR_HPP "${IE_VERSION_PARTS}") - string(REGEX REPLACE ".+IE_VERSION_PATCH[ ]+([0-9]+).*" "\\1" - IE_VERSION_PATCH_HPP "${IE_VERSION_PARTS}") + file(STRINGS "${ie_version_hpp}" IE_VERSION_PARTS REGEX "#define IE_VERSION_[A-Z]+[ ]+" ) + file(STRINGS "${ov_version_hpp}" OV_VERSION_PARTS REGEX "#define OPENVINO_VERSION_[A-Z]+[ ]+" ) + + foreach(suffix MAJOR MINOR PATCH) + set(ie_version_name "IE_VERSION_${suffix}") + set(ov_version_name "OPENVINO_VERSION_${suffix}") + + string(REGEX REPLACE ".+${ie_version_name}[ ]+([0-9]+).*" "\\1" + ${ie_version_name}_HPP "${IE_VERSION_PARTS}") + string(REGEX REPLACE ".+${ov_version_name}[ ]+([0-9]+).*" "\\1" + ${ov_version_name}_HPP "${OV_VERSION_PARTS}") + + if(NOT ${ie_version_name}_HPP EQUAL ${ov_version_name}_HPP) + message(FATAL_ERROR "${ov_version_name} (${${ov_version_name}_HPP})" + " and ${ie_version_name} (${${ie_version_name}_HPP}) are not equal") + endif() + endforeach() set(ie_hpp_version_is_found ON) endmacro() @@ -95,14 +109,22 @@ endif() # 2. Otherwise, parses ie_version.hpp ie_parse_ci_build_number() -function (addVersionDefines FILE) +macro (addVersionDefines FILE) + set(__version_file ${FILE}) + if(NOT IS_ABSOLUTE ${__version_file}) + set(__version_file "${CMAKE_CURRENT_SOURCE_DIR}/${__version_file}") + endif() + if(NOT EXISTS ${__version_file}) + message(FATAL_ERROR "${FILE} does not exists in current source directory") + endif() foreach (VAR ${ARGN}) if (DEFINED ${VAR} AND NOT "${${VAR}}" STREQUAL "") set_property( - SOURCE ${FILE} + SOURCE ${__version_file} APPEND PROPERTY COMPILE_DEFINITIONS ${VAR}="${${VAR}}") endif() endforeach() -endfunction() + unset(__version_file) +endmacro() diff --git a/inference-engine/src/inference_engine/include/openvino/runtime/common.hpp b/inference-engine/src/inference_engine/include/openvino/runtime/common.hpp index 33748156028..af3eb4aa645 100644 --- a/inference-engine/src/inference_engine/include/openvino/runtime/common.hpp +++ b/inference-engine/src/inference_engine/include/openvino/runtime/common.hpp @@ -31,13 +31,12 @@ /** * @def OPENVINO_PLUGIN_API(type) * @brief Defines OpenVINO Runtime Plugin API method - * @param type A plugin type */ #ifdef IMPLEMENT_INFERENCE_ENGINE_PLUGIN -# define OPENVINO_PLUGIN_API(type) OPENVINO_EXTERN_C OPENVINO_CORE_EXPORTS type +# define OPENVINO_PLUGIN_API OPENVINO_EXTERN_C OPENVINO_CORE_EXPORTS #else -# define OPENVINO_PLUGIN_API(type) OPENVINO_EXTERN_C type +# define OPENVINO_PLUGIN_API OPENVINO_EXTERN_C #endif namespace InferenceEngine {} diff --git a/inference-engine/src/inference_engine/include/openvino/runtime/core.hpp b/inference-engine/src/inference_engine/include/openvino/runtime/core.hpp index cdb523184ba..a240e11e4e8 100644 --- a/inference-engine/src/inference_engine/include/openvino/runtime/core.hpp +++ b/inference-engine/src/inference_engine/include/openvino/runtime/core.hpp @@ -16,7 +16,7 @@ #include #include "ie_plugin_config.hpp" -#include "ie_version.hpp" +#include "openvino/core/version.hpp" #include "openvino/runtime/common.hpp" #include "openvino/runtime/executable_network.hpp" #include "openvino/runtime/remote_context.hpp" @@ -59,7 +59,7 @@ public: * @param deviceName Device name to identify plugin * @return A vector of versions */ - std::map get_versions(const std::string& deviceName) const; + std::map get_versions(const std::string& deviceName) const; #ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT /** diff --git a/inference-engine/src/inference_engine/src/ie_core.cpp b/inference-engine/src/inference_engine/src/ie_core.cpp index 87a0e30181e..7eb8d320aeb 100644 --- a/inference-engine/src/inference_engine/src/ie_core.cpp +++ b/inference-engine/src/inference_engine/src/ie_core.cpp @@ -1241,8 +1241,14 @@ Core::Core(const std::string& xmlConfigFile) { OV_CORE_CALL_STATEMENT(register_plugins(parseXmlConfig(xmlConfigFile))); } -std::map Core::get_versions(const std::string& deviceName) const { - OV_CORE_CALL_STATEMENT(return _impl->GetVersions(deviceName)) +std::map Core::get_versions(const std::string& deviceName) const { + OV_CORE_CALL_STATEMENT({ + std::map versions; + for (auto&& kvp : _impl->GetVersions(deviceName)) { + versions[kvp.first] = Version{kvp.second.buildNumber, kvp.second.description}; + } + return versions; + }) } #ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT @@ -1264,29 +1270,33 @@ std::shared_ptr Core::read_model(const std::string& model, con ExecutableNetwork Core::compile_model(const std::shared_ptr& network, const std::string& deviceName, const ConfigMap& config) { - OV_CORE_CALL_STATEMENT( + OV_CORE_CALL_STATEMENT({ auto exec = _impl->LoadNetwork(ie::CNNNetwork(std::const_pointer_cast(network)), deviceName, config); return {exec.operator const InferenceEngine::details::SharedObjectLoader&().get(), - exec.operator std::shared_ptr&()};); + exec.operator std::shared_ptr&()}; + }); } ExecutableNetwork Core::compile_model(const std::string& modelPath, const std::string& deviceName, const ConfigMap& config) { - OV_CORE_CALL_STATEMENT(auto exec = _impl->LoadNetwork(modelPath, deviceName, config); - return {exec.operator const InferenceEngine::details::SharedObjectLoader&().get(), - exec.operator std::shared_ptr&()};); + OV_CORE_CALL_STATEMENT({ + auto exec = _impl->LoadNetwork(modelPath, deviceName, config); + return {exec.operator const InferenceEngine::details::SharedObjectLoader&().get(), + exec.operator std::shared_ptr&()}; + }); } ExecutableNetwork Core::compile_model(const std::shared_ptr& network, const RemoteContext& context, const ConfigMap& config) { - OV_CORE_CALL_STATEMENT(auto exec = - _impl->LoadNetwork(ie::CNNNetwork(std::const_pointer_cast(network)), - context._impl, - config); - return {exec._so, exec._ptr};); + OV_CORE_CALL_STATEMENT({ + auto exec = _impl->LoadNetwork(ie::CNNNetwork(std::const_pointer_cast(network)), + context._impl, + config); + return {exec._so, exec._ptr}; + }); } void Core::add_extension(const ie::IExtensionPtr& extension) { @@ -1297,9 +1307,11 @@ ExecutableNetwork Core::import_model(std::istream& networkModel, const std::string& deviceName, const ConfigMap& config) { OV_ITT_SCOPED_TASK(ov::itt::domains::IE, "Core::import_model"); - OV_CORE_CALL_STATEMENT(auto exec = _impl->ImportNetwork(networkModel, deviceName, config); - return {exec.operator const InferenceEngine::details::SharedObjectLoader&().get(), - exec.operator std::shared_ptr&()};); + OV_CORE_CALL_STATEMENT({ + auto exec = _impl->ImportNetwork(networkModel, deviceName, config); + return {exec.operator const InferenceEngine::details::SharedObjectLoader&().get(), + exec.operator std::shared_ptr&()}; + }); } ExecutableNetwork Core::import_model(std::istream& networkModel, @@ -1323,16 +1335,20 @@ ExecutableNetwork Core::import_model(std::istream& networkModel, } networkModel.seekg(currentPos, networkModel.beg); - OV_CORE_CALL_STATEMENT(auto exec = _impl->GetCPPPluginByName(deviceName).import_model(networkModel, {}); - return {exec._so, exec._ptr};); + OV_CORE_CALL_STATEMENT({ + auto exec = _impl->GetCPPPluginByName(deviceName).import_model(networkModel, {}); + return {exec._so, exec._ptr}; + }); } SupportedOpsMap Core::query_model(const std::shared_ptr& network, const std::string& deviceName, const ConfigMap& config) const { - OV_CORE_CALL_STATEMENT(auto cnnNet = ie::CNNNetwork(std::const_pointer_cast(network)); - auto qnResult = _impl->QueryNetwork(cnnNet, deviceName, config); - return qnResult.supportedLayersMap;); + OV_CORE_CALL_STATEMENT({ + auto cnnNet = ie::CNNNetwork(std::const_pointer_cast(network)); + auto qnResult = _impl->QueryNetwork(cnnNet, deviceName, config); + return qnResult.supportedLayersMap; + }); } void Core::set_config(const ConfigMap& config, const std::string& deviceName) { @@ -1351,11 +1367,14 @@ void Core::set_config(const ConfigMap& config, const std::string& deviceName) { "set_config is supported only for device family itself (without particular device .#). " "You can pass .# as a particular device instance to query_model, compile_model, import_model only"); - OV_CORE_CALL_STATEMENT( - if (deviceName.empty()) { _impl->SetConfigForPlugins(config, std::string()); } else { + OV_CORE_CALL_STATEMENT({ + if (deviceName.empty()) { + _impl->SetConfigForPlugins(config, std::string()); + } else { auto parsed = parseDeviceNameIntoConfig(deviceName, config); _impl->SetConfigForPlugins(parsed._config, parsed._deviceName); - }); + } + }); } Parameter Core::get_config(const std::string& deviceName, const std::string& name) const { @@ -1369,13 +1388,14 @@ Parameter Core::get_config(const std::string& deviceName, const std::string& nam "You can only get_config of the AUTO itself (without devices). " "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); // we need to return a copy of Parameter object which is created on Core side, // not in ie plugin side, which can be unloaded from Core in a parallel thread // TODO: remove this WA after *-31417 is resolved - return copyParameterValue(_impl->GetCPPPluginByName(parsed._deviceName).get_config(name, parsed._config));); + return copyParameterValue(_impl->GetCPPPluginByName(parsed._deviceName).get_config(name, parsed._config)); + }); } Parameter Core::get_metric(const std::string& deviceName, const std::string& name) const { @@ -1391,9 +1411,12 @@ void Core::register_plugin(const std::string& pluginName, const std::string& dev } void Core::unload_plugin(const std::string& deviceName) { - OV_CORE_CALL_STATEMENT(ie::DeviceIDParser parser(deviceName); std::string devName = parser.getDeviceName(); + OV_CORE_CALL_STATEMENT({ + ie::DeviceIDParser parser(deviceName); + std::string devName = parser.getDeviceName(); - _impl->UnloadPluginByName(devName);); + _impl->UnloadPluginByName(devName); + }); } void Core::register_plugins(const std::string& xmlConfigFile) { @@ -1405,10 +1428,11 @@ RemoteContext Core::create_context(const std::string& deviceName, const ParamMap 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"); - OV_CORE_CALL_STATEMENT(auto parsed = parseDeviceNameIntoConfig(deviceName, params); - auto remoteContext = - _impl->GetCPPPluginByName(parsed._deviceName).create_context(parsed._config); - return {remoteContext._so, remoteContext._ptr};); + OV_CORE_CALL_STATEMENT({ + auto parsed = parseDeviceNameIntoConfig(deviceName, params); + auto remoteContext = _impl->GetCPPPluginByName(parsed._deviceName).create_context(parsed._config); + return {remoteContext._so, remoteContext._ptr}; + }); } RemoteContext Core::get_default_context(const std::string& deviceName) { @@ -1416,10 +1440,11 @@ RemoteContext Core::get_default_context(const std::string& deviceName) { 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"); - OV_CORE_CALL_STATEMENT(auto parsed = parseDeviceNameIntoConfig(deviceName, ParamMap()); - auto remoteContext = - _impl->GetCPPPluginByName(parsed._deviceName).get_default_context(parsed._config); - return {remoteContext._so, remoteContext._ptr};); + OV_CORE_CALL_STATEMENT({ + auto parsed = parseDeviceNameIntoConfig(deviceName, ParamMap()); + auto remoteContext = _impl->GetCPPPluginByName(parsed._deviceName).get_default_context(parsed._config); + return {remoteContext._so, remoteContext._ptr}; + }); } } // namespace runtime diff --git a/inference-engine/src/readers/ir_reader_v7/ie_ir_reader.cpp b/inference-engine/src/readers/ir_reader_v7/ie_ir_reader.cpp index 470885257f8..2ddba71a563 100644 --- a/inference-engine/src/readers/ir_reader_v7/ie_ir_reader.cpp +++ b/inference-engine/src/readers/ir_reader_v7/ie_ir_reader.cpp @@ -42,6 +42,6 @@ CNNNetwork IRReader::read(std::istream& model, const Blob::CPtr& weights, const return CNNNetwork(parser.parse(root, weights)); } -OPENVINO_PLUGIN_API(void) InferenceEngine::CreateReader(std::shared_ptr& reader) { +OPENVINO_PLUGIN_API void InferenceEngine::CreateReader(std::shared_ptr& reader) { reader = std::make_shared(); } diff --git a/inference-engine/src/readers/reader_api/ie_reader.hpp b/inference-engine/src/readers/reader_api/ie_reader.hpp index b63757a4c9c..399afc10240 100644 --- a/inference-engine/src/readers/reader_api/ie_reader.hpp +++ b/inference-engine/src/readers/reader_api/ie_reader.hpp @@ -58,6 +58,6 @@ protected: * @brief Creates the default instance of the reader * @return Reader interface */ -OPENVINO_PLUGIN_API(void) CreateReader(std::shared_ptr& reader); +OPENVINO_PLUGIN_API void CreateReader(std::shared_ptr& reader); } // namespace InferenceEngine diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.cpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.cpp index fb83ff57c13..89be4ca019b 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.cpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.cpp @@ -133,17 +133,17 @@ std::string MockPlugin::GetName() const noexcept { InferenceEngine::IInferencePlugin *__target = nullptr; -OPENVINO_PLUGIN_API(void) CreatePluginEngine(std::shared_ptr& plugin) { +OPENVINO_PLUGIN_API void CreatePluginEngine(std::shared_ptr& plugin) { IInferencePlugin *p = nullptr; std::swap(__target, p); plugin = std::make_shared(p); } -OPENVINO_PLUGIN_API(InferenceEngine::IInferencePlugin*) +OPENVINO_PLUGIN_API InferenceEngine::IInferencePlugin* CreatePluginEngineProxy(InferenceEngine::IInferencePlugin *target) { return new MockPlugin(target); } -OPENVINO_PLUGIN_API(void) InjectProxyEngine(InferenceEngine::IInferencePlugin *target) { +OPENVINO_PLUGIN_API void InjectProxyEngine(InferenceEngine::IInferencePlugin *target) { __target = target; } diff --git a/ngraph/core/CMakeLists.txt b/ngraph/core/CMakeLists.txt index 8f9772091d5..f4f2aae971a 100644 --- a/ngraph/core/CMakeLists.txt +++ b/ngraph/core/CMakeLists.txt @@ -17,8 +17,6 @@ add_subdirectory(reference) source_group("src" FILES ${LIBRARY_SRC}) source_group("include" FILES ${PUBLIC_HEADERS}) -configure_file(include/ngraph/version.in.hpp include/ngraph/version.hpp) - # Create static or shared library depending on BUILD_SHARED_LIBS add_library(ngraph ${LIBRARY_SRC} ${PUBLIC_HEADERS}) @@ -39,6 +37,8 @@ if(COMMAND ie_add_vs_version_file) FILEDESCRIPTION "nGraph library") endif() +addVersionDefines(src/version.cpp CI_BUILD_NUMBER) + target_link_libraries(ngraph PRIVATE ngraph::builder ngraph::reference openvino::util) ie_mark_target_as_cc(ngraph) @@ -71,8 +71,7 @@ set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/src/pass/convert_precis # Defines macro in C++ to load backend plugin target_include_directories(ngraph PUBLIC $ - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src - ${CMAKE_CURRENT_BINARY_DIR}/include) + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src) # Add an alias so that library can be used inside the build tree, e.g. when testing add_library(ngraph::ngraph ALIAS ngraph) @@ -103,12 +102,7 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ COMPONENT ngraph_dev FILES_MATCHING PATTERN "*.hpp" - PATTERN "*.h" - PATTERN "*version.in.hpp" EXCLUDE) - -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/ngraph/version.hpp - DESTINATION "runtime/include/ngraph" - COMPONENT ngraph_dev) + PATTERN "*.h") configure_package_config_file(${OpenVINO_SOURCE_DIR}/cmake/templates/ngraphConfig.cmake.in ${ngraph_BINARY_DIR}/ngraphConfig.cmake diff --git a/ngraph/core/include/ngraph/ngraph.hpp b/ngraph/core/include/ngraph/ngraph.hpp index a759eae29b6..8cee2eb06a0 100644 --- a/ngraph/core/include/ngraph/ngraph.hpp +++ b/ngraph/core/include/ngraph/ngraph.hpp @@ -11,6 +11,7 @@ #include #include "ngraph/deprecated.hpp" +#include "ngraph/version.hpp" #ifdef IN_NGRAPH_LIBRARY # error("ngraph.hpp is for external use only") diff --git a/ngraph/core/include/ngraph/ngraph_visibility.hpp b/ngraph/core/include/ngraph/ngraph_visibility.hpp index c19bc8f5591..0e913378317 100644 --- a/ngraph/core/include/ngraph/ngraph_visibility.hpp +++ b/ngraph/core/include/ngraph/ngraph_visibility.hpp @@ -5,8 +5,10 @@ #include "ngraph/visibility.hpp" #include "openvino/core/core_visibility.hpp" -#define NGRAPH_API OPENVINO_API +#define NGRAPH_API OPENVINO_API +#define NGRAPH_API_C OPENVINO_API_C +#define NGRAPH_EXTERN_C OPENVINO_EXTERN_C -#ifdef ENABLE_UNICODE_PATH_SUPPORT -# define OPENVINO_ENABLE_UNICODE_PATH_SUPPORT +#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT +# define ENABLE_UNICODE_PATH_SUPPORT #endif diff --git a/ngraph/core/include/ngraph/version.hpp b/ngraph/core/include/ngraph/version.hpp new file mode 100644 index 00000000000..32b21432df4 --- /dev/null +++ b/ngraph/core/include/ngraph/version.hpp @@ -0,0 +1,7 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "ngraph/ngraph_visibility.hpp" + +NGRAPH_EXTERN_C NGRAPH_API const char* NGRAPH_VERSION_NUMBER; diff --git a/ngraph/core/include/ngraph/version.in.hpp b/ngraph/core/include/ngraph/version.in.hpp deleted file mode 100644 index ac5f3934c26..00000000000 --- a/ngraph/core/include/ngraph/version.in.hpp +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -const char* NGRAPH_VERSION_NUMBER = "${CI_BUILD_NUMBER}"; diff --git a/ngraph/core/include/openvino/core/core_visibility.hpp b/ngraph/core/include/openvino/core/core_visibility.hpp index 82f60293a69..0152fb157ff 100644 --- a/ngraph/core/include/openvino/core/core_visibility.hpp +++ b/ngraph/core/include/openvino/core/core_visibility.hpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#pragma once + #include "openvino/core/visibility.hpp" #define OV_NEW_API 1 @@ -16,11 +18,13 @@ #ifdef NGRAPH_STATIC_LIBRARY // defined if we are building or calling NGRAPH as a static library # define OPENVINO_API -# define OPENVINO_API +# define OPENVINO_API_C(...) __VA_ARGS__ #else # ifdef ngraph_EXPORTS // defined if we are building the NGRAPH DLL (instead of using it) -# define OPENVINO_API OPENVINO_CORE_EXPORTS +# define OPENVINO_API OPENVINO_CORE_EXPORTS +# define OPENVINO_API_C(...) OPENVINO_EXTERN_C OPENVINO_CORE_EXPORTS __VA_ARGS__ OPENVINO_CDECL # else -# define OPENVINO_API OPENVINO_CORE_IMPORTS +# define OPENVINO_API OPENVINO_CORE_IMPORTS +# define OPENVINO_API_C(...) OPENVINO_EXTERN_C OPENVINO_CORE_IMPORTS __VA_ARGS__ OPENVINO_CDECL # endif // ngraph_EXPORTS #endif // NGRAPH_STATIC_LIBRARY diff --git a/ngraph/core/include/openvino/core/version.hpp b/ngraph/core/include/openvino/core/version.hpp new file mode 100644 index 00000000000..593340bf3df --- /dev/null +++ b/ngraph/core/include/openvino/core/version.hpp @@ -0,0 +1,48 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "openvino/core/core_visibility.hpp" + +/** + * @def OPENVINO_VERSION_MAJOR + * @brief Defines OpenVINO major version + * + * @def OPENVINO_VERSION_MINOR + * @brief Defines OpenVINO minor version + * + * @def OPENVINO_VERSION_PATCH + * @brief Defines OpenVINO patch version + */ + +#define OPENVINO_VERSION_MAJOR 2022 +#define OPENVINO_VERSION_MINOR 1 +#define OPENVINO_VERSION_PATCH 0 + +namespace ov { + +/** + * @struct Version + * @brief Represents version information that describes plugins and the OpemVINO library + */ +#pragma pack(push, 1) +struct Version { + /** + * @brief A null terminated string with build number + */ + const char* buildNumber; + + /** + * @brief A null terminated description string + */ + const char* description; +}; +#pragma pack(pop) + +/** + * @brief Gets the current OpenVINO version + * @return The current OpenVINO version + */ +OPENVINO_API_C(const Version*) get_openvino_version() noexcept; + +} // namespace ov diff --git a/ngraph/core/src/ngraph.cpp b/ngraph/core/src/ngraph.cpp index 69e0d84d0da..8403d374250 100644 --- a/ngraph/core/src/ngraph.cpp +++ b/ngraph/core/src/ngraph.cpp @@ -6,17 +6,16 @@ #include "ngraph/util.hpp" #include "ngraph/version.hpp" - -using namespace std; +#include "openvino/core/version.hpp" extern "C" NGRAPH_API const char* get_ngraph_version_string() { - return NGRAPH_VERSION_NUMBER; + return ov::get_openvino_version()->buildNumber; } namespace ngraph { NGRAPH_API void get_version(size_t& major, size_t& minor, size_t& patch, std::string& extra) { NGRAPH_SUPPRESS_DEPRECATED_START - string version = NGRAPH_VERSION_NUMBER; + std::string version = get_ngraph_version_string(); ngraph::parse_version_string(version, major, minor, patch, extra); NGRAPH_SUPPRESS_DEPRECATED_END } diff --git a/ngraph/core/src/version.cpp b/ngraph/core/src/version.cpp new file mode 100644 index 00000000000..4edfce14b94 --- /dev/null +++ b/ngraph/core/src/version.cpp @@ -0,0 +1,18 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "openvino/core/version.hpp" + +#include "ngraph/version.hpp" + +const char* NGRAPH_VERSION_NUMBER = CI_BUILD_NUMBER; + +namespace ov { + +const Version* get_openvino_version() noexcept { + static const Version version = {NGRAPH_VERSION_NUMBER, "OpenVINO Runtime"}; + return &version; +} + +} // namespace ov diff --git a/ngraph/test/util.cpp b/ngraph/test/util.cpp index e94c2dacd85..0d57bd8d8be 100644 --- a/ngraph/test/util.cpp +++ b/ngraph/test/util.cpp @@ -18,6 +18,7 @@ #include "ngraph/opsets/opset8.hpp" #include "ngraph/pass/manager.hpp" #include "ngraph/pass/visualize_tree.hpp" +#include "openvino/core/version.hpp" #include "util/all_close.hpp" #include "util/ndarray.hpp" @@ -25,6 +26,16 @@ NGRAPH_SUPPRESS_DEPRECATED_START using namespace std; using namespace ngraph; +TEST(openvino_version, version) { + auto version = ov::get_openvino_version(); + ASSERT_EQ(std::string("OpenVINO Runtime"), version->description); + ASSERT_FALSE(std::string(version->buildNumber).empty()); +} + +TEST(ngraph_version_variable, version) { + ASSERT_FALSE(std::string(NGRAPH_VERSION_NUMBER).empty()); +} + TEST(util, split) { { string s1 = "this,is,a,test";