Skip to content

Commit ffa5e8a

Browse files
committed
[iOS] added workflows for libtorchvision_ops.a binary build
ghstack-source-id: e333d14 Pull Request resolved: #3582
1 parent c00c4d3 commit ffa5e8a

File tree

8 files changed

+645
-2
lines changed

8 files changed

+645
-2
lines changed

.circleci/config.yml

Lines changed: 148 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,58 @@ commands:
4646
fi
4747
echo "export UPLOAD_CHANNEL=${our_upload_channel}" >> ${BASH_ENV}
4848
49+
brew_update:
50+
description: "Update Homebrew and install base formulae"
51+
steps:
52+
- run:
53+
name: Update Homebrew
54+
no_output_timeout: "10m"
55+
command: |
56+
set -ex
57+
58+
# Update repositories manually.
59+
# Running `brew update` produces a comparison between the
60+
# current checkout and the updated checkout, which takes a
61+
# very long time because the existing checkout is 2y old.
62+
for path in $(find /usr/local/Homebrew -type d -name .git)
63+
do
64+
cd $path/..
65+
git fetch --depth=1 origin
66+
git reset --hard origin/master
67+
done
68+
69+
export HOMEBREW_NO_AUTO_UPDATE=1
70+
71+
# Install expect and moreutils so that we can call `unbuffer` and `ts`.
72+
# moreutils installs a `parallel` executable by default, which conflicts
73+
# with the executable from the GNU `parallel`, so we must unlink GNU
74+
# `parallel` first, and relink it afterwards.
75+
brew unlink parallel
76+
brew install moreutils
77+
brew link parallel --overwrite
78+
brew install expect
79+
80+
brew_install:
81+
description: "Install Homebrew formulae"
82+
parameters:
83+
formulae:
84+
type: string
85+
default: ""
86+
steps:
87+
- run:
88+
name: Install << parameters.formulae >>
89+
no_output_timeout: "10m"
90+
command: |
91+
set -ex
92+
export HOMEBREW_NO_AUTO_UPDATE=1
93+
brew install << parameters.formulae >>
94+
95+
run_brew_for_ios_build:
96+
steps:
97+
- brew_update
98+
- brew_install:
99+
formulae: libtool
100+
49101
binary_common: &binary_common
50102
parameters:
51103
# Edit these defaults to do a release
@@ -83,6 +135,22 @@ binary_common: &binary_common
83135
UNICODE_ABI: << parameters.unicode_abi >>
84136
CU_VERSION: << parameters.cu_version >>
85137

138+
torchvision_ios_params: &torchvision_ios_params
139+
parameters:
140+
build_environment:
141+
type: string
142+
default: ""
143+
ios_arch:
144+
type: string
145+
default: ""
146+
ios_platform:
147+
type: string
148+
default: ""
149+
environment:
150+
BUILD_ENVIRONMENT: << parameters.build_environment >>
151+
IOS_ARCH: << parameters.ios_arch >>
152+
IOS_PLATFORM: << parameters.ios_platform >>
153+
86154
smoke_test_common: &smoke_test_common
87155
<<: *binary_common
88156
docker:
@@ -278,6 +346,43 @@ jobs:
278346
paths:
279347
- "*"
280348

349+
binary_ios_build:
350+
<<: *torchvision_ios_params
351+
macos:
352+
xcode: "12.0"
353+
steps:
354+
- attach_workspace:
355+
at: ~/workspace
356+
- checkout
357+
- run_brew_for_ios_build
358+
- run:
359+
name: Build
360+
no_output_timeout: "1h"
361+
command: |
362+
script="/Users/distiller/project/.circleci/unittest/ios/scripts/binary_ios_build.sh"
363+
cat "$script"
364+
source "$script"
365+
- persist_to_workspace:
366+
root: /Users/distiller/workspace/
367+
paths: ios
368+
369+
binary_ios_upload:
370+
<<: *torchvision_ios_params
371+
macos:
372+
xcode: "12.0"
373+
steps:
374+
- attach_workspace:
375+
at: ~/workspace
376+
- checkout
377+
- run_brew_for_ios_build
378+
- run:
379+
name: Upload
380+
no_output_timeout: "1h"
381+
command: |
382+
script="/Users/distiller/project/.circleci/unittest/ios/scripts/binary_ios_upload.sh"
383+
cat "$script"
384+
source "$script"
385+
281386
binary_macos_conda:
282387
<<: *binary_common
283388
macos:
@@ -595,7 +700,7 @@ jobs:
595700

596701
keys:
597702
- env-v1-windows-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/windows/scripts/environment.yml" }}-{{ checksum ".circleci-weekly" }}
598-
703+
599704
- run:
600705
name: Setup
601706
command: .circleci/unittest/windows/scripts/setup_env.sh
@@ -1336,6 +1441,18 @@ workflows:
13361441
- clang_format
13371442
- torchhub_test
13381443
- torch_onnx_test
1444+
- binary_ios_build:
1445+
build_environment: binary-libtorchvision_ops-ios-12.0.0-x86_64
1446+
context: org-member
1447+
ios_arch: x86_64
1448+
ios_platform: SIMULATOR
1449+
name: binary_libtorchvision_ops_ios_12.0.0_x86_64
1450+
- binary_ios_build:
1451+
build_environment: binary-libtorchvision_ops-ios-12.0.0-arm64
1452+
context: org-member
1453+
ios_arch: arm64
1454+
ios_platform: OS
1455+
name: binary_libtorchvision_ops_ios_12.0.0_arm64
13391456

13401457
unittest:
13411458
jobs:
@@ -1483,6 +1600,36 @@ workflows:
14831600
- clang_format
14841601
- torchhub_test
14851602
- torch_onnx_test
1603+
- binary_ios_build:
1604+
build_environment: nightly-binary-libtorchvision_ops-ios-12.0.0-x86_64
1605+
context: org-member
1606+
filters:
1607+
branches:
1608+
only:
1609+
- nightly
1610+
ios_arch: x86_64
1611+
ios_platform: SIMULATOR
1612+
name: nightly_binary_libtorchvision_ops_ios_12.0.0_x86_64
1613+
- binary_ios_build:
1614+
build_environment: nightly-binary-libtorchvision_ops-ios-12.0.0-arm64
1615+
context: org-member
1616+
filters:
1617+
branches:
1618+
only:
1619+
- nightly
1620+
ios_arch: arm64
1621+
ios_platform: OS
1622+
name: nightly_binary_libtorchvision_ops_ios_12.0.0_arm64
1623+
- binary_ios_upload:
1624+
build_environment: nightly-binary-libtorchvision_ops-ios-12.0.0-upload
1625+
context: org-member
1626+
filters:
1627+
branches:
1628+
only:
1629+
- nightly
1630+
requires:
1631+
- nightly_binary_libtorchvision_ops_ios_12.0.0_x86_64
1632+
- nightly_binary_libtorchvision_ops_ios_12.0.0_arm64
14861633
- binary_linux_wheel:
14871634
conda_docker_image: pytorch/conda-builder:cpu
14881635
cu_version: cpu

.circleci/config.yml.in

Lines changed: 108 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,58 @@ commands:
4646
fi
4747
echo "export UPLOAD_CHANNEL=${our_upload_channel}" >> ${BASH_ENV}
4848

49+
brew_update:
50+
description: "Update Homebrew and install base formulae"
51+
steps:
52+
- run:
53+
name: Update Homebrew
54+
no_output_timeout: "10m"
55+
command: |
56+
set -ex
57+
58+
# Update repositories manually.
59+
# Running `brew update` produces a comparison between the
60+
# current checkout and the updated checkout, which takes a
61+
# very long time because the existing checkout is 2y old.
62+
for path in $(find /usr/local/Homebrew -type d -name .git)
63+
do
64+
cd $path/..
65+
git fetch --depth=1 origin
66+
git reset --hard origin/master
67+
done
68+
69+
export HOMEBREW_NO_AUTO_UPDATE=1
70+
71+
# Install expect and moreutils so that we can call `unbuffer` and `ts`.
72+
# moreutils installs a `parallel` executable by default, which conflicts
73+
# with the executable from the GNU `parallel`, so we must unlink GNU
74+
# `parallel` first, and relink it afterwards.
75+
brew unlink parallel
76+
brew install moreutils
77+
brew link parallel --overwrite
78+
brew install expect
79+
80+
brew_install:
81+
description: "Install Homebrew formulae"
82+
parameters:
83+
formulae:
84+
type: string
85+
default: ""
86+
steps:
87+
- run:
88+
name: Install << parameters.formulae >>
89+
no_output_timeout: "10m"
90+
command: |
91+
set -ex
92+
export HOMEBREW_NO_AUTO_UPDATE=1
93+
brew install << parameters.formulae >>
94+
95+
run_brew_for_ios_build:
96+
steps:
97+
- brew_update
98+
- brew_install:
99+
formulae: libtool
100+
49101
binary_common: &binary_common
50102
parameters:
51103
# Edit these defaults to do a release
@@ -83,6 +135,22 @@ binary_common: &binary_common
83135
UNICODE_ABI: << parameters.unicode_abi >>
84136
CU_VERSION: << parameters.cu_version >>
85137

138+
torchvision_ios_params: &torchvision_ios_params
139+
parameters:
140+
build_environment:
141+
type: string
142+
default: ""
143+
ios_arch:
144+
type: string
145+
default: ""
146+
ios_platform:
147+
type: string
148+
default: ""
149+
environment:
150+
BUILD_ENVIRONMENT: << parameters.build_environment >>
151+
IOS_ARCH: << parameters.ios_arch >>
152+
IOS_PLATFORM: << parameters.ios_platform >>
153+
86154
smoke_test_common: &smoke_test_common
87155
<<: *binary_common
88156
docker:
@@ -278,6 +346,43 @@ jobs:
278346
paths:
279347
- "*"
280348

349+
binary_ios_build:
350+
<<: *torchvision_ios_params
351+
macos:
352+
xcode: "12.0"
353+
steps:
354+
- attach_workspace:
355+
at: ~/workspace
356+
- checkout
357+
- run_brew_for_ios_build
358+
- run:
359+
name: Build
360+
no_output_timeout: "1h"
361+
command: |
362+
script="/Users/distiller/project/.circleci/unittest/ios/scripts/binary_ios_build.sh"
363+
cat "$script"
364+
source "$script"
365+
- persist_to_workspace:
366+
root: /Users/distiller/workspace/
367+
paths: ios
368+
369+
binary_ios_upload:
370+
<<: *torchvision_ios_params
371+
macos:
372+
xcode: "12.0"
373+
steps:
374+
- attach_workspace:
375+
at: ~/workspace
376+
- checkout
377+
- run_brew_for_ios_build
378+
- run:
379+
name: Upload
380+
no_output_timeout: "1h"
381+
command: |
382+
script="/Users/distiller/project/.circleci/unittest/ios/scripts/binary_ios_upload.sh"
383+
cat "$script"
384+
source "$script"
385+
281386
binary_macos_conda:
282387
<<: *binary_common
283388
macos:
@@ -595,7 +700,7 @@ jobs:
595700
{% raw %}
596701
keys:
597702
- env-v1-windows-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/windows/scripts/environment.yml" }}-{{ checksum ".circleci-weekly" }}
598-
{% endraw %}
703+
{% endraw %}
599704
- run:
600705
name: Setup
601706
command: .circleci/unittest/windows/scripts/setup_env.sh
@@ -813,6 +918,7 @@ workflows:
813918
- clang_format
814919
- torchhub_test
815920
- torch_onnx_test
921+
{{ ios_workflows() }}
816922

817923
unittest:
818924
jobs:
@@ -832,6 +938,7 @@ workflows:
832938
- clang_format
833939
- torchhub_test
834940
- torch_onnx_test
941+
{{ ios_workflows(nightly=True) }}
835942
{{ build_workflows(prefix="nightly_", filter_branch="nightly", upload=True) }}
836943
docker_build:
837944
triggers:

.circleci/regenerate.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,34 @@ def cmake_workflows(indentation=6):
251251
jobs.append({f'cmake_{os_type}_{device}': job})
252252
return indent(indentation, jobs)
253253

254+
def ios_workflows(indentation=6, nightly=False):
255+
jobs = []
256+
build_job_names = []
257+
name_prefix = "nightly_" if nightly else ""
258+
env_prefix = "nightly-" if nightly else ""
259+
for arch, platform in [('x86_64', 'SIMULATOR'), ('arm64', 'OS')]:
260+
name = f'{name_prefix}binary_libtorchvision_ops_ios_12.0.0_{arch}'
261+
build_job_names.append(name)
262+
build_job = {
263+
'build_environment': f'{env_prefix}binary-libtorchvision_ops-ios-12.0.0-{arch}',
264+
'context': 'org-member',
265+
'ios_arch': arch,
266+
'ios_platform': platform,
267+
'name': name,
268+
}
269+
if nightly:
270+
build_job['filters'] = gen_filter_branch_tree('nightly')
271+
jobs.append({'binary_ios_build': build_job})
272+
273+
if nightly:
274+
upload_job = {
275+
'build_environment': f'{env_prefix}binary-libtorchvision_ops-ios-12.0.0-upload',
276+
'context': 'org-member',
277+
'filters': gen_filter_branch_tree('nightly'),
278+
'requires': build_job_names,
279+
}
280+
jobs.append({'binary_ios_upload': upload_job})
281+
return indent(indentation, jobs)
254282

255283
if __name__ == "__main__":
256284
d = os.path.dirname(__file__)
@@ -266,4 +294,5 @@ def cmake_workflows(indentation=6):
266294
build_workflows=build_workflows,
267295
unittest_workflows=unittest_workflows,
268296
cmake_workflows=cmake_workflows,
297+
ios_workflows=ios_workflows,
269298
))

0 commit comments

Comments
 (0)