Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethan Tao committed Apr 24, 2020
2 parents 4aa033b + f48b9e2 commit e9f1e7e
Show file tree
Hide file tree
Showing 91 changed files with 3,831 additions and 2,479 deletions.
36 changes: 22 additions & 14 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,17 +227,27 @@ See more information on the nGraph Execution Provider [here](./docs/execution_pr
See more information on the OpenVINO Execution Provider [here](./docs/execution_providers/OpenVINO-ExecutionProvider.md).
#### Pre-Requisites
* Install the OpenVINO release along with its dependencies: [Windows]([https://software.intel.com/en-us/openvino-toolkit](https://software.intel.com/en-us/openvino-toolkit), [Linux](https://software.intel.com/en-us/openvino-toolkit).
* For Linux, currently supports and is validated on OpenVINO 2019 R3.1
* For Windows, download the 2019 R3.1 Windows Installer.
* Install the model optimizer prerequisites for ONNX by running:
* Windows: `<openvino_install_dir>/deployment_tools/model_optimizer/install_prerequisites/install_prerequisites_onnx.bat`
* Linux: `<openvino_install_dir>/deployment_tools/model_optimizer/install_prerequisites/install_prerequisites_onnx.sh`
* Initialize the OpenVINO environment by running the setupvars in `\<openvino\_install\_directory\>\/bin` using `setupvars.bat` (Windows) or `source setupvars.sh` (Linux)
* To configure Intel<sup>®</sup> Processor Graphics(GPU) please follow these instructions: [Windows](https://docs.openvinotoolkit.org/2019_R3.1/_docs_install_guides_installing_openvino_windows.html#Install-GPU), [Linux](https://docs.openvinotoolkit.org/2019_R3.1/_docs_install_guides_installing_openvino_linux.html#additional-GPU-steps)
* To configure Intel<sup>®</sup> Movidius<sup>TM</sup> USB, please follow this getting started guide: [Windows](https://docs.openvinotoolkit.org/2019_R3.1/_docs_install_guides_installing_openvino_windows.html#usb-myriad), [Linux](https://docs.openvinotoolkit.org/2019_R3.1/_docs_install_guides_installing_openvino_linux.html#additional-NCS-steps)
* To configure Intel<sup>®</sup> Vision Accelerator Design based on 8 Movidius<sup>TM</sup> MyriadX VPUs, please follow this configuration guide: [Windows](https://docs.openvinotoolkit.org/2019_R3.1/_docs_install_guides_installing_openvino_windows.html#hddl-myriad), [Linux](https://docs.openvinotoolkit.org/2019_R3.1/_docs_install_guides_installing_openvino_linux.html#install-VPU)
* To configure Intel<sup>®</sup> Vision Accelerator Design with an Intel<sup>®</sup> Arria<sup>®</sup> 10 FPGA, please follow this configuration guide: [Linux](https://docs.openvinotoolkit.org/2019_R3.1/_docs_install_guides_VisionAcceleratorFPGA_Configure_2019R3.html)
1. Install the Intel<sup>®</sup> Distribution of OpenVINO<sup>TM</sup> Toolkit **Release 2020.2** for the appropriate OS and target hardware :
* [Linux - CPU, GPU, VPU, VAD-M](https://software.intel.com/en-us/openvino-toolkit/choose-download/free-download-linux)
* [Linux - FPGA](https://software.intel.com/en-us/openvino-toolkit/choose-download/free-download-linux-fpga)
* [Windows - CPU, GPU, VPU, VAD-M](https://software.intel.com/en-us/openvino-toolkit/choose-download/free-download-windows).
Follow [documentation](https://docs.openvinotoolkit.org/2020.2/index.html) for detailed instructions.
2. Configure the target hardware with specific follow on instructions:
* To configure Intel<sup>®</sup> Processor Graphics(GPU) please follow these instructions: [Windows](https://docs.openvinotoolkit.org/2020.2/_docs_install_guides_installing_openvino_windows.html#Install-GPU), [Linux](https://docs.openvinotoolkit.org/2020.2/_docs_install_guides_installing_openvino_linux.html#additional-GPU-steps)
* To configure Intel<sup>®</sup> Movidius<sup>TM</sup> USB, please follow this getting started guide: [Linux](https://docs.openvinotoolkit.org/2020.2/_docs_install_guides_installing_openvino_linux.html#additional-NCS-steps)
* To configure Intel<sup>®</sup> Vision Accelerator Design based on 8 Movidius<sup>TM</sup> MyriadX VPUs, please follow this configuration guide: [Windows](https://docs.openvinotoolkit.org/2020.2/_docs_install_guides_installing_openvino_windows.html#hddl-myriad), [Linux](https://docs.openvinotoolkit.org/2020.2/_docs_install_guides_installing_openvino_linux.html#install-VPU)
* To configure Intel<sup>®</sup> Vision Accelerator Design with an Intel<sup>®</sup> Arria<sup>®</sup> 10 FPGA, please follow this configuration guide: [Linux](https://docs.openvinotoolkit.org/2020.2/_docs_install_guides_installing_openvino_linux_fpga.html)
3. Initialize the OpenVINO environment by running the setupvars script as shown below:
* For Linux run:
```
$ source <openvino_install_directory>/bin/setupvars.sh
```
* For Windows run:
```
C:\ <openvino_install_directory>\bin\setupvars.bat
```
#### Build Instructions
Expand All @@ -254,9 +264,7 @@ See more information on the OpenVINO Execution Provider [here](./docs/execution_
<code>--use_openvino</code>: Builds the OpenVINO Execution Provider in ONNX Runtime.
<code>--build_server</code>: Using this flag in addition to --use_openvino builds the OpenVINO Execution Provider with ONNX Runtime Server.
* `<hardware_option>`: Specifies the hardware target for building OpenVINO Execution Provider. Below are the options for different Intel target devices.
* `<hardware_option>`: Specifies the default hardware target for building OpenVINO Execution Provider. This can be overriden dynamically at runtime with another option (refer to [OpenVINO-ExecutionProvider.md](./docs/execution_providers/OpenVINO-ExecutionProvider.md) for more details on dynamic device selection). Below are the options for different Intel target devices.
| Hardware Option | Target Device |
| --------------- | ------------------------|
Expand Down
2 changes: 1 addition & 1 deletion cgmanifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@
{
"component": {
"git": {
"commitHash": "f01d8beeac92b54bf93df8053a2acb6a8a10f03c",
"commitHash": "fd5fe3de507d4a19f5923c5d4c267e3d730500a9",
"repositoryUrl": "https://github.com/microsoft/FeaturizersLibrary.git"
},
"type": "git"
Expand Down
49 changes: 29 additions & 20 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ if (MSVC)
else()
if(onnxruntime_BUILD_FOR_NATIVE_MACHINE)
string(APPEND CMAKE_CXX_FLAGS " -march=native -mtune=native")
string(APPEND CMAKE_C_FLAGS " -march=native -mtune=native")
string(APPEND CMAKE_C_FLAGS " -march=native -mtune=native")
elseif(onnxruntime_USE_AVX)
string(APPEND CMAKE_CXX_FLAGS " -mavx")
string(APPEND CMAKE_C_FLAGS " -mavx")
Expand All @@ -284,7 +284,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "iOSCross")
message("Adding flags for ios builds")
if (CMAKE_OSX_ARCHITECTURES STREQUAL "arm64")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -target arm64-apple-darwin-macho")
elseif (CMAKE_OSX_ARCHITECTURES STREQUAL "arm")
elseif (CMAKE_OSX_ARCHITECTURES STREQUAL "arm")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -target armv7a-apple-darwin-macho")
endif()
endif()
Expand Down Expand Up @@ -722,31 +722,40 @@ endif()

if(onnxruntime_USE_OPENVINO)

if (NOT onnxruntime_USE_FULL_PROTOBUF)
message(FATAL_ERROR "Please set onnxruntime_USE_FULL_PROTOBUF=ON for OpenVINO execution provider.")
endif()

add_definitions(-DUSE_OPENVINO=1)
if (NOT WIN32)
include(openvino)
list(APPEND onnxruntime_EXTERNAL_LIBRARIES ovep_ngraph)
list(APPEND onnxruntime_EXTERNAL_DEPENDENCIES project_ngraph)
endif()

if(onnxruntime_USE_OPENVINO_MYRIAD)
add_definitions(-DOPENVINO_CONFIG_MYRIAD=1)
endif()
if(onnxruntime_USE_OPENVINO_MYRIAD)
add_definitions(-DOPENVINO_CONFIG_MYRIAD=1)
endif()

if(onnxruntime_USE_OPENVINO_GPU_FP32)
add_definitions(-DOPENVINO_CONFIG_GPU_FP32=1)
endif()
if(onnxruntime_USE_OPENVINO_GPU_FP32)
add_definitions(-DOPENVINO_CONFIG_GPU_FP32=1)
endif()

if(onnxruntime_USE_OPENVINO_GPU_FP16)
add_definitions(-DOPENVINO_CONFIG_GPU_FP16=1)
endif()
if(onnxruntime_USE_OPENVINO_GPU_FP16)
add_definitions(-DOPENVINO_CONFIG_GPU_FP16=1)
endif()

if(onnxruntime_USE_OPENVINO_CPU_FP32)
add_definitions(-DOPENVINO_CONFIG_CPU_FP32=1)
endif()
if(onnxruntime_USE_OPENVINO_CPU_FP32)
add_definitions(-DOPENVINO_CONFIG_CPU_FP32=1)
endif()

if(onnxruntime_USE_OPENVINO_VAD_M)
add_definitions(-DOPENVINO_CONFIG_VAD_M=1)
endif()
if(onnxruntime_USE_OPENVINO_VAD_M)
add_definitions(-DOPENVINO_CONFIG_VAD_M=1)
endif()

if(onnxruntime_USE_OPENVINO_VAD_F)
add_definitions(-DOPENVINO_CONFIG_VAD_F=1)
endif()
if(onnxruntime_USE_OPENVINO_VAD_F)
add_definitions(-DOPENVINO_CONFIG_VAD_F=1)
endif()

endif()

Expand Down
107 changes: 107 additions & 0 deletions cmake/external/openvino.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Copyright(C) 2019 Intel Corporation
# Licensed under the MIT License

include (ExternalProject)

set(ngraph_ROOT_DIR ${CMAKE_CURRENT_BINARY_DIR}/external/ngraph)
set(ngraph_INSTALL_DIR ${ngraph_ROOT_DIR})
set(ngraph_INCLUDE_DIRS ${ngraph_INSTALL_DIR}/include)
set(ngraph_LIBRARIES ${ngraph_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR})
set(ngraph_SRC ${CMAKE_CURRENT_BINARY_DIR}/ngraph/src/project_ngraph)
set(prebuilt_ONNX_SOURCE_DIR "${PROJECT_SOURCE_DIR}/external/onnx")
set(prebuilt_ONNX_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
set(ngraph_URL "https://github.com/NervanaSystems/ngraph.git")
set(ngraph_TAG "edc65ca0111f86a7e63a98f62cb17d153cc2535c")

# Libraries for python package.
if (WIN32)
set(NGRAPH_SHARED_LIB ovep_ngraph.dll)
else()
set(NGRAPH_SHARED_LIB libovep_ngraph.so)
endif()

# discard prior changes due to unblock incremental builds.
set(NGRAPH_CHANGE_DIR_COMMAND cd ${ngraph_SRC})

if (MSVC)
# For the moment, Windows does not support codegen, it works on DEX-only mode
ExternalProject_Add(project_ngraph
PREFIX ngraph
GIT_REPOSITORY ${ngraph_URL}
GIT_TAG ${ngraph_TAG}
GIT_SHALLOW TRUE
GIT_CONFIG core.autocrlf=input
PATCH_COMMAND ${NGRAPH_CHANGE_DIR_COMMAND}
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/patches/openvino/ngraph_onnx.cmake ${ngraph_SRC}/cmake/external_onnx.cmake
COMMAND git apply --ignore-space-change --ignore-whitespace ${PROJECT_SOURCE_DIR}/patches/openvino/ngraph_protobuf.patch
COMMAND git apply --ignore-space-change --ignore-whitespace ${PROJECT_SOURCE_DIR}/patches/openvino/lib_name.patch
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DNGRAPH_ONNX_IMPORT_ENABLE=TRUE
-DNGRAPH_JSON_ENABLE=FALSE
-DNGRAPH_USE_SYSTEM_PROTOBUF=FALSE
-DNGRAPH_UNIT_TEST_ENABLE=FALSE
-DNGRAPH_TEST_UTIL_ENABLE=FALSE
-DNGRAPH_TOOLS_ENABLE=FALSE
-DNGRAPH_CPU_ENABLE=FALSE
-DNGRAPH_INTERPRETER_ENABLE=FALSE
-DNGRAPH_NOP_ENABLE=FALSE
-DNGRAPH_GPU_ENABLE=FALSE
-DNGRAPH_GENERIC_CPU_ENABLE=FALSE
-DNGRAPH_PLAIDML_ENABLE=FALSE
-DNGRAPH_ENABLE_CPU_CONV_AUTO=FALSE
-DNGRAPH_PYTHON_BUILD_ENABLE=FALSE
-DNGRAPH_FAST_MATH_ENABLE=FALSE
-DNGRAPH_DYNAMIC_COMPONENTS_ENABLE=FALSE
-DNGRAPH_NATIVE_ARCH_ENABLE=FALSE
-DCMAKE_INSTALL_PREFIX=${ngraph_INSTALL_DIR}
-Dprebuilt_ONNX_BINARY_DIR=${prebuilt_ONNX_BINARY_DIR}
-Dprebuilt_ONNX_SOURCE_DIR=${prebuilt_ONNX_SOURCE_DIR}
DEPENDS onnx
)
add_library(ovep_ngraph SHARED IMPORTED)
set_property(TARGET ovep_ngraph PROPERTY IMPORTED_LOCATION ${ngraph_LIBRARIES}/${NGRAPH_SHARED_LIB})
set_property(TARGET ovep_ngraph PROPERTY IMPORTED_IMPLIB ${ngraph_LIBRARIES}/ovep_ngraph.lib)

else()
ExternalProject_Add(project_ngraph
PREFIX ngraph
GIT_REPOSITORY ${ngraph_URL}
GIT_TAG ${ngraph_TAG}
GIT_SHALLOW TRUE
PATCH_COMMAND ${NGRAPH_CHANGE_DIR_COMMAND}
# Here we use onnx and protobuf built by onnxruntime to avoid linking with incompatible libraries. This might change in future.
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/patches/openvino/ngraph_onnx.cmake ${ngraph_SRC}/cmake/external_onnx.cmake
# TODO: Use cmake.file+copy as above.
COMMAND git apply --ignore-space-change --ignore-whitespace ${PROJECT_SOURCE_DIR}/patches/openvino/ngraph_protobuf.patch
COMMAND git apply --ignore-space-change --ignore-whitespace ${PROJECT_SOURCE_DIR}/patches/openvino/lib_name.patch
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DNGRAPH_ONNX_IMPORT_ENABLE=TRUE
-DNGRAPH_JSON_ENABLE=FALSE
-DNGRAPH_USE_SYSTEM_PROTOBUF=FALSE
-DNGRAPH_UNIT_TEST_ENABLE=FALSE
-DNGRAPH_TEST_UTIL_ENABLE=FALSE
-DNGRAPH_TOOLS_ENABLE=FALSE
-DNGRAPH_CPU_ENABLE=FALSE
-DNGRAPH_INTERPRETER_ENABLE=FALSE
-DNGRAPH_NOP_ENABLE=FALSE
-DNGRAPH_GPU_ENABLE=FALSE
-DNGRAPH_GENERIC_CPU_ENABLE=FALSE
-DNGRAPH_PLAIDML_ENABLE=FALSE
-DNGRAPH_ENABLE_CPU_CONV_AUTO=FALSE
-DNGRAPH_PYTHON_BUILD_ENABLE=FALSE
-DNGRAPH_FAST_MATH_ENABLE=FALSE
-DNGRAPH_DYNAMIC_COMPONENTS_ENABLE=FALSE
-DNGRAPH_NATIVE_ARCH_ENABLE=FALSE
-DCMAKE_INSTALL_PREFIX=${ngraph_INSTALL_DIR}
-Dprebuilt_ONNX_BINARY_DIR=${prebuilt_ONNX_BINARY_DIR}
-Dprebuilt_ONNX_SOURCE_DIR=${prebuilt_ONNX_SOURCE_DIR}
DEPENDS onnx
)

add_library(ovep_ngraph SHARED IMPORTED)
set_property(TARGET ovep_ngraph PROPERTY IMPORTED_LOCATION ${ngraph_LIBRARIES}/${NGRAPH_SHARED_LIB})
endif()
add_dependencies(ovep_ngraph project_ngraph)
include_directories(${ngraph_INCLUDE_DIRS})
Loading

0 comments on commit e9f1e7e

Please sign in to comment.