xref: /aosp_15_r20/external/pytorch/scripts/README.md (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1*da0073e9SAndroid Build Coastguard WorkerThis directory contains the useful tools.
2*da0073e9SAndroid Build Coastguard Worker
3*da0073e9SAndroid Build Coastguard Worker
4*da0073e9SAndroid Build Coastguard Worker## build_android.sh
5*da0073e9SAndroid Build Coastguard WorkerThis script is to build PyTorch/Caffe2 library for Android. Take the following steps to start the build:
6*da0073e9SAndroid Build Coastguard Worker
7*da0073e9SAndroid Build Coastguard Worker- set ANDROID_NDK to the location of ndk
8*da0073e9SAndroid Build Coastguard Worker
9*da0073e9SAndroid Build Coastguard Worker```bash
10*da0073e9SAndroid Build Coastguard Workerexport ANDROID_NDK=YOUR_NDK_PATH
11*da0073e9SAndroid Build Coastguard Worker```
12*da0073e9SAndroid Build Coastguard Worker
13*da0073e9SAndroid Build Coastguard Worker- run build_android.sh
14*da0073e9SAndroid Build Coastguard Worker```bash
15*da0073e9SAndroid Build Coastguard Worker#in your PyTorch root directory
16*da0073e9SAndroid Build Coastguard Workerbash scripts/build_android.sh
17*da0073e9SAndroid Build Coastguard Worker```
18*da0073e9SAndroid Build Coastguard WorkerIf succeeded, the libraries and headers would be generated to build_android/install directory. You can then copy these files from build_android/install to your Android project for further usage.
19*da0073e9SAndroid Build Coastguard Worker
20*da0073e9SAndroid Build Coastguard WorkerYou can also override the cmake flags via command line, e.g., following command will also compile the executable binary files:
21*da0073e9SAndroid Build Coastguard Worker```bash
22*da0073e9SAndroid Build Coastguard Workerbash scripts/build_android.sh -DBUILD_BINARY=ON
23*da0073e9SAndroid Build Coastguard Worker```
24*da0073e9SAndroid Build Coastguard Worker
25*da0073e9SAndroid Build Coastguard Worker## build_ios.sh
26*da0073e9SAndroid Build Coastguard WorkerThis script is to build PyTorch/Caffe2 library for iOS, and can only be performed on macOS. Take the following steps to start the build:
27*da0073e9SAndroid Build Coastguard Worker
28*da0073e9SAndroid Build Coastguard Worker- Install Xcode from App Store, and configure "Command Line Tools" properly on Xcode.
29*da0073e9SAndroid Build Coastguard Worker- Install the dependencies:
30*da0073e9SAndroid Build Coastguard Worker
31*da0073e9SAndroid Build Coastguard Worker```bash
32*da0073e9SAndroid Build Coastguard Workerbrew install cmake automake libtool
33*da0073e9SAndroid Build Coastguard Worker```
34*da0073e9SAndroid Build Coastguard Worker
35*da0073e9SAndroid Build Coastguard Worker- run build_ios.sh
36*da0073e9SAndroid Build Coastguard Worker```bash
37*da0073e9SAndroid Build Coastguard Worker#in your PyTorch root directory
38*da0073e9SAndroid Build Coastguard Workerbash scripts/build_ios.sh
39*da0073e9SAndroid Build Coastguard Worker```
40*da0073e9SAndroid Build Coastguard WorkerIf succeeded, the libraries and headers would be generated to build_ios/install directory. You can then copy these files  to your Xcode project for further usage.
41