@@ -169,7 +169,49 @@ commands:
169169 echo "This is not a pull request, skipping..."
170170 fi
171171
172-
172+ upload_binary_size_for_android_build :
173+ description : " Upload binary size data for Android build"
174+ parameters :
175+ build_type :
176+ type : string
177+ default : " "
178+ artifacts :
179+ type : string
180+ default : " "
181+ steps :
182+ - run :
183+ name : " Binary Size - Set Python Version"
184+ no_output_timeout : " 1m"
185+ command : pyenv global 3.7.0
186+ - run :
187+ name : " Binary Size - Install Dependencies"
188+ no_output_timeout : " 5m"
189+ command : |
190+ retry () {
191+ $* || (sleep 1 && $*) || (sleep 2 && $*) || (sleep 4 && $*) || (sleep 8 && $*)
192+ }
193+ retry pip3 install requests
194+ - run :
195+ name : " Binary Size - Untar Artifacts"
196+ no_output_timeout : " 5m"
197+ command : |
198+ # The artifact file is created inside docker container, which contains the result binaries.
199+ # Now unpackage it into the project folder. The subsequent script will scan project folder
200+ # to locate result binaries and report their sizes.
201+ # If artifact file is not provided it assumes that the project folder has been mounted in
202+ # the docker during build and already contains the result binaries, so this step can be skipped.
203+ export ARTIFACTS="<< parameters.artifacts >>"
204+ if [ -n "${ARTIFACTS}" ]; then
205+ tar xf "${ARTIFACTS}" -C ~/project
206+ fi
207+ - run :
208+ name : " Binary Size - Upload << parameters.build_type >>"
209+ no_output_timeout : " 5m"
210+ command : |
211+ cd ~/project
212+ export ANDROID_BUILD_TYPE="<< parameters.build_type >>"
213+ export COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0)
214+ python3 .circleci/scripts/upload_binary_size_to_scuba.py android
173215
174216# #############################################################################
175217# Binary build (nightlies nightly build) defaults
@@ -538,6 +580,7 @@ jobs:
538580 # See https://circleci.com/docs/2.0/env-vars/#using-parameters-and-bash-environment
539581 echo "export PARALLEL_FLAGS=\"${PARALLEL_FLAGS}\"" >> $BASH_ENV
540582 echo "export id=$id" >> $BASH_ENV
583+ echo "export COMMIT_DOCKER_IMAGE=${COMMIT_DOCKER_IMAGE}" >> $BASH_ENV
541584 - run :
542585 name : Check for no AVX instruction by default
543586 no_output_timeout : " 20m"
@@ -554,8 +597,8 @@ jobs:
554597 }
555598
556599 if is_vanilla_build; then
557- echo "apt-get update && apt-get install -y qemu-user" | docker exec -u root -i "$id" bash
558- echo "cd workspace/build; qemu-x86_64 -cpu Broadwell -E ATEN_CPU_CAPABILITY=default ./bin/basic --gtest_filter=BasicTest.BasicTestCPU" | docker exec -u jenkins -i "$id" bash
600+ echo "apt-get update && apt-get install -y qemu-user gdb " | docker exec -u root -i "$id" bash
601+ echo "cd workspace/build; qemu-x86_64 -g 2345 - cpu Broadwell -E ATEN_CPU_CAPABILITY=default ./bin/basic --gtest_filter=BasicTest.BasicTestCPU & gdb ./bin/basic -ex 'set pagination off' -ex 'target remote :2345' -ex 'continue' -ex 'bt' -ex='set confirm off' -ex 'quit \$_isvoid(\$_exitcode)' " | docker exec -u jenkins -i "$id" bash
559602 else
560603 echo "Skipping for ${BUILD_ENVIRONMENT}"
561604 fi
@@ -580,6 +623,12 @@ jobs:
580623 echo "cd workspace; python test/print_test_stats.py test" | docker exec -u jenkins -i "$id" bash
581624 echo "Retrieving test reports"
582625 docker cp $id:/var/lib/jenkins/workspace/test/test-reports ./ || echo 'No test reports found!'
626+ echo "Stopping current container"
627+ docker container stop $id
628+ echo "Pruning stopped containers"
629+ docker container prune -f
630+ echo "Deleting the image"
631+ docker image rm ${COMMIT_DOCKER_IMAGE}
583632 when : always
584633 - store_test_results :
585634 path : test-reports
@@ -1529,26 +1578,9 @@ jobs:
15291578 output_image=$docker_image_libtorch_android_x86_32-gradle
15301579 docker commit "$id_x86_32" ${output_image}
15311580 time docker push ${output_image}
1532- - run :
1533- name : save binary size
1534- no_output_timeout : " 5m"
1535- command : |
1536- docker_image=${DOCKER_IMAGE}-${CIRCLE_SHA1}-android-x86_32-gradle
1537- export id=$(docker run --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -t -d -w /var/lib/jenkins ${docker_image})
1538- echo "docker-id: $id"
1539- cat \<< EOL | docker exec -u jenkins -i "$id" bash
1540- # ============================== Begin Docker ==============================
1541- cd workspace
1542- source ./env
1543- export ANDROID_BUILD_TYPE="prebuild"
1544- export COMMIT_TIME=\$(git log --max-count=1 --format=%ct || echo 0)
1545- export CIRCLE_BUILD_NUM="${CIRCLE_BUILD_NUM}"
1546- export CIRCLE_SHA1="${CIRCLE_SHA1}"
1547- export CIRCLE_BRANCH="${CIRCLE_BRANCH}"
1548- export SCRIBE_GRAPHQL_ACCESS_TOKEN="${SCRIBE_GRAPHQL_ACCESS_TOKEN}"
1549- python .circleci/scripts/upload_binary_size_to_scuba.py android
1550- # ============================== End Docker ==============================
1551- EOL
1581+ - upload_binary_size_for_android_build :
1582+ build_type : prebuilt
1583+ artifacts : /home/circleci/workspace/build_android_artifacts/artifacts.tgz
15521584 - store_artifacts :
15531585 path : ~/workspace/build_android_artifacts/artifacts.tgz
15541586 destination : artifacts.tgz
@@ -1599,14 +1631,6 @@ jobs:
15991631 image : ubuntu-1604:201903-01
16001632 steps :
16011633 - checkout
1602- - run :
1603- name : filter out not PR runs
1604- no_output_timeout : " 5m"
1605- command : |
1606- echo "CIRCLE_PULL_REQUEST: ${CIRCLE_PULL_REQUEST:-}"
1607- if [ -z "${CIRCLE_PULL_REQUEST:-}" ]; then
1608- circleci step halt
1609- fi
16101634 - setup_linux_system_environment
16111635 - checkout
16121636 - setup_ci_environment
@@ -1631,30 +1655,53 @@ jobs:
16311655 output_image=${docker_image_libtorch_android_x86_32}-gradle
16321656 docker commit "$id" ${output_image}
16331657 time docker push ${output_image}
1634- - run :
1635- name : save binary size
1636- no_output_timeout : " 5m"
1637- command : |
1638- docker_image=${DOCKER_IMAGE}-${CIRCLE_SHA1}-android-x86_32-gradle
1639- export id=$(docker run --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -t -d -w /var/lib/jenkins ${docker_image})
1640- echo "docker-id: $id"
1641- cat \<< EOL | docker exec -u jenkins -i "$id" bash
1642- # ============================== Begin Docker ==============================
1643- cd workspace
1644- source ./env
1645- export ANDROID_BUILD_TYPE="prebuild-single"
1646- export COMMIT_TIME=\$(git log --max-count=1 --format=%ct || echo 0)
1647- export CIRCLE_BUILD_NUM="${CIRCLE_BUILD_NUM}"
1648- export CIRCLE_SHA1="${CIRCLE_SHA1}"
1649- export CIRCLE_BRANCH="${CIRCLE_BRANCH}"
1650- export SCRIBE_GRAPHQL_ACCESS_TOKEN="${SCRIBE_GRAPHQL_ACCESS_TOKEN}"
1651- python .circleci/scripts/upload_binary_size_to_scuba.py android
1652- # ============================== End Docker ==============================
1653- EOL
1658+ - upload_binary_size_for_android_build :
1659+ build_type : prebuilt-single
1660+ artifacts : /home/circleci/workspace/build_android_x86_32_artifacts/artifacts.tgz
16541661 - store_artifacts :
16551662 path : ~/workspace/build_android_x86_32_artifacts/artifacts.tgz
16561663 destination : artifacts.tgz
16571664
1665+ pytorch_android_gradle_custom_build_single :
1666+ environment :
1667+ BUILD_ENVIRONMENT : pytorch-linux-xenial-py3-clang5-android-ndk-r19c-gradle-custom-build-single
1668+ DOCKER_IMAGE : " 308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/pytorch-linux-xenial-py3-clang5-android-ndk-r19c:209062ef-ab58-422a-b295-36c4eed6e906"
1669+ PYTHON_VERSION : " 3.6"
1670+ resource_class : large
1671+ machine :
1672+ image : ubuntu-1604:201903-01
1673+ steps :
1674+ - checkout
1675+ - setup_linux_system_environment
1676+ - checkout
1677+ - setup_ci_environment
1678+ - run :
1679+ name : pytorch android gradle custom build single architecture (for PR)
1680+ no_output_timeout : " 1h"
1681+ command : |
1682+ set -e
1683+ # Unlike other gradle jobs, it's not worth building libtorch in a separate CI job and share via docker, because:
1684+ # 1) Not shareable: it's custom selective build, which is different from default libtorch mobile build;
1685+ # 2) Not parallelizable by architecture: it only builds libtorch for one architecture;
1686+
1687+ echo "DOCKER_IMAGE: ${DOCKER_IMAGE}"
1688+ time docker pull ${DOCKER_IMAGE} >/dev/null
1689+ export id=$(docker run --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -t -d -w /var/lib/jenkins ${DOCKER_IMAGE})
1690+
1691+ git submodule sync && git submodule update -q --init --recursive
1692+
1693+ VOLUME_MOUNTS="-v /home/circleci/project/:/var/lib/jenkins/workspace"
1694+ export id=$(docker run ${VOLUME_MOUNTS} --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -t -d -w /var/lib/jenkins ${DOCKER_IMAGE})
1695+
1696+ export COMMAND='((echo "source ./workspace/env" && echo "export BUILD_ENVIRONMENT=${BUILD_ENVIRONMENT}" && echo "export GRADLE_OFFLINE=1" && echo "sudo chown -R jenkins workspace && cd workspace && ./.circleci/scripts/build_android_gradle.sh") | docker exec -u jenkins -i "$id" bash) 2>&1'
1697+ echo ${COMMAND} > ./command.sh && unbuffer bash ./command.sh | ts
1698+
1699+ # Skip docker push as this job is purely for size analysis purpose.
1700+ # Result binaries are already in `/home/circleci/project/` as it's mounted instead of copied.
1701+
1702+ - upload_binary_size_for_android_build :
1703+ build_type : custom-build-single
1704+
16581705 pytorch_ios_build :
16591706 << : *pytorch_ios_params
16601707 macos :
@@ -1903,6 +1950,7 @@ jobs:
19031950 update_s3_htmls : &update_s3_htmls
19041951 machine :
19051952 image : ubuntu-1604:201903-01
1953+ resource_class : medium
19061954 steps :
19071955 - checkout
19081956 - setup_linux_system_environment
@@ -7546,9 +7594,21 @@ workflows:
75467594 docker_image : " 308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/pytorch-linux-xenial-py3-clang5-android-ndk-r19c:fff7795428560442086f7b2bb6004b65245dc11a"
75477595 name : pytorch_linux_xenial_py3_clang5_android_ndk_r19c_vulkan_x86_32_build
75487596 - pytorch_android_gradle_build-x86_32 :
7597+ filters :
7598+ branches :
7599+ only :
7600+ - /gh\/.*\/head/
7601+ - /pull\/.*/
75497602 name : pytorch-linux-xenial-py3-clang5-android-ndk-r19c-gradle-build-x86_32
75507603 requires :
75517604 - pytorch_linux_xenial_py3_clang5_android_ndk_r19c_x86_32_build
7605+ - pytorch_android_gradle_custom_build_single :
7606+ filters :
7607+ branches :
7608+ only :
7609+ - /gh\/.*\/head/
7610+ - /pull\/.*/
7611+ name : pytorch-linux-xenial-py3-clang5-android-ndk-r19c-gradle-custom-build-single
75527612 - pytorch_android_gradle_build :
75537613 filters :
75547614 branches :
0 commit comments