From 1ae83f53ae924801021e187015f36b4d33ce03e9 Mon Sep 17 00:00:00 2001 From: edgchen1 <18449977+edgchen1@users.noreply.github.com> Date: Fri, 20 Sep 2024 13:52:02 -0700 Subject: [PATCH 1/7] remove redundant set_property --- cmake/onnxruntime_unittests.cmake | 2 -- 1 file changed, 2 deletions(-) diff --git a/cmake/onnxruntime_unittests.cmake b/cmake/onnxruntime_unittests.cmake index 4b880c4437dfd..a4ba85e868896 100644 --- a/cmake/onnxruntime_unittests.cmake +++ b/cmake/onnxruntime_unittests.cmake @@ -893,8 +893,6 @@ if (MSVC) set_property(SOURCE "${TEST_SRC_DIR}/optimizer/graph_transform_test.cc" "${TEST_SRC_DIR}/optimizer/qdq_transformer_test.cc" APPEND PROPERTY COMPILE_OPTIONS "/bigobj") - set_property(SOURCE "${TEST_SRC_DIR}/optimizer/qdq_transformer_test.cc" - APPEND PROPERTY COMPILE_OPTIONS "/bigobj") else() target_compile_options(onnxruntime_test_all PRIVATE "-Wno-parentheses") endif() From 6452ffb7716b2752d4a34c571cfcb61e09c1847c Mon Sep 17 00:00:00 2001 From: edgchen1 <18449977+edgchen1@users.noreply.github.com> Date: Fri, 20 Sep 2024 13:52:35 -0700 Subject: [PATCH 2/7] alphabetize check_compiler_flag calls --- cmake/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 246675b72f4e6..d980adb0793ff 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -642,6 +642,7 @@ else() check_cxx_compiler_flag(-Wcast-function-type HAS_CAST_FUNCTION_TYPE) check_cxx_compiler_flag(-Wcatch-value HAS_CATCH_VALUE) check_cxx_compiler_flag(-Wclass-memaccess HAS_CLASS_MEMACCESS) + check_cxx_compiler_flag(-Wdangling-reference HAS_DANGLING_REFERENCE) check_cxx_compiler_flag(-Wdeprecated-anon-enum-enum-conversion HAS_DEPRECATED_ANON_ENUM_ENUM_CONVERSION) check_cxx_compiler_flag(-Wdeprecated-builtins HAS_DEPRECATED_BUILTINS) check_cxx_compiler_flag(-Wdeprecated-copy HAS_DEPRECATED_COPY) @@ -656,15 +657,15 @@ else() check_cxx_compiler_flag(-Wshorten-64-to-32 HAS_SHORTEN_64_TO_32) check_cxx_compiler_flag(-Wstrict-aliasing HAS_STRICT_ALIASING) check_nvcc_compiler_flag(-Wstrict-aliasing NVCC_HAS_STRICT_ALIASING) + check_cxx_compiler_flag(-Wstringop-overflow HAS_STRINGOP_OVERFLOW) check_cxx_compiler_flag(-Wtautological-pointer-compare HAS_TAUTOLOGICAL_POINTER_COMPARE) check_cxx_compiler_flag(-Wundefined-var-template HAS_UNDEFINED_VAR_TEMPLATE) check_cxx_compiler_flag(-Wunused-but-set-parameter HAS_UNUSED_BUT_SET_PARAMETER) check_cxx_compiler_flag(-Wunused-but-set-variable HAS_UNUSED_BUT_SET_VARIABLE) check_cxx_compiler_flag(-Wunused-variable HAS_UNUSED_VARIABLE) check_cxx_compiler_flag(-Wuseless-cast HAS_USELESS_CAST) - check_cxx_compiler_flag(-Wstringop-overflow HAS_STRINGOP_OVERFLOW) + if(onnxruntime_ENABLE_TRAINING_APIS) - check_cxx_compiler_flag(-Wdangling-reference HAS_DANGLING_REFERENCE) if(HAS_DANGLING_REFERENCE) list(APPEND ORT_WARNING_FLAGS -Wno-dangling-reference) endif() From e34c91c35bc9c274378e7aef88e67479ca12962c Mon Sep 17 00:00:00 2001 From: edgchen1 <18449977+edgchen1@users.noreply.github.com> Date: Fri, 20 Sep 2024 14:06:23 -0700 Subject: [PATCH 3/7] patch nsync --- cmake/external/onnxruntime_external_deps.cmake | 1 + cmake/patches/nsync/nsync_1.26.0.patch | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 cmake/patches/nsync/nsync_1.26.0.patch diff --git a/cmake/external/onnxruntime_external_deps.cmake b/cmake/external/onnxruntime_external_deps.cmake index 43f18abbe9522..cb737ee53639f 100644 --- a/cmake/external/onnxruntime_external_deps.cmake +++ b/cmake/external/onnxruntime_external_deps.cmake @@ -91,6 +91,7 @@ if (NOT WIN32) google_nsync URL ${DEP_URL_google_nsync} URL_HASH SHA1=${DEP_SHA1_google_nsync} + PATCH_COMMAND ${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 < ${PROJECT_SOURCE_DIR}/patches/nsync/nsync_1.26.0.patch FIND_PACKAGE_ARGS NAMES nsync unofficial-nsync ) #nsync tests failed on Mac Build diff --git a/cmake/patches/nsync/nsync_1.26.0.patch b/cmake/patches/nsync/nsync_1.26.0.patch new file mode 100644 index 0000000000000..78ef2b3cb20d4 --- /dev/null +++ b/cmake/patches/nsync/nsync_1.26.0.patch @@ -0,0 +1,14 @@ +diff --git a/public/nsync_atomic.h b/public/nsync_atomic.h +index aebe4f7..466a262 100644 +--- a/public/nsync_atomic.h ++++ b/public/nsync_atomic.h +@@ -45,7 +45,8 @@ NSYNC_CPP_END_ + NSYNC_CPP_START_ + typedef std::atomic nsync_atomic_uint32_; + NSYNC_CPP_END_ +-#define NSYNC_ATOMIC_UINT32_INIT_ ATOMIC_VAR_INIT (0) ++// Replace deprecated ATOMIC_VAR_INIT with std::atomic brace initialization ++#define NSYNC_ATOMIC_UINT32_INIT_ { 0 } + #define NSYNC_ATOMIC_UINT32_LOAD_(p) (std::atomic_load (p)) + #define NSYNC_ATOMIC_UINT32_STORE_(p,v) (std::atomic_store ((p), (uint32_t) (v))) + #define NSYNC_ATOMIC_UINT32_PTR_(p) (p) From 2d9d28bd42aedeb182896d3e07c0cb5964b238a0 Mon Sep 17 00:00:00 2001 From: edgchen1 <18449977+edgchen1@users.noreply.github.com> Date: Fri, 20 Sep 2024 15:26:05 -0700 Subject: [PATCH 4/7] fixes to build --- cmake/CMakeLists.txt | 1 + cmake/onnxruntime_config.h.in | 1 + include/onnxruntime/core/common/eigen_common_wrapper.h | 6 ++++++ onnxruntime/contrib_ops/cpu/bert/embed_layer_norm.cc | 2 +- onnxruntime/core/session/inference_session.cc | 2 +- onnxruntime/test/optimizer/optimizer_test.cc | 2 -- 6 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index d980adb0793ff..7168a99fe1f93 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -647,6 +647,7 @@ else() check_cxx_compiler_flag(-Wdeprecated-builtins HAS_DEPRECATED_BUILTINS) check_cxx_compiler_flag(-Wdeprecated-copy HAS_DEPRECATED_COPY) check_cxx_compiler_flag(-Wdeprecated-declarations HAS_DEPRECATED_DECLARATIONS) + check_cxx_compiler_flag(-Wdeprecated-this-capture HAS_DEPRECATED_THIS_CAPTURE) check_cxx_compiler_flag(-Wenum-constexpr-conversion HAS_ENUM_CONSTEXPR_CONVERSION) check_cxx_compiler_flag(-Wformat-truncation HAS_FORMAT_TRUNCATION) check_cxx_compiler_flag(-Wignored-attributes HAS_IGNORED_ATTRIBUTES) diff --git a/cmake/onnxruntime_config.h.in b/cmake/onnxruntime_config.h.in index e3ea767401ddc..bbddefe531cb8 100644 --- a/cmake/onnxruntime_config.h.in +++ b/cmake/onnxruntime_config.h.in @@ -9,6 +9,7 @@ #cmakedefine HAS_CLASS_MEMACCESS #cmakedefine HAS_DEPRECATED_COPY #cmakedefine HAS_DEPRECATED_DECLARATIONS +#cmakedefine HAS_DEPRECATED_THIS_CAPTURE #cmakedefine HAS_FORMAT_TRUNCATION #cmakedefine HAS_IGNORED_ATTRIBUTES #cmakedefine HAS_MAYBE_UNINITIALIZED diff --git a/include/onnxruntime/core/common/eigen_common_wrapper.h b/include/onnxruntime/core/common/eigen_common_wrapper.h index 57599e04037dc..19efa7bcff107 100644 --- a/include/onnxruntime/core/common/eigen_common_wrapper.h +++ b/include/onnxruntime/core/common/eigen_common_wrapper.h @@ -49,6 +49,12 @@ #pragma GCC diagnostic ignored "-Wshorten-64-to-32" #endif +// eigen-src/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceThreadPool.h:215:9: +// error: implicit capture of 'this' with a capture default of '=' is deprecated [-Werror,-Wdeprecated-this-capture] +#ifdef HAS_DEPRECATED_THIS_CAPTURE +#pragma GCC diagnostic ignored "-Wdeprecated-this-capture" +#endif + #elif defined(_MSC_VER) // build\windows\debug\external\eigen3\unsupported\eigen\cxx11\src/Tensor/Tensor.h(76): // warning C4554: '&': check operator precedence for possible error; use parentheses to clarify precedence diff --git a/onnxruntime/contrib_ops/cpu/bert/embed_layer_norm.cc b/onnxruntime/contrib_ops/cpu/bert/embed_layer_norm.cc index 570f4108c3f62..05a36e8d142a3 100644 --- a/onnxruntime/contrib_ops/cpu/bert/embed_layer_norm.cc +++ b/onnxruntime/contrib_ops/cpu/bert/embed_layer_norm.cc @@ -87,7 +87,7 @@ Status EmbedLayerNorm::Compute(OpKernelContext* context) const { int n = batch_size * sequence_length; concurrency::ThreadPool::TryBatchParallelFor( - context->GetOperatorThreadPool(), n, [=, &failed](ptrdiff_t index) { + context->GetOperatorThreadPool(), n, [=, &failed, this](ptrdiff_t index) { int word_col_index = input_ids_data[index]; if (word_col_index < 0 || word_col_index >= word_embedding_length) { failed.store(true, std::memory_order_release); diff --git a/onnxruntime/core/session/inference_session.cc b/onnxruntime/core/session/inference_session.cc index b9e017df5baa3..46f514c7d7ddc 100644 --- a/onnxruntime/core/session/inference_session.cc +++ b/onnxruntime/core/session/inference_session.cc @@ -2770,7 +2770,7 @@ common::Status InferenceSession::RunAsync(const RunOptions* run_options, if (!tp || concurrency::ThreadPool::DegreeOfParallelism(tp) < 2) { return ORT_MAKE_STATUS(ONNXRUNTIME, INVALID_ARGUMENT, "intra op thread pool must have at least one thread for RunAsync"); } - std::function run_fn = [=]() { + std::function run_fn = [=, this]() { Status status = Status::OK(); ORT_TRY { if (run_options) { diff --git a/onnxruntime/test/optimizer/optimizer_test.cc b/onnxruntime/test/optimizer/optimizer_test.cc index 79704f2cc79e3..81c1a4ace1e33 100644 --- a/onnxruntime/test/optimizer/optimizer_test.cc +++ b/onnxruntime/test/optimizer/optimizer_test.cc @@ -24,8 +24,6 @@ using namespace ONNX_NAMESPACE; namespace onnxruntime { namespace test { -static const std::string MODEL_FOLDER = "testdata/transform/"; - TEST(OptimizerTest, Basic) { Model model("OptimizerBasic", false, ModelMetaData(), PathString(), IOnnxRuntimeOpSchemaRegistryList(), {{kOnnxDomain, 12}}, {}, DefaultLoggingManager().DefaultLogger()); From cae32c1ea471294c5995e44a5caedf9ebc848e5a Mon Sep 17 00:00:00 2001 From: edgchen1 <18449977+edgchen1@users.noreply.github.com> Date: Fri, 20 Sep 2024 15:34:52 -0700 Subject: [PATCH 5/7] change xcode version to 16 and change line endings in mac.yml --- .github/workflows/mac.yml | 384 +++++++++++++++++++------------------- 1 file changed, 192 insertions(+), 192 deletions(-) diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index 6efa8a5592337..c1bf948ac10cd 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -1,192 +1,192 @@ -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_coreml \ - --use_xnnpack \ - --use_binskim_compliant_compile_flags - - Vcpkg: - runs-on: macos-13 - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: ${{ env.python_version }} - - - name: "Run vcpkg(x64-osx)" - uses: lukka/run-vcpkg@v11 - with: - vcpkgDirectory: "${{ runner.temp }}/vcpkg" - vcpkgGitCommitId: "1de2026f28ead93ff1773e6e680387643e914ea1" # 2024.07.12 - runVcpkgInstall: true - vcpkgJsonGlob: "cmake/vcpkg.json" - vcpkgConfigurationJsonGlob: "cmake/vcpkg-configuration.json" - env: - VCPKG_INSTALLED_DIR: "${{ github.workspace }}/.build" - VCPKG_DEFAULT_TRIPLET: "x64-osx" - # VCPKG_BINARY_SOURCES: "default" # https://learn.microsoft.com/en-us/vcpkg/reference/binarycaching - - - name: "Run compile_schema.py" - run: | - # Runner's host triplet should be x64-osx or arm64-osx - export FLATC_DIR="${{ github.workspace }}/.build/${{ runner.arch }}-osx/tools/flatbuffers" - export PATH="$FLATC_DIR:$PATH" - flatc --version - python onnxruntime/core/flatbuffers/schema/compile_schema.py --flatc "$(which flatc)" - - - name: "Detect protoc" - id: protoc-detect - run: | - export PROTOC_DIR="${{ github.workspace }}/.build/${{ runner.arch }}-osx/tools/protobuf" - export PATH="$PROTOC_DIR:$PATH" - protoc --version - echo "protoc_path=$(which protoc)" >> "$GITHUB_OUTPUT" - - - name: "Run build.py(x64-osx)" - run: | - python ./tools/ci_build/build.py \ - --build_dir "build/x64-osx" \ - --skip_submodule_sync \ - --skip_tests \ - --compile_no_warning_as_error \ - --parallel \ - --path_to_protoc_exe "${{ steps.protoc-detect.outputs.protoc_path }}" \ - --osx_arch x86_64 \ - --use_vcpkg \ - --cmake_extra_defines "CMAKE_TOOLCHAIN_FILE:FILEPATH=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" \ - --cmake_extra_defines "VCPKG_TARGET_TRIPLET=x64-osx" \ - --cmake_extra_defines "VCPKG_INSTALLED_DIR:PATH=${{ github.workspace }}/.build" \ - --cmake_extra_defines "VCPKG_INSTALL_OPTIONS=--x-feature=tests" - shell: bash - - - name: "Run vcpkg(arm64-osx)" - uses: lukka/run-vcpkg@v11 - with: - vcpkgDirectory: "${{ runner.temp }}/vcpkg" - vcpkgGitCommitId: "1de2026f28ead93ff1773e6e680387643e914ea1" # 2024.07.12 - runVcpkgInstall: true - vcpkgJsonGlob: "cmake/vcpkg.json" - vcpkgConfigurationJsonGlob: "cmake/vcpkg-configuration.json" - env: - VCPKG_INSTALLED_DIR: "${{ github.workspace }}/.build" - VCPKG_DEFAULT_TRIPLET: "arm64-osx" - # VCPKG_BINARY_SOURCES: "default" # https://learn.microsoft.com/en-us/vcpkg/reference/binarycaching - - - name: "Run build.py(arm64-osx)" - run: | - python ./tools/ci_build/build.py \ - --build_dir "build/arm64-osx" \ - --skip_submodule_sync \ - --skip_tests \ - --compile_no_warning_as_error \ - --parallel \ - --path_to_protoc_exe "${{ steps.protoc-detect.outputs.protoc_path }}" \ - --osx_arch arm64 \ - --use_vcpkg \ - --cmake_extra_defines "CMAKE_TOOLCHAIN_FILE:FILEPATH=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" \ - --cmake_extra_defines "VCPKG_TARGET_TRIPLET=arm64-osx" \ - --cmake_extra_defines "VCPKG_INSTALLED_DIR:PATH=${{ github.workspace }}/.build" \ - --cmake_extra_defines "VCPKG_INSTALL_OPTIONS=--x-feature=tests" - shell: bash - - 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 +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: 16 + +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_coreml \ + --use_xnnpack \ + --use_binskim_compliant_compile_flags + + Vcpkg: + runs-on: macos-13 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ env.python_version }} + + - name: "Run vcpkg(x64-osx)" + uses: lukka/run-vcpkg@v11 + with: + vcpkgDirectory: "${{ runner.temp }}/vcpkg" + vcpkgGitCommitId: "1de2026f28ead93ff1773e6e680387643e914ea1" # 2024.07.12 + runVcpkgInstall: true + vcpkgJsonGlob: "cmake/vcpkg.json" + vcpkgConfigurationJsonGlob: "cmake/vcpkg-configuration.json" + env: + VCPKG_INSTALLED_DIR: "${{ github.workspace }}/.build" + VCPKG_DEFAULT_TRIPLET: "x64-osx" + # VCPKG_BINARY_SOURCES: "default" # https://learn.microsoft.com/en-us/vcpkg/reference/binarycaching + + - name: "Run compile_schema.py" + run: | + # Runner's host triplet should be x64-osx or arm64-osx + export FLATC_DIR="${{ github.workspace }}/.build/${{ runner.arch }}-osx/tools/flatbuffers" + export PATH="$FLATC_DIR:$PATH" + flatc --version + python onnxruntime/core/flatbuffers/schema/compile_schema.py --flatc "$(which flatc)" + + - name: "Detect protoc" + id: protoc-detect + run: | + export PROTOC_DIR="${{ github.workspace }}/.build/${{ runner.arch }}-osx/tools/protobuf" + export PATH="$PROTOC_DIR:$PATH" + protoc --version + echo "protoc_path=$(which protoc)" >> "$GITHUB_OUTPUT" + + - name: "Run build.py(x64-osx)" + run: | + python ./tools/ci_build/build.py \ + --build_dir "build/x64-osx" \ + --skip_submodule_sync \ + --skip_tests \ + --compile_no_warning_as_error \ + --parallel \ + --path_to_protoc_exe "${{ steps.protoc-detect.outputs.protoc_path }}" \ + --osx_arch x86_64 \ + --use_vcpkg \ + --cmake_extra_defines "CMAKE_TOOLCHAIN_FILE:FILEPATH=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" \ + --cmake_extra_defines "VCPKG_TARGET_TRIPLET=x64-osx" \ + --cmake_extra_defines "VCPKG_INSTALLED_DIR:PATH=${{ github.workspace }}/.build" \ + --cmake_extra_defines "VCPKG_INSTALL_OPTIONS=--x-feature=tests" + shell: bash + + - name: "Run vcpkg(arm64-osx)" + uses: lukka/run-vcpkg@v11 + with: + vcpkgDirectory: "${{ runner.temp }}/vcpkg" + vcpkgGitCommitId: "1de2026f28ead93ff1773e6e680387643e914ea1" # 2024.07.12 + runVcpkgInstall: true + vcpkgJsonGlob: "cmake/vcpkg.json" + vcpkgConfigurationJsonGlob: "cmake/vcpkg-configuration.json" + env: + VCPKG_INSTALLED_DIR: "${{ github.workspace }}/.build" + VCPKG_DEFAULT_TRIPLET: "arm64-osx" + # VCPKG_BINARY_SOURCES: "default" # https://learn.microsoft.com/en-us/vcpkg/reference/binarycaching + + - name: "Run build.py(arm64-osx)" + run: | + python ./tools/ci_build/build.py \ + --build_dir "build/arm64-osx" \ + --skip_submodule_sync \ + --skip_tests \ + --compile_no_warning_as_error \ + --parallel \ + --path_to_protoc_exe "${{ steps.protoc-detect.outputs.protoc_path }}" \ + --osx_arch arm64 \ + --use_vcpkg \ + --cmake_extra_defines "CMAKE_TOOLCHAIN_FILE:FILEPATH=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" \ + --cmake_extra_defines "VCPKG_TARGET_TRIPLET=arm64-osx" \ + --cmake_extra_defines "VCPKG_INSTALLED_DIR:PATH=${{ github.workspace }}/.build" \ + --cmake_extra_defines "VCPKG_INSTALL_OPTIONS=--x-feature=tests" + shell: bash + + 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 From 197957c73131a66c658cf79d4503e60169927d4d Mon Sep 17 00:00:00 2001 From: edgchen1 <18449977+edgchen1@users.noreply.github.com> Date: Fri, 20 Sep 2024 16:02:40 -0700 Subject: [PATCH 6/7] move xcode version specifiers to individual jobs --- .github/workflows/mac.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index c1bf948ac10cd..aecc05c91d736 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -17,12 +17,14 @@ concurrency: env: python_version: 3.11 - xcode_version: 16 jobs: ARM64: runs-on: macos-14 + env: + xcode_version: 16 + timeout-minutes: 60 steps: @@ -145,6 +147,9 @@ jobs: Objective-C-StaticAnalysis: runs-on: macos-14 + env: + xcode_version: 15.2 + timeout-minutes: 30 steps: From b7ff4e01b91adcd240c3698447fa67f1c50e41fc Mon Sep 17 00:00:00 2001 From: edgchen1 <18449977+edgchen1@users.noreply.github.com> Date: Mon, 23 Sep 2024 11:13:38 -0700 Subject: [PATCH 7/7] fix up lambda capture changes --- onnxruntime/contrib_ops/cpu/bert/embed_layer_norm.cc | 9 +++++++-- onnxruntime/core/session/inference_session.cc | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/onnxruntime/contrib_ops/cpu/bert/embed_layer_norm.cc b/onnxruntime/contrib_ops/cpu/bert/embed_layer_norm.cc index 05a36e8d142a3..72adfa025da57 100644 --- a/onnxruntime/contrib_ops/cpu/bert/embed_layer_norm.cc +++ b/onnxruntime/contrib_ops/cpu/bert/embed_layer_norm.cc @@ -86,8 +86,13 @@ Status EmbedLayerNorm::Compute(OpKernelContext* context) const { std::atomic_bool failed{false}; int n = batch_size * sequence_length; + + // Put epsilon into local variable here to avoid the need to capture 'this' in the TryBatchParallelFor() lambda. + // Using the copy capture default (=) to implicitly capture 'this' is deprecated. + const float epsilon_value = epsilon(); + concurrency::ThreadPool::TryBatchParallelFor( - context->GetOperatorThreadPool(), n, [=, &failed, this](ptrdiff_t index) { + context->GetOperatorThreadPool(), n, [=, &failed](ptrdiff_t index) { int word_col_index = input_ids_data[index]; if (word_col_index < 0 || word_col_index >= word_embedding_length) { failed.store(true, std::memory_order_release); @@ -136,7 +141,7 @@ Status EmbedLayerNorm::Compute(OpKernelContext* context) const { y[i] = a; sum += a * a; } - T e = sqrt(sum / hidden_size + static_cast(epsilon())); + T e = sqrt(sum / hidden_size + static_cast(epsilon_value)); for (int i = 0; i < hidden_size; i++) { y[i] = y[i] / e * gamma_data[i] + beta_data[i]; } diff --git a/onnxruntime/core/session/inference_session.cc b/onnxruntime/core/session/inference_session.cc index 46f514c7d7ddc..83e7596d2f6b8 100644 --- a/onnxruntime/core/session/inference_session.cc +++ b/onnxruntime/core/session/inference_session.cc @@ -2770,7 +2770,8 @@ common::Status InferenceSession::RunAsync(const RunOptions* run_options, if (!tp || concurrency::ThreadPool::DegreeOfParallelism(tp) < 2) { return ORT_MAKE_STATUS(ONNXRUNTIME, INVALID_ARGUMENT, "intra op thread pool must have at least one thread for RunAsync"); } - std::function run_fn = [=, this]() { + std::function run_fn = [run_options, feed_names, feeds, fetch_names, fetches, num_fetches, + callback, user_data, this]() { Status status = Status::OK(); ORT_TRY { if (run_options) {