-
Notifications
You must be signed in to change notification settings - Fork 697
Arm backend: Add model-converter and other mlsdk package download option #12397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Sebastian-Larsson
merged 2 commits into
pytorch:main
from
YufengShi-dudu:model-converter-script
Jul 14, 2025
+249
−21
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| #!/usr/bin/env bash | ||
| # Copyright 2025 Arm Limited and/or its affiliates. | ||
| # | ||
| # This source code is licensed under the BSD-style license found in the | ||
| # LICENSE file in the root directory of this source tree. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| # TODO | ||
| mlsdk_manifest_url="" | ||
|
|
||
| script_dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) | ||
|
|
||
| source ${script_dir}/utils.sh | ||
|
|
||
| usage() { echo "Usage: $0 [-u <mlsdk-manifest-url>]" 1>&2; exit 1; } | ||
|
|
||
| while getopts ":u:" opt; do | ||
| case "${opt}" in | ||
| u) | ||
| mlsdk_manifest_url=${OPTARG} | ||
| ;; | ||
| *) | ||
| usage | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| function download_ai_mlsdk_manifest() { | ||
| local _dada_dir="$1" | ||
|
|
||
| if [[ -z "${_dada_dir}" ]]; then | ||
| echo "Error: _dada_dir parameter missing?" | ||
| return 1 | ||
| fi | ||
|
|
||
| if [[ -z "${mlsdk_manifest_url}" ]]; then | ||
| echo "Error: mlsdk_manifest_url parameter missing?" | ||
| return 1 | ||
| fi | ||
|
|
||
| if [[ ! -d "${_dada_dir}" ]]; then | ||
| mkdir -p "$_dada_dir" | ||
| pushd "$_dada_dir" || exit 1 | ||
|
|
||
| curl https://storage.googleapis.com/git-repo-downloads/repo > repo | ||
| chmod u+x repo | ||
| ./repo init --no-repo-verify --depth=1 --manifest-url ${mlsdk_manifest_url} -g model-converter,emulation-layer,vgf-library | ||
| ./repo sync | ||
|
|
||
| popd | ||
| fi | ||
| } | ||
|
|
||
| function setup_model_converter() { | ||
| local work_dir="$1" | ||
| local manifest_dir="$2" | ||
| local enable_vgf_lib="$3" | ||
| local enable_emulation_layer="$4" | ||
|
|
||
| if [[ -z "$work_dir" ]]; then | ||
| echo "Error: work_dir parameter is required." | ||
| return 1 | ||
| fi | ||
|
|
||
| if [[ -z "$manifest_dir" ]]; then | ||
| echo "Error: manifest_dir parameter is required." | ||
| return 1 | ||
| fi | ||
|
|
||
| mkdir -p "$work_dir" | ||
| pushd "$work_dir" || exit 1 | ||
|
|
||
| download_ai_mlsdk_manifest ${manifest_dir} | ||
|
|
||
| pushd "$manifest_dir" | ||
|
|
||
| # model-converter | ||
| # TODO: Remove macOS patch after mlsdk fully supports macOS | ||
| if [[ "$(uname)" == "Darwin" ]]; then | ||
| sed -i '' '/^ *print(f"Unsupported host platform/ i\ | ||
| if system == "Darwin":\ | ||
| # Use default Apple toolchain (Clang) on macOS\ | ||
| return True\ | ||
| \ | ||
| ' sw/model-converter/scripts/build.py | ||
| fi | ||
| python sw/model-converter/scripts/build.py -j$(nproc) | ||
|
|
||
| # libvgf | ||
| if [[ "${enable_vgf_lib}" -eq 1 ]]; then | ||
| # TODO: Remove macOS patch after mlsdk fully supports macOS | ||
| if [[ "$(uname)" == "Darwin" ]]; then | ||
| sed -i '' '/^ *print(f"ERROR: Unsupported host platform/ i\ | ||
| if system == "Darwin":\ | ||
| # Use default Apple toolchain (Clang) on macOS\ | ||
| return True\ | ||
| \ | ||
| ' sw/vgf-lib/scripts/build.py | ||
| fi | ||
| python sw/vgf-lib/scripts/build.py -j$(nproc) | ||
| fi | ||
|
|
||
| # emu layer | ||
| if [[ "${enable_emulation_layer}" -eq 1 ]]; then | ||
| pushd sw/emulation-layer | ||
| cmake -B build \ | ||
| -DGLSLANG_PATH=../../dependencies/glslang \ | ||
| -DSPIRV_CROSS_PATH=../../dependencies/SPIRV-Cross \ | ||
| -DSPIRV_HEADERS_PATH=../../dependencies/SPIRV-Headers \ | ||
| -DSPIRV_TOOLS_PATH=../../dependencies/SPIRV-Tools \ | ||
| -DVULKAN_HEADERS_PATH=../../dependencies/Vulkan-Headers | ||
| cmake --build build | ||
| popd | ||
| fi | ||
|
|
||
| popd | ||
| } | ||
|
|
||
| #setup_model_converter() $1 | ||
| # `"$manifest_dir"' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.