Skip to content

[iOS] added workflows for libtorchvision_ops.a binary build #3582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 149 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,59 @@ commands:
command: |
powershell .circleci/scripts/vs_install_cmath.ps1

brew_update:
description: "Update Homebrew and install base formulae"
steps:
- run:
name: Update Homebrew
no_output_timeout: "10m"
command: |
set -ex

# Update repositories manually.
# Running `brew update` produces a comparison between the
# current checkout and the updated checkout, which takes a
# very long time because the existing checkout is 2y old.
for path in $(find /usr/local/Homebrew -type d -name .git)
do
cd $path/..
git fetch --depth=1 origin
git reset --hard origin/master
done

export HOMEBREW_NO_AUTO_UPDATE=1

# Install expect and moreutils so that we can call `unbuffer` and `ts`.
# moreutils installs a `parallel` executable by default, which conflicts
# with the executable from the GNU `parallel`, so we must unlink GNU
# `parallel` first, and relink it afterwards.
brew install coreutils
brew unlink parallel
brew install moreutils
brew link parallel --overwrite
brew install expect

brew_install:
description: "Install Homebrew formulae"
parameters:
formulae:
type: string
default: ""
steps:
- run:
name: Install << parameters.formulae >>
no_output_timeout: "10m"
command: |
set -ex
export HOMEBREW_NO_AUTO_UPDATE=1
brew install << parameters.formulae >>

run_brew_for_ios_build:
steps:
- brew_update
- brew_install:
formulae: libtool

binary_common: &binary_common
parameters:
# Edit these defaults to do a release
Expand Down Expand Up @@ -91,6 +144,22 @@ binary_common: &binary_common
UNICODE_ABI: << parameters.unicode_abi >>
CU_VERSION: << parameters.cu_version >>

torchvision_ios_params: &torchvision_ios_params
parameters:
build_environment:
type: string
default: ""
ios_arch:
type: string
default: ""
ios_platform:
type: string
default: ""
environment:
BUILD_ENVIRONMENT: << parameters.build_environment >>
IOS_ARCH: << parameters.ios_arch >>
IOS_PLATFORM: << parameters.ios_platform >>

smoke_test_common: &smoke_test_common
<<: *binary_common
docker:
Expand Down Expand Up @@ -288,6 +357,43 @@ jobs:
paths:
- "*"

binary_ios_build:
<<: *torchvision_ios_params
macos:
xcode: "12.0"
steps:
- attach_workspace:
at: ~/workspace
- checkout
- run_brew_for_ios_build
- run:
name: Build
no_output_timeout: "1h"
command: |
script="/Users/distiller/project/.circleci/unittest/ios/scripts/binary_ios_build.sh"
cat "$script"
source "$script"
- persist_to_workspace:
root: /Users/distiller/workspace/
paths: ios

binary_ios_upload:
<<: *torchvision_ios_params
macos:
xcode: "12.0"
steps:
- attach_workspace:
at: ~/workspace
- checkout
- run_brew_for_ios_build
- run:
name: Upload
no_output_timeout: "1h"
command: |
script="/Users/distiller/project/.circleci/unittest/ios/scripts/binary_ios_upload.sh"
cat "$script"
source "$script"

binary_macos_conda:
<<: *binary_common
macos:
Expand Down Expand Up @@ -607,7 +713,7 @@ jobs:

keys:
- env-v1-windows-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/windows/scripts/environment.yml" }}-{{ checksum ".circleci-weekly" }}

- run:
name: Setup
command: .circleci/unittest/windows/scripts/setup_env.sh
Expand Down Expand Up @@ -1370,6 +1476,18 @@ workflows:
- clang_format
- torchhub_test
- torch_onnx_test
- binary_ios_build:
build_environment: binary-libtorchvision_ops-ios-12.0.0-x86_64
context: org-member
ios_arch: x86_64
ios_platform: SIMULATOR
name: binary_libtorchvision_ops_ios_12.0.0_x86_64
- binary_ios_build:
build_environment: binary-libtorchvision_ops-ios-12.0.0-arm64
context: org-member
ios_arch: arm64
ios_platform: OS
name: binary_libtorchvision_ops_ios_12.0.0_arm64

unittest:
jobs:
Expand Down Expand Up @@ -1517,6 +1635,36 @@ workflows:
- clang_format
- torchhub_test
- torch_onnx_test
- binary_ios_build:
build_environment: nightly-binary-libtorchvision_ops-ios-12.0.0-x86_64
context: org-member
filters:
branches:
only:
- nightly
ios_arch: x86_64
ios_platform: SIMULATOR
name: nightly_binary_libtorchvision_ops_ios_12.0.0_x86_64
- binary_ios_build:
build_environment: nightly-binary-libtorchvision_ops-ios-12.0.0-arm64
context: org-member
filters:
branches:
only:
- nightly
ios_arch: arm64
ios_platform: OS
name: nightly_binary_libtorchvision_ops_ios_12.0.0_arm64
- binary_ios_upload:
build_environment: nightly-binary-libtorchvision_ops-ios-12.0.0-upload
context: org-member
filters:
branches:
only:
- nightly
requires:
- nightly_binary_libtorchvision_ops_ios_12.0.0_x86_64
- nightly_binary_libtorchvision_ops_ios_12.0.0_arm64
- binary_linux_wheel:
conda_docker_image: pytorch/conda-builder:cpu
cu_version: cpu
Expand Down
110 changes: 109 additions & 1 deletion .circleci/config.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,59 @@ commands:
command: |
powershell .circleci/scripts/vs_install_cmath.ps1

brew_update:
description: "Update Homebrew and install base formulae"
steps:
- run:
name: Update Homebrew
no_output_timeout: "10m"
command: |
set -ex

# Update repositories manually.
# Running `brew update` produces a comparison between the
# current checkout and the updated checkout, which takes a
# very long time because the existing checkout is 2y old.
for path in $(find /usr/local/Homebrew -type d -name .git)
do
cd $path/..
git fetch --depth=1 origin
git reset --hard origin/master
done

export HOMEBREW_NO_AUTO_UPDATE=1

# Install expect and moreutils so that we can call `unbuffer` and `ts`.
# moreutils installs a `parallel` executable by default, which conflicts
# with the executable from the GNU `parallel`, so we must unlink GNU
# `parallel` first, and relink it afterwards.
brew install coreutils
brew unlink parallel
brew install moreutils
brew link parallel --overwrite
brew install expect

brew_install:
description: "Install Homebrew formulae"
parameters:
formulae:
type: string
default: ""
steps:
- run:
name: Install << parameters.formulae >>
no_output_timeout: "10m"
command: |
set -ex
export HOMEBREW_NO_AUTO_UPDATE=1
brew install << parameters.formulae >>

run_brew_for_ios_build:
steps:
- brew_update
- brew_install:
formulae: libtool

binary_common: &binary_common
parameters:
# Edit these defaults to do a release
Expand Down Expand Up @@ -91,6 +144,22 @@ binary_common: &binary_common
UNICODE_ABI: << parameters.unicode_abi >>
CU_VERSION: << parameters.cu_version >>

torchvision_ios_params: &torchvision_ios_params
parameters:
build_environment:
type: string
default: ""
ios_arch:
type: string
default: ""
ios_platform:
type: string
default: ""
environment:
BUILD_ENVIRONMENT: << parameters.build_environment >>
IOS_ARCH: << parameters.ios_arch >>
IOS_PLATFORM: << parameters.ios_platform >>

smoke_test_common: &smoke_test_common
<<: *binary_common
docker:
Expand Down Expand Up @@ -288,6 +357,43 @@ jobs:
paths:
- "*"

binary_ios_build:
<<: *torchvision_ios_params
macos:
xcode: "12.0"
steps:
- attach_workspace:
at: ~/workspace
- checkout
- run_brew_for_ios_build
- run:
name: Build
no_output_timeout: "1h"
command: |
script="/Users/distiller/project/.circleci/unittest/ios/scripts/binary_ios_build.sh"
cat "$script"
source "$script"
- persist_to_workspace:
root: /Users/distiller/workspace/
paths: ios

binary_ios_upload:
<<: *torchvision_ios_params
macos:
xcode: "12.0"
steps:
- attach_workspace:
at: ~/workspace
- checkout
- run_brew_for_ios_build
- run:
name: Upload
no_output_timeout: "1h"
command: |
script="/Users/distiller/project/.circleci/unittest/ios/scripts/binary_ios_upload.sh"
cat "$script"
source "$script"

binary_macos_conda:
<<: *binary_common
macos:
Expand Down Expand Up @@ -607,7 +713,7 @@ jobs:
{% raw %}
keys:
- env-v1-windows-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/windows/scripts/environment.yml" }}-{{ checksum ".circleci-weekly" }}
{% endraw %}
{% endraw %}
- run:
name: Setup
command: .circleci/unittest/windows/scripts/setup_env.sh
Expand Down Expand Up @@ -827,6 +933,7 @@ workflows:
- clang_format
- torchhub_test
- torch_onnx_test
{{ ios_workflows() }}

unittest:
jobs:
Expand All @@ -846,6 +953,7 @@ workflows:
- clang_format
- torchhub_test
- torch_onnx_test
{{ ios_workflows(nightly=True) }}
{{ build_workflows(prefix="nightly_", filter_branch="nightly", upload=True) }}
docker_build:
triggers:
Expand Down
31 changes: 31 additions & 0 deletions .circleci/regenerate.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,36 @@ def cmake_workflows(indentation=6):
return indent(indentation, jobs)


def ios_workflows(indentation=6, nightly=False):
jobs = []
build_job_names = []
name_prefix = "nightly_" if nightly else ""
env_prefix = "nightly-" if nightly else ""
for arch, platform in [('x86_64', 'SIMULATOR'), ('arm64', 'OS')]:
name = f'{name_prefix}binary_libtorchvision_ops_ios_12.0.0_{arch}'
build_job_names.append(name)
build_job = {
'build_environment': f'{env_prefix}binary-libtorchvision_ops-ios-12.0.0-{arch}',
'context': 'org-member',
'ios_arch': arch,
'ios_platform': platform,
'name': name,
}
if nightly:
build_job['filters'] = gen_filter_branch_tree('nightly')
jobs.append({'binary_ios_build': build_job})

if nightly:
upload_job = {
'build_environment': f'{env_prefix}binary-libtorchvision_ops-ios-12.0.0-upload',
'context': 'org-member',
'filters': gen_filter_branch_tree('nightly'),
'requires': build_job_names,
}
jobs.append({'binary_ios_upload': upload_job})
return indent(indentation, jobs)


if __name__ == "__main__":
d = os.path.dirname(__file__)
env = jinja2.Environment(
Expand All @@ -275,4 +305,5 @@ def cmake_workflows(indentation=6):
build_workflows=build_workflows,
unittest_workflows=unittest_workflows,
cmake_workflows=cmake_workflows,
ios_workflows=ios_workflows,
))
Loading