Skip to content

Commit

Permalink
fix the build for mobile packaging (#843)
Browse files Browse the repository at this point in the history
* fix the build for mobile packaging

* update the cmake file as well

* more fixing on dlib related ops

* release the iOS cmake version constraint

* upgrade cmake in Linux CUDA build

* Update Dockerfile.ubuntu_cuda11_8_tensorrt8_6 for typo

* Update ios_packaging.yml for Azure Pipelines

* update the dlib versoin

* update all cases of cmake version

* update the comment for dlb cmake
  • Loading branch information
wenbingl authored Nov 18, 2024
1 parent 5104bb9 commit c3379ec
Show file tree
Hide file tree
Showing 17 changed files with 85 additions and 47 deletions.
5 changes: 2 additions & 3 deletions .pipelines/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -851,10 +851,9 @@ stages:
architecture: 'x64'
displayName: "Use Python 3.12"

# iOS xcframework build doesn't work with CMake 3.25.1, pin to 3.25.0
- script: |
python -m pip install cmake==3.25.0
displayName: "Install CMake 3.25.0"
python -m pip install cmake
displayName: "Install CMake"
- template: templates/set-package-version-variable-step.yml
parameters:
Expand Down
5 changes: 2 additions & 3 deletions .pipelines/ios_packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ jobs:
addToPath: true
architecture: "x64"

# iOS xcframework build doesn't work with CMake 3.25.1, pin to 3.25.0
- script: |
python -m pip install cmake==3.25.0
displayName: "Install CMake 3.25.0"
python -m pip install cmake
displayName: "Install CMake"
- template: templates/install-appcenter.yml

Expand Down
5 changes: 2 additions & 3 deletions .pipelines/templates/build-package-for-ios-cocoapods.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,9 @@ jobs:
addToPath: true
architecture: "x64"

# iOS xcframework build doesn't work with CMake 3.25.1, pin to 3.25.0
- script: |
python -m pip install cmake==3.25.0
displayName: "Install CMake 3.25.0"
python -m pip install cmake
displayName: "Install CMake"
- template: set-package-version-variable-step.yml
parameters:
Expand Down
2 changes: 1 addition & 1 deletion .pipelines/templates/build-package-for-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
sudo apt-get install -y libssh-dev
displayName: Install OpenSSL for Azure custom ops
# NOTE: on arm64 machine, CMake version needs to be updated since we now require CMake 3.25 or newer.
# NOTE: on arm64 machine, CMake version needs to be updated since we now require CMake 3.28 or newer.
- ${{ if eq(parameters.OrtExtensionsArch, 'x64') }}:
- bash: |
export CFLAGS="${{parameters.OrtExtensionsCFlags}}"
Expand Down
5 changes: 2 additions & 3 deletions .pipelines/templates/ios-framework-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ jobs:
addToPath: true
architecture: "x64"

# iOS xcframework build doesn't work with CMake 3.25.1, pin to 3.25.0
- script: |
python -m pip install cmake==3.25.0
displayName: "Install CMake 3.25.0"
python -m pip install cmake
displayName: "Install CMake"
- template: set-package-version-variable-step.yml
parameters:
Expand Down
39 changes: 25 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Licensed under the MIT License.

# Minimum CMake required
cmake_minimum_required(VERSION 3.25)
cmake_minimum_required(VERSION 3.28)
project(onnxruntime_extensions LANGUAGES C CXX)

# set(CMAKE_VERBOSE_MAKEFILE ON)
Expand Down Expand Up @@ -334,6 +334,20 @@ endif()
file(GLOB TARGET_SRC_NOEXCEPTION "base/*.h" "base/*.cc")
file(GLOB TARGET_SRC "operators/*.cc" "operators/*.h" "include/*.h" "include/*.hpp")

if(OCOS_ENABLE_DLIB)
set(DLIB_ISO_CPP_ONLY ON CACHE INTERNAL "")
set(DLIB_NO_GUI_SUPPORT ON CACHE INTERNAL "")
set(DLIB_USE_CUDA OFF CACHE INTERNAL "")
set(DLIB_USE_LAPACK OFF CACHE INTERNAL "")
set(DLIB_USE_BLAS OFF CACHE INTERNAL "")
include(dlib)

# Ideally, dlib should be included as file(GLOB TARGET_SRC_DLIB "${dlib_SOURCE_DIR}/dlib/all/source.cpp")
# To avoid the unintentional using some unwanted component, we only include the test_for_odr_violations.cpp
# to check if there is any violation in build configuration to ensure compiling some dlib source files correctly.
file(GLOB TARGET_SRC_DLIB "${dlib_SOURCE_DIR}/dlib/test_for_odr_violations.cpp")
endif()

if(OCOS_ENABLE_TF_STRING)
set(farmhash_SOURCE_DIR ${PROJECT_SOURCE_DIR}/cmake/externals/farmhash)
file(GLOB TARGET_SRC_KERNELS "operators/text/*.cc" "operators/text/*.h*")
Expand All @@ -342,8 +356,12 @@ if(OCOS_ENABLE_TF_STRING)
endif()

if(OCOS_ENABLE_AUDIO)
if (NOT OCOS_ENABLE_DLIB)
message(FATAL_ERROR "Audio operators require DLIB to be enabled.")
endif()
include(dr_libs)
file(GLOB TARGET_SRC_AUDIO "operators/audio/*.*")
list(APPEND TARGET_SRC_AUDIO ${dlib_SOURCE_DIR}/dlib/fft/fft.cpp)
list(APPEND TARGET_SRC_NOEXCEPTION ${TARGET_SRC_AUDIO})
endif()

Expand All @@ -353,20 +371,10 @@ if(OCOS_ENABLE_RE2_REGEX)
endif()

if(OCOS_ENABLE_MATH)
if(OCOS_ENABLE_DLIB)
set(DLIB_ISO_CPP_ONLY ON CACHE INTERNAL "")
set(DLIB_NO_GUI_SUPPORT ON CACHE INTERNAL "")
set(DLIB_USE_CUDA OFF CACHE INTERNAL "")
set(DLIB_USE_LAPACK OFF CACHE INTERNAL "")
set(DLIB_USE_BLAS OFF CACHE INTERNAL "")
include(dlib)

# Ideally, dlib should be included as
# file(GLOB TARGET_SRC_DLIB "${dlib_SOURCE_DIR}/dlib/all/source.cpp")
# To avoid the unintentional using some unwanted component, only include
file(GLOB TARGET_SRC_DLIB "${dlib_SOURCE_DIR}/dlib/test_for_odr_violations.cpp")
file(GLOB TARGET_SRC_INVERSE "operators/math/dlib/*.cc" "operators/math/dlib/*.h*")
if (NOT OCOS_ENABLE_DLIB)
message(FATAL_ERROR "Math operators require DLIB to be enabled.")
endif()
file(GLOB TARGET_SRC_INVERSE "operators/math/dlib/*.cc" "operators/math/dlib/*.h*")

file(GLOB TARGET_SRC_MATH "operators/math/*.cc" "operators/math/*.h*")
if(OCOS_USE_CUDA)
Expand Down Expand Up @@ -664,6 +672,9 @@ if(OCOS_ENABLE_VISION)

set(_DEFAULT_CODEC_ENABLE ON) # libpng and libjpeg can be optional after EncodeImage with native support too.
if(_DEFAULT_CODEC_ENABLE)
if (NOT OCOS_ENABLE_DLIB)
message(FATAL_ERROR "Vision operators require DLIB to be enabled.") # for now, we need dlib for image processing
endif()
include(ext_imgcodecs)
target_include_directories(ocos_operators PUBLIC ${libPNG_SOURCE_DIR} ${libJPEG_SOURCE_DIR})
target_link_libraries(ocos_operators PUBLIC ${PNG_LIBRARY} ${JPEG_LIBRARY})
Expand Down
4 changes: 2 additions & 2 deletions ThirdPartyNotices.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ blingfire 0831265c1aca95ca02eca5bf1155e4251e545328

_____

dlib a12824d42584e292ecb3bad05c4b32c2015a7b89
dlib v19.24.6

Boost Software License - Version 1.0 - August 17th, 2003

Expand Down Expand Up @@ -106,7 +106,7 @@ Google Inc.
Samsung Electronics
Stefano Rivera <[email protected]>

Dominic Battr� <[email protected]>
Dominic Battré <[email protected]>
Doug Kwan <[email protected]>
Dmitriy Vyukov <[email protected]>
John Millikin <[email protected]>
Expand Down
34 changes: 33 additions & 1 deletion cgmanifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"component": {
"type": "git",
"git": {
"commitHash": "a12824d42584e292ecb3bad05c4b32c2015a7b89",
"commitHash": "v19.24.6",
"repositoryUrl": "https://github.com/davisking/dlib.git"
}
}
Expand Down Expand Up @@ -87,6 +87,38 @@
"comments": "v3.10.5"
}
},
{
"component": {
"type": "other",
"other": {
"name": "libjpeg",
"version": "release 9e of 16-Jan-2022",
"downloadUrl": "https://github.com/davisking/dlib/tree/v19.24.6/dlib/external/libjpeg"
},
"comments": "for vision domain"
}
},
{
"component": {
"type": "other",
"other": {
"name": "libpng",
"version": "1.6.37",
"downloadUrl": "https://github.com/davisking/dlib/tree/v19.24.6/dlib/external/libpng"
},
"comments": "for vision domain"
}
},
{
"component": {
"other": {
"name": "zlib",
"version": "1.2.11",
"downloadUrl": "https://github.com/davisking/dlib/tree/v19.24.6/dlib/external/zlib"
},
"comments": "for vision domain"
}
},
{
"component": {
"type": "git",
Expand Down
10 changes: 5 additions & 5 deletions cmake/externals/dlib.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FetchContent_Declare(dlib
GIT_REPOSITORY https://github.com/davisking/dlib.git
# there is non an official tag which supports STFT,
# choose a relatively stable commit id for that.
GIT_TAG a12824d42584e292ecb3bad05c4b32c2015a7b89
FetchContent_Declare(
dlib
URL https://github.com/davisking/dlib/archive/refs/tags/v19.24.6.zip
URL_HASH SHA1=59b1fb4e9909697c646e4f74e94871dacf49f0bf
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
SOURCE_SUBDIR not_set
)

Expand Down
1 change: 0 additions & 1 deletion include/ortx_extractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

typedef OrtxObject OrtxFeatureExtractor;
typedef OrtxObject OrtxRawAudios;
typedef OrtxObject OrtxTensorResult;

#ifdef __cplusplus
extern "C" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,9 @@ jobs:
addToPath: true
architecture: "x64"

# iOS xcframework build doesn't work with CMake 3.25.1, pin to 3.25.0
- script: |
python -m pip install cmake==3.25.0
displayName: "Install CMake 3.25.0"
python -m pip install cmake
displayName: "Install CMake"
- template: set-package-version-variable-step.yml
parameters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
sudo apt-get install -y libssh-dev
displayName: Install OpenSSL for Azure custom ops
# NOTE: on arm64 machine, CMake version needs to be updated since we now require CMake 3.25 or newer.
# NOTE: on arm64 machine, CMake version needs to be updated since we now require CMake 3.28 or newer.
- ${{ if eq(parameters.OrtExtensionsArch, 'x64') }}:
- bash: |
export CFLAGS="${{parameters.OrtExtensionsCFlags}}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ jobs:
addToPath: true
architecture: "x64"

# iOS xcframework build doesn't work with CMake 3.25.1, pin to 3.25.0
- script: |
python -m pip install cmake==3.25.0
displayName: "Install CMake 3.25.0"
python -m pip install cmake
displayName: "Install CMake"
- template: set-package-version-variable-step.yml
parameters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ RUN dnf install -y \

RUN pip3 install --upgrade pip
RUN pip3 install setuptools>=68.2.2
RUN pip3 install cmake==3.27.2
RUN pip3 install cmake==3.28.4

# Install TensorRT
RUN dnf install -y libnvinfer8 libnvonnxparsers8 libnvparsers8 libnvinfer-plugin8 libnvinfer-lean8 libnvinfer-vc-plugin8 libnvinfer-dispatch8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ RUN apt-get install -y --no-install-recommends \

RUN pip install --upgrade pip
RUN pip install setuptools>=68.2.2
RUN pip3 install cmake==3.27.2
RUN pip3 install cmake==3.28.4

# Install TensorRT
RUN v="8.6.1.6-1+cuda11.8" &&\
Expand Down
4 changes: 3 additions & 1 deletion tools/gen_selectedops.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@
],
"OCOS_ENABLE_DLIB": [
"Inverse",
"StftNorm"
"StftNorm",
"DecodeImage",
"EncodeImage"
],
"OCOS_ENABLE_TRIE_TOKENIZER": [
"TrieTokenizer",
Expand Down
2 changes: 1 addition & 1 deletion tutorials/ortx_api/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.25)
cmake_minimum_required(VERSION 3.28)

project(ortx_api_test)

Expand Down

0 comments on commit c3379ec

Please sign in to comment.