Skip to content

Commit

Permalink
[openvino] new recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-lavrenov committed Sep 8, 2023
1 parent b2f903b commit 081dff1
Show file tree
Hide file tree
Showing 9 changed files with 755 additions and 0 deletions.
31 changes: 31 additions & 0 deletions recipes/openvino/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
sources:
"2023.1.0":
"openvino":
url: "https://github.com/openvinotoolkit/openvino/archive/47b736f63edda256d66e2bbb572f42a9d6549f6e.tar.gz"
sha256: "8a1dd5b35fe4b60440e97ee61e12e01aa4dd78b5be30550aa08fcd96c416e1d7"
"arm_compute":
url: "https://github.com/ARM-software/ComputeLibrary/archive/refs/tags/v23.02.1.tar.gz"
sha256: "c3a443e26539f866969242e690cf0651ef629149741ee18732f954c734da6763"
"onednn_cpu":
url: "https://github.com/openvinotoolkit/oneDNN/archive/ae825539bd850d1ad5c83d4bb0d56c65d46d5842.tar.gz"
sha256: "1204df17785c8603f9dfa1f4f91e91e5ffd4391bf7680d2b256de2513490ebee"
"mlas":
url: "https://github.com/openvinotoolkit/mlas/archive/c7c8a631315000f17c650af34431009d2f22129c.tar.gz"
sha256: "7b790dfeef8e1dd612f920c85186c52ad3a3e2245e2a2afd6cc91ce4b1dc64a9"
"onednn_gpu":
url: "https://github.com/oneapi-src/oneDNN/archive/4b82a66ed38ecaa993352e5cc6ed7753656b8a26.tar.gz"
sha256: "cb17c003fe51bc9b4e20189573956b4446468162adf0fc4cea2ee0820cff0cd0"
patches:
"2023.1.0":
- patch_file: "patches/2023.1.0/0001-cpu-plugin-compilation-c++17.patch"
patch_description: "Fixed CPU plugin compilation with C++17"
patch_type: "portability"
patch_source: "https://github.com/openvinotoolkit/openvino/pull/19628"
- patch_file: "patches/2023.1.0/0002-core-compilation-c++17.patch"
patch_description: "Fixed OpenVINO Core compilation with C++17"
patch_type: "portability"
patch_source: "https://github.com/openvinotoolkit/openvino/pull/19707"
- patch_file: "patches/2023.1.0/0003-gpu-plugin-compilation-with-conan-opencl.patch"
patch_description: "Fixed OpenVINO Intel GPU plugin compilation with OpenCL fron Conan"
patch_type: "portability"
patch_source: "https://github.com/openvinotoolkit/openvino/pull/19668"
402 changes: 402 additions & 0 deletions recipes/openvino/all/conanfile.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/src/plugins/intel_cpu/src/cpu_tensor.cpp b/src/plugins/intel_cpu/src/cpu_tensor.cpp
index 48d8fdd4be..815edd9309 100644
--- a/src/plugins/intel_cpu/src/cpu_tensor.cpp
+++ b/src/plugins/intel_cpu/src/cpu_tensor.cpp
@@ -68,8 +68,9 @@ void Tensor::update_strides() const {
OPENVINO_ASSERT(blocked_desc, "not a valid blocked memory descriptor.");
auto& strides = blocked_desc->getStrides();
m_strides.resize(strides.size());
- std::transform(strides.cbegin(), strides.cend(), m_strides.begin(),
- std::bind1st(std::multiplies<size_t>(), m_element_type.size()));
+ std::transform(strides.cbegin(), strides.cend(), m_strides.begin(), [this] (const size_t stride) {
+ return stride * m_element_type.size();
+ });
}

void* Tensor::data(const element::Type& element_type) const {
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
diff --git a/src/frontends/common/src/utils.cpp b/src/frontends/common/src/utils.cpp
index 8ef7481551..3a0db585fd 100644
--- a/src/frontends/common/src/utils.cpp
+++ b/src/frontends/common/src/utils.cpp
@@ -12,10 +12,6 @@
# include <dlfcn.h>
# include <limits.h>
# include <unistd.h>
-# ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT
-# include <codecvt>
-# include <locale>
-# endif
#else
# if defined(WINAPI_FAMILY) && !WINAPI_PARTITION_DESKTOP
# error "Only WINAPI_PARTITION_DESKTOP is supported, because of GetModuleHandleEx[A|W]"
diff --git a/src/frontends/paddle/src/input_model.cpp b/src/frontends/paddle/src/input_model.cpp
index 6987b3285e..287fa5e54a 100644
--- a/src/frontends/paddle/src/input_model.cpp
+++ b/src/frontends/paddle/src/input_model.cpp
@@ -13,14 +13,10 @@
#include "openvino/frontend/paddle/node_context.hpp"
#include "openvino/opsets/opset7.hpp"
#include "openvino/util/common_util.hpp"
+#include "openvino/util/file_util.hpp"
#include "paddle_utils.hpp"
#include "place.hpp"

-#if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32)
-# include <codecvt>
-# include <locale>
-#endif
-
namespace ov {
namespace frontend {
namespace paddle {
@@ -169,9 +165,7 @@ std::basic_string<T> get_const_path(const std::basic_string<T>& folder_with_weig
#if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32)
template <>
std::basic_string<wchar_t> get_const_path(const std::basic_string<wchar_t>& folder, const std::string& name) {
- std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
- std::wstring _name = converter.from_bytes(name);
- return folder + paddle::get_path_sep<wchar_t>() + _name;
+ return folder + paddle::get_path_sep<wchar_t>() + ov::util::string_to_wstring(name);
}
#endif

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 461f1a209c..0b552b3da3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -47,6 +47,7 @@ message (STATUS "CMAKE_GENERATOR ....................... " ${CMAKE_GENERATOR})
message (STATUS "CPACK_GENERATOR ....................... " ${CPACK_GENERATOR})
message (STATUS "CMAKE_C_COMPILER_ID ................... " ${CMAKE_C_COMPILER_ID})
message (STATUS "CMAKE_CXX_COMPILER_ID ................. " ${CMAKE_CXX_COMPILER_ID})
+message (STATUS "CMAKE_CXX_STANDARD .................... " ${CMAKE_CXX_STANDARD})
if(OV_GENERATOR_MULTI_CONFIG)
string(REPLACE ";" " " config_types "${CMAKE_CONFIGURATION_TYPES}")
message (STATUS "CMAKE_CONFIGURATION_TYPES ............. " ${config_types})
diff --git a/src/plugins/intel_gpu/thirdparty/CMakeLists.txt b/src/plugins/intel_gpu/thirdparty/CMakeLists.txt
index c7c616d0df..7a3132d8b1 100644
--- a/src/plugins/intel_gpu/thirdparty/CMakeLists.txt
+++ b/src/plugins/intel_gpu/thirdparty/CMakeLists.txt
@@ -62,6 +62,9 @@ if(ENABLE_ONEDNN_FOR_GPU)
list(APPEND cmake_extra_args "-DCMAKE_CONFIGURATION_TYPES=${CMAKE_DEFAULT_BUILD_TYPE}")
list(APPEND cmake_extra_args "-DCMAKE_DEFAULT_BUILD_TYPE=${CMAKE_DEFAULT_BUILD_TYPE}")
endif()
+ # sometimes $<CONFIG> is evaluated as real build type even for non-multi-config generators
+ # so, have to put under OV_GENERATOR_MULTI_CONFIG (example: docker pull conanio/gcc11-ubuntu16.04:latest)
+ list(APPEND cmake_config "$<CONFIG>")
else()
list(APPEND cmake_extra_args "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
endif()
@@ -114,7 +117,7 @@ if(ENABLE_ONEDNN_FOR_GPU)
"-DDNNL_GPU_RUNTIME=OCL"
"-DDNNL_LIBRARY_NAME=openvino_onednn_gpu"
"-DCMAKE_INSTALL_PREFIX=${ONEDNN_INSTALL_DIR}"
- "-DCMAKE_INSTALL_LIBDIR=lib/$<CONFIG>"
+ "-DCMAKE_INSTALL_LIBDIR=lib/${cmake_config}"
"-DDNNL_ENABLE_CONCURRENT_EXEC=ON"
"-DDNNL_ENABLE_PRIMITIVE_CACHE=OFF"
"-DDNNL_ENABLE_WORKLOAD=INFERENCE"
@@ -132,7 +135,7 @@ if(ENABLE_ONEDNN_FOR_GPU)
)
add_library(onednn_gpu_tgt INTERFACE)
set_target_properties(onednn_gpu_tgt PROPERTIES
- INTERFACE_LINK_DIRECTORIES "${ONEDNN_INSTALL_DIR}/lib/$<CONFIG>"
+ INTERFACE_LINK_DIRECTORIES "${ONEDNN_INSTALL_DIR}/lib/${cmake_config}"
INTERFACE_LINK_LIBRARIES "openvino_onednn_gpu"
INTERFACE_INCLUDE_DIRECTORIES "${ONEDNN_INSTALL_DIR}/include"
INTERFACE_COMPILE_DEFINITIONS ENABLE_ONEDNN_FOR_GPU
48 changes: 48 additions & 0 deletions recipes/openvino/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES CXX)

macro(add_component def comp)
if(${def})
list(APPEND OpenVINO_COMPONENTS ${comp})
endif()
endmacro()

add_component(ENABLE_ONNX_FRONTEND ONNX)
add_component(ENABLE_PADDLE_FRONTEND Paddle)
add_component(ENABLE_TF_FRONTEND TensorFlow)
add_component(ENABLE_TF_LITE_FRONTEND TensorFlowLite)
add_component(ENABLE_PYTORCH_FRONTEND PyTroch)

find_package(OpenVINO REQUIRED COMPONENTS Runtime ${OpenVINO_COMPONENTS})

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE openvino::runtime)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)

function(add_plugin def)
if(${def})
target_compile_definitions(${PROJECT_NAME} PRIVATE ${def})
endif()
endfunction()

add_plugin(ENABLE_INTEL_CPU)
add_plugin(ENABLE_INTEL_GPU)
add_plugin(ENABLE_AUTO)
add_plugin(ENABLE_HETERO)
add_plugin(ENABLE_AUTO_BATCH)

function(add_frontend def frontend)
if(${def})
target_compile_definitions(${PROJECT_NAME} PRIVATE ${def})
if(NOT TARGET openvino::frontend::${frontend})
message(FATAL_ERROR "Target for ${frontend} has not been created")
endif()
endif()
endfunction()

add_plugin(ENABLE_IR_FRONTEND)
add_frontend(ENABLE_ONNX_FRONTEND onnx)
add_frontend(ENABLE_PADDLE_FRONTEND paddle)
add_frontend(ENABLE_TF_FRONTEND tensorflow)
add_frontend(ENABLE_TF_LITE_FRONTEND tensorflow_lite)
add_frontend(ENABLE_PYTORCH_FRONTEND pytorch)
49 changes: 49 additions & 0 deletions recipes/openvino/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "VirtualRunEnv"
test_type = "explicit"

def layout(self):
cmake_layout(self)

def requirements(self):
self.requires(self.tested_reference_str)

def generate(self):
deps = CMakeDeps(self)
# deps.check_components_exist = True
deps.generate()

tc = CMakeToolchain(self)
tc.variables["CMAKE_VERBOSE_MAKEFILE"] = True
# HW plugins
tc.variables["ENABLE_INTEL_CPU"] = self.dependencies[self.tested_reference_str].options.enable_cpu
tc.variables["ENABLE_INTEL_GPU"] = self.dependencies[self.tested_reference_str].options.get_safe("enable_gpu", False)
# SW plugins
tc.variables["ENABLE_AUTO"] = self.dependencies[self.tested_reference_str].options.enable_auto
tc.variables["ENABLE_HETERO"] = self.dependencies[self.tested_reference_str].options.enable_hetero
tc.variables["ENABLE_AUTO_BATCH"] = self.dependencies[self.tested_reference_str].options.enable_auto_batch
# Frontends
tc.variables["ENABLE_IR_FRONTEND"] = self.dependencies[self.tested_reference_str].options.enable_ir_frontend
tc.variables["ENABLE_ONNX_FRONTEND"] = self.dependencies[self.tested_reference_str].options.enable_onnx_frontend
tc.variables["ENABLE_TF_FRONTEND"] = self.dependencies[self.tested_reference_str].options.enable_tf_frontend
tc.variables["ENABLE_TF_LITE_FRONTEND"] = self.dependencies[self.tested_reference_str].options.enable_tf_lite_frontend
tc.variables["ENABLE_PADDLE_FRONTEND"] = self.dependencies[self.tested_reference_str].options.enable_paddle_frontend
tc.variables["ENABLE_PYTORCH_FRONTEND"] = self.dependencies[self.tested_reference_str].options.enable_pytorch_frontend
tc.generate()

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
116 changes: 116 additions & 0 deletions recipes/openvino/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#include <openvino/c/openvino.h>
#include <openvino/core/visibility.hpp>
#include <openvino/frontend/manager.hpp>

#include <iostream>

#define OV_SUCCESS(statement) \
if ((statement) != 0) \
return 1;

#define OV_FAIL(statement) \
if ((statement) == 0) \
return 1;

int test_available_devices() {
ov_core_t* core = NULL;
char* ret = NULL;
OV_SUCCESS(ov_core_create(&core));
#ifdef ENABLE_INTEL_CPU
OV_SUCCESS(ov_core_get_property(core, "CPU", "AVAILABLE_DEVICES", &ret));
std::cout << "CPU has passed with SUCCESS" << std::endl;
#else
OV_FAIL(ov_core_get_property(core, "CPU", "AVAILABLE_DEVICES", &ret));
std::cout << "CPU has passed with FAIL" << std::endl;
#endif
#ifdef ENABLE_INTEL_GPU
OV_SUCCESS(ov_core_get_property(core, "GPU", "AVAILABLE_DEVICES", &ret));
std::cout << "GPU has passed with SUCCESS" << std::endl;
#else
OV_FAIL(ov_core_get_property(core, "GPU", "AVAILABLE_DEVICES", &ret));
std::cout << "GPU has passed with FAIL" << std::endl;
#endif
#ifdef ENABLE_AUTO
OV_SUCCESS(ov_core_get_property(core, "AUTO", "SUPPORTED_METRICS", &ret));
OV_SUCCESS(ov_core_get_property(core, "MULTI", "SUPPORTED_METRICS", &ret));
std::cout << "AUTO / MULTI has passed with SUCCESS" << std::endl;
#else
OV_FAIL(ov_core_get_property(core, "AUTO", "SUPPORTED_METRICS", &ret));
OV_FAIL(ov_core_get_property(core, "MULTI", "SUPPORTED_METRICS", &ret));
std::cout << "AUTO / MULTI has passed with FAIL" << std::endl;
#endif
#ifdef ENABLE_HETERO
OV_SUCCESS(ov_core_get_property(core, "HETERO", "SUPPORTED_METRICS", &ret));
std::cout << "HETERO has passed with SUCCESS" << std::endl;
#else
OV_FAIL(ov_core_get_property(core, "HETERO", "SUPPORTED_METRICS", &ret));
std::cout << "HETERO has passed with FAIL" << std::endl;
#endif
#ifdef ENABLE_AUTO_BATCH
OV_SUCCESS(ov_core_get_property(core, "BATCH", "SUPPORTED_METRICS", &ret));
std::cout << "BATCH has passed with SUCCESS" << std::endl;
#else
OV_FAIL(ov_core_get_property(core, "BATCH", "SUPPORTED_METRICS", &ret));
std::cout << "BATCH has passed with FAIL" << std::endl;
#endif
ov_core_free(core);
return 0;
}

int test_available_frontends() {
ov::frontend::FrontEndManager manager;
auto frontend_found = [&] (const std::string & name) -> int {
try {
manager.load_by_framework(name);
std::cout << name << " has passed with SUCCESS" << std::endl;
} catch (const std::exception & e) {
std::cout << name << " has passed with FAIL" << std::endl;
return 1;
}
return 0;
};

#ifdef ENABLE_IR_FRONTEND
OV_SUCCESS(frontend_found("ir"));
#else
OV_FAIL(frontend_found("ir"));
#endif
#ifdef ENABLE_TF_LITE_FRONTEND
OV_SUCCESS(frontend_found("tflite"));
#else
OV_FAIL(frontend_found("tflite"));
#endif
#ifdef ENABLE_PYTORCH_FRONTEND
OV_SUCCESS(frontend_found("pytorch"));
#else
OV_FAIL(frontend_found("pytorch"));
#endif
#ifdef ENABLE_ONNX_FRONTEND
OV_SUCCESS(frontend_found("onnx"));
#else
OV_FAIL(frontend_found("onnx"));
#endif
#ifdef ENABLE_TF_FRONTEND
OV_SUCCESS(frontend_found("tf"));
#else
OV_FAIL(frontend_found("tf"));
#endif
#ifdef ENABLE_PADDLE_FRONTEND
OV_SUCCESS(frontend_found("paddle"));
#else
OV_FAIL(frontend_found("paddle"));
#endif
return 0;
}

int main() {
OV_SUCCESS(test_available_devices());
OV_SUCCESS(test_available_frontends());

// Deinitialize OpenVINO. Important for old systems like Ubuntu 16.04 with obsolete glibc,
// where application deinit can lead to the following issue on exit:
// Inconsistency detected by ld.so: dl-close.c: 811: _dl_close: Assertion `map->l_init_called' failed!
ov::shutdown();

return 0;
}
3 changes: 3 additions & 0 deletions recipes/openvino/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"2023.1.0":
folder: "all"

0 comments on commit 081dff1

Please sign in to comment.