xref: /aosp_15_r20/external/pytorch/.ci/docker/common/install_executorch.sh (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1#!/bin/bash
2
3set -ex
4
5source "$(dirname "${BASH_SOURCE[0]}")/common_utils.sh"
6
7clone_executorch() {
8  EXECUTORCH_PINNED_COMMIT=$(get_pinned_commit executorch)
9
10  # Clone the Executorch
11  git clone https://github.com/pytorch/executorch.git
12
13  # and fetch the target commit
14  pushd executorch
15  git checkout "${EXECUTORCH_PINNED_COMMIT}"
16  git submodule update --init
17  popd
18
19  chown -R jenkins executorch
20}
21
22install_buck2() {
23  pushd executorch/.ci/docker
24
25  BUCK2_VERSION=$(cat ci_commit_pins/buck2.txt)
26  source common/install_buck.sh
27
28  popd
29}
30
31install_conda_dependencies() {
32  pushd executorch/.ci/docker
33  # Install conda dependencies like flatbuffer
34  conda_install --file conda-env-ci.txt
35  popd
36}
37
38install_pip_dependencies() {
39  pushd executorch/.ci/docker
40  # Install PyTorch CPU build beforehand to avoid installing the much bigger CUDA
41  # binaries later, ExecuTorch only needs CPU
42  pip_install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
43  # Install all Python dependencies
44  pip_install -r requirements-ci.txt
45  popd
46}
47
48setup_executorch() {
49  pushd executorch
50  # Setup swiftshader and Vulkan SDK which are required to build the Vulkan delegate
51  as_jenkins bash .ci/scripts/setup-vulkan-linux-deps.sh
52
53  export PYTHON_EXECUTABLE=python
54  export EXECUTORCH_BUILD_PYBIND=ON
55  export CMAKE_ARGS="-DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON"
56
57  as_jenkins .ci/scripts/setup-linux.sh cmake
58  popd
59}
60
61clone_executorch
62install_buck2
63install_conda_dependencies
64install_pip_dependencies
65setup_executorch
66