Load model in background thread (#2470) #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Apple | |
on: | |
push: | |
branches: | |
- main | |
- release/* | |
pull_request: | |
paths: | |
- .ci/docker/** | |
- .github/workflows/apple.yml | |
- install_requirements.sh | |
- backends/apple/** | |
- build/build_apple_frameworks.sh | |
- build/create_frameworks.sh | |
- build/test_ios_ci.sh | |
- examples/demo-apps/** | |
- extension/apple/** | |
- extension/module/** | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}-${{ github.event_name == 'schedule' }} | |
cancel-in-progress: true | |
jobs: | |
test-demo-ios: | |
name: test-demo-ios | |
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main | |
with: | |
runner: macos-latest-xlarge | |
python-version: '3.11' | |
submodules: 'true' | |
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} | |
timeout: 90 | |
script: | | |
WORKSPACE=$(pwd) | |
pushd "${WORKSPACE}/pytorch/executorch" | |
BUILD_TOOL=cmake | |
.ci/scripts/setup-conda.sh | |
# Setup MacOS dependencies as there is no Docker support on MacOS atm | |
GITHUB_RUNNER=1 PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \ | |
.ci/scripts/setup-macos.sh "${BUILD_TOOL}" | |
# Build and test iOS Demo App | |
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \ | |
build/test_ios_ci.sh | |
popd | |
build-frameworks-ios: | |
name: build-frameworks-ios | |
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main | |
with: | |
runner: macos-latest-xlarge | |
python-version: '3.11' | |
submodules: 'true' | |
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} | |
upload-artifact: executorch-frameworks-ios | |
timeout: 90 | |
script: | | |
WORKSPACE=$(pwd) | |
pushd "${WORKSPACE}/pytorch/executorch" | |
BUILD_TOOL=cmake | |
VERSION="0.1.0" | |
FRAMEWORKS=( | |
"executorch" | |
"coreml_backend" | |
"mps_backend" | |
"portable_backend" | |
"xnnpack_backend" | |
) | |
.ci/scripts/setup-conda.sh | |
# Setup MacOS dependencies as there is no Docker support on MacOS atm | |
GITHUB_RUNNER=1 PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \ | |
.ci/scripts/setup-macos.sh "${BUILD_TOOL}" | |
# Install CoreML Backend Requirements | |
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \ | |
backends/apple/coreml/scripts/install_requirements.sh | |
# Install MPS Backend Requirements | |
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \ | |
backends/apple/mps/install_requirements.sh | |
# Build iOS Frameworks | |
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \ | |
build/build_apple_frameworks.sh --coreml --mps --portable --xnnpack | |
# Bundle iOS Frameworks | |
for FRAMEWORK in "${FRAMEWORKS[@]}"; do ( | |
cd cmake-out && \ | |
zip -r "${RUNNER_TEMP}/artifacts/${FRAMEWORK}-${VERSION}.zip" \ | |
"${FRAMEWORK}.xcframework" \ | |
../LICENSE | |
) done | |
popd | |
upload-frameworks-ios: | |
runs-on: ubuntu-22.04 | |
needs: build-frameworks-ios | |
timeout-minutes: 30 | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
cache: pip | |
- name: configure aws credentials | |
uses: aws-actions/[email protected] | |
with: | |
role-to-assume: arn:aws:iam::308535385114:role/gha_executorch_upload-frameworks-ios | |
aws-region: us-east-1 | |
- name: Download the artifact | |
uses: actions/download-artifact@v3 | |
with: | |
# NB: The name here needs to match the upload-artifact name from build-frameworks-ios job | |
name: executorch-frameworks-ios | |
path: ${{ runner.temp }}/frameworks-ios/ | |
- name: Only push to S3 from main branch | |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | |
shell: bash | |
run: | | |
set -eux | |
echo "UPLOAD_ON_MAIN=1" >> "${GITHUB_ENV}" | |
- name: Upload the artifact to ossci-ios S3 bucket | |
shell: bash | |
run: | | |
set -eux | |
pip install awscli==1.32.18 | |
AWS_CMD="aws s3 cp --dryrun" | |
if [[ "${UPLOAD_ON_MAIN:-0}" == "1" ]]; then | |
AWS_CMD="aws s3 cp" | |
fi | |
for FILENAME in "${RUNNER_TEMP}"/frameworks-ios/*.zip; do | |
[ -e "${FILENAME}" ] || continue | |
${AWS_CMD} "${FILENAME}" s3://ossci-ios/executorch/ --acl public-read | |
done |