@@ -26,6 +26,7 @@ enable_model_converter=0 # model-converter tool for VGF output
2626enable_vgf_lib=0 # vgf reader - runtime backend dependency
2727enable_emulation_layer=0 # Vulkan layer driver - emulates Vulkan ML extensions
2828enable_vulkan_sdk=0 # Download and export Vulkan SDK required by emulation layer
29+ enable_mlsdk_pip_install=0 # This is a temporary option that will soon be the default
2930
3031# Figure out if setup.sh was called or sourced and save it into "is_script_sourced"
3132(return 0 2> /dev/null) && is_script_sourced=1 || is_script_sourced=0
@@ -51,6 +52,7 @@ OPTION_LIST=(
5152 " --enable-emulation-layer Enable MLSDK Vulkan emulation layer"
5253 " --disable-ethos-u-deps Do not setup what is needed for Ethos-U"
5354 " --enable-mlsdk-deps Setup what is needed for MLSDK"
55+ " --install-mlsdk-deps-with-pip Use MLSDK PyPi package instead of building from source"
5456 " --mlsdk-manifest-url URL to the MLSDK manifest for vulkan."
5557 " --help Display help"
5658)
@@ -140,6 +142,10 @@ function check_options() {
140142 enable_vela=0
141143 shift
142144 ;;
145+ --install-mlsdk-deps-with-pip)
146+ enable_mlsdk_pip_install=1
147+ shift
148+ ;;
143149 --enable-mlsdk-deps)
144150 enable_model_converter=1
145151 enable_vgf_lib=1
@@ -176,12 +182,22 @@ function setup_ethos_u_tools() {
176182 CMAKE_POLICY_VERSION_MINIMUM=3.5 BUILD_PYBIND=1 pip install --no-dependencies -r $et_dir /backends/arm/requirements-arm-ethos-u.txt
177183}
178184
185+ function setup_mlsdk_dependencies() {
186+ log_step " mlsdk" " Installing MLSDK dependencies from pip"
187+ pip install -r $et_dir /backends/arm/requirements-arm-vgf.txt
188+ }
189+
179190function create_setup_path(){
180191 cd " ${root_dir} "
181192
182193 clear_setup_path
183194 log_step " path" " Generating setup path scripts at ${setup_path_script} "
184195
196+ local use_mlsdk_pip=0
197+ if use_mlsdk_pip_package; then
198+ use_mlsdk_pip=1
199+ fi
200+
185201 if [[ " ${enable_fvps} " -eq 1 ]]; then
186202 setup_path_fvp
187203 fi
@@ -194,19 +210,48 @@ function create_setup_path(){
194210 setup_path_vulkan
195211 fi
196212
197- if [[ " ${enable_model_converter} " -eq 1 ]]; then
213+ if [[ " ${enable_model_converter} " -eq 1 && " ${use_mlsdk_pip} " -eq 0 ]]; then
198214 setup_path_model_converter
199215 fi
200216
201- if [[ " ${enable_vgf_lib} " -eq 1 ]]; then
217+ if [[ " ${enable_vgf_lib} " -eq 1 && " ${use_mlsdk_pip} " -eq 0 ]]; then
202218 setup_path_vgf_lib
203219 fi
204220
205221 if [[ " ${enable_emulation_layer} " -eq 1 ]]; then
206- setup_path_emulation_layer
222+ if [[ " ${use_mlsdk_pip} " -eq 0 ]]; then
223+ setup_path_emulation_layer
224+ else
225+ setup_path_emulation_layer_from_pip
226+ fi
227+ fi
228+
229+ log_step " path" " Update PATH by sourcing ${setup_path_script} .{sh|fish}"
230+ }
231+
232+ function use_mlsdk_pip_package() {
233+ os=$( uname -s)
234+ arch=$( uname -m)
235+
236+ if [[ " ${enable_mlsdk_pip_install} " -eq 0 ]]; then
237+ return 1
238+ fi
239+
240+ if [[ " $os " == " Darwin" ]]; then
241+ if [[ " ${enable_mlsdk_pip_install} " -eq 1 ]]; then
242+ log_step " mlsdk" " [error] MLSDK pip install not yet supported on MacOS"
243+ exit 1
244+ fi
245+ fi
246+
247+ if [[ " $arch " == " arm64" || " $arch " == " aarch64" ]]; then
248+ if [[ " ${enable_mlsdk_pip_install} " -eq 1 ]]; then
249+ log_step " mlsdk" " [error] MLSDK pip install not yet supported on aarch64"
250+ exit 1
251+ fi
207252 fi
208253
209- log_step " path " " Update PATH by sourcing ${setup_path_script} .{sh|fish} "
254+ return 0
210255}
211256
212257
@@ -224,6 +269,7 @@ if [[ $is_script_sourced -eq 0 ]]; then
224269 source $et_dir /backends/arm/scripts/fvp_utils.sh
225270 source $et_dir /backends/arm/scripts/toolchain_utils.sh
226271 source $et_dir /backends/arm/scripts/vulkan_utils.sh
272+ source $et_dir /backends/arm/scripts/mlsdk_utils.sh
227273
228274 log_step " main" " Checking platform and OS"
229275 check_platform_support
@@ -239,8 +285,12 @@ if [[ $is_script_sourced -eq 0 ]]; then
239285 mlsdk_manifest_dir=" ${root_dir} /${mlsdk_manifest_dir} "
240286 fi
241287
242- log_step " options" " root=${root_dir} , target-toolchain=${target_toolchain:- <default>} , mlsdk-dir=${mlsdk_manifest_dir} "
243- log_step " options" " ethos-u: fvps=${enable_fvps} , toolchain=${enable_baremetal_toolchain} , vela=${enable_vela} | mlsdk: model-converter=${enable_model_converter} , vgf-lib=${enable_vgf_lib} , emu-layer=${enable_emulation_layer} , vulkan-sdk=${enable_vulkan_sdk} "
288+ log_step " options" \
289+ " root=${root_dir} , target-toolchain=${target_toolchain:- <default>} , mlsdk-dir=${mlsdk_manifest_dir} "
290+ log_step " options" \
291+ " ethos-u: fvps=${enable_fvps} , toolchain=${enable_baremetal_toolchain} , vela=${enable_vela} | " \
292+ " mlsdk: model-converter=${enable_model_converter} , vgf-lib=${enable_vgf_lib} , " \
293+ " emu-layer=${enable_emulation_layer} , vulkan-sdk=${enable_vulkan_sdk} "
244294
245295 # Setup toolchain
246296 if [[ " ${enable_baremetal_toolchain} " -eq 1 ]]; then
@@ -267,13 +317,18 @@ if [[ $is_script_sourced -eq 0 ]]; then
267317 if [[ " ${enable_model_converter} " -eq 1 || \
268318 " ${enable_vgf_lib} " -eq 1 || \
269319 " ${enable_emulation_layer} " -eq 1 ]]; then
270- log_step " mlsdk" " Configuring MLSDK components (model-converter=${enable_model_converter} , vgf-lib=${enable_vgf_lib} , emu-layer=${enable_emulation_layer} )"
271- source $et_dir /backends/arm/scripts/mlsdk_utils.sh
272- setup_mlsdk " ${root_dir} " \
273- " ${mlsdk_manifest_dir} " \
274- " ${enable_model_converter} " \
275- " ${enable_vgf_lib} " \
276- " ${enable_emulation_layer} "
320+ log_step " mlsdk" " Configuring MLSDK components (model-converter=${enable_model_converter} , " \
321+ " vgf-lib=${enable_vgf_lib} , emu-layer=${enable_emulation_layer} )"
322+ if use_mlsdk_pip_package; then
323+ setup_mlsdk_dependencies
324+ else
325+ log_step " mlsdk" " Installing MLSDK dependencies from source"
326+ setup_mlsdk ${root_dir} \
327+ ${mlsdk_manifest_dir} \
328+ ${enable_model_converter} \
329+ ${enable_vgf_lib} \
330+ ${enable_emulation_layer}
331+ fi
277332 fi
278333
279334 # Create the setup_path.sh used to create the PATH variable for shell
0 commit comments