Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
56e735a
initial commit
NinaARM May 3, 2025
82b31e6
Updates in build LiteRT pages and in prerequisites
NinaARM May 6, 2025
2664a92
initial commit
May 7, 2025
330cba0
Initial new migrate-ease LP
odincodeshen May 7, 2025
4f1492b
Merge branch 'ArmDeveloperEcosystem:main' into main
odincodeshen May 7, 2025
d1596e8
Clear up files
odincodeshen May 7, 2025
b495fdc
Clear up contributor
odincodeshen May 7, 2025
98068b9
Initial new migrate-ease LP
odincodeshen May 7, 2025
3143829
To prevent readers from directly copying non-useful JSON example output.
odincodeshen May 7, 2025
1f86b61
Merge branch 'ArmDeveloperEcosystem:main' into main
odincodeshen May 7, 2025
c4aa62a
Add migrate-ease repo, detect issue type and description.
odincodeshen May 9, 2025
f0d7ef7
Merge branch 'ArmDeveloperEcosystem:main' into main
odincodeshen May 9, 2025
2ec48d1
Rename files to remove capital letters from filenames.
odincodeshen May 9, 2025
2634d2b
Merge branch 'ArmDeveloperEcosystem:main' into main
odincodeshen May 12, 2025
3fa4938
updates
NinaARM May 12, 2025
e4cb6ba
Add WebUI
odincodeshen May 12, 2025
8be7bc7
Update Vision LLM with MNN LP
annietllnd May 13, 2025
5e501c6
updates:
NinaARM May 13, 2025
0e9b687
remove bazel prerequisite, other small updates
NinaARM May 13, 2025
8b75f40
Merge pull request #1952 from annietllnd/fix
pareenaverma May 13, 2025
2a776e2
updates
NinaARM May 13, 2025
75e5878
change to available 1.0 model for now
NinaARM May 13, 2025
c7d58e1
near-final version
May 13, 2025
922d19a
removed unused images
May 13, 2025
e65d992
updates for model conversion
NinaARM May 13, 2025
0084d97
updates
NinaARM May 13, 2025
238930f
final review before PR
May 13, 2025
17bcc9b
extra updates to convert models and create simple program
NinaARM May 13, 2025
a599af3
New Python script to count Learning Path content
jasonrandrews May 13, 2025
686b7b4
Merge pull request #1945 from odincodeshen/main
pareenaverma May 13, 2025
cc7f682
Merge pull request #1954 from jasonrandrews/review
jasonrandrews May 13, 2025
e06eaca
Update _index.md
pareenaverma May 13, 2025
d0e4078
Merge pull request #1955 from pareenaverma/content_review
pareenaverma May 13, 2025
01919b7
Merge pull request #1953 from kieranhejmadi01/false-sharing-spe
jasonrandrews May 14, 2025
f2a3222
Begin tech review
jasonrandrews May 14, 2025
eccf114
Merge pull request #1956 from jasonrandrews/review
jasonrandrews May 14, 2025
ebcaee0
Merge pull request #28 from NinaARM/audio-generation
annietllnd May 14, 2025
f6299b6
Partial tech review of LiteRT LP
annietllnd May 14, 2025
cb0bbba
Remove mac support
annietllnd May 14, 2025
91cb70b
updates:
NinaARM May 14, 2025
24e7cb5
align updates
NinaARM May 14, 2025
32c0947
updates for bazel build
NinaARM May 14, 2025
06de27f
updated formatting of bazel string
NinaARM May 14, 2025
649b31d
updates to align branches
NinaARM May 14, 2025
9991589
Update _index.md
madeline-underwood May 14, 2025
32fc74e
updates to commands:
NinaARM May 14, 2025
0f88441
Merge remote-tracking branch 'nina/audio-generation' into review
annietllnd May 14, 2025
788b427
Update 1-prerequisites.md
madeline-underwood May 14, 2025
06cc58f
Align with Nina's branch
annietllnd May 14, 2025
9480006
updates
NinaARM May 14, 2025
6a7936d
Update 2-testing-model.md
madeline-underwood May 14, 2025
76dbb9c
updates for adb push
NinaARM May 14, 2025
65bff79
Merge branch 'review' into patch-22
annietllnd May 14, 2025
d011515
Merge pull request #31 from madeline-underwood/patch-22
annietllnd May 14, 2025
38054a8
Merge branch 'review' into patch-28
annietllnd May 14, 2025
2f4e032
Merge pull request #32 from madeline-underwood/patch-28
annietllnd May 14, 2025
82c5064
Update 3-converting-model.md
madeline-underwood May 14, 2025
b62b24a
Merge pull request #33 from madeline-underwood/patch-29
annietllnd May 14, 2025
c8762d4
Fix authors
annietllnd May 14, 2025
202cd04
Merge pull request #35 from madeline-underwood/patch-35
annietllnd May 14, 2025
d2be367
Align with Nina's branch
annietllnd May 14, 2025
f05afb4
Merge remote-tracking branch 'nina/audio-generation' into review
annietllnd May 14, 2025
338571b
Rename LP
annietllnd May 14, 2025
4c90509
updates to page 2,3,5
NinaARM May 14, 2025
0a18ffb
Add editorial review for 5-creating-simple-program.md
annietllnd May 14, 2025
6027afe
Merge remote-tracking branch 'nina/audio-generation' into review
annietllnd May 14, 2025
56802b3
Update 3-converting-model.md
annietllnd May 14, 2025
9261337
Merge branch 'main' into review
annietllnd May 14, 2025
8cacaac
Update 3-converting-model.md
annietllnd May 14, 2025
adaf33b
Merge pull request #1957 from annietllnd/review
pareenaverma May 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion assets/contributors.csv
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,5 @@ Yiyang Fan,Arm,,,,
Julien Jayat,Arm,,,,
Geremy Cohen,Arm,geremyCohen,geremyinanutshell,,
Barbara Corriero,Arm,,,,

Nina Drozd,Arm,,ninadrozd,,
Jun He,Arm,JunHe77,jun-he-91969822,,
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
---
title: Set up your development environment
weight: 2

### FIXED, DO NOT MODIFY
layout: learningpathall
---

## Identify software requirements

In this Learning Path, you'll learn how to convert the Stable Audio Open Small model to the LiteRT (.tflite) format, then build a simple test program to generate audio on a mobile device.

Your first task is to prepare a development environment with the required software:

- Android NDK: version r25b or newer.
- Python: version 3.10 or newer (tested with 3.10).
- CMake: version 3.16.0 or newer (tested with 3.28.1).
- [Arm GNU Toolchain](/install-guides/gcc/arm-gnu).

### Create workspace directory

Create a separate directory for all dependencies and repositories that this Learning Path uses.

Export the `WORKSPACE` variable to point to this directory, which you will use in the following steps:

```bash
mkdir my-workspace
export WORKSPACE=$PWD/my-workspace
```

### Install Python 3.10

Download and install [Python version 3.10](https://www.python.org/downloads/release/python-3100/) using the following commands:

{{< tabpane code=true >}}
{{< tab header="Linux">}}
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.10 python3.10-venv python3.10-pip
{{< /tab >}}
{{< tab header="MacOS">}}
brew install [email protected]
brew link [email protected] --force
{{< /tab >}}
{{< /tabpane >}}

You can verify the installation and check the version with:

```console
python3.10 --version
```

### Install CMake

CMake is an open-source tool that automates the build process for software projects, helping to generate platform-specific build configurations.

{{< tabpane code=true >}}
{{< tab header="Linux">}}
sudo apt update
sudo apt install cmake
{{< /tab >}}
{{< tab header="MacOS">}}
brew install cmake
{{< /tab >}}
{{< /tabpane >}}

You can verify the installation and check the version with:

```console
cmake --version
```

See the [CMake install guide](/install-guides/cmake/) for troubleshooting instructions.

### Install Bazel

Bazel is an open-source build tool which we will use to build LiteRT libraries.

{{< tabpane code=true >}}
{{< tab header="Linux">}}
cd $WORKSPACE
wget https://github.com/bazelbuild/bazel/releases/download/7.4.1/bazel-7.4.1-installer-linux-x86_64.sh
sudo bash bazel-7.4.1-installer-linux-x86_64.sh
{{< /tab >}}
{{< tab header="MacOS">}}
brew install bazel@7
{{< /tab >}}
{{< /tabpane >}}

### Install Android NDK

To run the model on Android, install Android Native Development Kit (Android NDK):

{{< tabpane code=true >}}
{{< tab header="Linux">}}
cd $WORKSPACE
wget https://dl.google.com/android/repository/android-ndk-r25b-linux.zip
unzip android-ndk-r25b-linux.zip
{{< /tab >}}
{{< tab header="MacOS">}}
brew install --cask android-studio temurin
{{< /tab >}}
{{< /tabpane >}}

For easier access and execution of Android NDK tools, add these to the `PATH` and set the `ANDROID_NDK` variable:

{{< tabpane code=true >}}
{{< tab header="Linux">}}
export ANDROID_NDK=$WORKSPACE/android-ndk-r25b/
export PATH=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/:$PATH
{{< /tab >}}
{{< tab header="MacOS">}}
export ANDROID_NDK=~/Library/Android/sdk/ndk/27.0.12077973/
export PATH=$PATH:$ANDROID_NDK/toolchains/llvm/prebuilt/darwin-x86_64/bin
export PATH=$PATH:~/Library/Android/sdk/cmdline-tools/latest/bin
{{< /tab >}}
{{< /tabpane >}}

Now that your development environment is ready and all pre-requisites installed, you can test the Audio Stable Open model.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
title: Download and test the model
weight: 3

### FIXED, DO NOT MODIFY
layout: learningpathall
---

## Download the model

Stable Audio Open is an open-source model optimized for generating short audio samples, sound effects, and production elements using text prompts.

[Log in](https://huggingface.co/login) to HuggingFace and navigate to the model landing page:

```bash
https://huggingface.co/stabilityai/stable-audio-open-small
```

You may need to fill out a form with your contact information to use the model:

![Agree to share contact information#center](./contact-information.png)

Download and copy the configuration file `model_config.json` and the model itself, `model.ckpt`, to your workspace directory, and verify they exist by running the command:

```bash
ls $WORKSPACE/model_config.json $WORKSPACE/model.ckpt
```

## Test the model

To test the model, use the Stable Audio demo site, which lets you experiment directly through a web-based interface:

```bash
https://stableaudio.com/
```

Use the UI to enter a prompt. A good prompt can include:

* Music genre and subgenre.
* Musical elements (texture, rhythm and articulation).
* Musical atmosphere (mood and emotion).
* Tempo, using beats per minute (BPM).

The order of prompt parameters matters. For more information, see the [Prompt structure user guide](https://stableaudio.com/user-guide/prompt-structure).

You can explore training and inference code for audio generation models in the [Stable Audio Tools repository](https://github.com/Stability-AI/stable-audio-tools).

Now that you've downloaded and tested the model, continue to the next section to convert the model to LiteRT.

Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
---
title: Convert Open Stable Audio Small model to LiteRT
weight: 4

### FIXED, DO NOT MODIFY
layout: learningpathall
---

## Stable Audio Open Small Model

|Submodule|Description|
|------|------|
|Conditioners| Includes a T5-based text encoder for the input prompt and a numerical duration encoder. These components convert the inputs into embeddings passed to the DiT model. |
|Diffusion Transformer (DiT)| Denoises random noise over multiple steps to produce structured latent audio, guided by conditioner embeddings. |
|AutoEncoder| Compresses audio waveforms into a latent representation for processing by the DiT model, and decompresses the output back into audio. |

The submodules work together to provide the pipeline as shown below:
![Model structure#center](./model.png)

As part of this section, you will covert each of the three submodules into [LiteRT](https://ai.google.dev/edge/litert) format, using two separate conversion routes:
1. Conditioners submodule - ONNX to LiteRT using [onnx2tf](https://github.com/PINTO0309/onnx2tf) tool.
2. DiT and AutoEncoder submodules - PyTorch to LiteRT using Google AI Edge Torch tool.

### Create virtual environment and install dependencies

The Conditioners submodule is made of the T5Encoder model. You will use the ONNX to TFLite conversion for this submodule.

To avoid dependency issues, create a virtual environment. In this guide, we will use `virtualenv`:

```bash
cd $WORKSPACE
python3.10 -m venv env
source env/bin/activate
```

Clone the examples repository:

```bash
cd $WORKSPACE
git clone https://github.com/ARM-software/ML-examples/tree/main/kleidiai-examples/audiogen
cd audio-stale-open-litert
```

We now install the needed python packages for this, including *onnx2tf* and *ai_edge_litert*

```bash
bash install_requirements.sh
```

{{% notice %}}

If you are using GPU on your machine, you may notice the following error:
```text
Traceback (most recent call last):
File "$WORKSPACE/env/lib/python3.10/site-packages/torch/_inductor/runtime/hints.py",
line 46, in <module> from triton.backends.compiler import AttrsDescriptor
ImportError: cannot import name 'AttrsDescriptor' from 'triton.backends.compiler'
($WORKSPACE/env/lib/python3.10/site-packages/triton/backends/compiler.py)
.
ImportError: cannot import name 'AttrsDescriptor' from 'triton.compiler.compiler'
($WORKSPACE/env/lib/python3.10/site-packages/triton/compiler/compiler.py)
```

Install the following dependency and rerun the script:
```bash
pip install triton==3.2.0
bash install_requirements.sh
```

{{% /notice %}}

### Convert Conditioners Submodule

The Conditioners submodule is based on the T5Encoder model. We convert it first to ONNX, then to LiteRT.

For this conversion we include the following steps:
1. Load the Conditioners submodule from the Stable Audio Open model configuration and checkpoint.
2. Export the Conditioners submodule to ONNX via *torch.onnx.export()*.
3. Convert the resulting ONNX file to LiteRT using *onnx2tf*.

You can use the provided script to convert the Conditioners submodule:

```bash
python3 ./scripts/export_conditioners.py --model_config "$WORKSPACE/model_config.json" --ckpt_path "$WORKSPACE/model.ckpt"
```

After successful conversion, you now have a `conditioners.onnx` model in your current directory.

### Convert DiT and AutoEncoder

To convert the DiT and AutoEncoder submodules, use the [Generative API](https://github.com/google-ai-edge/ai-edge-torch/tree/main/ai_edge_torch/generative/) provided by the ai-edge-torch tools. This enables you to export a generative PyTorch model directly to tflite using three main steps:

1. Model re-authoring.
2. Quantization.
3. Conversion.

Convert the DiT and AutoEncoder submodules using the provided python script:
```bash
CUDA_VISIBLE_DEVICES="" python3 ./scripts/export_dit_autoencoder.py --model_config "$WORKSPACE/model_config.json" --ckpt_path "$WORKSPACE/model.ckpt"
```

After successful conversion, you now have `dit_model.tflite` and `autoencoder_model.tflite` models in your current directory and can deactivate the virtual environment:

```bash
deactivate
```

For easier access, we add all needed models to one directory:

```bash
export LITERT_MODELS_PATH=$WORKSPACE/litert-models
mkdir $LITERT_MODELS_PATH
cp conditioners_tflite/conditioners_float32.tflite $LITERT_MODELS_PATH
cp dit_model.tflite $LITERT_MODELS_PATH
cp autoencoder_model.tflite $LITERT_MODELS_PATH
```

With all three submodules converted to LiteRT format, you're ready to build LiteRT and run the model on a mobile device in the next step.









Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
title: Build LiteRT
weight: 5

### FIXED, DO NOT MODIFY
layout: learningpathall
---

## LiteRT

LiteRT (short for Lite Runtime), formerly known as TensorFlow Lite, is Google's high-performance runtime for on-device AI.

## Build LiteRT libraries

Clone the repository and get the latest modules

```console
cd $WORKSPACE
git clone https://github.com/tensorflow/tensorflow.git tensorflow_src
cd tensorflow_src
```

We will use a specific commit of tensorflow for build so you can checkout and set the `TF_SRC_PATH`:
```bash
git checkout 84dd28bbc29d75e6a6d917eb2998e4e8ea90ec56
export TF_SRC_PATH=$(pwd)
```

We can use `bazel` to build LiteRT libraries, first we use configure script to create a custom configuration for this:

You can now create a custom TFLite build for android:

Ensure the `ANDROID_NDK` variable is set to your previously installed Android NDK:
{{< tabpane code=true >}}
{{< tab header="Linux">}}
export ANDROID_NDK=$WORKSPACE/android-ndk-r25b/
export PATH=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/:$PATH
{{< /tab >}}
{{< tab header="MacOS">}}
export TF_CXX_FLAGS="-DTF_MAJOR_VERSION=0 -DTF_MINOR_VERSION=0 -DTF_PATCH_VERSION=0 -DTF_VERSION_SUFFIX=''"
export ANDROID_NDK=~/Library/Android/sdk/ndk/27.0.12077973/
export PATH=$PATH:$ANDROID_NDK/toolchains/llvm/prebuilt/darwin-x86_64/bin
export PATH=$PATH:~/Library/Android/sdk/cmdline-tools/latest/bin
{{< /tab >}}
{{< /tabpane >}}

Set the TensorFlow version

```bash
export TF_CXX_FLAGS="-DTF_MAJOR_VERSION=0 -DTF_MINOR_VERSION=0 -DTF_PATCH_VERSION=0 -DTF_VERSION_SUFFIX=''"
```


Now you can configure TensorFlow. Here you can set the custom build parameters needed as follows:

```bash { output_lines = "2-14" }
python3 ./configure.py
Please specify the location of python. [Default is $WORKSPACE/bin/python3]:
Please input the desired Python library path to use. Default is [$WORKSPACE/lib/python3.10/site-packages]
Do you wish to build TensorFlow with ROCm support? [y/N]: n
Do you wish to build TensorFlow with CUDA support? [y/N]: n
Do you want to use Clang to build TensorFlow? [Y/n]: n
Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: y
Please specify the home path of the Android NDK to use. [Default is /home/user/Android/Sdk/ndk-bundle]: /home/user/Workspace/tools/ndk/android-ndk-r25b
Please specify the (min) Android NDK API level to use. [Available levels: [16, 17, 18, 19, 21, 22, 23, 24, 26, 27, 28, 29, 30, 31, 32, 33]] [Default is 21]: 30
Please specify the home path of the Android SDK to use. [Default is /home/user/Android/Sdk]:
Please specify the Android SDK API level to use. [Available levels: ['31', '33', '34', '35']] [Default is 35]:
Please specify an Android build tools version to use. [Available versions: ['30.0.3', '34.0.0', '35.0.0']] [Default is 35.0.0]:
```

Once the bazel configuration is complete, you can build TFLite as follows:
```console
bazel build -c opt --config android_arm64 //tensorflow/lite:libtensorflowlite.so \
--define tflite_with_xnnpack=true \
--define=xnn_enable_arm_i8mm=true \
--define tflite_with_xnnpack_qs8=true \
--define tflite_with_xnnpack_qu8=true
```

This will produce a `libtensorflowlite.so` shared library for android with XNNPack enabled, which we will use to build the example next.








Loading
Loading