Removed pointer from ov::get_openvino_version (#8687)

* Removed pointer from ov::get_openvino_version

* Fixed issues with version print

* Clang-format
This commit is contained in:
Ilya Lavrenov
2021-11-22 15:21:09 +03:00
committed by GitHub
parent b05d90032b
commit 7c10998cf8
14 changed files with 39 additions and 40 deletions

View File

@@ -44,6 +44,6 @@ struct Version {
* @brief Gets the current OpenVINO version
* @return The current OpenVINO version
*/
OPENVINO_API_C(const Version*) get_openvino_version() noexcept;
OPENVINO_API_C(const Version) get_openvino_version() noexcept;
} // namespace ov

View File

@@ -11,7 +11,7 @@
OPENVINO_SUPPRESS_DEPRECATED_START
const char* get_ngraph_version_string() {
return ov::get_openvino_version()->buildNumber;
return ov::get_openvino_version().buildNumber;
}
void ngraph::get_version(size_t& major, size_t& minor, size_t& patch, std::string& extra) {

View File

@@ -10,9 +10,9 @@ const char* NGRAPH_VERSION_NUMBER = CI_BUILD_NUMBER;
namespace ov {
const Version* get_openvino_version() noexcept {
const Version get_openvino_version() noexcept {
static const Version version = {NGRAPH_VERSION_NUMBER, "OpenVINO Runtime"};
return &version;
return version;
}
} // namespace ov

View File

@@ -29,8 +29,8 @@ 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());
ASSERT_EQ(std::string("OpenVINO Runtime"), version.description);
ASSERT_FALSE(std::string(version.buildNumber).empty());
}
TEST(ngraph_version_variable, version) {

View File

@@ -7,7 +7,7 @@
#include <pybind11/numpy.h>
#include "ngraph/validation_util.hpp"
#include "openvino/core/version.hpp"
#include "ngraph/version.hpp"
namespace py = pybind11;
@@ -37,6 +37,8 @@ void regmodule_pyngraph_util(py::module m) {
)");
mod.def("get_ngraph_version_string", []() -> std::string {
return ov::get_openvino_version()->buildNumber;
NGRAPH_SUPPRESS_DEPRECATED_START
return get_ngraph_version_string();
NGRAPH_SUPPRESS_DEPRECATED_END
});
}

View File

@@ -53,7 +53,7 @@ std::string get_version() {
auto version = ov::get_openvino_version();
std::string version_str = std::to_string(OPENVINO_VERSION_MAJOR) + ".";
version_str += std::to_string(OPENVINO_VERSION_MINOR) + ".";
version_str += version->buildNumber;
version_str += version.buildNumber;
return version_str;
}

View File

@@ -207,7 +207,7 @@ int main(int argc, char* argv[]) {
slog::info << "InferenceEngine: " << GetInferenceEngineVersion() << slog::endl;
slog::info << "Device info: " << slog::endl;
std::cout << ie.GetVersions(device_name) << std::endl;
slog::info << ie.GetVersions(device_name) << slog::endl;
// ----------------- 3. Setting device configuration
// -----------------------------------------------------------

View File

@@ -62,7 +62,7 @@ bool ParseAndCheckCommandLine(int argc, char* argv[]) {
int main(int argc, char* argv[]) {
try {
// -------- Get OpenVINO Runtime version --------
slog::info << "OpenVINO runtime: " << ov::get_openvino_version() << slog::endl;
slog::info << ov::get_openvino_version() << slog::endl;
// -------- Parsing and validation of input arguments --------
if (!ParseAndCheckCommandLine(argc, argv)) {

View File

@@ -24,6 +24,7 @@
#include <vector>
#include "openvino/openvino.hpp"
#include "slog.hpp"
#ifndef UNUSED
# if defined(_MSC_VER) && !defined(__clang__)
@@ -101,7 +102,7 @@ inline std::string& trim(std::string& s) {
* @param filepath - full file name
* @return filename without extension
*/
static UNUSED std::string fileNameNoExt(const std::string& filepath) {
inline std::string fileNameNoExt(const std::string& filepath) {
auto pos = filepath.rfind('.');
if (pos == std::string::npos)
return filepath;
@@ -120,46 +121,40 @@ inline std::string fileExt(const std::string& filename) {
return filename.substr(pos + 1);
}
inline std::ostream& operator<<(std::ostream& os, const InferenceEngine::Version& version) {
os << "\t" << version.description << " version ......... ";
os << IE_VERSION_MAJOR << "." << IE_VERSION_MINOR << "." << IE_VERSION_PATCH;
inline slog::LogStream& operator<<(slog::LogStream& os, const InferenceEngine::Version& version) {
os << version.description << " version ......... ";
os << IE_VERSION_MAJOR << "." << IE_VERSION_MINOR << "." << IE_VERSION_PATCH << slog::endl;
os << "\n\tBuild ........... ";
os << version.buildNumber;
os << "Build ........... ";
os << version.buildNumber << slog::endl;
return os;
}
inline std::ostream& operator<<(std::ostream& os, const ov::Version& version) {
os << "\t" << version.description << " version ......... ";
os << OPENVINO_VERSION_MAJOR << "." << OPENVINO_VERSION_MINOR << "." << OPENVINO_VERSION_PATCH;
inline slog::LogStream& operator<<(slog::LogStream& os, const ov::Version& version) {
os << version.description << " version ......... ";
os << OPENVINO_VERSION_MAJOR << "." << OPENVINO_VERSION_MINOR << "." << OPENVINO_VERSION_PATCH << slog::endl;
os << "\n\tBuild ........... ";
os << version.buildNumber;
os << "Build ........... ";
os << version.buildNumber << slog::endl;
return os;
}
inline std::ostream& operator<<(std::ostream& os, const InferenceEngine::Version* version) {
if (nullptr != version) {
os << std::endl << *version;
}
return os;
}
inline std::ostream& operator<<(std::ostream& os, const std::map<std::string, InferenceEngine::Version>& versions) {
inline slog::LogStream& operator<<(slog::LogStream& os,
const std::map<std::string, InferenceEngine::Version>& versions) {
for (auto&& version : versions) {
os << "\t" << version.first << std::endl;
os << version.second << std::endl;
os << version.first << slog::endl;
os << version.second << slog::endl;
}
return os;
}
inline std::ostream& operator<<(std::ostream& os, const std::map<std::string, ov::Version>& versions) {
inline slog::LogStream& operator<<(slog::LogStream& os, const std::map<std::string, ov::Version>& versions) {
for (auto&& version : versions) {
os << "\t" << version.first << std::endl;
os << version.second << std::endl;
os << version.first << slog::endl;
os << version.second << slog::endl;
}
return os;

View File

@@ -18,6 +18,8 @@ LogStream::LogStream(const std::string& prefix, std::ostream& log_stream) : _pre
// Specializing for LogStreamEndLine to support slog::endl
LogStream& LogStream::operator<<(const LogStreamEndLine& /*arg*/) {
if (_new_line)
(*_log_stream) << "[ " << _prefix << " ] ";
_new_line = true;
(*_log_stream) << std::endl;

View File

@@ -249,7 +249,7 @@ std::shared_ptr<ov::Function> createNgraphFunction() {
int main(int argc, char* argv[]) {
try {
// -------- Get OpenVINO runtime version --------
slog::info << "OpenVINO Runtime: " << ov::get_openvino_version() << slog::endl;
slog::info << ov::get_openvino_version() << slog::endl;
// -------- Parsing and validation of input arguments --------
if (!ParseAndCheckCommandLine(argc, argv)) {
@@ -266,7 +266,7 @@ int main(int argc, char* argv[]) {
runtime::Core core;
slog::info << "Device info: " << slog::endl;
std::cout << core.get_versions(FLAGS_d) << std::endl;
slog::info << core.get_versions(FLAGS_d) << slog::endl;
// -------- Step 2. Create network using ov::Function --------

View File

@@ -86,7 +86,7 @@ int main(int argc, char* argv[]) {
// ------------------------------ Get Available Devices
// ------------------------------------------------------
slog::info << "Device info: " << slog::endl;
std::cout << ie.GetVersions(FLAGS_d) << std::endl;
slog::info << ie.GetVersions(FLAGS_d) << slog::endl;
if (!FLAGS_l.empty()) {
IExtensionPtr extension_ptr = std::make_shared<Extension>(FLAGS_l);

View File

@@ -586,7 +586,7 @@ int main(int argc, char* argv[]) {
std::string deviceStr = useHetero && useGna ? "HETERO:GNA,CPU" : FLAGS_d.substr(0, (FLAGS_d.find("_")));
slog::info << "Device info: " << slog::endl;
std::cout << ie.GetVersions(deviceStr) << std::endl;
slog::info << ie.GetVersions(deviceStr) << slog::endl;
// -----------------------------------------------------------------------------------------------------
// --------------------------- Step 2. Read a model in OpenVINO Intermediate Representation (.xml and .bin

View File

@@ -76,7 +76,7 @@ int main(int argc, char* argv[]) {
// ------------------------------ Get Available Devices
// ------------------------------------------------------
slog::info << "Device info: " << slog::endl;
std::cout << ie.GetVersions(FLAGS_d) << std::endl;
slog::info << ie.GetVersions(FLAGS_d) << slog::endl;
if (!FLAGS_l.empty()) {
IExtensionPtr extension_ptr = std::make_shared<Extension>(FLAGS_l);