Skip to content

Commit c065c18

Browse files
Merge pull request #425 from puneetmatharu/tidy-up-pytorch-build-scripts
Tidy up pytorch-aarch64 build scripts
2 parents 0e10596 + 69fa236 commit c065c18

File tree

4 files changed

+108
-89
lines changed

4 files changed

+108
-89
lines changed

.github/workflows/pytorch.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Copyright 2025 Arm Limited and affiliates.
1+
# SPDX-FileCopyrightText: Copyright 2025, 2026 Arm Limited and affiliates.
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

@@ -55,7 +55,7 @@ jobs:
5555
]
5656
runs-on: ${{ matrix.config.label }}
5757
env:
58-
CCACHE_HOST_DIR: ${{ github.workspace }}/Tool-Solutions/ML-Frameworks/pytorch-aarch64/.ccache
58+
CCACHE_LOCAL_DIR: ${{ github.workspace }}/Tool-Solutions/ML-Frameworks/pytorch-aarch64/.ccache
5959
TORCH_BUILD_CONTAINER_ID_FILE: ${{ github.workspace }}/Tool-Solutions/ML-Frameworks/pytorch-aarch64/.torch_build_container_id
6060
steps:
6161
- name: Checkout Tool-Solutions
@@ -71,14 +71,14 @@ jobs:
7171
run: echo "week=$(date -u +%G-%V)" >> "$GITHUB_OUTPUT"
7272

7373
# Restore cache if available. GitHub automatically evicts cache entries that have not been
74-
# accessed for over 7 days. We rotate the cache key weekly; if no cache exists for the
75-
# current week, a cache from a previous week (via the prefix restore key) will be restored
76-
# and then saved under the current week's key at the end of the job. This effectively limits
74+
# accessed for over 7 days. We rotate the cache key weekly; if no cache exists for the
75+
# current week, a cache from a previous week (via the prefix restore key) will be restored
76+
# and then saved under the current week's key at the end of the job. This effectively limits
7777
# the cache to at most two weeks of cache data.
7878
- name: Restore ccache cache
7979
uses: actions/cache@v5
8080
with:
81-
path: ${{ env.CCACHE_HOST_DIR }}
81+
path: ${{ env.CCACHE_LOCAL_DIR }}
8282
key: ccache-${{ matrix.config.name }}-${{ steps.cache_suffix.outputs.week }}
8383
restore-keys: |
8484
ccache-${{ matrix.config.name }}-
@@ -88,11 +88,11 @@ jobs:
8888
run: ${{ github.workspace }}/Tool-Solutions/ML-Frameworks/pytorch-aarch64/build.sh
8989
env:
9090
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91-
CCACHE_HOST_DIR: ${{ env.CCACHE_HOST_DIR }}
91+
CCACHE_LOCAL_DIR: ${{ env.CCACHE_LOCAL_DIR }}
9292
CCACHE_MAXSIZE: 2G
9393

9494
- name: Print ccache disk usage
95-
run: du -sh "${{ env.CCACHE_HOST_DIR }}" || true
95+
run: du -sh "${{ env.CCACHE_LOCAL_DIR }}" || true
9696

9797
- name: Report final ccache build stats
9898
run: docker exec "$(cat ${{ env.TORCH_BUILD_CONTAINER_ID_FILE }})" ccache -s || true

ML-Frameworks/pytorch-aarch64/build-torch-ao-wheel.sh

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,35 @@
99

1010
set -eux -o pipefail
1111

12+
docker_exec() {
13+
docker exec "$TORCH_BUILD_CONTAINER" "$@"
14+
}
15+
1216
PYTHON_VERSION="3.12"
1317

1418
# Specify DOCKER_IMAGE_MIRROR if you want to use a mirror of hub.docker.com
1519
IMAGE_NAME="${DOCKER_IMAGE_MIRROR:-}pytorch/manylinux2_28_aarch64-builder:cpu-aarch64-69d4c1f80b5e7da224d4f9c2170ef100e75dfe03"
1620
TORCH_BUILD_CONTAINER_ID_FILE="${PWD}/.torch_ao_build_container_id"
1721

18-
TEST_VENV=aarch64_env_test_torch_ao
22+
# Name of the virtual environment inside the container
23+
TEST_VENV_CONTAINER_DIR=/aarch64_env_test_torch_ao
1924

20-
TORCH_AO_HOST_DIR="${PWD}/ao"
25+
# Local and container dirs for the torchao source code
26+
TORCH_AO_LOCAL_DIR="${PWD}/ao"
27+
TORCH_AO_CONTAINER_DIR=/ao
2128

22-
TORCH_AO_ROOT=/ao
29+
# Output dir for PyTorch wheel and other artifacts
30+
OUTPUT_LOCAL_DIR="${OUTPUT_DIR:-"${PWD}/results"}"
2331

2432
if [ -f "$TORCH_BUILD_CONTAINER_ID_FILE" ]; then
25-
TORCH_BUILD_CONTAINER=$(cat $TORCH_BUILD_CONTAINER_ID_FILE)
33+
TORCH_BUILD_CONTAINER=$(cat "$TORCH_BUILD_CONTAINER_ID_FILE")
2634
echo "Found an existing torch build container id: $TORCH_BUILD_CONTAINER"
2735
else
2836
TORCH_BUILD_CONTAINER=""
2937
echo "Did not find torch build container id in $(readlink -f $TORCH_BUILD_CONTAINER_ID_FILE), we will create one later"
3038
fi
3139

32-
if ! docker container inspect $TORCH_BUILD_CONTAINER >/dev/null 2>&1 ; then
40+
if ! docker container inspect "$TORCH_BUILD_CONTAINER" >/dev/null 2>&1 ; then
3341

3442
TORCH_BUILD_CONTAINER=$(docker run -t -d \
3543
-e BINARY_ENV_FILE=/tmp/env \
@@ -39,36 +47,42 @@ if ! docker container inspect $TORCH_BUILD_CONTAINER >/dev/null 2>&1 ; then
3947
-e GITHUB_ACTIONS=0 \
4048
-e GPU_ARCH_TYPE=cpu-aarch64 \
4149
-e PACKAGE_TYPE=manywheel \
42-
-e TORCH_AO_ROOT="${TORCH_AO_ROOT}" \
50+
-e TORCH_AO_ROOT="${TORCH_AO_CONTAINER_DIR}" \
4351
-e SKIP_ALL_TESTS=1 \
44-
-e TEST_VENV="${TEST_VENV}" \
45-
-v "${TORCH_AO_HOST_DIR}:${TORCH_AO_ROOT}" \
52+
-e TEST_VENV="${TEST_VENV_CONTAINER_DIR}" \
53+
-v "${TORCH_AO_LOCAL_DIR}:${TORCH_AO_CONTAINER_DIR}" \
4654
-w / \
4755
"${IMAGE_NAME}")
4856

4957
# The Docker image comes with a copy of ACL, but we want to build against whichever
5058
# version is compatible with the pip-installed torch (which ships its own copy of ACL),
5159
# so we remove the existing copy here
52-
docker exec -t $TORCH_BUILD_CONTAINER bash -c "cd / && rm -rf acl/"
60+
docker_exec rm -rf /acl
5361

54-
docker exec -t $TORCH_BUILD_CONTAINER bash -c "python${PYTHON_VERSION} -m venv $TEST_VENV"
55-
docker exec -t $TORCH_BUILD_CONTAINER bash -c "source $TEST_VENV/bin/activate && pip install typing_extensions torch wheel numpy --no-deps"
62+
docker_exec python${PYTHON_VERSION} -m venv ${TEST_VENV_CONTAINER_DIR}
63+
docker_exec bash -c "source ${TEST_VENV_CONTAINER_DIR}/bin/activate && pip install typing_extensions torch wheel numpy --no-deps"
5664

5765
echo "Storing torch build container id in $TORCH_BUILD_CONTAINER_ID_FILE for reuse: $TORCH_BUILD_CONTAINER"
58-
echo $TORCH_BUILD_CONTAINER > "$TORCH_BUILD_CONTAINER_ID_FILE"
66+
echo "$TORCH_BUILD_CONTAINER" > "$TORCH_BUILD_CONTAINER_ID_FILE"
5967
else
60-
docker restart $TORCH_BUILD_CONTAINER
68+
docker restart "$TORCH_BUILD_CONTAINER"
6169
fi
6270

6371
# Clean up any old builds
64-
docker exec -t $TORCH_BUILD_CONTAINER bash -c "rm -rf ${TORCH_AO_ROOT}/build ${TORCH_AO_ROOT}/dist"
72+
docker_exec rm -rf ${TORCH_AO_CONTAINER_DIR}/build ${TORCH_AO_CONTAINER_DIR}/dist
6573

6674
# Build
67-
docker exec -t $TORCH_BUILD_CONTAINER bash -c \
68-
"source ${TEST_VENV}/bin/activate && \
69-
cd ${TORCH_AO_ROOT} && \
70-
python${PYTHON_VERSION} -m pip install setuptools build && \
71-
python${PYTHON_VERSION} -m build --wheel --no-isolation"
75+
docker_exec bash -lc "
76+
source ${TEST_VENV_CONTAINER_DIR}/bin/activate && \
77+
cd ${TORCH_AO_CONTAINER_DIR} && \
78+
python${PYTHON_VERSION} -m pip install setuptools build && \
79+
python${PYTHON_VERSION} -m build --wheel --no-isolation
80+
"
7281

7382
# directories generated by the docker container are owned by root, so transfer ownership to user
74-
docker exec $TORCH_BUILD_CONTAINER chown -R "$(id -u)":"$(id -g)" "${TORCH_AO_ROOT}"
83+
docker_exec chown -R "$(id -u)":"$(id -g)" "${TORCH_AO_CONTAINER_DIR}"
84+
85+
# Place the torchao wheel next to the torch wheel
86+
TORCH_AO_WHEEL_PATH=$(find "${TORCH_AO_LOCAL_DIR}/dist" -name '*.whl' -type f)
87+
mkdir -p "${OUTPUT_LOCAL_DIR}"
88+
cp "${TORCH_AO_WHEEL_PATH}" "${OUTPUT_LOCAL_DIR}/"

ML-Frameworks/pytorch-aarch64/build-wheel.sh

Lines changed: 58 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -17,39 +17,42 @@
1717

1818
set -eux -o pipefail
1919

20+
docker_exec() {
21+
docker exec "$TORCH_BUILD_CONTAINER" "$@"
22+
}
23+
2024
PYTHON_VERSION="3.12"
2125
OPENBLAS_VERSION="v0.3.30"
2226
ACL_VERSION="v52.8.0"
2327

24-
PYTHON_TAG="cp$(echo "$PYTHON_VERSION" | tr -d .)-cp$(echo "$PYTHON_VERSION" | tr -d .)"
25-
PYTHON_BIN="/opt/python/${PYTHON_TAG}/bin"
26-
2728
# Specify DOCKER_IMAGE_MIRROR if you want to use a mirror of hub.docker.com
2829
IMAGE_NAME="${DOCKER_IMAGE_MIRROR:-}pytorch/manylinux2_28_aarch64-builder:cpu-aarch64-69d4c1f80b5e7da224d4f9c2170ef100e75dfe03"
2930
TORCH_BUILD_CONTAINER_ID_FILE="${PWD}/.torch_build_container_id"
3031

31-
# Output dir for PyTorch wheel and other artifacts
32-
OUTPUT_DIR=${OUTPUT_DIR:-"${PWD}/results"}
32+
PYTHON_TAG="cp$(echo "$PYTHON_VERSION" | tr -d .)-cp$(echo "$PYTHON_VERSION" | tr -d .)"
33+
PYTHON_CONTAINER_BIN="/opt/python/${PYTHON_TAG}/bin"
34+
35+
# Output dir for PyTorch wheel and other artifacts. Rename with the "_LOCAL_DIR"
36+
# suffix for consistency with other variables
37+
OUTPUT_LOCAL_DIR="${OUTPUT_DIR:-"${PWD}/results"}"
3338

3439
# Where folders sit locally
35-
PYTORCH_HOST_DIR="${PWD}/pytorch"
36-
OPENSSL_HOST_DIR="/opt/openssl"
37-
PYTORCH_FINAL_PACKAGE_HOST_DIR="${OUTPUT_DIR}"
40+
PYTORCH_LOCAL_DIR="${PWD}/pytorch"
41+
PYTORCH_FINAL_PACKAGE_LOCAL_DIR="${OUTPUT_LOCAL_DIR}"
3842

39-
# Where folders sit mounted in the container
40-
PYTORCH_ROOT=/pytorch
41-
UTILS=/utils
42-
COMMON_UTILS=/common_utils
43-
PYTORCH_FINAL_PACKAGE_DIR=/artifacts
43+
# Where folders sit in the container
44+
PYTORCH_CONTAINER_DIR=/pytorch
45+
PYTORCH_FINAL_PACKAGE_CONTAINER_DIR=/artifacts
46+
OPENSSL_CONTAINER_DIR=/opt/openssl
4447

4548
# Enable ccache support by default.
4649
# NOTE: The default behaviour is to have a project-specific cache directory that we cache
4750
# build artefacts inside and can be easily wiped. These build artefacts are specific to the
4851
# manylinux builder container (and thus compilers) that we use to build the torch wheel. As
4952
# such, you may not want to populate the global ccache cache with them. However, if you wish
50-
# to do so, simply set CCACHE_HOST_DIR to that directory.
51-
CCACHE_HOST_DIR=${CCACHE_HOST_DIR:-"${PWD}/.ccache"}
52-
LOCAL_CCACHE_DIR=/.ccache
53+
# to do so, simply set CCACHE_LOCAL_DIR to that directory.
54+
CCACHE_LOCAL_DIR="${CCACHE_LOCAL_DIR:-"${PWD}/.ccache"}"
55+
CCACHE_CONTAINER_DIR=/.ccache
5356
CCACHE_MAXSIZE=${CCACHE_MAXSIZE:-}
5457

5558
# If the user wants to use ccache for build caching
@@ -58,10 +61,10 @@ if [[ "$*" == *--disable-ccache* ]]; then
5861
ccache_args+=(-e USE_CCACHE=0)
5962
else
6063
ccache_args+=(-e USE_CCACHE=1)
61-
mkdir -p "${CCACHE_HOST_DIR}"
64+
mkdir -p "${CCACHE_LOCAL_DIR}"
6265
ccache_args+=(
63-
-e CCACHE_DIR="${LOCAL_CCACHE_DIR}"
64-
-v "${CCACHE_HOST_DIR}:${LOCAL_CCACHE_DIR}"
66+
-e CCACHE_DIR="${CCACHE_CONTAINER_DIR}"
67+
-v "${CCACHE_LOCAL_DIR}:${CCACHE_CONTAINER_DIR}"
6568
)
6669
fi
6770

@@ -73,14 +76,14 @@ GPU_ARCH_TYPE=cpu-aarch64
7376
MAX_JOBS=${MAX_JOBS:-$(nproc --ignore=2)}
7477

7578
if [ -f "$TORCH_BUILD_CONTAINER_ID_FILE" ]; then
76-
TORCH_BUILD_CONTAINER=$(cat $TORCH_BUILD_CONTAINER_ID_FILE)
79+
TORCH_BUILD_CONTAINER=$(cat "$TORCH_BUILD_CONTAINER_ID_FILE")
7780
echo "Found an existing torch build container id: $TORCH_BUILD_CONTAINER"
7881
else
7982
TORCH_BUILD_CONTAINER=""
8083
echo "Did not find torch build container id in $(readlink -f $TORCH_BUILD_CONTAINER_ID_FILE), we will create one later"
8184
fi
8285

83-
if ! docker container inspect $TORCH_BUILD_CONTAINER >/dev/null 2>&1 ; then
86+
if ! docker container inspect "$TORCH_BUILD_CONTAINER" >/dev/null 2>&1 ; then
8487
# Based on environment used in pytorch/.github/workflows/_binary-build-linux.yml
8588
# and pytorch/.github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
8689
TORCH_BUILD_CONTAINER=$(docker run -t -d \
@@ -94,79 +97,80 @@ if ! docker container inspect $TORCH_BUILD_CONTAINER >/dev/null 2>&1 ; then
9497
-e GITHUB_ACTIONS=0 \
9598
-e GPU_ARCH_TYPE=${GPU_ARCH_TYPE} \
9699
-e PACKAGE_TYPE=manywheel \
97-
-e PYTORCH_FINAL_PACKAGE_DIR="${PYTORCH_FINAL_PACKAGE_DIR}" \
98-
-e PYTORCH_ROOT="${PYTORCH_ROOT}" \
100+
-e PYTORCH_FINAL_PACKAGE_DIR="${PYTORCH_FINAL_PACKAGE_CONTAINER_DIR}" \
101+
-e PYTORCH_ROOT="${PYTORCH_CONTAINER_DIR}" \
99102
-e SKIP_ALL_TESTS=1 \
100-
-e OPENSSL_ROOT_DIR="${OPENSSL_HOST_DIR}" \
101-
-e CMAKE_INCLUDE_PATH="${OPENSSL_HOST_DIR}/include" \
103+
-e OPENSSL_ROOT_DIR="${OPENSSL_CONTAINER_DIR}" \
104+
-e CMAKE_INCLUDE_PATH="${OPENSSL_CONTAINER_DIR}/include" \
102105
"${ccache_args[@]}" \
103-
-v "${PYTORCH_HOST_DIR}:${PYTORCH_ROOT}" \
104-
-v "${PYTORCH_FINAL_PACKAGE_HOST_DIR}:${PYTORCH_FINAL_PACKAGE_DIR}" \
105-
-v "${PWD}/utils:${UTILS}" \
106-
-v "${PWD}/../utils:${COMMON_UTILS}" \
106+
-v "${PYTORCH_LOCAL_DIR}:${PYTORCH_CONTAINER_DIR}" \
107+
-v "${PYTORCH_FINAL_PACKAGE_LOCAL_DIR}:${PYTORCH_FINAL_PACKAGE_CONTAINER_DIR}" \
107108
-w / \
108109
"${IMAGE_NAME}")
109110

110111
# Provide ccache support
111112
if [[ "$*" != *--disable-ccache* ]]; then
112-
docker exec "$TORCH_BUILD_CONTAINER" yum install -y ccache || true
113+
docker_exec yum install -y ccache || true
113114
if [ -n "${CCACHE_MAXSIZE}" ]; then
114-
docker exec "$TORCH_BUILD_CONTAINER" ccache --max-size="$CCACHE_MAXSIZE" || true
115+
docker_exec ccache --max-size="$CCACHE_MAXSIZE" || true
115116
fi
116-
docker exec "$TORCH_BUILD_CONTAINER" ccache -z || true
117-
docker exec "$TORCH_BUILD_CONTAINER" ccache -o compression=true || true
118-
docker exec "$TORCH_BUILD_CONTAINER" ccache -o compression_level=6 || true
119-
docker exec "$TORCH_BUILD_CONTAINER" ccache -s || true
117+
docker_exec ccache -z || true
118+
docker_exec ccache -o compression=true || true
119+
docker_exec ccache -o compression_level=6 || true
120+
docker_exec ccache -s || true
120121
fi
121122

122123
# Currently changes in these scripts will not be applied without a clean
123124
# build, which is not ideal for dev work. But we have to balance this with
124125
# extra time/network traffic when rebuilding many times.
125-
docker exec $TORCH_BUILD_CONTAINER bash "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
126+
docker_exec bash "${PYTORCH_CONTAINER_DIR}/.circleci/scripts/binary_populate_env.sh"
126127

127-
# Install scons for ACL build
128-
docker exec $TORCH_BUILD_CONTAINER ${PYTHON_BIN}/python3 -m pip install scons==4.7.0
129-
docker exec $TORCH_BUILD_CONTAINER ln -sf ${PYTHON_BIN}/scons /usr/local/bin
128+
# Install scons for the Compute Library (ACL) build
129+
docker_exec ${PYTHON_CONTAINER_BIN}/python3 -m pip install scons==4.7.0
130+
docker_exec ln -sf "${PYTHON_CONTAINER_BIN}/scons" /usr/local/bin
130131

131-
# The Docker image comes with a pre-built version of ACL, but we want to build our own
132-
# so we remove the provided version here
133-
docker exec "$TORCH_BUILD_CONTAINER" rm -rf /acl
132+
# The Docker image comes with a pre-built version of ACL, but we
133+
# want to build our own so we remove the provided version here
134+
docker_exec rm -rf /acl
134135

135136
# Affected by ACL_VERSION set as an environment variable above
136137
echo "Overriding Arm Compute Library version: ${ACL_VERSION}"
137-
docker exec "$TORCH_BUILD_CONTAINER" "${PYTORCH_ROOT}/.ci/docker/common/install_acl.sh"
138+
docker_exec "${PYTORCH_CONTAINER_DIR}/.ci/docker/common/install_acl.sh"
138139

139140
# Affected by OPENBLAS_VERSION set as an environment variable above
140141
echo "Installing OpenBLAS version: ${OPENBLAS_VERSION}"
141-
docker exec "$TORCH_BUILD_CONTAINER" "${PYTORCH_ROOT}/.ci/docker/common/install_openblas.sh"
142+
docker_exec "${PYTORCH_CONTAINER_DIR}/.ci/docker/common/install_openblas.sh"
142143

143144
echo "Storing torch build container ID in ${TORCH_BUILD_CONTAINER_ID_FILE} for reuse: ${TORCH_BUILD_CONTAINER}"
144-
echo $TORCH_BUILD_CONTAINER > "${TORCH_BUILD_CONTAINER_ID_FILE}"
145+
echo "$TORCH_BUILD_CONTAINER" > "${TORCH_BUILD_CONTAINER_ID_FILE}"
145146
else
146-
docker restart $TORCH_BUILD_CONTAINER
147+
docker restart "$TORCH_BUILD_CONTAINER"
147148
fi
148149

149150
# If there are multiple wheels in the dist directory, an old wheel can be
150151
# erroneously copied to results, so we clear the directory to be sure
151-
docker exec $TORCH_BUILD_CONTAINER rm -rf "${PYTORCH_ROOT}/dist"
152+
docker_exec rm -rf "${PYTORCH_CONTAINER_DIR}/dist"
152153

153154
# We set OVERRIDE_PACKAGE_VERSION to be based on the date of the latest torch
154155
# commit, this allows us to also install the matching torch* packages, set in
155156
# the Dockerfile. This is what PyTorch does in its nightly pipeline, see
156157
# pytorch/.ci/aarch64_linux/aarch64_wheel_ci_build.py for this logic.
157-
build_date=$(cd $PYTORCH_HOST_DIR && git log --pretty=format:%cs -1 | tr -d '-')
158-
version=$(cat $PYTORCH_HOST_DIR/version.txt| tr -d "[:space:]" )
158+
build_date=$(cd "$PYTORCH_LOCAL_DIR" && git log --pretty=format:%cs -1 | tr -d '-')
159+
version=$(cat "$PYTORCH_LOCAL_DIR/version.txt" | tr -d "[:space:]")
159160
OVERRIDE_PACKAGE_VERSION="${version%??}.dev${build_date}${TORCH_RELEASE_ID:+"+$TORCH_RELEASE_ID"}"
160161

161-
docker exec $TORCH_BUILD_CONTAINER bash -lc "
162+
# Build the wheel!
163+
docker_exec bash -lc "
162164
source /tmp/env &&
163165
BUILD_TEST=0 \
164166
DO_SETUP_PY_CLEAN_BEFORE_BUILD=0 \
165167
WIPE_RH_CUDA_AFTER_BUILD=0 \
166168
OVERRIDE_PACKAGE_VERSION=$OVERRIDE_PACKAGE_VERSION \
167-
bash ${PYTORCH_ROOT}/.ci/manywheel/build.sh
169+
bash ${PYTORCH_CONTAINER_DIR}/.ci/manywheel/build.sh
168170
"
169171

170-
# directories generated by the docker container are owned by root, so transfer ownership to user
171-
docker exec "$TORCH_BUILD_CONTAINER" chown -R "$(id -u)":"$(id -g)" \
172-
"${PYTORCH_ROOT}" "${PYTORCH_FINAL_PACKAGE_DIR}" "${LOCAL_CCACHE_DIR}"
172+
# Directories generated by the docker container are owned by root, so transfer ownership to user
173+
docker_exec chown -R "$(id -u)":"$(id -g)" \
174+
"${PYTORCH_CONTAINER_DIR}" \
175+
"${PYTORCH_FINAL_PACKAGE_CONTAINER_DIR}" \
176+
"${CCACHE_CONTAINER_DIR}"

ML-Frameworks/pytorch-aarch64/build.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#!/bin/bash
22

3-
# SPDX-FileCopyrightText: Copyright 2020-2025 Arm Limited and affiliates.
3+
# SPDX-FileCopyrightText: Copyright 2020-2026 Arm Limited and affiliates.
44
#
55
# SPDX-License-Identifier: Apache-2.0
66

77
set -eux -o pipefail
88

99
# exec redirects all output from now on into a file and stdout
1010
build_log=build-$(git rev-parse --short=7 HEAD)-$(date '+%Y-%m-%dT%H-%M-%S').log
11-
exec &> >(tee -a $build_log)
11+
exec &> >(tee -a "$build_log")
1212

1313
# Bail out if sources are already there
1414
if [ -f .torch_build_container_id ] || [ -f .torch_ao_build_container_id ] || \
@@ -70,6 +70,10 @@ if ! [[ $* == *--use-existing-sources* ]]; then
7070
./get-source.sh
7171
fi
7272

73+
# Set the output dir for the wheels
74+
OUTPUT_DIR=${OUTPUT_DIR:-"${PWD}/results"}
75+
export OUTPUT_DIR="${OUTPUT_DIR}"
76+
7377
# We build the wheel with ccache by default; allow disabling it via the --disable-ccache flag
7478
build_wheel_args=()
7579
if [[ "$*" == *--disable-ccache* ]]; then
@@ -80,14 +84,11 @@ fi
8084
[[ $* == *--wheel-only* ]] && exit 0
8185

8286
# Use the second to last match, otherwise grep finds itself
83-
torch_wheel_name=$(grep -o "torch-.*.whl" $build_log | head -n -1 | tail -n 1)
87+
torch_wheel_name=$(grep -o "torch-.*.whl" "$build_log" | head -n -1 | tail -n 1)
8488

8589
./build-torch-ao-wheel.sh
8690

8791
# Use the second to last match, otherwise grep finds itself
88-
torch_ao_wheel_name=$(grep -o "torchao-.*.whl" $build_log | head -n -1 | tail -n 1)
89-
90-
# Place the torchao wheel next to the torch wheel
91-
cp "ao/dist/$torch_ao_wheel_name" "results/$torch_ao_wheel_name"
92+
torch_ao_wheel_name=$(grep -o "torchao-.*.whl" "$build_log" | head -n -1 | tail -n 1)
9293

9394
./dockerize.sh "results/$torch_wheel_name" "results/$torch_ao_wheel_name" --build-only

0 commit comments

Comments
 (0)