Skip to content

Commit 7689624

Browse files
authored
Update 3-buid-model.md
1 parent f723d48 commit 7689624

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

  • content/learning-paths/mobile-graphics-and-gaming/litert-sme

content/learning-paths/mobile-graphics-and-gaming/litert-sme/3-buid-model.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,14 @@ TransposeConv:
5151
### Create LiteRT models using Keras
5252
To demonstrate SME2 acceleration on Android, you will construct simple single-layer models (e.g., Fully Connected) using Keras and convert them into LiteRT (.tflite) format.
5353
This allows you to benchmark isolated operators and directly observe SME2 improvements.
54-
Use the following script as an example:
54+
55+
Install the tensorflow package dependency for your script:
56+
57+
```bash
58+
sudo pip3 install tensorflow
59+
```
60+
61+
Save the following script as an example in a file named `model.py`:
5562

5663
``` python
5764
import tensorflow as tf
@@ -79,6 +86,12 @@ fc_fp32 = converter.convert()
7986
save_litert_model(fc_fp32, "fc_fp32.tflite")
8087
```
8188

89+
Now run the script:
90+
91+
```bash
92+
python3 model.py
93+
```
94+
8295
The model `fc_fp32.tflite` is created in FP32 format. As mentioned in the previous section, this operator can invoke the KleidiAI SME2 micro-kernel for acceleration.
8396

8497
You can also optimize this Keras model using post-training quantization to create a LiteRT model that suits your requirements.

0 commit comments

Comments
 (0)