@@ -37,6 +37,18 @@ if [[ -z "${MODE:-}" ]]; then
37
37
exit 1
38
38
fi
39
39
40
+ if [[ " ${MODE} " =~ xnnpack.* ]]; then
41
+ XNNPACK=ON
42
+ else
43
+ XNNPACK=OFF
44
+ fi
45
+
46
+ if [[ " ${MODE} " =~ .* custom.* ]]; then
47
+ CUSTOM=ON
48
+ else
49
+ CUSTOM=OFF
50
+ fi
51
+
40
52
if [[ -z " ${BUCK:- } " ]]; then
41
53
BUCK=buck2
42
54
fi
@@ -51,17 +63,13 @@ which "${PYTHON_EXECUTABLE}"
51
63
cmake_install_executorch_libraries () {
52
64
echo " Installing libexecutorch.a, libextension_module.so, libportable_ops_lib.a"
53
65
rm -rf cmake-out
54
- if [[ " ${MODE} " =~ xnnpack.* ]]; then
55
- XNNPACK=ON
56
- else
57
- XNNPACK=OFF
58
- fi
59
66
retry cmake -DBUCK2=" $BUCK " \
60
67
-DCMAKE_INSTALL_PREFIX=cmake-out \
61
68
-DCMAKE_PREFIX_PATH=$( $PYTHON_EXECUTABLE -c " from distutils.sysconfig import get_python_lib; print(get_python_lib())" ) \
62
69
-DCMAKE_BUILD_TYPE=Debug \
63
70
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
64
71
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
72
+ -DEXECUTORCH_BUILD_CUSTOM=" $CUSTOM " \
65
73
-DEXECUTORCH_BUILD_OPTIMIZED=ON \
66
74
-DEXECUTORCH_BUILD_XNNPACK=" $XNNPACK " \
67
75
-DPYTHON_EXECUTABLE=" $PYTHON_EXECUTABLE " \
@@ -76,9 +84,9 @@ cmake_build_llama_runner() {
76
84
-DCMAKE_INSTALL_PREFIX=cmake-out \
77
85
-DCMAKE_PREFIX_PATH=$( $PYTHON_EXECUTABLE -c " from distutils.sysconfig import get_python_lib; print(get_python_lib())" ) \
78
86
-DCMAKE_BUILD_TYPE=Debug \
79
- -DEXECUTORCH_BUILD_CUSTOM=ON \
87
+ -DEXECUTORCH_BUILD_CUSTOM=" $CUSTOM " \
80
88
-DEXECUTORCH_BUILD_OPTIMIZED=ON \
81
- -DEXECUTORCH_BUILD_XNNPACK=ON \
89
+ -DEXECUTORCH_BUILD_XNNPACK=" $XNNPACK " \
82
90
-DPYTHON_EXECUTABLE=" $PYTHON_EXECUTABLE " \
83
91
-Bcmake-out/${dir} \
84
92
${dir}
@@ -117,11 +125,9 @@ else
117
125
exit 1
118
126
fi
119
127
120
- # For cmake install custom ops before running
121
- if [[ " ${BUILD_TOOL} " == " cmake" ]]; then
122
- echo " Installing executorch libraries"
123
- cmake_install_executorch_libraries
124
- fi
128
+ # Install custom ops before exporting
129
+ echo " Installing executorch libraries"
130
+ cmake_install_executorch_libraries
125
131
126
132
# Export model.
127
133
EXPORTED_MODEL_NAME=" ${EXPORTED_MODEL_NAME} .pte"
0 commit comments