diff --git a/.ci/scripts/wheel/pre_build_script.sh b/.ci/scripts/wheel/pre_build_script.sh index 54283bd9c0a..f5d8cd362ee 100755 --- a/.ci/scripts/wheel/pre_build_script.sh +++ b/.ci/scripts/wheel/pre_build_script.sh @@ -9,6 +9,18 @@ set -euxo pipefail # This script is run before building ExecuTorch binaries +if [[ "$(uname -m)" == "aarch64" ]]; then + # On some Linux aarch64 systems, the "atomic" library is not found during linking. + # To work around this, replace "atomic" with the literal ${ATOMIC_LIB} so the + # build system uses the full path to the atomic library. + file="extension/llm/tokenizers/third-party/sentencepiece/src/CMakeLists.txt" + sed 's/list(APPEND SPM_LIBS "atomic")/list(APPEND SPM_LIBS ${ATOMIC_LIB})/' \ + "$file" > "${file}.tmp" && mv "${file}.tmp" "$file" + + grep -n 'list(APPEND SPM_LIBS ${ATOMIC_LIB})' "$file" && \ + echo "the file $file has been modified for atomic to use full path" +fi + # Clone nested submodules for tokenizers - this is a workaround for recursive # submodule clone failing due to path length limitations on Windows. Eventually, # we should update the core job in test-infra to enable long paths before diff --git a/.ci/scripts/wheel/test_linux_aarch64.py b/.ci/scripts/wheel/test_linux_aarch64.py new file mode 100644 index 00000000000..d514738c005 --- /dev/null +++ b/.ci/scripts/wheel/test_linux_aarch64.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. + +import test_base +from examples.models import Backend, Model + +if __name__ == "__main__": + # coremltools does not support linux aarch64 yet and install from the source fails on runtime + # https://github.com/apple/coremltools/issues/1254 + # https://github.com/apple/coremltools/issues/2195 + test_base.run_tests( + model_tests=[ + test_base.ModelTest( + model=Model.Mv3, + backend=Backend.XnnpackQuantizationDelegation, + ), + ] + ) diff --git a/.github/workflows/build-wheels-aarch64-linux.yml b/.github/workflows/build-wheels-aarch64-linux.yml new file mode 100644 index 00000000000..abc378f9061 --- /dev/null +++ b/.github/workflows/build-wheels-aarch64-linux.yml @@ -0,0 +1,66 @@ +# From https://github.com/pytorch/test-infra/wiki/Using-Nova-Reusable-Build-Workflows +name: Build Aarch64 Linux Wheels + +on: + pull_request: + paths: + - .ci/**/* + - .github/workflows/build-wheels-aarch64-linux.yml + - examples/**/* + - pyproject.toml + - setup.py + tags: + - ciflow/binaries/* + push: + branches: + - nightly + - release/* + tags: + # NOTE: Binary build pipelines should only get triggered on release candidate builds + # Release candidate tags look like: v1.11.0-rc1 + - v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+ + - ciflow/binaries/* + workflow_dispatch: + +jobs: + generate-matrix: + uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main + with: + package-type: wheel + os: linux-aarch64 + test-infra-repository: pytorch/test-infra + test-infra-ref: main + with-cuda: disabled + with-rocm: disabled + python-versions: '["3.10", "3.11", "3.12"]' + + build: + needs: generate-matrix + permissions: + id-token: write + contents: read + strategy: + fail-fast: false + matrix: + include: + - repository: pytorch/executorch + pre-script: .ci/scripts/wheel/pre_build_script.sh + post-script: .ci/scripts/wheel/post_build_script.sh + smoke-test-script: .ci/scripts/wheel/test_linux_aarch64.py + package-name: executorch + name: ${{ matrix.repository }} + uses: pytorch/test-infra/.github/workflows/build_wheels_linux.yml@main + with: + repository: ${{ matrix.repository }} + ref: "" + test-infra-repository: pytorch/test-infra + test-infra-ref: main + build-matrix: ${{ needs.generate-matrix.outputs.matrix }} + submodules: recursive + env-var-script: .ci/scripts/wheel/envvar_linux.sh + pre-script: ${{ matrix.pre-script }} + post-script: ${{ matrix.post-script }} + package-name: ${{ matrix.package-name }} + smoke-test-script: ${{ matrix.smoke-test-script }} + trigger-event: ${{ github.event_name }} + architecture: aarch64 diff --git a/backends/apple/coreml/runtime/inmemoryfs/inmemory_filesystem.cpp b/backends/apple/coreml/runtime/inmemoryfs/inmemory_filesystem.cpp index ec2f0459a47..c5671b1e6c4 100644 --- a/backends/apple/coreml/runtime/inmemoryfs/inmemory_filesystem.cpp +++ b/backends/apple/coreml/runtime/inmemoryfs/inmemory_filesystem.cpp @@ -7,9 +7,11 @@ #include "inmemory_filesystem.hpp" +#include #include #include #include +#include #include #if __has_include()