Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into fs-eire/nodejs-suppor…
Browse files Browse the repository at this point in the history
…t-f16
  • Loading branch information
fs-eire committed May 22, 2024
2 parents 06a35e9 + 0a10a30 commit c02a5f4
Show file tree
Hide file tree
Showing 307 changed files with 11,380 additions and 7,268 deletions.
109 changes: 109 additions & 0 deletions .github/workflows/mac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Mac_CI

on:
push:
branches:
- main
- rel-*
pull_request:
branches:
- main
- rel-*
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
python_version: 3.11
xcode_version: 15.2

jobs:
ARM64:
runs-on: macos-14

timeout-minutes: 60

steps:
- uses: actions/setup-python@v5
with:
python-version: ${{ env.python_version }}

- name: Verify ARM64 machine
shell: python
run: |
import platform
assert platform.machine() == "arm64", "This job expects to be run on an ARM64 machine."
- name: Use Xcode ${{ env.xcode_version }}
shell: bash
run: |
XCODE_DEVELOPER_DIR="/Applications/Xcode_${{ env.xcode_version }}.app/Contents/Developer"
sudo xcode-select --switch "${XCODE_DEVELOPER_DIR}"
- uses: actions/checkout@v4

- name: Build and test
shell: bash
run: |
python ./tools/ci_build/build.py \
--build_dir ./build \
--update \
--build --parallel \
--test \
--build_shared_lib \
--build_objc \
--use_xnnpack \
--use_binskim_compliant_compile_flags
# TODO add --use_coreml once unit test failures are addressed
Objective-C-StaticAnalysis:
runs-on: macos-14

timeout-minutes: 30

steps:
- uses: actions/setup-python@v5
with:
python-version: ${{ env.python_version }}

- name: Use Xcode ${{ env.xcode_version }}
shell: bash
run: |
XCODE_DEVELOPER_DIR="/Applications/Xcode_${{ env.xcode_version }}.app/Contents/Developer"
sudo xcode-select --switch "${XCODE_DEVELOPER_DIR}"
- uses: actions/checkout@v4

- name: Generate compile_commands.json and ONNX protobuf files
shell: bash
run: |
python ./tools/ci_build/build.py \
--build_dir ./build \
--cmake_generator "Unix Makefiles" \
--config Debug \
--build_shared_lib \
--use_coreml \
--build_objc \
--enable_training_apis \
--cmake_extra_defines CMAKE_EXPORT_COMPILE_COMMANDS=ON \
--use_binskim_compliant_compile_flags \
--update \
--build --parallel \
--target onnx_proto
- name: Analyze Objective-C/C++ source code
shell: bash
run: |
CLANG_TIDY_CHECKS="-*,clang-analyzer-*"
"$(brew --prefix llvm@15)/bin/clang-tidy" \
-p=./build/Debug \
--checks="${CLANG_TIDY_CHECKS}" \
--warnings-as-errors="${CLANG_TIDY_CHECKS}" \
--header-filter="objectivec/include|objectivec|onnxruntime/core" \
./objectivec/*.mm \
./onnxruntime/core/platform/apple/logging/apple_log_sink.mm \
./onnxruntime/core/providers/coreml/model/*.mm
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
[submodule "cmake/external/emsdk"]
path = cmake/external/emsdk
url = https://github.com/emscripten-core/emsdk.git
branch = 3.1.57
branch = 3.1.59
2 changes: 1 addition & 1 deletion cgmanifests/generated/cgmanifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"component": {
"type": "git",
"git": {
"commitHash": "229d83fc706e10a39d4948a804cbbf17225cdda0",
"commitHash": "d52c46520124845b1e0e0525f2759299d840143f",
"repositoryUrl": "https://github.com/emscripten-core/emsdk.git"
},
"comments": "git submodule at cmake/external/emsdk"
Expand Down
6 changes: 4 additions & 2 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,8 @@ if (onnxruntime_USE_QNN)
message(STATUS "Building MSVC for architecture ${CMAKE_SYSTEM_PROCESSOR} with CMAKE_GENERATOR_PLATFORM as ${GEN_PLATFORM}")
if (${GEN_PLATFORM} STREQUAL "arm64")
set(QNN_ARCH_ABI aarch64-windows-msvc)
elseif (${GEN_PLATFORM} STREQUAL "arm64ec")
set(QNN_ARCH_ABI arm64x-windows-msvc)
else()
set(QNN_ARCH_ABI x86_64-windows-msvc)
endif()
Expand All @@ -815,7 +817,7 @@ if (onnxruntime_USE_QNN)

if (MSVC OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
file(GLOB QNN_LIB_FILES LIST_DIRECTORIES false "${onnxruntime_QNN_HOME}/lib/${QNN_ARCH_ABI}/libQnn*.so" "${onnxruntime_QNN_HOME}/lib/${QNN_ARCH_ABI}/Qnn*.dll")
if (${QNN_ARCH_ABI} STREQUAL "aarch64-windows-msvc")
if (${QNN_ARCH_ABI} STREQUAL "aarch64-windows-msvc" OR ${QNN_ARCH_ABI} STREQUAL "arm64x-windows-msvc")
file(GLOB EXTRA_HTP_LIB LIST_DIRECTORIES false "${onnxruntime_QNN_HOME}/lib/hexagon-v68/unsigned/libQnnHtpV68Skel.so"
"${onnxruntime_QNN_HOME}/lib/hexagon-v73/unsigned/libQnnHtpV73Skel.so"
"${onnxruntime_QNN_HOME}/lib/hexagon-v73/unsigned/libqnnhtpv73.cat")
Expand Down Expand Up @@ -1829,5 +1831,5 @@ endif()

if(DEFINED BUILD_AS_ARM64X)
set(ARM64X_TARGETS onnxruntime)
include("${CMAKE_SOURCE_DIR}/arm64x.cmake")
include("${CMAKE_CURRENT_SOURCE_DIR}/arm64x.cmake")
endif()
43 changes: 23 additions & 20 deletions cmake/arm64x.cmake
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
set(arm64ReproDir "${CMAKE_SOURCE_DIR}/repros")
set(arm64ReproDir "${CMAKE_CURRENT_SOURCE_DIR}/repros")

function(set_arm64_dependencies n)
set(ARM64_LIBS)
set(ARM64_OBJS)
set(ARM64_DEF)
set(REPRO_PATH "${arm64ReproDir}/${n}")
if(NOT EXISTS "${REPRO_PATH}")
set(REPRO_PATH "${arm64ReproDir}/${n}_temp")
endif()
file(GLOB ARM64_OBJS "${REPRO_PATH}/*.obj")
file(GLOB ARM64_DEF "${REPRO_PATH}/*.def")
file(GLOB ARM64_LIBS "${REPRO_PATH}/*.LIB")

if(NOT "${ARM64_DEF}" STREQUAL "")
set(ARM64_DEF "/defArm64Native:${ARM64_DEF}")
endif()
target_sources(${n} PRIVATE ${ARM64_OBJS})
target_link_options(${n} PRIVATE /machine:arm64x "${ARM64_DEF}" "${ARM64_LIBS}")
endfunction()

if("${BUILD_AS_ARM64X}" STREQUAL "ARM64")
foreach (n ${ARM64X_TARGETS})
add_custom_target(mkdirs_${n} ALL COMMAND cmd /c (if exist \"${arm64ReproDir}/${n}_temp/\" rmdir /s /q \"${arm64ReproDir}/${n}_temp\") && mkdir \"${arm64ReproDir}/${n}_temp\" )
add_dependencies(${n} mkdirs_${n})
target_link_options(${n} PRIVATE "/LINKREPRO:${arm64ReproDir}/${n}_temp")
add_custom_target(${n}_checkRepro ALL COMMAND cmd /c if exist \"${n}_temp/*.obj\" if exist \"${n}\" rmdir /s /q \"${n}\" 2>nul && if not exist \"${n}\" ren \"${n}_temp\" \"${n}\" DEPENDS ${n}
WORKING_DIRECTORY ${arm64ReproDir})
add_custom_target(${n}_checkRepro ALL COMMAND cmd /c if exist \"${n}_temp/*.obj\" if exist \"${n}\" rmdir /s /q \"${n}\" 2>nul && if not exist \"${n}\" ren \"${n}_temp\" \"${n}\" WORKING_DIRECTORY ${arm64ReproDir})
add_dependencies(${n}_checkRepro ${n})
endforeach()


elseif("${BUILD_AS_ARM64X}" STREQUAL "ARM64EC")
foreach (n ${ARM64X_TARGETS})
set(ARM64_LIBS)
set(ARM64_OBJS)
set(ARM64_DEF)

file(GLOB ARM64_OBJS "${arm64ReproDir}/${n}/*.obj")
file(GLOB ARM64_DEF "${arm64ReproDir}/${n}/*.def")
file(GLOB ARM64_LIBS "${arm64ReproDir}/${n}/*.LIB")

if(NOT "${ARM64_DEF}" STREQUAL "")
set(ARM64_DEF "/defArm64Native:${ARM64_DEF}")
endif()
target_sources(${n} PRIVATE ${ARM64_OBJS})
target_link_options(${n} PRIVATE /machine:arm64x "${ARM64_DEF}")

if(NOT "${ARM64_LIBS}" STREQUAL "")
target_link_libraries(${n} PUBLIC ${ARM64_LIBS})
endif()
set_arm64_dependencies(${n})
endforeach()
endif()
2 changes: 1 addition & 1 deletion cmake/external/emsdk
Submodule emsdk updated 52 files
+6 −35 .circleci/config.yml
+10 −0 bazel/emscripten_toolchain/toolchain.bzl
+14 −0 bazel/revisions.bzl
+61 −0 bazel/test_external/long_command_line/BUILD.bazel
+3 −0 bazel/test_external/long_command_line/include/long_command_line_file01.hh
+3 −0 bazel/test_external/long_command_line/include/long_command_line_file02.hh
+3 −0 bazel/test_external/long_command_line/include/long_command_line_file03.hh
+3 −0 bazel/test_external/long_command_line/include/long_command_line_file04.hh
+3 −0 bazel/test_external/long_command_line/include/long_command_line_file05.hh
+3 −0 bazel/test_external/long_command_line/include/long_command_line_file06.hh
+3 −0 bazel/test_external/long_command_line/include/long_command_line_file07.hh
+3 −0 bazel/test_external/long_command_line/include/long_command_line_file08.hh
+3 −0 bazel/test_external/long_command_line/include/long_command_line_file09.hh
+3 −0 bazel/test_external/long_command_line/include/long_command_line_file10.hh
+3 −0 bazel/test_external/long_command_line/include/long_command_line_file11.hh
+3 −0 bazel/test_external/long_command_line/include/long_command_line_file12.hh
+3 −0 bazel/test_external/long_command_line/include/long_command_line_file13.hh
+3 −0 bazel/test_external/long_command_line/include/long_command_line_file14.hh
+3 −0 bazel/test_external/long_command_line/include/long_command_line_file15.hh
+3 −0 bazel/test_external/long_command_line/include/long_command_line_file16.hh
+3 −0 bazel/test_external/long_command_line/include/long_command_line_file17.hh
+3 −0 bazel/test_external/long_command_line/include/long_command_line_file18.hh
+3 −0 bazel/test_external/long_command_line/include/long_command_line_file19.hh
+3 −0 bazel/test_external/long_command_line/include/long_command_line_file20.hh
+43 −0 bazel/test_external/long_command_line/long_command_line.cc
+5 −0 bazel/test_external/long_command_line/long_command_line_file01.cc
+5 −0 bazel/test_external/long_command_line/long_command_line_file02.cc
+5 −0 bazel/test_external/long_command_line/long_command_line_file03.cc
+5 −0 bazel/test_external/long_command_line/long_command_line_file04.cc
+5 −0 bazel/test_external/long_command_line/long_command_line_file05.cc
+5 −0 bazel/test_external/long_command_line/long_command_line_file06.cc
+5 −0 bazel/test_external/long_command_line/long_command_line_file07.cc
+5 −0 bazel/test_external/long_command_line/long_command_line_file08.cc
+5 −0 bazel/test_external/long_command_line/long_command_line_file09.cc
+5 −0 bazel/test_external/long_command_line/long_command_line_file10.cc
+5 −0 bazel/test_external/long_command_line/long_command_line_file11.cc
+5 −0 bazel/test_external/long_command_line/long_command_line_file12.cc
+5 −0 bazel/test_external/long_command_line/long_command_line_file13.cc
+5 −0 bazel/test_external/long_command_line/long_command_line_file14.cc
+5 −0 bazel/test_external/long_command_line/long_command_line_file15.cc
+5 −0 bazel/test_external/long_command_line/long_command_line_file16.cc
+5 −0 bazel/test_external/long_command_line/long_command_line_file17.cc
+5 −0 bazel/test_external/long_command_line/long_command_line_file18.cc
+5 −0 bazel/test_external/long_command_line/long_command_line_file19.cc
+5 −0 bazel/test_external/long_command_line/long_command_line_file20.cc
+2 −2 docker/README.md
+6 −2 emscripten-releases-tags.json
+0 −3 emsdk.py
+0 −23 scripts/update_linux_arm64.sh
+3 −0 test/test_bazel.ps1
+2 −1 test/test_bazel.sh
+1 −0 test/test_bazel_mac.sh
47 changes: 32 additions & 15 deletions cmake/external/onnxruntime_external_deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ FetchContent_Declare(
)



# Flatbuffers
# We do not need to build flatc for iOS or Android Cross Compile
if (CMAKE_SYSTEM_NAME STREQUAL "iOS" OR CMAKE_SYSTEM_NAME STREQUAL "Android" OR CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
Expand All @@ -122,6 +121,19 @@ FetchContent_Declare(
FIND_PACKAGE_ARGS 23.5.9 NAMES Flatbuffers
)


#Protobuf depends on utf8_range
FetchContent_Declare(
utf8_range
URL ${DEP_URL_utf8_range}
URL_HASH SHA1=${DEP_SHA1_utf8_range}
FIND_PACKAGE_ARGS NAMES utf8_range
)

set(utf8_range_ENABLE_TESTS OFF CACHE BOOL "Build test suite" FORCE)
set(utf8_range_ENABLE_INSTALL OFF CACHE BOOL "Configure installation" FORCE)


# Download a protoc binary from Internet if needed
if(NOT ONNX_CUSTOM_PROTOC_EXECUTABLE)
# This part of code is only for users' convenience. The code couldn't handle all cases. Users always can manually
Expand All @@ -148,6 +160,7 @@ if(NOT ONNX_CUSTOM_PROTOC_EXECUTABLE)
FetchContent_Declare(protoc_binary URL ${DEP_URL_protoc_win32} URL_HASH SHA1=${DEP_SHA1_protoc_win32})
FetchContent_Populate(protoc_binary)
endif()

if(protoc_binary_SOURCE_DIR)
message("Use prebuilt protoc")
set(ONNX_CUSTOM_PROTOC_EXECUTABLE ${protoc_binary_SOURCE_DIR}/bin/protoc.exe)
Expand All @@ -164,15 +177,30 @@ if(NOT ONNX_CUSTOM_PROTOC_EXECUTABLE)
FetchContent_Declare(protoc_binary URL ${DEP_URL_protoc_linux_aarch64} URL_HASH SHA1=${DEP_SHA1_protoc_linux_aarch64})
FetchContent_Populate(protoc_binary)
endif()

if(protoc_binary_SOURCE_DIR)
message("Use prebuilt protoc")
set(ONNX_CUSTOM_PROTOC_EXECUTABLE ${protoc_binary_SOURCE_DIR}/bin/protoc)
set(PROTOC_EXECUTABLE ${ONNX_CUSTOM_PROTOC_EXECUTABLE})
endif()
endif()

if(NOT ONNX_CUSTOM_PROTOC_EXECUTABLE)
message(FATAL_ERROR "ONNX_CUSTOM_PROTOC_EXECUTABLE must be set to cross-compile.")
endif()
endif()
endif()

# if ONNX_CUSTOM_PROTOC_EXECUTABLE is set we don't need to build the protoc binary
if (ONNX_CUSTOM_PROTOC_EXECUTABLE)
if (NOT EXISTS "${ONNX_CUSTOM_PROTOC_EXECUTABLE}")
message(FATAL_ERROR "ONNX_CUSTOM_PROTOC_EXECUTABLE is set to '${ONNX_CUSTOM_PROTOC_EXECUTABLE}' "
"but protoc executable was not found there.")
endif()

set(protobuf_BUILD_PROTOC_BINARIES OFF CACHE BOOL "Build protoc" FORCE)
endif()

#Here we support two build mode:
#1. if ONNX_CUSTOM_PROTOC_EXECUTABLE is set, build Protobuf from source, except protoc.exe. This mode is mainly
# for cross-compiling
Expand All @@ -183,17 +211,6 @@ else()
set(ONNXRUNTIME_PROTOBUF_PATCH_COMMAND "")
endif()

FetchContent_Declare(
utf8_range
URL ${DEP_URL_utf8_range}
URL_HASH SHA1=${DEP_SHA1_utf8_range}
FIND_PACKAGE_ARGS NAMES utf8_range
)

set(utf8_range_ENABLE_TESTS OFF CACHE BOOL "Build test suite" FORCE)
set(utf8_range_ENABLE_INSTALL OFF CACHE BOOL "Configure installation" FORCE)


#Protobuf depends on absl and utf8_range
FetchContent_Declare(
Protobuf
Expand All @@ -211,10 +228,10 @@ set(protobuf_BUILD_TESTS OFF CACHE BOOL "Build protobuf tests" FORCE)
#set(protobuf_INSTALL OFF CACHE BOOL "Install protobuf binaries and files" FORCE)
set(protobuf_USE_EXTERNAL_GTEST ON CACHE BOOL "" FORCE)

if (CMAKE_SYSTEM_NAME STREQUAL "Android")
set(protobuf_BUILD_PROTOC_BINARIES OFF CACHE BOOL "Build protobuf tests" FORCE)
set(protobuf_WITH_ZLIB OFF CACHE BOOL "Build with zlib support" FORCE)
if (ANDROID)
set(protobuf_WITH_ZLIB OFF CACHE BOOL "Build protobuf with zlib support" FORCE)
endif()

if (onnxruntime_DISABLE_RTTI)
set(protobuf_DISABLE_RTTI ON CACHE BOOL "Remove runtime type information in the binaries" FORCE)
endif()
Expand Down
6 changes: 6 additions & 0 deletions cmake/onnxruntime_common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ if(onnxruntime_target_platform STREQUAL "ARM64EC")
endif()
endif()

if(onnxruntime_target_platform STREQUAL "ARM64")
if (MSVC)
add_compile_options("/bigobj")
endif()
endif()

file(GLOB onnxruntime_common_src CONFIGURE_DEPENDS
${onnxruntime_common_src_patterns}
)
Expand Down
5 changes: 4 additions & 1 deletion cmake/onnxruntime_nodejs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ endif()
if (onnxruntime_USE_COREML)
set(NODEJS_BINDING_USE_COREML "--use_coreml")
endif()
if (onnxruntime_USE_QNN)
set(NODEJS_BINDING_USE_QNN "--use_qnn")
endif()

if(NOT onnxruntime_ENABLE_STATIC_ANALYSIS)
# add custom target
Expand All @@ -90,7 +93,7 @@ add_custom_target(nodejs_binding_wrapper ALL
COMMAND ${NPM_CLI} ci
COMMAND ${NPM_CLI} run build -- --onnxruntime-build-dir=${CMAKE_CURRENT_BINARY_DIR} --config=${CMAKE_BUILD_TYPE} --onnxruntime-generator=${CMAKE_GENERATOR}
--arch=${NODEJS_BINDING_ARCH} ${NODEJS_BINDING_USE_CUDA} ${NODEJS_BINDING_USE_DML} ${NODEJS_BINDING_USE_TENSORRT}
${NODEJS_BINDING_USE_COREML}
${NODEJS_BINDING_USE_COREML} ${NODEJS_BINDING_USE_QNN}
WORKING_DIRECTORY ${JS_NODE_ROOT}
COMMENT "Using cmake-js to build OnnxRuntime Node.js binding")

Expand Down
3 changes: 3 additions & 0 deletions cmake/onnxruntime_optimizer.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ if (onnxruntime_MINIMAL_BUILD)
"${ONNXRUNTIME_ROOT}/core/optimizer/graph_transformer_utils.cc"
"${ONNXRUNTIME_ROOT}/core/optimizer/initializer.cc"
"${ONNXRUNTIME_ROOT}/core/optimizer/initializer.h"
"${ONNXRUNTIME_ROOT}/core/optimizer/matmul_nbits_fusion.cc"
"${ONNXRUNTIME_ROOT}/core/optimizer/matmul_nbits_fusion.h"
"${ONNXRUNTIME_ROOT}/core/optimizer/nhwc_transformer.cc"
"${ONNXRUNTIME_ROOT}/core/optimizer/nhwc_transformer.h"
"${ONNXRUNTIME_ROOT}/core/optimizer/qdq_transformer/qdq_final_cleanup.cc"
Expand Down Expand Up @@ -111,6 +113,7 @@ onnxruntime_add_include_to_target(onnxruntime_optimizer onnxruntime_common onnxr
target_include_directories(onnxruntime_optimizer PRIVATE ${ONNXRUNTIME_ROOT})
if (onnxruntime_ENABLE_TRAINING)
target_include_directories(onnxruntime_optimizer PRIVATE ${ORTTRAINING_ROOT})
onnxruntime_add_include_to_target(onnxruntime_optimizer nlohmann_json::nlohmann_json)
if (onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
onnxruntime_add_include_to_target(onnxruntime_optimizer Python::Module)
endif()
Expand Down
Loading

0 comments on commit c02a5f4

Please sign in to comment.