From 1c6ec7ab9172aa210599a69cc37dfce678e15b2d Mon Sep 17 00:00:00 2001 From: Pashupati Kumar Date: Wed, 2 Dec 2020 01:48:05 -0800 Subject: [PATCH 01/17] Add port for onnxruntime --- ports/onnxruntime/portfile.cmake | 222 +++++++++++++++++++++++++++++++ ports/onnxruntime/vcpkg.json | 5 + 2 files changed, 227 insertions(+) create mode 100644 ports/onnxruntime/portfile.cmake create mode 100644 ports/onnxruntime/vcpkg.json diff --git a/ports/onnxruntime/portfile.cmake b/ports/onnxruntime/portfile.cmake new file mode 100644 index 00000000000000..4461e3d0924701 --- /dev/null +++ b/ports/onnxruntime/portfile.cmake @@ -0,0 +1,222 @@ +if(NOT TARGET_TRIPLET MATCHES "(x|X)64-(windows|linux)-static-md") + message(FATAL_ERROR "onnxruntime doesn't support ${TARGET_TRIPLET} currently.") +endif() + +set(ORT_REVISION "v1.5.3") + +# check out the `https://github.com/microsoft/onnxruntime/archive/${ORT_REVISION}.tar.gz` +# hash checksum can be obtained with `curl -L -o tmp.tgz ${URL} && vcpkg hash tmp.tgz` +#vcpkg_from_github( +# OUT_SOURCE_PATH SOURCE_PATH +# REPO microsoft/onnxruntime +# REF aec4cb489e49a63fc8523ee3d22e406c2af9c22b +# SHA512 965046f76083c36f728d74275b7db091abb43e8eb514b45fce4223a43c1d8a0825db79f8528f0a7a68e12e3419e3467a949177a9d8e54b8a853baa0394e6f4d7 +# HEAD_REF master +# PATCHES +# "CMakeLists.patch" +#) + +vcpkg_find_acquire_program(GIT) +get_filename_component(GIT_PATH ${GIT} DIRECTORY) +vcpkg_find_acquire_program(PYTHON3) +get_filename_component(PYTHON3_PATH ${PYTHON3} DIRECTORY) +vcpkg_find_acquire_program(NINJA) +get_filename_component(NINJA_PATH ${NINJA} DIRECTORY) +set(ONNXRUNTIME "onnxruntime.git") +set(ONNX_GITHUB_URL "https://github.com/microsoft/${ONNXRUNTIME}") + +#vcpkg_from_git( +# OUT_SOURCE_PATH SOURCE_PATH +# URL "${ONNX_GITHUB_URL}" +# REF aec4cb489e49a63fc8523ee3d22e406c2af9c22b +# PATCHES +# "CMakeLists.patch" +#) + +if(EXISTS "${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME}") + # Purge any local changes + vcpkg_execute_required_process( + COMMAND ${GIT} reset --hard + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} + LOGNAME build-${TARGET_TRIPLET}) + + # + vcpkg_execute_required_process( + COMMAND ${GIT} submodule sync --recursive + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} + LOGNAME build-${TARGET_TRIPLET}) + + # + vcpkg_execute_required_process( + COMMAND ${GIT} submodule update --init --recursive + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} + LOGNAME build-${TARGET_TRIPLET}) + +else() + vcpkg_execute_required_process( + COMMAND ${GIT} clone --recursive ${ONNX_GITHUB_URL} ${ONNXRUNTIME} + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR} + LOGNAME build-${TARGET_TRIPLET}) +endif() + +#set(FEATURE_OPTIONS -A) +#list(APPEND FEATURE_OPTIONS -T) +#list(APPEND FEATURE_OPTIONS -G) + +if(VCPKG_TARGET_IS_WINDOWS) +# list(APPEND FEATURE_OPTIONS "Visual Studio 16 2019") +endif() + +if (VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") +# list(APPEND FEATURE_OPTIONS -x64) +# list(APPEND FEATURE_OPTIONS "host=x64") +endif() + +set(SOURCE_PATH "${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME}") + +vcpkg_configure_cmake( + SOURCE_PATH "${SOURCE_PATH}/cmake" + PREFER_NINJA + OPTIONS + -Donnxruntime_RUN_ONNX_TESTS=OFF + -Donnxruntime_BUILD_WINML_TESTS=ON + -Donnxruntime_GENERATE_TEST_REPORTS=ON + -Donnxruntime_USE_CUDA=OFF + -Donnxruntime_CUDNN_HOME= + -Donnxruntime_USE_FEATURIZERS=OFF + -Donnxruntime_CUDA_HOME= + -Donnxruntime_USE_JEMALLOC=OFF + -Donnxruntime_USE_MIMALLOC_STL_ALLOCATOR=OFF + -Donnxruntime_USE_MIMALLOC_ARENA_ALLOCATOR=OFF + -Donnxruntime_BUILD_SHARED_LIB=ON + -Donnxruntime_USE_EIGEN_FOR_BLAS=ON + -Donnxruntime_USE_OPENBLAS=OFF + -Donnxruntime_USE_DNNL=OFF + -Donnxruntime_DNNL_GPU_RUNTIME= + -Donnxruntime_DNNL_OPENCL_ROOT= + -Donnxruntime_USE_MKLML=OFF + -Donnxruntime_USE_NNAPI_BUILTIN=OFF + -Donnxruntime_USE_RKNPU=OFF + -Donnxruntime_USE_OPENMP=OFF + -Donnxruntime_USE_TVM=OFF + -Donnxruntime_USE_LLVM=OFF + -Donnxruntime_ENABLE_MICROSOFT_INTERNAL=OFF + -Donnxruntime_USE_VITISAI=OFF + -Donnxruntime_USE_NUPHAR=OFF + -Donnxruntime_USE_TENSORRT=OFF + -Donnxruntime_TENSORRT_HOME= + -Donnxruntime_USE_MIGRAPHX=OFF + -Donnxruntime_MIGRAPHX_HOME= + -Donnxruntime_CROSS_COMPILING=OFF + -Donnxruntime_DISABLE_CONTRIB_OPS=OFF + -Donnxruntime_DISABLE_ML_OPS=OFF + -Donnxruntime_DISABLE_RTTI=OFF + -Donnxruntime_DISABLE_EXCEPTIONS=OFF + -Donnxruntime_DISABLE_ORT_FORMAT_LOAD=OFF + -Donnxruntime_MINIMAL_BUILD=OFF + -Donnxruntime_ENABLE_LANGUAGE_INTEROP_OPS=OFF + -Donnxruntime_USE_DML=OFF + -Donnxruntime_USE_WINML=OFF + -Donnxruntime_USE_TELEMETRY=OFF + -Donnxruntime_ENABLE_LTO=OFF + -Donnxruntime_USE_ACL=OFF + -Donnxruntime_USE_ACL_1902=OFF + -Donnxruntime_USE_ACL_1905=OFF + -Donnxruntime_USE_ACL_1908=OFF + -Donnxruntime_USE_ACL_2002=OFF + -Donnxruntime_USE_ARMNN=OFF + -Donnxruntime_ARMNN_RELU_USE_CPU=ON + -Donnxruntime_ARMNN_BN_USE_CPU=ON + -Donnxruntime_ENABLE_NVTX_PROFILE=OFF + -Donnxruntime_ENABLE_TRAINING=ON + -Donnxruntime_USE_HOROVOD=OFF + -Donnxruntime_USE_NCCL=ON + -Donnxruntime_BUILD_BENCHMARKS=OFF + -Donnxruntime_USE_ROCM=OFF + -Donnxruntime_ROCM_HOME= + -Donnxruntime_PYBIND_EXPORT_OPSCHEMA=OFF + -Donnxruntime_ENABLE_MEMLEAK_CHECKER=OFF + -DCMAKE_BUILD_TYPE=RelWithDebInfo + ${FEATURE_OPTIONS} + OPTIONS_RELEASE + + OPTIONS_DEBUG + +) + +vcpkg_install_cmake() + +if(VCPKG_TARGET_IS_WINDOWS) + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + # copy the onnxruntime_*.libs + message(STATUS "Copying from ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg") + file(GLOB DEBUG_LIBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/*.lib) + file(COPY + ${DEBUG_LIBS} + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib + ) + # copy their corresponding *.pdbs + file(GLOB DEBUG_LIB_PDBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/*.pdb) + file(COPY + ${DEBUG_LIB_PDBS} + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib + ) + endif() + + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + # copy the onnxruntime_*.libs + message(STATUS "Copying from ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel") + file(GLOB DEBUG_LIBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/*.lib) + file(COPY + ${DEBUG_LIBS} + DESTINATION ${CURRENT_PACKAGES_DIR}/lib + ) + + # copy their corresponding *.pdbs + file(GLOB DEBUG_LIB_PDBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-release/*.pdb) + file(COPY + ${DEBUG_LIB_PDBS} + DESTINATION ${CURRENT_PACKAGES_DIR}/lib + ) + endif() + + # copy library from external modules + foreach(BUILD_TYPE rel dbg) + if(${BUILD_TYPE} STREQUAL "dbg") + set(Destination "${CURRENT_PACKAGES_DIR}/debug/lib") + else() + set(Destination "${CURRENT_PACKAGES_DIR}/lib") + endif() + foreach(EXTERNAL_MODULE flatbuffers onnx protobuf re2) + message(STATUS "Copying from ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/external/${EXTERNAL_MODULE}") + file(GLOB_RECURSE EXT_LIBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/external/${EXTERNAL_MODULE}/*.lib) + file(COPY + ${EXT_LIBS} + DESTINATION ${Destination} + ) + endforeach () + endforeach() + +elseif(VCPKG_TARGET_IS_LINUX) # !Winddows +message(STATUS "Copy libs and pdbs on Linux!") +endif() + +file(INSTALL + ${SOURCE_PATH}/LICENSE + DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) + +message(STATUS "Copy libs and pdbs done!") + +# Remove bin directories for static build, both debug and release build +# onnx_test_runner.exe, onnxruntime.dll +if(VCPKG_LIBRARY_LINKAGE STREQUAL static) + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin") +endif() + +if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +endif() + +vcpkg_copy_pdbs() + +message(STATUS "Installing done") diff --git a/ports/onnxruntime/vcpkg.json b/ports/onnxruntime/vcpkg.json new file mode 100644 index 00000000000000..5a68910f6414ad --- /dev/null +++ b/ports/onnxruntime/vcpkg.json @@ -0,0 +1,5 @@ +{ + "name": "onnxruntime", + "version-string": "v1.5.3", + "description": "ONNX Runtime is a cross-platform inferencing and training accelerator compatible with many popular ML/DNN frameworks, including PyTorch, TensorFlow/Keras, scikit-learn." +} \ No newline at end of file From f40e58862ea370336182762826cee2ebf8be7b89 Mon Sep 17 00:00:00 2001 From: Pashupati Kumar Date: Thu, 3 Dec 2020 22:40:19 -0800 Subject: [PATCH 02/17] Incorporate CR comments --- ports/onnxruntime/portfile.cmake | 442 +++++++++++++++---------------- ports/onnxruntime/vcpkg.json | 11 +- 2 files changed, 226 insertions(+), 227 deletions(-) diff --git a/ports/onnxruntime/portfile.cmake b/ports/onnxruntime/portfile.cmake index 4461e3d0924701..7bd99c09829f10 100644 --- a/ports/onnxruntime/portfile.cmake +++ b/ports/onnxruntime/portfile.cmake @@ -1,222 +1,220 @@ -if(NOT TARGET_TRIPLET MATCHES "(x|X)64-(windows|linux)-static-md") - message(FATAL_ERROR "onnxruntime doesn't support ${TARGET_TRIPLET} currently.") -endif() - -set(ORT_REVISION "v1.5.3") - -# check out the `https://github.com/microsoft/onnxruntime/archive/${ORT_REVISION}.tar.gz` -# hash checksum can be obtained with `curl -L -o tmp.tgz ${URL} && vcpkg hash tmp.tgz` -#vcpkg_from_github( -# OUT_SOURCE_PATH SOURCE_PATH -# REPO microsoft/onnxruntime -# REF aec4cb489e49a63fc8523ee3d22e406c2af9c22b -# SHA512 965046f76083c36f728d74275b7db091abb43e8eb514b45fce4223a43c1d8a0825db79f8528f0a7a68e12e3419e3467a949177a9d8e54b8a853baa0394e6f4d7 -# HEAD_REF master -# PATCHES -# "CMakeLists.patch" -#) - -vcpkg_find_acquire_program(GIT) -get_filename_component(GIT_PATH ${GIT} DIRECTORY) -vcpkg_find_acquire_program(PYTHON3) -get_filename_component(PYTHON3_PATH ${PYTHON3} DIRECTORY) -vcpkg_find_acquire_program(NINJA) -get_filename_component(NINJA_PATH ${NINJA} DIRECTORY) -set(ONNXRUNTIME "onnxruntime.git") -set(ONNX_GITHUB_URL "https://github.com/microsoft/${ONNXRUNTIME}") - -#vcpkg_from_git( -# OUT_SOURCE_PATH SOURCE_PATH -# URL "${ONNX_GITHUB_URL}" -# REF aec4cb489e49a63fc8523ee3d22e406c2af9c22b -# PATCHES -# "CMakeLists.patch" -#) - -if(EXISTS "${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME}") - # Purge any local changes - vcpkg_execute_required_process( - COMMAND ${GIT} reset --hard - WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} - LOGNAME build-${TARGET_TRIPLET}) - - # - vcpkg_execute_required_process( - COMMAND ${GIT} submodule sync --recursive - WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} - LOGNAME build-${TARGET_TRIPLET}) - - # - vcpkg_execute_required_process( - COMMAND ${GIT} submodule update --init --recursive - WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} - LOGNAME build-${TARGET_TRIPLET}) - -else() - vcpkg_execute_required_process( - COMMAND ${GIT} clone --recursive ${ONNX_GITHUB_URL} ${ONNXRUNTIME} - WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR} - LOGNAME build-${TARGET_TRIPLET}) -endif() - -#set(FEATURE_OPTIONS -A) -#list(APPEND FEATURE_OPTIONS -T) -#list(APPEND FEATURE_OPTIONS -G) - -if(VCPKG_TARGET_IS_WINDOWS) -# list(APPEND FEATURE_OPTIONS "Visual Studio 16 2019") -endif() - -if (VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") -# list(APPEND FEATURE_OPTIONS -x64) -# list(APPEND FEATURE_OPTIONS "host=x64") -endif() - -set(SOURCE_PATH "${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME}") - -vcpkg_configure_cmake( - SOURCE_PATH "${SOURCE_PATH}/cmake" - PREFER_NINJA - OPTIONS - -Donnxruntime_RUN_ONNX_TESTS=OFF - -Donnxruntime_BUILD_WINML_TESTS=ON - -Donnxruntime_GENERATE_TEST_REPORTS=ON - -Donnxruntime_USE_CUDA=OFF - -Donnxruntime_CUDNN_HOME= - -Donnxruntime_USE_FEATURIZERS=OFF - -Donnxruntime_CUDA_HOME= - -Donnxruntime_USE_JEMALLOC=OFF - -Donnxruntime_USE_MIMALLOC_STL_ALLOCATOR=OFF - -Donnxruntime_USE_MIMALLOC_ARENA_ALLOCATOR=OFF - -Donnxruntime_BUILD_SHARED_LIB=ON - -Donnxruntime_USE_EIGEN_FOR_BLAS=ON - -Donnxruntime_USE_OPENBLAS=OFF - -Donnxruntime_USE_DNNL=OFF - -Donnxruntime_DNNL_GPU_RUNTIME= - -Donnxruntime_DNNL_OPENCL_ROOT= - -Donnxruntime_USE_MKLML=OFF - -Donnxruntime_USE_NNAPI_BUILTIN=OFF - -Donnxruntime_USE_RKNPU=OFF - -Donnxruntime_USE_OPENMP=OFF - -Donnxruntime_USE_TVM=OFF - -Donnxruntime_USE_LLVM=OFF - -Donnxruntime_ENABLE_MICROSOFT_INTERNAL=OFF - -Donnxruntime_USE_VITISAI=OFF - -Donnxruntime_USE_NUPHAR=OFF - -Donnxruntime_USE_TENSORRT=OFF - -Donnxruntime_TENSORRT_HOME= - -Donnxruntime_USE_MIGRAPHX=OFF - -Donnxruntime_MIGRAPHX_HOME= - -Donnxruntime_CROSS_COMPILING=OFF - -Donnxruntime_DISABLE_CONTRIB_OPS=OFF - -Donnxruntime_DISABLE_ML_OPS=OFF - -Donnxruntime_DISABLE_RTTI=OFF - -Donnxruntime_DISABLE_EXCEPTIONS=OFF - -Donnxruntime_DISABLE_ORT_FORMAT_LOAD=OFF - -Donnxruntime_MINIMAL_BUILD=OFF - -Donnxruntime_ENABLE_LANGUAGE_INTEROP_OPS=OFF - -Donnxruntime_USE_DML=OFF - -Donnxruntime_USE_WINML=OFF - -Donnxruntime_USE_TELEMETRY=OFF - -Donnxruntime_ENABLE_LTO=OFF - -Donnxruntime_USE_ACL=OFF - -Donnxruntime_USE_ACL_1902=OFF - -Donnxruntime_USE_ACL_1905=OFF - -Donnxruntime_USE_ACL_1908=OFF - -Donnxruntime_USE_ACL_2002=OFF - -Donnxruntime_USE_ARMNN=OFF - -Donnxruntime_ARMNN_RELU_USE_CPU=ON - -Donnxruntime_ARMNN_BN_USE_CPU=ON - -Donnxruntime_ENABLE_NVTX_PROFILE=OFF - -Donnxruntime_ENABLE_TRAINING=ON - -Donnxruntime_USE_HOROVOD=OFF - -Donnxruntime_USE_NCCL=ON - -Donnxruntime_BUILD_BENCHMARKS=OFF - -Donnxruntime_USE_ROCM=OFF - -Donnxruntime_ROCM_HOME= - -Donnxruntime_PYBIND_EXPORT_OPSCHEMA=OFF - -Donnxruntime_ENABLE_MEMLEAK_CHECKER=OFF - -DCMAKE_BUILD_TYPE=RelWithDebInfo - ${FEATURE_OPTIONS} - OPTIONS_RELEASE - - OPTIONS_DEBUG - -) - -vcpkg_install_cmake() - -if(VCPKG_TARGET_IS_WINDOWS) - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - # copy the onnxruntime_*.libs - message(STATUS "Copying from ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg") - file(GLOB DEBUG_LIBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/*.lib) - file(COPY - ${DEBUG_LIBS} - DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib - ) - # copy their corresponding *.pdbs - file(GLOB DEBUG_LIB_PDBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/*.pdb) - file(COPY - ${DEBUG_LIB_PDBS} - DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib - ) - endif() - - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") - # copy the onnxruntime_*.libs - message(STATUS "Copying from ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel") - file(GLOB DEBUG_LIBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/*.lib) - file(COPY - ${DEBUG_LIBS} - DESTINATION ${CURRENT_PACKAGES_DIR}/lib - ) - - # copy their corresponding *.pdbs - file(GLOB DEBUG_LIB_PDBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-release/*.pdb) - file(COPY - ${DEBUG_LIB_PDBS} - DESTINATION ${CURRENT_PACKAGES_DIR}/lib - ) - endif() - - # copy library from external modules - foreach(BUILD_TYPE rel dbg) - if(${BUILD_TYPE} STREQUAL "dbg") - set(Destination "${CURRENT_PACKAGES_DIR}/debug/lib") - else() - set(Destination "${CURRENT_PACKAGES_DIR}/lib") - endif() - foreach(EXTERNAL_MODULE flatbuffers onnx protobuf re2) - message(STATUS "Copying from ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/external/${EXTERNAL_MODULE}") - file(GLOB_RECURSE EXT_LIBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/external/${EXTERNAL_MODULE}/*.lib) - file(COPY - ${EXT_LIBS} - DESTINATION ${Destination} - ) - endforeach () - endforeach() - -elseif(VCPKG_TARGET_IS_LINUX) # !Winddows -message(STATUS "Copy libs and pdbs on Linux!") -endif() - -file(INSTALL - ${SOURCE_PATH}/LICENSE - DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) - -message(STATUS "Copy libs and pdbs done!") - -# Remove bin directories for static build, both debug and release build -# onnx_test_runner.exe, onnxruntime.dll -if(VCPKG_LIBRARY_LINKAGE STREQUAL static) - file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin") -endif() - -if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") -endif() - -vcpkg_copy_pdbs() - -message(STATUS "Installing done") +if(NOT TARGET_TRIPLET MATCHES "(x|X)64-(windows|linux)-static-md") + vcpkg_fail_port_install(MESSAGE "${PORT} doesn't support ${TARGET_TRIPLET} currently" ALWAYS) +endif() + +set(ORT_REVISION "v1.5.3") + +# check out the `https://github.com/microsoft/onnxruntime/archive/${ORT_REVISION}.tar.gz` +# hash checksum can be obtained with `curl -L -o tmp.tgz ${URL} && vcpkg hash tmp.tgz` +#vcpkg_from_github( +# OUT_SOURCE_PATH SOURCE_PATH +# REPO microsoft/onnxruntime +# REF aec4cb489e49a63fc8523ee3d22e406c2af9c22b +# SHA512 965046f76083c36f728d74275b7db091abb43e8eb514b45fce4223a43c1d8a0825db79f8528f0a7a68e12e3419e3467a949177a9d8e54b8a853baa0394e6f4d7 +# HEAD_REF master +# PATCHES +# "CMakeLists.patch" +#) + +vcpkg_find_acquire_program(GIT) +get_filename_component(GIT_PATH ${GIT} DIRECTORY) +vcpkg_find_acquire_program(PYTHON3) +get_filename_component(PYTHON3_PATH ${PYTHON3} DIRECTORY) +vcpkg_find_acquire_program(NINJA) +get_filename_component(NINJA_PATH ${NINJA} DIRECTORY) +set(ONNXRUNTIME "onnxruntime.git") +set(ONNX_GITHUB_URL "https://github.com/microsoft/${ONNXRUNTIME}") + +#vcpkg_from_git( +# OUT_SOURCE_PATH SOURCE_PATH +# URL "${ONNX_GITHUB_URL}" +# REF aec4cb489e49a63fc8523ee3d22e406c2af9c22b +# PATCHES +# "CMakeLists.patch" +#) + +if(EXISTS "${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME}") + # Purge any local changes + vcpkg_execute_required_process( + COMMAND ${GIT} reset --hard + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} + LOGNAME build-${TARGET_TRIPLET}) + + # + vcpkg_execute_required_process( + COMMAND ${GIT} submodule sync --recursive + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} + LOGNAME build-${TARGET_TRIPLET}) + + # + vcpkg_execute_required_process( + COMMAND ${GIT} submodule update --init --recursive + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} + LOGNAME build-${TARGET_TRIPLET}) + +else() + vcpkg_execute_required_process( + COMMAND ${GIT} clone --recursive ${ONNX_GITHUB_URL} ${ONNXRUNTIME} + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR} + LOGNAME build-${TARGET_TRIPLET}) +endif() + + + +if(VCPKG_TARGET_IS_WINDOWS) +# list(APPEND FEATURE_OPTIONS "Visual Studio 16 2019") +endif() + +if (VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") +# list(APPEND FEATURE_OPTIONS -x64) +# list(APPEND FEATURE_OPTIONS "host=x64") +endif() + +set(SOURCE_PATH "${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME}") + +vcpkg_configure_cmake( + SOURCE_PATH "${SOURCE_PATH}/cmake" + PREFER_NINJA + OPTIONS + -Donnxruntime_RUN_ONNX_TESTS=OFF + -Donnxruntime_BUILD_WINML_TESTS=ON + -Donnxruntime_GENERATE_TEST_REPORTS=ON + -Donnxruntime_USE_CUDA=OFF + -Donnxruntime_CUDNN_HOME= + -Donnxruntime_USE_FEATURIZERS=OFF + -Donnxruntime_CUDA_HOME= + -Donnxruntime_USE_JEMALLOC=OFF + -Donnxruntime_USE_MIMALLOC_STL_ALLOCATOR=OFF + -Donnxruntime_USE_MIMALLOC_ARENA_ALLOCATOR=OFF + -Donnxruntime_BUILD_SHARED_LIB=ON + -Donnxruntime_USE_EIGEN_FOR_BLAS=ON + -Donnxruntime_USE_OPENBLAS=OFF + -Donnxruntime_USE_DNNL=OFF + -Donnxruntime_DNNL_GPU_RUNTIME= + -Donnxruntime_DNNL_OPENCL_ROOT= + -Donnxruntime_USE_MKLML=OFF + -Donnxruntime_USE_NNAPI_BUILTIN=OFF + -Donnxruntime_USE_RKNPU=OFF + -Donnxruntime_USE_OPENMP=OFF + -Donnxruntime_USE_TVM=OFF + -Donnxruntime_USE_LLVM=OFF + -Donnxruntime_ENABLE_MICROSOFT_INTERNAL=OFF + -Donnxruntime_USE_VITISAI=OFF + -Donnxruntime_USE_NUPHAR=OFF + -Donnxruntime_USE_TENSORRT=OFF + -Donnxruntime_TENSORRT_HOME= + -Donnxruntime_USE_MIGRAPHX=OFF + -Donnxruntime_MIGRAPHX_HOME= + -Donnxruntime_CROSS_COMPILING=OFF + -Donnxruntime_DISABLE_CONTRIB_OPS=OFF + -Donnxruntime_DISABLE_ML_OPS=OFF + -Donnxruntime_DISABLE_RTTI=OFF + -Donnxruntime_DISABLE_EXCEPTIONS=OFF + -Donnxruntime_DISABLE_ORT_FORMAT_LOAD=OFF + -Donnxruntime_MINIMAL_BUILD=OFF + -Donnxruntime_ENABLE_LANGUAGE_INTEROP_OPS=OFF + -Donnxruntime_USE_DML=OFF + -Donnxruntime_USE_WINML=OFF + -Donnxruntime_USE_TELEMETRY=OFF + -Donnxruntime_ENABLE_LTO=OFF + -Donnxruntime_USE_ACL=OFF + -Donnxruntime_USE_ACL_1902=OFF + -Donnxruntime_USE_ACL_1905=OFF + -Donnxruntime_USE_ACL_1908=OFF + -Donnxruntime_USE_ACL_2002=OFF + -Donnxruntime_USE_ARMNN=OFF + -Donnxruntime_ARMNN_RELU_USE_CPU=ON + -Donnxruntime_ARMNN_BN_USE_CPU=ON + -Donnxruntime_ENABLE_NVTX_PROFILE=OFF + -Donnxruntime_ENABLE_TRAINING=ON + -Donnxruntime_USE_HOROVOD=OFF + -Donnxruntime_USE_NCCL=ON + -Donnxruntime_BUILD_BENCHMARKS=OFF + -Donnxruntime_USE_ROCM=OFF + -Donnxruntime_ROCM_HOME= + -Donnxruntime_PYBIND_EXPORT_OPSCHEMA=OFF + -Donnxruntime_ENABLE_MEMLEAK_CHECKER=OFF + -DCMAKE_BUILD_TYPE=RelWithDebInfo + ${FEATURE_OPTIONS} + OPTIONS_RELEASE + + OPTIONS_DEBUG + +) + +vcpkg_install_cmake() + +if(VCPKG_TARGET_IS_WINDOWS) + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + # copy the onnxruntime_*.libs + message(STATUS "Copying from ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg") + file(GLOB DEBUG_LIBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/*.lib) + file(COPY + ${DEBUG_LIBS} + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib + ) + # copy their corresponding *.pdbs + file(GLOB DEBUG_LIB_PDBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/*.pdb) + file(COPY + ${DEBUG_LIB_PDBS} + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib + ) + endif() + + if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + # copy the onnxruntime_*.libs + message(STATUS "Copying from ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel") + file(GLOB DEBUG_LIBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/*.lib) + file(COPY + ${DEBUG_LIBS} + DESTINATION ${CURRENT_PACKAGES_DIR}/lib + ) + + # copy their corresponding *.pdbs + file(GLOB DEBUG_LIB_PDBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-release/*.pdb) + file(COPY + ${DEBUG_LIB_PDBS} + DESTINATION ${CURRENT_PACKAGES_DIR}/lib + ) + endif() + + # copy library from external modules + foreach(BUILD_TYPE rel dbg) + if(${BUILD_TYPE} STREQUAL "dbg") + set(Destination "${CURRENT_PACKAGES_DIR}/debug/lib") + else() + set(Destination "${CURRENT_PACKAGES_DIR}/lib") + endif() + foreach(EXTERNAL_MODULE flatbuffers onnx protobuf re2) + message(STATUS "Copying from ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/external/${EXTERNAL_MODULE}") + file(GLOB_RECURSE EXT_LIBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/external/${EXTERNAL_MODULE}/*.lib) + file(COPY + ${EXT_LIBS} + DESTINATION ${Destination} + ) + endforeach () + endforeach() + +elseif(VCPKG_TARGET_IS_LINUX) # !Winddows +message(STATUS "Copy libs and pdbs on Linux!") +endif() + +file(INSTALL + ${SOURCE_PATH}/LICENSE + DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) + +message(STATUS "Copy libs and pdbs done!") + +# Remove bin directories for static build, both debug and release build +# onnx_test_runner.exe, onnxruntime.dll +if(VCPKG_LIBRARY_LINKAGE STREQUAL static) + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin") +endif() + +if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +endif() + +vcpkg_copy_pdbs() + +message(STATUS "Installing done") diff --git a/ports/onnxruntime/vcpkg.json b/ports/onnxruntime/vcpkg.json index 5a68910f6414ad..10f92f2dcd2e6a 100644 --- a/ports/onnxruntime/vcpkg.json +++ b/ports/onnxruntime/vcpkg.json @@ -1,5 +1,6 @@ -{ - "name": "onnxruntime", - "version-string": "v1.5.3", - "description": "ONNX Runtime is a cross-platform inferencing and training accelerator compatible with many popular ML/DNN frameworks, including PyTorch, TensorFlow/Keras, scikit-learn." -} \ No newline at end of file +{ + "name": "onnxruntime", + "version-string": "1.5.3", + "description": "ONNX Runtime is a cross-platform inferencing and training accelerator compatible with many popular ML/DNN frameworks, including PyTorch, TensorFlow/Keras, scikit-learn.", + "homepage": "https://github.com/microsoft/onnxruntime" +} From 234a0faf43c9977f02cfaef7315e4a9fc7fc1651 Mon Sep 17 00:00:00 2001 From: Pashupati Kumar Date: Tue, 8 Dec 2020 01:57:00 -0800 Subject: [PATCH 03/17] Fix for Linux --- ports/onnxruntime/portfile.cmake | 164 +++++++++++++++---------------- 1 file changed, 78 insertions(+), 86 deletions(-) diff --git a/ports/onnxruntime/portfile.cmake b/ports/onnxruntime/portfile.cmake index 7bd99c09829f10..baebe3e7f4be67 100644 --- a/ports/onnxruntime/portfile.cmake +++ b/ports/onnxruntime/portfile.cmake @@ -1,21 +1,15 @@ -if(NOT TARGET_TRIPLET MATCHES "(x|X)64-(windows|linux)-static-md") - vcpkg_fail_port_install(MESSAGE "${PORT} doesn't support ${TARGET_TRIPLET} currently" ALWAYS) +if(VCPKG_TARGET_IS_WINDOWS) + vcpkg_fail_port_install(ON_LIBRARY_LINKAGE "dynamic") + vcpkg_fail_port_install(ON_TARGET "uwp") + vcpkg_fail_port_install(ON_ARCH "arm" "arm64" "wasm32" "x86") +elseif(VCPKG_TARGET_IS_LINUX) + vcpkg_fail_port_install(ON_ARCH "x86") +else() + vcpkg_fail_port_install(ALWAYS) endif() set(ORT_REVISION "v1.5.3") -# check out the `https://github.com/microsoft/onnxruntime/archive/${ORT_REVISION}.tar.gz` -# hash checksum can be obtained with `curl -L -o tmp.tgz ${URL} && vcpkg hash tmp.tgz` -#vcpkg_from_github( -# OUT_SOURCE_PATH SOURCE_PATH -# REPO microsoft/onnxruntime -# REF aec4cb489e49a63fc8523ee3d22e406c2af9c22b -# SHA512 965046f76083c36f728d74275b7db091abb43e8eb514b45fce4223a43c1d8a0825db79f8528f0a7a68e12e3419e3467a949177a9d8e54b8a853baa0394e6f4d7 -# HEAD_REF master -# PATCHES -# "CMakeLists.patch" -#) - vcpkg_find_acquire_program(GIT) get_filename_component(GIT_PATH ${GIT} DIRECTORY) vcpkg_find_acquire_program(PYTHON3) @@ -25,28 +19,20 @@ get_filename_component(NINJA_PATH ${NINJA} DIRECTORY) set(ONNXRUNTIME "onnxruntime.git") set(ONNX_GITHUB_URL "https://github.com/microsoft/${ONNXRUNTIME}") -#vcpkg_from_git( -# OUT_SOURCE_PATH SOURCE_PATH -# URL "${ONNX_GITHUB_URL}" -# REF aec4cb489e49a63fc8523ee3d22e406c2af9c22b -# PATCHES -# "CMakeLists.patch" -#) - if(EXISTS "${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME}") # Purge any local changes vcpkg_execute_required_process( COMMAND ${GIT} reset --hard WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} LOGNAME build-${TARGET_TRIPLET}) - - # + + # vcpkg_execute_required_process( COMMAND ${GIT} submodule sync --recursive WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} LOGNAME build-${TARGET_TRIPLET}) - # + # vcpkg_execute_required_process( COMMAND ${GIT} submodule update --init --recursive WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} @@ -60,16 +46,6 @@ else() endif() - -if(VCPKG_TARGET_IS_WINDOWS) -# list(APPEND FEATURE_OPTIONS "Visual Studio 16 2019") -endif() - -if (VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") -# list(APPEND FEATURE_OPTIONS -x64) -# list(APPEND FEATURE_OPTIONS "host=x64") -endif() - set(SOURCE_PATH "${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME}") vcpkg_configure_cmake( @@ -80,9 +56,7 @@ vcpkg_configure_cmake( -Donnxruntime_BUILD_WINML_TESTS=ON -Donnxruntime_GENERATE_TEST_REPORTS=ON -Donnxruntime_USE_CUDA=OFF - -Donnxruntime_CUDNN_HOME= -Donnxruntime_USE_FEATURIZERS=OFF - -Donnxruntime_CUDA_HOME= -Donnxruntime_USE_JEMALLOC=OFF -Donnxruntime_USE_MIMALLOC_STL_ALLOCATOR=OFF -Donnxruntime_USE_MIMALLOC_ARENA_ALLOCATOR=OFF @@ -90,8 +64,6 @@ vcpkg_configure_cmake( -Donnxruntime_USE_EIGEN_FOR_BLAS=ON -Donnxruntime_USE_OPENBLAS=OFF -Donnxruntime_USE_DNNL=OFF - -Donnxruntime_DNNL_GPU_RUNTIME= - -Donnxruntime_DNNL_OPENCL_ROOT= -Donnxruntime_USE_MKLML=OFF -Donnxruntime_USE_NNAPI_BUILTIN=OFF -Donnxruntime_USE_RKNPU=OFF @@ -131,79 +103,99 @@ vcpkg_configure_cmake( -Donnxruntime_USE_NCCL=ON -Donnxruntime_BUILD_BENCHMARKS=OFF -Donnxruntime_USE_ROCM=OFF - -Donnxruntime_ROCM_HOME= -Donnxruntime_PYBIND_EXPORT_OPSCHEMA=OFF -Donnxruntime_ENABLE_MEMLEAK_CHECKER=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo ${FEATURE_OPTIONS} - OPTIONS_RELEASE - - OPTIONS_DEBUG - ) vcpkg_install_cmake() +message(STATUS "Copy libs and additional header files!") +# Copy lib and PDB files if(VCPKG_TARGET_IS_WINDOWS) - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - # copy the onnxruntime_*.libs - message(STATUS "Copying from ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg") - file(GLOB DEBUG_LIBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/*.lib) - file(COPY - ${DEBUG_LIBS} - DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib - ) - # copy their corresponding *.pdbs - file(GLOB DEBUG_LIB_PDBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/*.pdb) + set(STATIC_LIB_EXTN "*.lib") + set(DYN_LIB_EXTN "*.dll") + set(SYM_FILE_EXTN "*.pdb") +elseif(VCPKG_TARGET_IS_LINUX) # !Winddows + set(STATIC_LIB_EXTN "*.a") + set(DYN_LIB_EXTN "*.(s|S)(o|O)") + set(SYM_FILE_EXTN "*.pdb") +endif() + +if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + # copy the onnxruntime_*.libs + message(STATUS "Copying from ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg") + file(GLOB DEBUG_LIBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/${STATIC_LIB_EXTN}) + file(COPY + ${DEBUG_LIBS} + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib + ) + # copy their corresponding *.pdbs + if(VCPKG_TARGET_IS_WINDOWS) + file(GLOB DEBUG_LIB_PDBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/${SYM_FILE_EXTN}) file(COPY ${DEBUG_LIB_PDBS} DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib ) endif() +endif() - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") - # copy the onnxruntime_*.libs - message(STATUS "Copying from ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel") - file(GLOB DEBUG_LIBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/*.lib) - file(COPY - ${DEBUG_LIBS} - DESTINATION ${CURRENT_PACKAGES_DIR}/lib - ) - - # copy their corresponding *.pdbs - file(GLOB DEBUG_LIB_PDBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-release/*.pdb) +if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + # copy the onnxruntime_*.libs + message(STATUS "Copying from ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel") + file(GLOB DEBUG_LIBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/${STATIC_LIB_EXTN}) + file(COPY + ${DEBUG_LIBS} + DESTINATION ${CURRENT_PACKAGES_DIR}/lib + ) + + # copy their corresponding *.pdbs + if(VCPKG_TARGET_IS_WINDOWS) + file(GLOB DEBUG_LIB_PDBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/${SYM_FILE_EXTN}) file(COPY ${DEBUG_LIB_PDBS} DESTINATION ${CURRENT_PACKAGES_DIR}/lib ) endif() - - # copy library from external modules - foreach(BUILD_TYPE rel dbg) - if(${BUILD_TYPE} STREQUAL "dbg") - set(Destination "${CURRENT_PACKAGES_DIR}/debug/lib") - else() - set(Destination "${CURRENT_PACKAGES_DIR}/lib") - endif() - foreach(EXTERNAL_MODULE flatbuffers onnx protobuf re2) - message(STATUS "Copying from ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/external/${EXTERNAL_MODULE}") - file(GLOB_RECURSE EXT_LIBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/external/${EXTERNAL_MODULE}/*.lib) - file(COPY - ${EXT_LIBS} - DESTINATION ${Destination} - ) - endforeach () - endforeach() - -elseif(VCPKG_TARGET_IS_LINUX) # !Winddows -message(STATUS "Copy libs and pdbs on Linux!") endif() +# copy library from external modules +foreach(BUILD_TYPE rel dbg) + if(${BUILD_TYPE} STREQUAL "dbg") + set(Destination "${CURRENT_PACKAGES_DIR}/debug/lib") + else() + set(Destination "${CURRENT_PACKAGES_DIR}/lib") + endif() + foreach(EXTERNAL_MODULE flatbuffers onnx protobuf re2) + message(STATUS "Copying from ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/external/${EXTERNAL_MODULE}") + file(GLOB_RECURSE EXT_LIBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/external/${EXTERNAL_MODULE}/${STATIC_LIB_EXTN}) + file(COPY + ${EXT_LIBS} + DESTINATION ${Destination} + ) + file(GLOB_RECURSE EXT_LIB_PDBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/external/${EXTERNAL_MODULE}/${SYM_FILE_EXTN}) + file(COPY + ${EXT_LIB_PDBS} + DESTINATION ${Destination} + ) + endforeach () # for all externam modules +endforeach() # for different linkage types + +message(STATUS "Copy libs done, copying additional header files!") +# Copy additional header files +# 1. Copy missing orttraining header files +# TODO: Make changes in ORT souce repo to put all training header files under top level include dir +file(GLOB_RECURSE TRAINING_HEADERS LIST_DIRECTORIES false ${SOURCE_PATH}/orttraining/*.h) +file(COPY ${SOURCE_PATH}/orttraining/orttraining/core DESTINATION ${CURRENT_PACKAGES_DIR}/include/orttraining FOLLOW_SYMLINK_CHAIN FILES_MATCHING PATTERN "*.h") +# file(INSTALL ${SOURCE_PATH}/orttraining/orttraining/models DESTINATION ${CURRENT_PACKAGES_DIR}/include/orttraining FOLLOW_SYMLINK_CHAIN PATTERN "*.h") + +# Copy the license file file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) -message(STATUS "Copy libs and pdbs done!") +message(STATUS "Copy libs and headers done!") # Remove bin directories for static build, both debug and release build # onnx_test_runner.exe, onnxruntime.dll From f8cbacfaabc0ed5a8f1cd998258f595061afe32e Mon Sep 17 00:00:00 2001 From: Pashupati Kumar Date: Fri, 11 Dec 2020 01:56:57 -0800 Subject: [PATCH 04/17] Ongoing integration fixes --- ports/onnxruntime/portfile.cmake | 30 ++++++++++++++++++++++++++++++ scripts/ci.baseline.txt | 7 +++++++ 2 files changed, 37 insertions(+) diff --git a/ports/onnxruntime/portfile.cmake b/ports/onnxruntime/portfile.cmake index baebe3e7f4be67..786ce294e82863 100644 --- a/ports/onnxruntime/portfile.cmake +++ b/ports/onnxruntime/portfile.cmake @@ -1,3 +1,7 @@ +# Only limited triplets supported +# x64-windows: x64-windows-static-md +# x64-linux +# No support for osx and uwp OS if(VCPKG_TARGET_IS_WINDOWS) vcpkg_fail_port_install(ON_LIBRARY_LINKAGE "dynamic") vcpkg_fail_port_install(ON_TARGET "uwp") @@ -106,6 +110,8 @@ vcpkg_configure_cmake( -Donnxruntime_PYBIND_EXPORT_OPSCHEMA=OFF -Donnxruntime_ENABLE_MEMLEAK_CHECKER=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo + -DONNX_ML=1 + -DONNX_NAMESPACE=onnx ${FEATURE_OPTIONS} ) @@ -190,6 +196,30 @@ file(GLOB_RECURSE TRAINING_HEADERS LIST_DIRECTORIES false ${SOURCE_PATH}/orttrai file(COPY ${SOURCE_PATH}/orttraining/orttraining/core DESTINATION ${CURRENT_PACKAGES_DIR}/include/orttraining FOLLOW_SYMLINK_CHAIN FILES_MATCHING PATTERN "*.h") # file(INSTALL ${SOURCE_PATH}/orttraining/orttraining/models DESTINATION ${CURRENT_PACKAGES_DIR}/include/orttraining FOLLOW_SYMLINK_CHAIN PATTERN "*.h") +# 2. copy headers from external modules +file(GLOB_RECURSE EXT_HEADERS LIST_DIRECTORIES false ${SOURCE_PATH}/cmake/external/onnx/onnx/*.h) +file(COPY ${EXT_HEADERS} DESTINATION ) ${CURRENT_PACKAGES_DIR}/include/onnxruntime/external/onnx/onnx) + +file(GLOB_RECURSE EXT_HEADERS LIST_DIRECTORIES false ${SOURCE_PATH}/cmake/external/SafeInt/*.h) +file(COPY ${EXT_HEADERS} DESTINATION ) ${CURRENT_PACKAGES_DIR}/include/onnxruntime/external/SafeInt) + +file(GLOB_RECURSE EXT_HEADERS LIST_DIRECTORIES false ${SOURCE_PATH}/cmake/external/protobuf/src/*.h) +file(COPY ${EXT_HEADERS} DESTINATION ) ${CURRENT_PACKAGES_DIR}/include/onnxruntime/external/protobuf/src) + +file(GLOB_RECURSE EXT_HEADERS LIST_DIRECTORIES false ${SOURCE_PATH}/cmake/external/nsync/public/*.h) +file(COPY ${EXT_HEADERS} DESTINATION ) ${CURRENT_PACKAGES_DIR}/include/onnxruntime/external/nsync/public) + +# Copy onnxruntime_config.h file +if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/onnxruntime_config.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/onnxruntime) + file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/onnxruntime_config.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/orttraining) +endif() + +if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/onnxruntime_config.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/onnxruntime) + file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/onnxruntime_config.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/orttraining) +endif + # Copy the license file file(INSTALL ${SOURCE_PATH}/LICENSE diff --git a/scripts/ci.baseline.txt b/scripts/ci.baseline.txt index e95105dc28568a..9f766bdc0755ef 100644 --- a/scripts/ci.baseline.txt +++ b/scripts/ci.baseline.txt @@ -1040,6 +1040,13 @@ ois:x64-uwp=fail # /usr/bin/ld: cannot find -lode ompl:x64-osx=fail ompl:x64-linux=fail +onnxruntime:arm64-windows=fail +onnxruntime:arm-uwp=fail +onnxruntime:x64-osx=fail +onnxruntime:x64-uwp=fail +onnxruntime:x64-windows=fail +onnxruntime:x64-windows-static=fail +onnxruntime:x86-windows=fail open62541:arm-uwp=fail open62541:x64-uwp=fail openal-soft:arm-uwp=fail From e2f53eacd2cff11fb727c032ee90b156fa0d8fc7 Mon Sep 17 00:00:00 2001 From: Pashupati Kumar Date: Fri, 11 Dec 2020 02:08:14 -0800 Subject: [PATCH 05/17] fix issue --- ports/onnxruntime/portfile.cmake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ports/onnxruntime/portfile.cmake b/ports/onnxruntime/portfile.cmake index 786ce294e82863..8b00d0b48158ed 100644 --- a/ports/onnxruntime/portfile.cmake +++ b/ports/onnxruntime/portfile.cmake @@ -198,16 +198,16 @@ file(COPY ${SOURCE_PATH}/orttraining/orttraining/core DESTINATION ${CURRENT_PACK # 2. copy headers from external modules file(GLOB_RECURSE EXT_HEADERS LIST_DIRECTORIES false ${SOURCE_PATH}/cmake/external/onnx/onnx/*.h) -file(COPY ${EXT_HEADERS} DESTINATION ) ${CURRENT_PACKAGES_DIR}/include/onnxruntime/external/onnx/onnx) +file(COPY ${EXT_HEADERS} DESTINATION ${CURRENT_PACKAGES_DIR}/include/onnxruntime/external/onnx/onnx) file(GLOB_RECURSE EXT_HEADERS LIST_DIRECTORIES false ${SOURCE_PATH}/cmake/external/SafeInt/*.h) -file(COPY ${EXT_HEADERS} DESTINATION ) ${CURRENT_PACKAGES_DIR}/include/onnxruntime/external/SafeInt) +file(COPY ${EXT_HEADERS} DESTINATION ${CURRENT_PACKAGES_DIR}/include/onnxruntime/external/SafeInt) file(GLOB_RECURSE EXT_HEADERS LIST_DIRECTORIES false ${SOURCE_PATH}/cmake/external/protobuf/src/*.h) -file(COPY ${EXT_HEADERS} DESTINATION ) ${CURRENT_PACKAGES_DIR}/include/onnxruntime/external/protobuf/src) +file(COPY ${EXT_HEADERS} DESTINATION ${CURRENT_PACKAGES_DIR}/include/onnxruntime/external/protobuf/src) file(GLOB_RECURSE EXT_HEADERS LIST_DIRECTORIES false ${SOURCE_PATH}/cmake/external/nsync/public/*.h) -file(COPY ${EXT_HEADERS} DESTINATION ) ${CURRENT_PACKAGES_DIR}/include/onnxruntime/external/nsync/public) +file(COPY ${EXT_HEADERS} DESTINATION ${CURRENT_PACKAGES_DIR}/include/onnxruntime/external/nsync/public) # Copy onnxruntime_config.h file if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") @@ -218,7 +218,7 @@ endif() if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/onnxruntime_config.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/onnxruntime) file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/onnxruntime_config.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/orttraining) -endif +endif() # Copy the license file file(INSTALL From 0444173fa520af00ca0093c9dd6742f6fe01bde2 Mon Sep 17 00:00:00 2001 From: Pashupati Kumar Date: Wed, 23 Dec 2020 01:06:40 -0800 Subject: [PATCH 06/17] Successfully built app using vcpkg --- ports/onnxruntime/portfile.cmake | 224 +++++++++++++++++++++---------- 1 file changed, 155 insertions(+), 69 deletions(-) diff --git a/ports/onnxruntime/portfile.cmake b/ports/onnxruntime/portfile.cmake index 8b00d0b48158ed..e3d1b1bbb2f542 100644 --- a/ports/onnxruntime/portfile.cmake +++ b/ports/onnxruntime/portfile.cmake @@ -64,7 +64,7 @@ vcpkg_configure_cmake( -Donnxruntime_USE_JEMALLOC=OFF -Donnxruntime_USE_MIMALLOC_STL_ALLOCATOR=OFF -Donnxruntime_USE_MIMALLOC_ARENA_ALLOCATOR=OFF - -Donnxruntime_BUILD_SHARED_LIB=ON + -Donnxruntime_BUILD_SHARED_LIB=OFF -Donnxruntime_USE_EIGEN_FOR_BLAS=ON -Donnxruntime_USE_OPENBLAS=OFF -Donnxruntime_USE_DNNL=OFF @@ -110,7 +110,7 @@ vcpkg_configure_cmake( -Donnxruntime_PYBIND_EXPORT_OPSCHEMA=OFF -Donnxruntime_ENABLE_MEMLEAK_CHECKER=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo - -DONNX_ML=1 + -DONNX_ML=ON -DONNX_NAMESPACE=onnx ${FEATURE_OPTIONS} ) @@ -129,85 +129,171 @@ elseif(VCPKG_TARGET_IS_LINUX) # !Winddows set(SYM_FILE_EXTN "*.pdb") endif() -if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - # copy the onnxruntime_*.libs - message(STATUS "Copying from ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg") - file(GLOB DEBUG_LIBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/${STATIC_LIB_EXTN}) - file(COPY - ${DEBUG_LIBS} - DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib - ) - # copy their corresponding *.pdbs - if(VCPKG_TARGET_IS_WINDOWS) - file(GLOB DEBUG_LIB_PDBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/${SYM_FILE_EXTN}) - file(COPY - ${DEBUG_LIB_PDBS} - DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib - ) - endif() -endif() - -if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") - # copy the onnxruntime_*.libs - message(STATUS "Copying from ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel") - file(GLOB DEBUG_LIBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/${STATIC_LIB_EXTN}) - file(COPY - ${DEBUG_LIBS} - DESTINATION ${CURRENT_PACKAGES_DIR}/lib - ) - - # copy their corresponding *.pdbs - if(VCPKG_TARGET_IS_WINDOWS) - file(GLOB DEBUG_LIB_PDBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/${SYM_FILE_EXTN}) - file(COPY - ${DEBUG_LIB_PDBS} - DESTINATION ${CURRENT_PACKAGES_DIR}/lib - ) - endif() -endif() - -# copy library from external modules +# Copy all libraries and PDBs foreach(BUILD_TYPE rel dbg) if(${BUILD_TYPE} STREQUAL "dbg") - set(Destination "${CURRENT_PACKAGES_DIR}/debug/lib") + set(SRCBASEDIR "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg") + set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/debug/lib") else() - set(Destination "${CURRENT_PACKAGES_DIR}/lib") + set(SRCBASEDIR "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel") + set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/lib") endif() - foreach(EXTERNAL_MODULE flatbuffers onnx protobuf re2) - message(STATUS "Copying from ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/external/${EXTERNAL_MODULE}") - file(GLOB_RECURSE EXT_LIBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/external/${EXTERNAL_MODULE}/${STATIC_LIB_EXTN}) - file(COPY - ${EXT_LIBS} - DESTINATION ${Destination} - ) - file(GLOB_RECURSE EXT_LIB_PDBS LIST_DIRECTORIES false ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${BUILD_TYPE}/external/${EXTERNAL_MODULE}/${SYM_FILE_EXTN}) - file(COPY - ${EXT_LIB_PDBS} - DESTINATION ${Destination} - ) - endforeach () # for all externam modules -endforeach() # for different linkage types + + file(GLOB_RECURSE ORT_LIBS LIST_DIRECTORIES false ${SRCBASEDIR}/${STATIC_LIB_EXTN}) + file(COPY ${ORT_LIBS} DESTINATION ${DESTBASEDIR}) + + file(GLOB_RECURSE ORT_LIB_PDBS LIST_DIRECTORIES false ${SRCBASEDIR}/${SYM_FILE_EXTN}) + file(COPY ${ORT_LIB_PDBS} DESTINATION ${DESTBASEDIR}) +endforeach() message(STATUS "Copy libs done, copying additional header files!") + # Copy additional header files -# 1. Copy missing orttraining header files # TODO: Make changes in ORT souce repo to put all training header files under top level include dir -file(GLOB_RECURSE TRAINING_HEADERS LIST_DIRECTORIES false ${SOURCE_PATH}/orttraining/*.h) -file(COPY ${SOURCE_PATH}/orttraining/orttraining/core DESTINATION ${CURRENT_PACKAGES_DIR}/include/orttraining FOLLOW_SYMLINK_CHAIN FILES_MATCHING PATTERN "*.h") -# file(INSTALL ${SOURCE_PATH}/orttraining/orttraining/models DESTINATION ${CURRENT_PACKAGES_DIR}/include/orttraining FOLLOW_SYMLINK_CHAIN PATTERN "*.h") -# 2. copy headers from external modules -file(GLOB_RECURSE EXT_HEADERS LIST_DIRECTORIES false ${SOURCE_PATH}/cmake/external/onnx/onnx/*.h) -file(COPY ${EXT_HEADERS} DESTINATION ${CURRENT_PACKAGES_DIR}/include/onnxruntime/external/onnx/onnx) +# 1. Copy missing external header files from build output folders. These are generaterd by build +# e.g. onnx-data.pb.h +# Trailing '/' is significant. Without it copying 'mydir' folder would be installed under Destination. +if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + set(SRCBASEDIR "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/external") + set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/include/onnxruntime/external") + foreach(MOD onnx/onnx/) # Placeholder to put more directories ,if needed!. + file(COPY ${SRCBASEDIR}/${MOD} DESTINATION ${DESTBASEDIR}/${MOD}/ FOLLOW_SYMLINK_CHAIN FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" PATTERN ".inc") + endforeach() +endif() -file(GLOB_RECURSE EXT_HEADERS LIST_DIRECTORIES false ${SOURCE_PATH}/cmake/external/SafeInt/*.h) -file(COPY ${EXT_HEADERS} DESTINATION ${CURRENT_PACKAGES_DIR}/include/onnxruntime/external/SafeInt) +# 2. Copy header files from source core directories +# Todo: Check if we need to copy this: core/providers/nuphar/compiler/x86/op_ir_creator/all_ops.h +set(SRCBASEDIR "${SOURCE_PATH}/onnxruntime/core") +set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/include/onnxruntime/core") +foreach(MOD + common/ + framework/ + graph/ + platform/ + optimizer/ + providers/ + session/ + util/ + ) + file(COPY + ${SRCBASEDIR}/${MOD} + DESTINATION ${DESTBASEDIR}/${MOD} + FOLLOW_SYMLINK_CHAIN + FILES_MATCHING + PATTERN "*.h" + PATTERN "*.hpp" + PATTERN ".inc" + PATTERN "cuda/atomic" EXCLUDE + PATTERN "cuda/cu_inc*" EXCLUDE + PATTERN "cuda/multi_tensor" EXCLUDE + PATTERN "nuphar/compiler/x86/op_ir_creator" EXCLUDE + PATTERN "nuphar/scripts" EXCLUDE + PATTERN "rocm/atomic" EXCLUDE + PATTERN "rocm/cu_inc" EXCLUDE + ) +endforeach() -file(GLOB_RECURSE EXT_HEADERS LIST_DIRECTORIES false ${SOURCE_PATH}/cmake/external/protobuf/src/*.h) -file(COPY ${EXT_HEADERS} DESTINATION ${CURRENT_PACKAGES_DIR}/include/onnxruntime/external/protobuf/src) +# 3. Copy header files from top level include directories +# Todo: Investigate why these headers files are not copied by vcpkg +set(SRCBASEDIR "${SOURCE_PATH}/include/onnxruntime/core/") +set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/include/onnxruntime/core/") +foreach(MOD + platform + graph + session + optimizer + providers + ) + file(COPY ${SRCBASEDIR}/${MOD}/ DESTINATION ${DESTBASEDIR}/${MOD} FOLLOW_SYMLINK_CHAIN FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" PATTERN ".inc") +endforeach() -file(GLOB_RECURSE EXT_HEADERS LIST_DIRECTORIES false ${SOURCE_PATH}/cmake/external/nsync/public/*.h) -file(COPY ${EXT_HEADERS} DESTINATION ${CURRENT_PACKAGES_DIR}/include/onnxruntime/external/nsync/public) +# 4. Copy external header files from source folders +set(SRCBASEDIR "${SOURCE_PATH}/cmake/external") +set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/include/onnxruntime/external") +foreach(MOD + optional-lite/include/nonstd/ + optional-lite/test/ + onnx/onnx/common/ + onnx/onnx/optimizer/ + onnx/onnx/shape_inference/ + onnx/onnx/version_converter/ + onnx/third_party/benchmark/include/ + onnx/third_party/benchmark/src/ + onnx/third_party/benchmark/test/ + onnx/third_party/pybind11/include/ + SafeInt/SafeInt/Archive/releases/2/ + SafeInt/SafeInt/Archive/releases/6/ + protobuf/src/google/ + nsync/public/ + ) + file(COPY + ${SRCBASEDIR}/${MOD} + DESTINATION ${DESTBASEDIR}/${MOD} + FOLLOW_SYMLINK_CHAIN + FILES_MATCHING + PATTERN "*.h" + PATTERN "*.hpp" + PATTERN ".inc" + PATTERN "protobuf/util/internal/testdata" EXCLUDE # protobuf/src/google/ subfolders to skip + PATTERN "protobuf/testdata" EXCLUDE + ) +endforeach() + +# Now copy files from folders that does need to be copied recursively +foreach(MOD + SafeInt/SafeInt/Test + onnx/onnx + onnx/onnx/defs + onnx/onnx/defs/tensor + onnx/third_party/pybind11/tests + ) + set(EXT_ADDL_HDRS "") + file(GLOB EXT_ADDL_HDRS LIST_DIRECTORIES false ${SRCBASEDIR}/${MOD}/*.h ) + file(COPY ${EXT_ADDL_HDRS} DESTINATION ${DESTBASEDIR}/${MOD}) +endforeach() + +# 4. Copy training header files from sources directories +set(SRCBASEDIR "${SOURCE_PATH}/orttraining/orttraining") +set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/include/orttraining") +foreach(MOD + core/ + models/mnist/ + models/runner/ + training_ops/ + ) + file(COPY + ${SRCBASEDIR}/${MOD} + DESTINATION ${DESTBASEDIR}/${MOD} + FOLLOW_SYMLINK_CHAIN + FILES_MATCHING + PATTERN "*.h" + PATTERN "*.hpp" + PATTERN ".inc" + PATTERN "rocm/activation" EXCLUDE + PATTERN "rocm/collective" EXCLUDE + PATTERN "rocm/loss" EXCLUDE + PATTERN "rocm/math" EXCLUDE + PATTERN "rocm/optimizer" EXCLUDE + PATTERN "rocm/reduction" EXCLUDE + ) +endforeach() + +# 5. Copy Test header files from sources directories +set(SRCBASEDIR "${SOURCE_PATH}/onnxruntime/test") +set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/include/onnxruntime/test") +foreach(MOD + util/include/ + framework/ + ) + file(COPY + ${SRCBASEDIR}/${MOD} + DESTINATION ${DESTBASEDIR}/${MOD} + FOLLOW_SYMLINK_CHAIN + FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" PATTERN ".inc" + PATTERN "cuda" EXCLUDE + ) +endforeach() # Copy onnxruntime_config.h file if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") From 8e69fac039fc8c40a07127d8bf83acea7ffe49b8 Mon Sep 17 00:00:00 2001 From: Pashupati Kumar Date: Tue, 5 Jan 2021 17:11:10 -0800 Subject: [PATCH 07/17] Add missing header file --- ports/onnxruntime/portfile.cmake | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/ports/onnxruntime/portfile.cmake b/ports/onnxruntime/portfile.cmake index e3d1b1bbb2f542..6a055ba2d66012 100644 --- a/ports/onnxruntime/portfile.cmake +++ b/ports/onnxruntime/portfile.cmake @@ -205,7 +205,15 @@ foreach(MOD optimizer providers ) - file(COPY ${SRCBASEDIR}/${MOD}/ DESTINATION ${DESTBASEDIR}/${MOD} FOLLOW_SYMLINK_CHAIN FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" PATTERN ".inc") + file(COPY + ${SRCBASEDIR}/${MOD} + DESTINATION ${DESTBASEDIR}/${MOD} + FOLLOW_SYMLINK_CHAIN + FILES_MATCHING + PATTERN "*.h" + PATTERN "*.hpp" + PATTERN ".inc" + ) endforeach() # 4. Copy external header files from source folders @@ -219,11 +227,10 @@ foreach(MOD onnx/onnx/shape_inference/ onnx/onnx/version_converter/ onnx/third_party/benchmark/include/ - onnx/third_party/benchmark/src/ - onnx/third_party/benchmark/test/ - onnx/third_party/pybind11/include/ - SafeInt/SafeInt/Archive/releases/2/ - SafeInt/SafeInt/Archive/releases/6/ + onnx/third_party/benchmark/src/ + onnx/third_party/benchmark/test/ + onnx/third_party/pybind11/include/ + SafeInt/safeInt/Archive/releases/ protobuf/src/google/ nsync/public/ ) @@ -242,14 +249,15 @@ endforeach() # Now copy files from folders that does need to be copied recursively foreach(MOD - SafeInt/SafeInt/Test + SafeInt/safeInt + SafeInt/safeInt/Test onnx/onnx onnx/onnx/defs onnx/onnx/defs/tensor onnx/third_party/pybind11/tests ) set(EXT_ADDL_HDRS "") - file(GLOB EXT_ADDL_HDRS LIST_DIRECTORIES false ${SRCBASEDIR}/${MOD}/*.h ) + file(GLOB EXT_ADDL_HDRS LIST_DIRECTORIES false ${SRCBASEDIR}/${MOD}/*.h ${SRCBASEDIR}/${MOD}/*.hpp) file(COPY ${EXT_ADDL_HDRS} DESTINATION ${DESTBASEDIR}/${MOD}) endforeach() @@ -323,6 +331,9 @@ if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") endif() +# Remove empty directories that are created during copy operations +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/onnxruntime/external/SafeInt/safeInt/Archive/releases/8") + vcpkg_copy_pdbs() message(STATUS "Installing done") From 8ad369cc6a2b134d59decf354d5a3bb08f547f4e Mon Sep 17 00:00:00 2001 From: Pashupati Kumar Date: Thu, 7 Jan 2021 02:46:51 -0800 Subject: [PATCH 08/17] Cleaned up after copy --- ports/onnxruntime/portfile.cmake | 57 +++++++++++++++++--------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/ports/onnxruntime/portfile.cmake b/ports/onnxruntime/portfile.cmake index 6a055ba2d66012..5ec94d69960bc1 100644 --- a/ports/onnxruntime/portfile.cmake +++ b/ports/onnxruntime/portfile.cmake @@ -151,21 +151,44 @@ message(STATUS "Copy libs done, copying additional header files!") # Copy additional header files # TODO: Make changes in ORT souce repo to put all training header files under top level include dir -# 1. Copy missing external header files from build output folders. These are generaterd by build +# 1. Copy header files from top level include directories +# Todo: Investigate why these headers files are not copied by vcpkg +set(SRCBASEDIR "${SOURCE_PATH}/include/onnxruntime/core") +set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/include/onnxruntime/core") +foreach(MOD + platform/ + graph/ + session/ + optimizer/ + providers/ + ) + file(COPY + ${SRCBASEDIR}/${MOD} + DESTINATION ${DESTBASEDIR}/${MOD} + FOLLOW_SYMLINK_CHAIN + FILES_MATCHING + PATTERN "*.h" + PATTERN "*.hpp" + PATTERN ".inc" + ) +endforeach() + +# 2. Copy missing external header files from build output folders. These are generaterd by build # e.g. onnx-data.pb.h # Trailing '/' is significant. Without it copying 'mydir' folder would be installed under Destination. if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") set(SRCBASEDIR "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/external") set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/include/onnxruntime/external") foreach(MOD onnx/onnx/) # Placeholder to put more directories ,if needed!. - file(COPY ${SRCBASEDIR}/${MOD} DESTINATION ${DESTBASEDIR}/${MOD}/ FOLLOW_SYMLINK_CHAIN FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" PATTERN ".inc") + file(COPY ${SRCBASEDIR}/${MOD} DESTINATION ${DESTBASEDIR}/${MOD} FOLLOW_SYMLINK_CHAIN FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" PATTERN ".inc") endforeach() endif() -# 2. Copy header files from source core directories +# 3. Copy header files from source core directories # Todo: Check if we need to copy this: core/providers/nuphar/compiler/x86/op_ir_creator/all_ops.h set(SRCBASEDIR "${SOURCE_PATH}/onnxruntime/core") set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/include/onnxruntime/core") +set(MOD "") foreach(MOD common/ framework/ @@ -194,31 +217,10 @@ foreach(MOD ) endforeach() -# 3. Copy header files from top level include directories -# Todo: Investigate why these headers files are not copied by vcpkg -set(SRCBASEDIR "${SOURCE_PATH}/include/onnxruntime/core/") -set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/include/onnxruntime/core/") -foreach(MOD - platform - graph - session - optimizer - providers - ) - file(COPY - ${SRCBASEDIR}/${MOD} - DESTINATION ${DESTBASEDIR}/${MOD} - FOLLOW_SYMLINK_CHAIN - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN ".inc" - ) -endforeach() - # 4. Copy external header files from source folders set(SRCBASEDIR "${SOURCE_PATH}/cmake/external") set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/include/onnxruntime/external") +set(MOD "") foreach(MOD optional-lite/include/nonstd/ optional-lite/test/ @@ -248,6 +250,7 @@ foreach(MOD endforeach() # Now copy files from folders that does need to be copied recursively +set(MOD "") foreach(MOD SafeInt/safeInt SafeInt/safeInt/Test @@ -264,6 +267,7 @@ endforeach() # 4. Copy training header files from sources directories set(SRCBASEDIR "${SOURCE_PATH}/orttraining/orttraining") set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/include/orttraining") +set(MOD "") foreach(MOD core/ models/mnist/ @@ -278,7 +282,7 @@ foreach(MOD PATTERN "*.h" PATTERN "*.hpp" PATTERN ".inc" - PATTERN "rocm/activation" EXCLUDE + PATTERN "rocm/activation" EXCLUDE # All these folders under training_ops do not have header files! PATTERN "rocm/collective" EXCLUDE PATTERN "rocm/loss" EXCLUDE PATTERN "rocm/math" EXCLUDE @@ -290,6 +294,7 @@ endforeach() # 5. Copy Test header files from sources directories set(SRCBASEDIR "${SOURCE_PATH}/onnxruntime/test") set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/include/onnxruntime/test") +set(MOD "") foreach(MOD util/include/ framework/ From 06d1449d1248d66386c7966abf1c89b02b2658b2 Mon Sep 17 00:00:00 2001 From: Pashupati Kumar Date: Thu, 7 Jan 2021 21:18:17 -0800 Subject: [PATCH 09/17] added *.inc files --- ports/onnxruntime/portfile.cmake | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ports/onnxruntime/portfile.cmake b/ports/onnxruntime/portfile.cmake index 5ec94d69960bc1..5e1ecfccfc1fa1 100644 --- a/ports/onnxruntime/portfile.cmake +++ b/ports/onnxruntime/portfile.cmake @@ -169,7 +169,7 @@ foreach(MOD FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" - PATTERN ".inc" + PATTERN "*.inc" ) endforeach() @@ -206,7 +206,7 @@ foreach(MOD FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" - PATTERN ".inc" + PATTERN "*.inc" PATTERN "cuda/atomic" EXCLUDE PATTERN "cuda/cu_inc*" EXCLUDE PATTERN "cuda/multi_tensor" EXCLUDE @@ -242,8 +242,8 @@ foreach(MOD FOLLOW_SYMLINK_CHAIN FILES_MATCHING PATTERN "*.h" - PATTERN "*.hpp" - PATTERN ".inc" + PATTERN "*.hpp" + PATTERN "*.inc" PATTERN "protobuf/util/internal/testdata" EXCLUDE # protobuf/src/google/ subfolders to skip PATTERN "protobuf/testdata" EXCLUDE ) @@ -281,7 +281,7 @@ foreach(MOD FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" - PATTERN ".inc" + PATTERN "*.inc" PATTERN "rocm/activation" EXCLUDE # All these folders under training_ops do not have header files! PATTERN "rocm/collective" EXCLUDE PATTERN "rocm/loss" EXCLUDE @@ -303,7 +303,10 @@ foreach(MOD ${SRCBASEDIR}/${MOD} DESTINATION ${DESTBASEDIR}/${MOD} FOLLOW_SYMLINK_CHAIN - FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" PATTERN ".inc" + FILES_MATCHING + PATTERN "*.h" + PATTERN "*.hpp" + PATTERN "*.inc" PATTERN "cuda" EXCLUDE ) endforeach() From 1d170123c53169ecfc34a0910f54e80271f73786 Mon Sep 17 00:00:00 2001 From: Pashupati Kumar Date: Fri, 8 Jan 2021 15:07:34 -0800 Subject: [PATCH 10/17] Fix with the latest ORT codebase --- ports/onnxruntime/portfile.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ports/onnxruntime/portfile.cmake b/ports/onnxruntime/portfile.cmake index 5e1ecfccfc1fa1..d729fd4d3b54e8 100644 --- a/ports/onnxruntime/portfile.cmake +++ b/ports/onnxruntime/portfile.cmake @@ -207,13 +207,14 @@ foreach(MOD PATTERN "*.h" PATTERN "*.hpp" PATTERN "*.inc" - PATTERN "cuda/atomic" EXCLUDE - PATTERN "cuda/cu_inc*" EXCLUDE + PATTERN "cuda/atomic" EXCLUDE #These paths under providers don't have any header files to be copied + PATTERN "cuda/cu_inc" EXCLUDE PATTERN "cuda/multi_tensor" EXCLUDE PATTERN "nuphar/compiler/x86/op_ir_creator" EXCLUDE PATTERN "nuphar/scripts" EXCLUDE PATTERN "rocm/atomic" EXCLUDE PATTERN "rocm/cu_inc" EXCLUDE + PATTERN "rocm/math" EXCLUDE ) endforeach() From 54d9767309d410405af02a65af5c564b3e6b6933 Mon Sep 17 00:00:00 2001 From: Pashupati Kumar Date: Tue, 12 Jan 2021 02:43:22 -0800 Subject: [PATCH 11/17] Added Python3 to path --- ports/onnxruntime/portfile.cmake | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/ports/onnxruntime/portfile.cmake b/ports/onnxruntime/portfile.cmake index d729fd4d3b54e8..e7b493a103470c 100644 --- a/ports/onnxruntime/portfile.cmake +++ b/ports/onnxruntime/portfile.cmake @@ -3,9 +3,8 @@ # x64-linux # No support for osx and uwp OS if(VCPKG_TARGET_IS_WINDOWS) - vcpkg_fail_port_install(ON_LIBRARY_LINKAGE "dynamic") - vcpkg_fail_port_install(ON_TARGET "uwp") - vcpkg_fail_port_install(ON_ARCH "arm" "arm64" "wasm32" "x86") + vcpkg_check_linkage(ONLY_STATIC_LIBRARY) + vcpkg_fail_port_install(ON_ARCH "arm" "arm64" "wasm32" "x86" ON_TARGET "uwp") elseif(VCPKG_TARGET_IS_LINUX) vcpkg_fail_port_install(ON_ARCH "x86") else() @@ -18,8 +17,10 @@ vcpkg_find_acquire_program(GIT) get_filename_component(GIT_PATH ${GIT} DIRECTORY) vcpkg_find_acquire_program(PYTHON3) get_filename_component(PYTHON3_PATH ${PYTHON3} DIRECTORY) +vcpkg_add_to_path(${PYTHON3_PATH}) vcpkg_find_acquire_program(NINJA) get_filename_component(NINJA_PATH ${NINJA} DIRECTORY) +vcpkg_add_to_path(${PYTHON3_PATH}) set(ONNXRUNTIME "onnxruntime.git") set(ONNX_GITHUB_URL "https://github.com/microsoft/${ONNXRUNTIME}") @@ -113,6 +114,7 @@ vcpkg_configure_cmake( -DONNX_ML=ON -DONNX_NAMESPACE=onnx ${FEATURE_OPTIONS} + -DPYTHON_EXECUTABLE=${PYTHON3} ) vcpkg_install_cmake() @@ -272,7 +274,12 @@ set(MOD "") foreach(MOD core/ models/mnist/ - models/runner/ + models/runner/ + test/distributed/ + test/gradient/ + test/graph/ + test/optimizer/ + test/session/ training_ops/ ) file(COPY @@ -292,6 +299,16 @@ foreach(MOD ) endforeach() +# Now copy files from folders that does need to be copied recursively +set(MOD "") +foreach(MOD + test/training_ops + ) + set(EXT_ADDL_HDRS "") + file(GLOB EXT_ADDL_HDRS LIST_DIRECTORIES false ${SRCBASEDIR}/${MOD}/*.h ${SRCBASEDIR}/${MOD}/*.hpp) + file(COPY ${EXT_ADDL_HDRS} DESTINATION ${DESTBASEDIR}/${MOD}) +endforeach() + # 5. Copy Test header files from sources directories set(SRCBASEDIR "${SOURCE_PATH}/onnxruntime/test") set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/include/onnxruntime/test") From 3bf1d2786604d3aea8da9ced2d0380bf34aba4d1 Mon Sep 17 00:00:00 2001 From: Pashupati Kumar Date: Wed, 13 Jan 2021 16:14:00 -0800 Subject: [PATCH 12/17] Set ORT codebase to a commit hash --- ports/onnxruntime/portfile.cmake | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ports/onnxruntime/portfile.cmake b/ports/onnxruntime/portfile.cmake index e7b493a103470c..665a9df502ca15 100644 --- a/ports/onnxruntime/portfile.cmake +++ b/ports/onnxruntime/portfile.cmake @@ -12,6 +12,7 @@ else() endif() set(ORT_REVISION "v1.5.3") +set(ORT_COMMIT_HASH "3b3e698674dca2014b91fb617e2c4f22ffd0c5c9") vcpkg_find_acquire_program(GIT) get_filename_component(GIT_PATH ${GIT} DIRECTORY) @@ -27,7 +28,7 @@ set(ONNX_GITHUB_URL "https://github.com/microsoft/${ONNXRUNTIME}") if(EXISTS "${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME}") # Purge any local changes vcpkg_execute_required_process( - COMMAND ${GIT} reset --hard + COMMAND ${GIT} reset --hard ${ORT_COMMIT_HASH} WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} LOGNAME build-${TARGET_TRIPLET}) @@ -48,8 +49,12 @@ else() COMMAND ${GIT} clone --recursive ${ONNX_GITHUB_URL} ${ONNXRUNTIME} WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR} LOGNAME build-${TARGET_TRIPLET}) -endif() + vcpkg_execute_required_process( + COMMAND ${GIT} reset --hard ${ORT_COMMIT_HASH} + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} + LOGNAME build-${TARGET_TRIPLET}) +endif() set(SOURCE_PATH "${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME}") From aa3d822136a9d4949f118ca74fe514d1119d2ea5 Mon Sep 17 00:00:00 2001 From: Pashupati Kumar Date: Thu, 14 Jan 2021 02:33:17 -0800 Subject: [PATCH 13/17] Fixed ORT codebase to specific commit hash --- ports/onnxruntime/portfile.cmake | 50 ++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/ports/onnxruntime/portfile.cmake b/ports/onnxruntime/portfile.cmake index 665a9df502ca15..4f06cfeeff28d2 100644 --- a/ports/onnxruntime/portfile.cmake +++ b/ports/onnxruntime/portfile.cmake @@ -25,37 +25,55 @@ vcpkg_add_to_path(${PYTHON3_PATH}) set(ONNXRUNTIME "onnxruntime.git") set(ONNX_GITHUB_URL "https://github.com/microsoft/${ONNXRUNTIME}") +# Clone ORT repo if(EXISTS "${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME}") # Purge any local changes vcpkg_execute_required_process( - COMMAND ${GIT} reset --hard ${ORT_COMMIT_HASH} + COMMAND ${GIT} clean -xfd WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} - LOGNAME build-${TARGET_TRIPLET}) - - # - vcpkg_execute_required_process( - COMMAND ${GIT} submodule sync --recursive - WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} - LOGNAME build-${TARGET_TRIPLET}) + LOGNAME build-${TARGET_TRIPLET} + ) - # vcpkg_execute_required_process( - COMMAND ${GIT} submodule update --init --recursive + COMMAND ${GIT} submodule foreach --recursive git clean -xfdf WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} LOGNAME build-${TARGET_TRIPLET}) else() + # Clone ORT Repo vcpkg_execute_required_process( COMMAND ${GIT} clone --recursive ${ONNX_GITHUB_URL} ${ONNXRUNTIME} WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR} - LOGNAME build-${TARGET_TRIPLET}) - - vcpkg_execute_required_process( - COMMAND ${GIT} reset --hard ${ORT_COMMIT_HASH} - WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} - LOGNAME build-${TARGET_TRIPLET}) + LOGNAME build-${TARGET_TRIPLET} + ) endif() +# Checkout the commit sha1 +vcpkg_execute_required_process( + COMMAND ${GIT} reset --hard ${ORT_COMMIT_HASH} + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} + LOGNAME build-${TARGET_TRIPLET} + ) + +vcpkg_execute_required_process( + COMMAND ${GIT} submodule foreach --recursive git reset --hard + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} + LOGNAME build-${TARGET_TRIPLET} + ) + + # +#vcpkg_execute_required_process( +#COMMAND ${GIT} submodule sync --recursive +#WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} +#LOGNAME build-${TARGET_TRIPLET}) + +# +vcpkg_execute_required_process( + COMMAND ${GIT} submodule update --init --recursive + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} + LOGNAME build-${TARGET_TRIPLET} + ) + set(SOURCE_PATH "${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME}") vcpkg_configure_cmake( From ef21307951386e905c4f21ebec8967aa95e8703f Mon Sep 17 00:00:00 2001 From: Pashupati Kumar Date: Wed, 20 Jan 2021 21:08:35 -0800 Subject: [PATCH 14/17] Fixed path to a header file --- ports/onnxruntime/portfile.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ports/onnxruntime/portfile.cmake b/ports/onnxruntime/portfile.cmake index 4f06cfeeff28d2..ee8f11138f18fd 100644 --- a/ports/onnxruntime/portfile.cmake +++ b/ports/onnxruntime/portfile.cmake @@ -258,7 +258,7 @@ foreach(MOD onnx/third_party/benchmark/src/ onnx/third_party/benchmark/test/ onnx/third_party/pybind11/include/ - SafeInt/safeInt/Archive/releases/ + SafeInt/safeint/Archive/releases/ protobuf/src/google/ nsync/public/ ) @@ -278,8 +278,8 @@ endforeach() # Now copy files from folders that does need to be copied recursively set(MOD "") foreach(MOD - SafeInt/safeInt - SafeInt/safeInt/Test + SafeInt/safeint + SafeInt/safeint/Test onnx/onnx onnx/onnx/defs onnx/onnx/defs/tensor @@ -381,7 +381,7 @@ if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") endif() # Remove empty directories that are created during copy operations -file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/onnxruntime/external/SafeInt/safeInt/Archive/releases/8") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/onnxruntime/external/SafeInt/safeint/Archive/releases/8") vcpkg_copy_pdbs() From 453299ec8c3575fdd4961fcf2282cfdda950f7e4 Mon Sep 17 00:00:00 2001 From: Pashupati Kumar Date: Thu, 21 Jan 2021 22:06:46 -0800 Subject: [PATCH 15/17] Remove pdb from packaging --- ports/onnxruntime/portfile.cmake | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/ports/onnxruntime/portfile.cmake b/ports/onnxruntime/portfile.cmake index ee8f11138f18fd..36e3a0f7153337 100644 --- a/ports/onnxruntime/portfile.cmake +++ b/ports/onnxruntime/portfile.cmake @@ -12,6 +12,7 @@ else() endif() set(ORT_REVISION "v1.5.3") +#Todo: Move to tag rathter than commit hash set(ORT_COMMIT_HASH "3b3e698674dca2014b91fb617e2c4f22ffd0c5c9") vcpkg_find_acquire_program(GIT) @@ -21,7 +22,7 @@ get_filename_component(PYTHON3_PATH ${PYTHON3} DIRECTORY) vcpkg_add_to_path(${PYTHON3_PATH}) vcpkg_find_acquire_program(NINJA) get_filename_component(NINJA_PATH ${NINJA} DIRECTORY) -vcpkg_add_to_path(${PYTHON3_PATH}) +vcpkg_add_to_path(${NINJA_PATH}) set(ONNXRUNTIME "onnxruntime.git") set(ONNX_GITHUB_URL "https://github.com/microsoft/${ONNXRUNTIME}") @@ -61,13 +62,12 @@ vcpkg_execute_required_process( LOGNAME build-${TARGET_TRIPLET} ) - # +# Todo: Check if we need to do the sync #vcpkg_execute_required_process( #COMMAND ${GIT} submodule sync --recursive #WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} #LOGNAME build-${TARGET_TRIPLET}) -# vcpkg_execute_required_process( COMMAND ${GIT} submodule update --init --recursive WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} @@ -167,8 +167,13 @@ foreach(BUILD_TYPE rel dbg) file(GLOB_RECURSE ORT_LIBS LIST_DIRECTORIES false ${SRCBASEDIR}/${STATIC_LIB_EXTN}) file(COPY ${ORT_LIBS} DESTINATION ${DESTBASEDIR}) - file(GLOB_RECURSE ORT_LIB_PDBS LIST_DIRECTORIES false ${SRCBASEDIR}/${SYM_FILE_EXTN}) - file(COPY ${ORT_LIB_PDBS} DESTINATION ${DESTBASEDIR}) + #Todo: 1. PDB's are contributing to 6GiB to the total package size of 10GiB + # Disabling it for time, enable back once we have fixed other issue + if(FALSE) + file(GLOB_RECURSE ORT_LIB_PDBS LIST_DIRECTORIES false ${SRCBASEDIR}/${SYM_FILE_EXTN}) + file(COPY ${ORT_LIB_PDBS} DESTINATION ${DESTBASEDIR}) + endif() + endforeach() message(STATUS "Copy libs done, copying additional header files!") @@ -383,6 +388,10 @@ endif() # Remove empty directories that are created during copy operations file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/onnxruntime/external/SafeInt/safeint/Archive/releases/8") -vcpkg_copy_pdbs() +#Todo: 2. PDB's are contributing to 6GiB to the total package size of 10GiB +# Disabling it for time, enable back once we have fixed other issue +if(FALSE) + vcpkg_copy_pdbs() +endif() -message(STATUS "Installing done") +message(STATUS "Installing done!") From 9392f6eb50e5852f71fe2cb8be8b702d09d9554a Mon Sep 17 00:00:00 2001 From: Pashupati Kumar Date: Tue, 26 Jan 2021 23:05:09 -0800 Subject: [PATCH 16/17] Set the ORT version to the used by application --- ports/onnxruntime/portfile.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ports/onnxruntime/portfile.cmake b/ports/onnxruntime/portfile.cmake index 36e3a0f7153337..1f6e73b888bcc4 100644 --- a/ports/onnxruntime/portfile.cmake +++ b/ports/onnxruntime/portfile.cmake @@ -13,7 +13,8 @@ endif() set(ORT_REVISION "v1.5.3") #Todo: Move to tag rathter than commit hash -set(ORT_COMMIT_HASH "3b3e698674dca2014b91fb617e2c4f22ffd0c5c9") +# set(ORT_COMMIT_HASH "3b3e698674dca2014b91fb617e2c4f22ffd0c5c9") +set(ORT_COMMIT_HASH "6c2162e97add696e9f7d0377dba322a4d1fe05cd") vcpkg_find_acquire_program(GIT) get_filename_component(GIT_PATH ${GIT} DIRECTORY) @@ -302,8 +303,7 @@ set(MOD "") foreach(MOD core/ models/mnist/ - models/runner/ - test/distributed/ + models/runner/ # Add this folder when move to newer commit hash, test/distributed/ test/gradient/ test/graph/ test/optimizer/ From bd64a7e96eb6c0710b2678b478061cc0060a13d9 Mon Sep 17 00:00:00 2001 From: Gautham Popuri Date: Tue, 9 Mar 2021 15:39:21 -0800 Subject: [PATCH 17/17] Portfile changes to enable building wheel and installing necessary python packages --- ports/onnxruntime/portfile.cmake | 814 ++++++++++++++++--------------- 1 file changed, 417 insertions(+), 397 deletions(-) diff --git a/ports/onnxruntime/portfile.cmake b/ports/onnxruntime/portfile.cmake index 1f6e73b888bcc4..1809e7f3edae62 100644 --- a/ports/onnxruntime/portfile.cmake +++ b/ports/onnxruntime/portfile.cmake @@ -1,397 +1,417 @@ -# Only limited triplets supported -# x64-windows: x64-windows-static-md -# x64-linux -# No support for osx and uwp OS -if(VCPKG_TARGET_IS_WINDOWS) - vcpkg_check_linkage(ONLY_STATIC_LIBRARY) - vcpkg_fail_port_install(ON_ARCH "arm" "arm64" "wasm32" "x86" ON_TARGET "uwp") -elseif(VCPKG_TARGET_IS_LINUX) - vcpkg_fail_port_install(ON_ARCH "x86") -else() - vcpkg_fail_port_install(ALWAYS) -endif() - -set(ORT_REVISION "v1.5.3") -#Todo: Move to tag rathter than commit hash -# set(ORT_COMMIT_HASH "3b3e698674dca2014b91fb617e2c4f22ffd0c5c9") -set(ORT_COMMIT_HASH "6c2162e97add696e9f7d0377dba322a4d1fe05cd") - -vcpkg_find_acquire_program(GIT) -get_filename_component(GIT_PATH ${GIT} DIRECTORY) -vcpkg_find_acquire_program(PYTHON3) -get_filename_component(PYTHON3_PATH ${PYTHON3} DIRECTORY) -vcpkg_add_to_path(${PYTHON3_PATH}) -vcpkg_find_acquire_program(NINJA) -get_filename_component(NINJA_PATH ${NINJA} DIRECTORY) -vcpkg_add_to_path(${NINJA_PATH}) -set(ONNXRUNTIME "onnxruntime.git") -set(ONNX_GITHUB_URL "https://github.com/microsoft/${ONNXRUNTIME}") - -# Clone ORT repo -if(EXISTS "${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME}") - # Purge any local changes - vcpkg_execute_required_process( - COMMAND ${GIT} clean -xfd - WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} - LOGNAME build-${TARGET_TRIPLET} - ) - - vcpkg_execute_required_process( - COMMAND ${GIT} submodule foreach --recursive git clean -xfdf - WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} - LOGNAME build-${TARGET_TRIPLET}) - -else() - # Clone ORT Repo - vcpkg_execute_required_process( - COMMAND ${GIT} clone --recursive ${ONNX_GITHUB_URL} ${ONNXRUNTIME} - WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR} - LOGNAME build-${TARGET_TRIPLET} - ) -endif() - -# Checkout the commit sha1 -vcpkg_execute_required_process( - COMMAND ${GIT} reset --hard ${ORT_COMMIT_HASH} - WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} - LOGNAME build-${TARGET_TRIPLET} - ) - -vcpkg_execute_required_process( - COMMAND ${GIT} submodule foreach --recursive git reset --hard - WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} - LOGNAME build-${TARGET_TRIPLET} - ) - -# Todo: Check if we need to do the sync -#vcpkg_execute_required_process( -#COMMAND ${GIT} submodule sync --recursive -#WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} -#LOGNAME build-${TARGET_TRIPLET}) - -vcpkg_execute_required_process( - COMMAND ${GIT} submodule update --init --recursive - WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} - LOGNAME build-${TARGET_TRIPLET} - ) - -set(SOURCE_PATH "${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME}") - -vcpkg_configure_cmake( - SOURCE_PATH "${SOURCE_PATH}/cmake" - PREFER_NINJA - OPTIONS - -Donnxruntime_RUN_ONNX_TESTS=OFF - -Donnxruntime_BUILD_WINML_TESTS=ON - -Donnxruntime_GENERATE_TEST_REPORTS=ON - -Donnxruntime_USE_CUDA=OFF - -Donnxruntime_USE_FEATURIZERS=OFF - -Donnxruntime_USE_JEMALLOC=OFF - -Donnxruntime_USE_MIMALLOC_STL_ALLOCATOR=OFF - -Donnxruntime_USE_MIMALLOC_ARENA_ALLOCATOR=OFF - -Donnxruntime_BUILD_SHARED_LIB=OFF - -Donnxruntime_USE_EIGEN_FOR_BLAS=ON - -Donnxruntime_USE_OPENBLAS=OFF - -Donnxruntime_USE_DNNL=OFF - -Donnxruntime_USE_MKLML=OFF - -Donnxruntime_USE_NNAPI_BUILTIN=OFF - -Donnxruntime_USE_RKNPU=OFF - -Donnxruntime_USE_OPENMP=OFF - -Donnxruntime_USE_TVM=OFF - -Donnxruntime_USE_LLVM=OFF - -Donnxruntime_ENABLE_MICROSOFT_INTERNAL=OFF - -Donnxruntime_USE_VITISAI=OFF - -Donnxruntime_USE_NUPHAR=OFF - -Donnxruntime_USE_TENSORRT=OFF - -Donnxruntime_TENSORRT_HOME= - -Donnxruntime_USE_MIGRAPHX=OFF - -Donnxruntime_MIGRAPHX_HOME= - -Donnxruntime_CROSS_COMPILING=OFF - -Donnxruntime_DISABLE_CONTRIB_OPS=OFF - -Donnxruntime_DISABLE_ML_OPS=OFF - -Donnxruntime_DISABLE_RTTI=OFF - -Donnxruntime_DISABLE_EXCEPTIONS=OFF - -Donnxruntime_DISABLE_ORT_FORMAT_LOAD=OFF - -Donnxruntime_MINIMAL_BUILD=OFF - -Donnxruntime_ENABLE_LANGUAGE_INTEROP_OPS=OFF - -Donnxruntime_USE_DML=OFF - -Donnxruntime_USE_WINML=OFF - -Donnxruntime_USE_TELEMETRY=OFF - -Donnxruntime_ENABLE_LTO=OFF - -Donnxruntime_USE_ACL=OFF - -Donnxruntime_USE_ACL_1902=OFF - -Donnxruntime_USE_ACL_1905=OFF - -Donnxruntime_USE_ACL_1908=OFF - -Donnxruntime_USE_ACL_2002=OFF - -Donnxruntime_USE_ARMNN=OFF - -Donnxruntime_ARMNN_RELU_USE_CPU=ON - -Donnxruntime_ARMNN_BN_USE_CPU=ON - -Donnxruntime_ENABLE_NVTX_PROFILE=OFF - -Donnxruntime_ENABLE_TRAINING=ON - -Donnxruntime_USE_HOROVOD=OFF - -Donnxruntime_USE_NCCL=ON - -Donnxruntime_BUILD_BENCHMARKS=OFF - -Donnxruntime_USE_ROCM=OFF - -Donnxruntime_PYBIND_EXPORT_OPSCHEMA=OFF - -Donnxruntime_ENABLE_MEMLEAK_CHECKER=OFF - -DCMAKE_BUILD_TYPE=RelWithDebInfo - -DONNX_ML=ON - -DONNX_NAMESPACE=onnx - ${FEATURE_OPTIONS} - -DPYTHON_EXECUTABLE=${PYTHON3} -) - -vcpkg_install_cmake() - -message(STATUS "Copy libs and additional header files!") -# Copy lib and PDB files -if(VCPKG_TARGET_IS_WINDOWS) - set(STATIC_LIB_EXTN "*.lib") - set(DYN_LIB_EXTN "*.dll") - set(SYM_FILE_EXTN "*.pdb") -elseif(VCPKG_TARGET_IS_LINUX) # !Winddows - set(STATIC_LIB_EXTN "*.a") - set(DYN_LIB_EXTN "*.(s|S)(o|O)") - set(SYM_FILE_EXTN "*.pdb") -endif() - -# Copy all libraries and PDBs -foreach(BUILD_TYPE rel dbg) - if(${BUILD_TYPE} STREQUAL "dbg") - set(SRCBASEDIR "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg") - set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/debug/lib") - else() - set(SRCBASEDIR "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel") - set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/lib") - endif() - - file(GLOB_RECURSE ORT_LIBS LIST_DIRECTORIES false ${SRCBASEDIR}/${STATIC_LIB_EXTN}) - file(COPY ${ORT_LIBS} DESTINATION ${DESTBASEDIR}) - - #Todo: 1. PDB's are contributing to 6GiB to the total package size of 10GiB - # Disabling it for time, enable back once we have fixed other issue - if(FALSE) - file(GLOB_RECURSE ORT_LIB_PDBS LIST_DIRECTORIES false ${SRCBASEDIR}/${SYM_FILE_EXTN}) - file(COPY ${ORT_LIB_PDBS} DESTINATION ${DESTBASEDIR}) - endif() - -endforeach() - -message(STATUS "Copy libs done, copying additional header files!") - -# Copy additional header files -# TODO: Make changes in ORT souce repo to put all training header files under top level include dir - -# 1. Copy header files from top level include directories -# Todo: Investigate why these headers files are not copied by vcpkg -set(SRCBASEDIR "${SOURCE_PATH}/include/onnxruntime/core") -set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/include/onnxruntime/core") -foreach(MOD - platform/ - graph/ - session/ - optimizer/ - providers/ - ) - file(COPY - ${SRCBASEDIR}/${MOD} - DESTINATION ${DESTBASEDIR}/${MOD} - FOLLOW_SYMLINK_CHAIN - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "*.inc" - ) -endforeach() - -# 2. Copy missing external header files from build output folders. These are generaterd by build -# e.g. onnx-data.pb.h -# Trailing '/' is significant. Without it copying 'mydir' folder would be installed under Destination. -if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - set(SRCBASEDIR "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/external") - set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/include/onnxruntime/external") - foreach(MOD onnx/onnx/) # Placeholder to put more directories ,if needed!. - file(COPY ${SRCBASEDIR}/${MOD} DESTINATION ${DESTBASEDIR}/${MOD} FOLLOW_SYMLINK_CHAIN FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" PATTERN ".inc") - endforeach() -endif() - -# 3. Copy header files from source core directories -# Todo: Check if we need to copy this: core/providers/nuphar/compiler/x86/op_ir_creator/all_ops.h -set(SRCBASEDIR "${SOURCE_PATH}/onnxruntime/core") -set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/include/onnxruntime/core") -set(MOD "") -foreach(MOD - common/ - framework/ - graph/ - platform/ - optimizer/ - providers/ - session/ - util/ - ) - file(COPY - ${SRCBASEDIR}/${MOD} - DESTINATION ${DESTBASEDIR}/${MOD} - FOLLOW_SYMLINK_CHAIN - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "*.inc" - PATTERN "cuda/atomic" EXCLUDE #These paths under providers don't have any header files to be copied - PATTERN "cuda/cu_inc" EXCLUDE - PATTERN "cuda/multi_tensor" EXCLUDE - PATTERN "nuphar/compiler/x86/op_ir_creator" EXCLUDE - PATTERN "nuphar/scripts" EXCLUDE - PATTERN "rocm/atomic" EXCLUDE - PATTERN "rocm/cu_inc" EXCLUDE - PATTERN "rocm/math" EXCLUDE - ) -endforeach() - -# 4. Copy external header files from source folders -set(SRCBASEDIR "${SOURCE_PATH}/cmake/external") -set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/include/onnxruntime/external") -set(MOD "") -foreach(MOD - optional-lite/include/nonstd/ - optional-lite/test/ - onnx/onnx/common/ - onnx/onnx/optimizer/ - onnx/onnx/shape_inference/ - onnx/onnx/version_converter/ - onnx/third_party/benchmark/include/ - onnx/third_party/benchmark/src/ - onnx/third_party/benchmark/test/ - onnx/third_party/pybind11/include/ - SafeInt/safeint/Archive/releases/ - protobuf/src/google/ - nsync/public/ - ) - file(COPY - ${SRCBASEDIR}/${MOD} - DESTINATION ${DESTBASEDIR}/${MOD} - FOLLOW_SYMLINK_CHAIN - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "*.inc" - PATTERN "protobuf/util/internal/testdata" EXCLUDE # protobuf/src/google/ subfolders to skip - PATTERN "protobuf/testdata" EXCLUDE - ) -endforeach() - -# Now copy files from folders that does need to be copied recursively -set(MOD "") -foreach(MOD - SafeInt/safeint - SafeInt/safeint/Test - onnx/onnx - onnx/onnx/defs - onnx/onnx/defs/tensor - onnx/third_party/pybind11/tests - ) - set(EXT_ADDL_HDRS "") - file(GLOB EXT_ADDL_HDRS LIST_DIRECTORIES false ${SRCBASEDIR}/${MOD}/*.h ${SRCBASEDIR}/${MOD}/*.hpp) - file(COPY ${EXT_ADDL_HDRS} DESTINATION ${DESTBASEDIR}/${MOD}) -endforeach() - -# 4. Copy training header files from sources directories -set(SRCBASEDIR "${SOURCE_PATH}/orttraining/orttraining") -set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/include/orttraining") -set(MOD "") -foreach(MOD - core/ - models/mnist/ - models/runner/ # Add this folder when move to newer commit hash, test/distributed/ - test/gradient/ - test/graph/ - test/optimizer/ - test/session/ - training_ops/ - ) - file(COPY - ${SRCBASEDIR}/${MOD} - DESTINATION ${DESTBASEDIR}/${MOD} - FOLLOW_SYMLINK_CHAIN - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "*.inc" - PATTERN "rocm/activation" EXCLUDE # All these folders under training_ops do not have header files! - PATTERN "rocm/collective" EXCLUDE - PATTERN "rocm/loss" EXCLUDE - PATTERN "rocm/math" EXCLUDE - PATTERN "rocm/optimizer" EXCLUDE - PATTERN "rocm/reduction" EXCLUDE - ) -endforeach() - -# Now copy files from folders that does need to be copied recursively -set(MOD "") -foreach(MOD - test/training_ops - ) - set(EXT_ADDL_HDRS "") - file(GLOB EXT_ADDL_HDRS LIST_DIRECTORIES false ${SRCBASEDIR}/${MOD}/*.h ${SRCBASEDIR}/${MOD}/*.hpp) - file(COPY ${EXT_ADDL_HDRS} DESTINATION ${DESTBASEDIR}/${MOD}) -endforeach() - -# 5. Copy Test header files from sources directories -set(SRCBASEDIR "${SOURCE_PATH}/onnxruntime/test") -set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/include/onnxruntime/test") -set(MOD "") -foreach(MOD - util/include/ - framework/ - ) - file(COPY - ${SRCBASEDIR}/${MOD} - DESTINATION ${DESTBASEDIR}/${MOD} - FOLLOW_SYMLINK_CHAIN - FILES_MATCHING - PATTERN "*.h" - PATTERN "*.hpp" - PATTERN "*.inc" - PATTERN "cuda" EXCLUDE - ) -endforeach() - -# Copy onnxruntime_config.h file -if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/onnxruntime_config.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/onnxruntime) - file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/onnxruntime_config.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/orttraining) -endif() - -if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") - file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/onnxruntime_config.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/onnxruntime) - file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/onnxruntime_config.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/orttraining) -endif() - -# Copy the license file -file(INSTALL - ${SOURCE_PATH}/LICENSE - DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) - -message(STATUS "Copy libs and headers done!") - -# Remove bin directories for static build, both debug and release build -# onnx_test_runner.exe, onnxruntime.dll -if(VCPKG_LIBRARY_LINKAGE STREQUAL static) - file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin") -endif() - -if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") -endif() - -# Remove empty directories that are created during copy operations -file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/onnxruntime/external/SafeInt/safeint/Archive/releases/8") - -#Todo: 2. PDB's are contributing to 6GiB to the total package size of 10GiB -# Disabling it for time, enable back once we have fixed other issue -if(FALSE) - vcpkg_copy_pdbs() -endif() - -message(STATUS "Installing done!") +# Only limited triplets supported +# x64-windows: x64-windows-static-md +# x64-linux +# No support for osx and uwp OS +if(VCPKG_TARGET_IS_WINDOWS) + vcpkg_check_linkage(ONLY_STATIC_LIBRARY) + vcpkg_fail_port_install(ON_ARCH "arm" "arm64" "wasm32" "x86" ON_TARGET "uwp") +elseif(VCPKG_TARGET_IS_LINUX) + vcpkg_fail_port_install(ON_ARCH "x86") +else() + vcpkg_fail_port_install(ALWAYS) +endif() + +set(ORT_REVISION "v1.5.3") +#Todo: Move to tag rathter than commit hash +# set(ORT_COMMIT_HASH "3b3e698674dca2014b91fb617e2c4f22ffd0c5c9") +set(ORT_COMMIT_HASH "6c2162e97add696e9f7d0377dba322a4d1fe05cd") + +vcpkg_find_acquire_program(GIT) +get_filename_component(GIT_PATH ${GIT} DIRECTORY) +vcpkg_find_acquire_program(PYTHON3) +get_filename_component(PYTHON3_PATH ${PYTHON3} DIRECTORY) +vcpkg_add_to_path(${PYTHON3_PATH}) + +# install pip +vcpkg_from_github( + OUT_SOURCE_PATH PYFILE_PATH + REPO pypa/get-pip + REF 667abf5829986a5e708dc2575fe12c8ad2ce14a4 + SHA512 59cf8dd4fd699c8ea46eb890c8287924c15a096b8a14d8b242fdc36becdaa0c1d67f0afc268f5507d1621b4d6ded85f0fb350cee1f8d39b496d8af980f871857 + HEAD_REF master +) +execute_process(COMMAND ${PYTHON3} ${PYFILE_PATH}/get-pip.py) + +# install numpy +vcpkg_execute_required_process(COMMAND ${PYTHON3} -m pip install --user -U numpy WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR} LOGNAME prerequesits-pip-${TARGET_TRIPLET}) + +vcpkg_find_acquire_program(NINJA) +get_filename_component(NINJA_PATH ${NINJA} DIRECTORY) +vcpkg_add_to_path(${NINJA_PATH}) +set(ONNXRUNTIME "onnxruntime.git") +set(ONNX_GITHUB_URL "https://github.com/microsoft/${ONNXRUNTIME}") + +# Clone ORT repo +if(EXISTS "${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME}") + # Purge any local changes + vcpkg_execute_required_process( + COMMAND ${GIT} clean -xfd + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} + LOGNAME build-${TARGET_TRIPLET} + ) + + vcpkg_execute_required_process( + COMMAND ${GIT} submodule foreach --recursive git clean -xfdf + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} + LOGNAME build-${TARGET_TRIPLET}) + +else() + # Clone ORT Repo + vcpkg_execute_required_process( + COMMAND ${GIT} clone --recursive ${ONNX_GITHUB_URL} ${ONNXRUNTIME} + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR} + LOGNAME build-${TARGET_TRIPLET} + ) +endif() + +# Checkout the commit sha1 +vcpkg_execute_required_process( + COMMAND ${GIT} reset --hard ${ORT_COMMIT_HASH} + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} + LOGNAME build-${TARGET_TRIPLET} + ) + +vcpkg_execute_required_process( + COMMAND ${GIT} submodule foreach --recursive git reset --hard + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} + LOGNAME build-${TARGET_TRIPLET} + ) + +# Todo: Check if we need to do the sync +#vcpkg_execute_required_process( +#COMMAND ${GIT} submodule sync --recursive +#WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} +#LOGNAME build-${TARGET_TRIPLET}) + +vcpkg_execute_required_process( + COMMAND ${GIT} submodule update --init --recursive + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME} + LOGNAME build-${TARGET_TRIPLET} + ) + +set(SOURCE_PATH "${CURRENT_BUILDTREES_DIR}/${ONNXRUNTIME}") + +vcpkg_configure_cmake( + SOURCE_PATH "${SOURCE_PATH}/cmake" + PREFER_NINJA + OPTIONS + -Donnxruntime_ENABLE_PYTHON=ON + -Donnxruntime_ENABLE_TRAINING=ON + -Donnxruntime_BUILD_SHARED_LIB=ON + -Donnxruntime_USE_MPI=ON + -Donnxruntime_ENABLE_MEMLEAK_CHECKER=OFF + -Donnxruntime_BUILD_WINML_TESTS=ON + -Donnxruntime_GENERATE_TEST_REPORTS=ON + -Donnxruntime_USE_EIGEN_FOR_BLAS=ON + -Donnxruntime_ARMNN_RELU_USE_CPU=ON + -Donnxruntime_ARMNN_BN_USE_CPU=ON + -Donnxruntime_USE_NCCL=ON + -Donnxruntime_RUN_ONNX_TESTS=OFF + -Donnxruntime_USE_FEATURIZERS=OFF + -Donnxruntime_USE_CUDA=OFF + -Donnxruntime_USE_JEMALLOC=OFF + -Donnxruntime_USE_MIMALLOC_STL_ALLOCATOR=OFF + -Donnxruntime_USE_MIMALLOC_ARENA_ALLOCATOR=OFF + -Donnxruntime_USE_OPENBLAS=OFF + -Donnxruntime_USE_DNNL=OFF + -Donnxruntime_USE_MKLML=OFF + -Donnxruntime_USE_NNAPI_BUILTIN=OFF + -Donnxruntime_USE_RKNPU=OFF + -Donnxruntime_USE_OPENMP=OFF + -Donnxruntime_USE_TVM=OFF + -Donnxruntime_USE_LLVM=OFF + -Donnxruntime_ENABLE_MICROSOFT_INTERNAL=OFF + -Donnxruntime_USE_VITISAI=OFF + -Donnxruntime_USE_NUPHAR=OFF + -Donnxruntime_USE_TENSORRT=OFF + -Donnxruntime_TENSORRT_HOME= + -Donnxruntime_USE_MIGRAPHX=OFF + -Donnxruntime_MIGRAPHX_HOME= + -Donnxruntime_CROSS_COMPILING=OFF + -Donnxruntime_DISABLE_CONTRIB_OPS=OFF + -Donnxruntime_DISABLE_ML_OPS=OFF + -Donnxruntime_DISABLE_RTTI=OFF + -Donnxruntime_DISABLE_EXCEPTIONS=OFF + -Donnxruntime_DISABLE_ORT_FORMAT_LOAD=OFF + -Donnxruntime_MINIMAL_BUILD=OFF + -Donnxruntime_ENABLE_LANGUAGE_INTEROP_OPS=OFF + -Donnxruntime_USE_DML=OFF + -Donnxruntime_USE_WINML=OFF + -Donnxruntime_USE_TELEMETRY=OFF + -Donnxruntime_ENABLE_LTO=OFF + -Donnxruntime_USE_ACL=OFF + -Donnxruntime_USE_ACL_1902=OFF + -Donnxruntime_USE_ACL_1905=OFF + -Donnxruntime_USE_ACL_1908=OFF + -Donnxruntime_USE_ACL_2002=OFF + -Donnxruntime_USE_ARMNN=OFF + -Donnxruntime_ENABLE_NVTX_PROFILE=OFF + -Donnxruntime_USE_HOROVOD=OFF + -Donnxruntime_BUILD_BENCHMARKS=OFF + -Donnxruntime_USE_ROCM=OFF + -Donnxruntime_PYBIND_EXPORT_OPSCHEMA=OFF + -DCMAKE_BUILD_TYPE=RelWithDebInfo + -DONNX_ML=ON + -DONNX_NAMESPACE=onnx + ${FEATURE_OPTIONS} + -DPYTHON_EXECUTABLE=${PYTHON3} +) + +vcpkg_install_cmake() + +message(STATUS "Copy libs and additional header files!") +# Copy lib and PDB files +if(VCPKG_TARGET_IS_WINDOWS) + set(STATIC_LIB_EXTN "*.lib") + set(SYM_FILE_EXTN "*.pdb") +elseif(VCPKG_TARGET_IS_LINUX) + set(STATIC_LIB_EXTN "*.a") + set(SYM_FILE_EXTN "*.pdb") +endif() + +# Copy all libraries and PDBs +foreach(BUILD_TYPE rel dbg) + if(${BUILD_TYPE} STREQUAL "dbg") + set(SRCBASEDIR "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg") + set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/debug/lib") + else() + set(SRCBASEDIR "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel") + set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/lib") + endif() + + file(GLOB_RECURSE ORT_LIBS LIST_DIRECTORIES false ${SRCBASEDIR}/${STATIC_LIB_EXTN}) + file(COPY ${ORT_LIBS} DESTINATION ${DESTBASEDIR}) + + #Todo: 1. PDB's are contributing to 6GiB to the total package size of 10GiB + # Disabling it for time, enable back once we have fixed other issue + if(FALSE) + file(GLOB_RECURSE ORT_LIB_PDBS LIST_DIRECTORIES false ${SRCBASEDIR}/${SYM_FILE_EXTN}) + file(COPY ${ORT_LIB_PDBS} DESTINATION ${DESTBASEDIR}) + endif() +endforeach() + +message(STATUS "Copy libs done, copying additional header files!") + +# Copy additional header files +# TODO: Make changes in ORT souce repo to put all training header files under top level include dir + +# 1. Copy header files from top level include directories +# Todo: Investigate why these headers files are not copied by vcpkg +set(SRCBASEDIR "${SOURCE_PATH}/include/onnxruntime/core") +set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/include/onnxruntime/core") +foreach(MOD + platform/ + graph/ + session/ + optimizer/ + providers/ + ) + file(COPY + ${SRCBASEDIR}/${MOD} + DESTINATION ${DESTBASEDIR}/${MOD} + FOLLOW_SYMLINK_CHAIN + FILES_MATCHING + PATTERN "*.h" + PATTERN "*.hpp" + PATTERN "*.inc" + ) +endforeach() + +# 2. Copy missing external header files from build output folders. These are generaterd by build +# e.g. onnx-data.pb.h +# Trailing '/' is significant. Without it copying 'mydir' folder would be installed under Destination. +if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + set(SRCBASEDIR "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/external") + set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/include/onnxruntime/external") + foreach(MOD onnx/onnx/) # Placeholder to put more directories ,if needed!. + file(COPY ${SRCBASEDIR}/${MOD} DESTINATION ${DESTBASEDIR}/${MOD} FOLLOW_SYMLINK_CHAIN FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" PATTERN ".inc") + endforeach() +endif() + +# 3. Copy header files from source core directories +# Todo: Check if we need to copy this: core/providers/nuphar/compiler/x86/op_ir_creator/all_ops.h +set(SRCBASEDIR "${SOURCE_PATH}/onnxruntime/core") +set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/include/onnxruntime/core") +set(MOD "") +foreach(MOD + common/ + framework/ + graph/ + platform/ + optimizer/ + providers/ + session/ + util/ + ) + file(COPY + ${SRCBASEDIR}/${MOD} + DESTINATION ${DESTBASEDIR}/${MOD} + FOLLOW_SYMLINK_CHAIN + FILES_MATCHING + PATTERN "*.h" + PATTERN "*.hpp" + PATTERN "*.inc" + PATTERN "cuda/atomic" EXCLUDE #These paths under providers don't have any header files to be copied + PATTERN "cuda/cu_inc" EXCLUDE + PATTERN "cuda/multi_tensor" EXCLUDE + PATTERN "nuphar/compiler/x86/op_ir_creator" EXCLUDE + PATTERN "nuphar/scripts" EXCLUDE + PATTERN "rocm/atomic" EXCLUDE + PATTERN "rocm/cu_inc" EXCLUDE + PATTERN "rocm/math" EXCLUDE + ) +endforeach() + +# 4. Copy external header files from source folders +set(SRCBASEDIR "${SOURCE_PATH}/cmake/external") +set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/include/onnxruntime/external") +set(MOD "") +foreach(MOD + optional-lite/include/nonstd/ + optional-lite/test/ + onnx/onnx/common/ + onnx/onnx/optimizer/ + onnx/onnx/shape_inference/ + onnx/onnx/version_converter/ + onnx/third_party/benchmark/include/ + onnx/third_party/benchmark/src/ + onnx/third_party/benchmark/test/ + onnx/third_party/pybind11/include/ + SafeInt/safeint/Archive/releases/ + protobuf/src/google/ + nsync/public/ + ) + file(COPY + ${SRCBASEDIR}/${MOD} + DESTINATION ${DESTBASEDIR}/${MOD} + FOLLOW_SYMLINK_CHAIN + FILES_MATCHING + PATTERN "*.h" + PATTERN "*.hpp" + PATTERN "*.inc" + PATTERN "protobuf/util/internal/testdata" EXCLUDE # protobuf/src/google/ subfolders to skip + PATTERN "protobuf/testdata" EXCLUDE + ) +endforeach() + +# Now copy files from folders that does need to be copied recursively +set(MOD "") +foreach(MOD + SafeInt/safeint + SafeInt/safeint/Test + onnx/onnx + onnx/onnx/defs + onnx/onnx/defs/tensor + onnx/third_party/pybind11/tests + ) + set(EXT_ADDL_HDRS "") + file(GLOB EXT_ADDL_HDRS LIST_DIRECTORIES false ${SRCBASEDIR}/${MOD}/*.h ${SRCBASEDIR}/${MOD}/*.hpp) + file(COPY ${EXT_ADDL_HDRS} DESTINATION ${DESTBASEDIR}/${MOD}) +endforeach() + +# 4. Copy training header files from sources directories +set(SRCBASEDIR "${SOURCE_PATH}/orttraining/orttraining") +set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/include/orttraining") +set(MOD "") +foreach(MOD + core/ + models/mnist/ + models/runner/ + test/gradient/ + test/graph/ + test/optimizer/ + training_ops/ + ) + file(COPY + ${SRCBASEDIR}/${MOD} + DESTINATION ${DESTBASEDIR}/${MOD} + FOLLOW_SYMLINK_CHAIN + FILES_MATCHING + PATTERN "*.h" + PATTERN "*.hpp" + PATTERN "*.inc" + PATTERN "rocm/activation" EXCLUDE # All these folders under training_ops do not have header files! + PATTERN "rocm/collective" EXCLUDE + PATTERN "rocm/loss" EXCLUDE + PATTERN "rocm/math" EXCLUDE + PATTERN "rocm/optimizer" EXCLUDE + PATTERN "rocm/reduction" EXCLUDE + ) +endforeach() + +# Now copy files from folders that does need to be copied recursively +set(MOD "") +foreach(MOD + test/training_ops + ) + set(EXT_ADDL_HDRS "") + file(GLOB EXT_ADDL_HDRS LIST_DIRECTORIES false ${SRCBASEDIR}/${MOD}/*.h ${SRCBASEDIR}/${MOD}/*.hpp) + file(COPY ${EXT_ADDL_HDRS} DESTINATION ${DESTBASEDIR}/${MOD}) +endforeach() + +# 5. Copy Test header files from sources directories +set(SRCBASEDIR "${SOURCE_PATH}/onnxruntime/test") +set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/include/onnxruntime/test") +set(MOD "") +foreach(MOD + util/include/ + framework/ + ) + file(COPY + ${SRCBASEDIR}/${MOD} + DESTINATION ${DESTBASEDIR}/${MOD} + FOLLOW_SYMLINK_CHAIN + FILES_MATCHING + PATTERN "*.h" + PATTERN "*.hpp" + PATTERN "*.inc" + PATTERN "cuda" EXCLUDE + ) +endforeach() + +# Copy onnxruntime_config.h file +if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/onnxruntime_config.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/onnxruntime) + file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/onnxruntime_config.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/orttraining) +endif() + +if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/onnxruntime_config.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/onnxruntime) + file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/onnxruntime_config.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/orttraining) +endif() + +# Copy the license file +file(INSTALL + ${SOURCE_PATH}/LICENSE + DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) + +message(STATUS "Copy libs and headers done!") + +# Copy python packages and libraries. +set(SRCBASEDIR "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/onnxruntime") +set(DESTBASEDIR "${CURRENT_PACKAGES_DIR}/share/onnxruntime") + +file(COPY + ${SRCBASEDIR}/ + DESTINATION ${DESTBASEDIR} + ) +# Remove bin directories for static build, both debug and release build +# onnx_test_runner.exe, onnxruntime.dll +if(VCPKG_LIBRARY_LINKAGE STREQUAL static) + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin") +endif() + +if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +endif() + +# Remove empty directories that are created during copy operations +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/onnxruntime/external/SafeInt/safeint/Archive/releases/8") + +#Todo: 2. PDB's are contributing to 6GiB to the total package size of 10GiB +# Disabling it for time, enable back once we have fixed other issue +if(FALSE) + vcpkg_copy_pdbs() +endif() + +message(STATUS "Installing done!")