# AidLite SDK Development Documents
## CONTENTS
- [Introduction](#introduction)
- [OS Environmental Description](#os-environmental-description)
- [Installation](#installation)
- [Tutorial](#tutorial)
- [API Documents](#api-documents)
## Introduction
**AidLite SDK** (also called **AidSDK**) is the AI inference SDK encapsulated by Aplux. It is aim to use a unified API to load and inference AI model for various mainstream AI frameworks, and to be able to schedule various computing units of the hardware (CPU, GPU, NPU). AidLux SDK is part of the AI tool chain in the AIoT field launched by Aplux Company.
The Aplux AI tool chain covers the entire inference part, as shown in the figure below:
Using Aplux AI tool chain can greatly reduce the development cycle in deploying AI models on edge devices.
AidLite works with AIMO (a model conversion platform), can help developers quickly migrate and deploy existing models to edge devices.
- AIMO online access link: [AI Model Optimization Platform](https://aidlux.com/product/aimo)
**AidLite SDK features are shown in the figure**
## OS Environmental Description
AidLite SDK support Android OS, Linux OS and AidLux OS.
**AI runtime support**
||Qualcomm SNPE|Qualcomm QNN|TFLite|RKNN|
|:----:|:----:|:----:|:----:|:----:|
|AidLux OS|✅|✅|✅|✅|
|Linux OS|✅|✅|✅|✅|
|Android OS|✅|🚧|🚧|⛔|
✅: Supported
🚧: Supported in the next version
⛔: To be supported
**AI Box support**
||Qualcomm SNPE1.61|Qualcomm SNPE2.1x|Qualcomm QNN|RKNN|
|:----:|:----:|:----:|:----:|:----:|
|QCS6490|✅|✅|✅|❌|
|QCS8250|✅|❌|❌|❌|
|QCS8550|❌|✅|✅|❌|
|RK3588|❌|❌|❌|✅|
✅: Supported
❌: Unsupported
## Installation
### Installation for AidLux
1. Install AidLite in APP store
> the password is `aidlux`
2. Install AidLite in terminal
```bash
# password is aidlux
# aidlite c++ sdk
sudo aid-pkg -i aidlite-sdk
# aidlite python sdk
python3 -m pip install pyaidlite -i https://mirrors.aidlux.com --trusted-host mirrors.aidlux.com
```
### Installation for Linux
The AidLite SDK is pre-install in AI Box Linux OS.
The update way show blow:
```bash
# password is aidlux
# aidlite c++ sdk
sudo aid-pkg -i aidlite-sdk
# aidlite python sdk
python3 -m pip install pyaidlite -i https://mirrors.aidlux.com --trusted-host mirrors.aidlux.com
```
### Installation for Android
1. Ensure compileSdk=30, minSdk=21, targetSdk=28 in the project build.gradle file

2. Import SDK: Create a new libs folder under the main application app under the project view of android studio, and import AidliteSDK-release.aar and snpe-release.aar into libs

3. Add dependencies: Add dependencies under the dependencies of build.gradle in the main application app directory
```java
implementation fileTree(include: ['*.jar', "*.aar"], dir: 'libs')
implementation 'com.github.tiann:FreeReflection:3.1.0'
implementation 'com.elvishew:xlog:1.10.1'
implementation "com.blankj:utilcodex:1.30.6"
implementation 'net.java.dev.jna:jna:5.10.0'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation "com.squareup.okhttp3:logging-interceptor:4.9.0"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9'
```
4. Add permissions and attribute configurations to the app/mainifests/AndroidManifest.xml file under the Android view

```xml
```
5. Add packagingOptions in build.gradle file
```java
packagingOptions {
doNotStrip "*/arm64-v8a/libsnpe_dsp_v68_domains_v3_skel.so"
doNotStrip "*/arm64-v8a/libsnpe_dsp_v66_domains_v2_skel.so"
doNotStrip "*/arm64-v8a/libsnpe_dsp_v65_domains_v2_skel.so"
doNotStrip "*/arm64-v8a/libsnpe_dsp_domains_v2.so"
doNotStrip "*/arm64-v8a/libsnpe_dsp_domains_v3.so"
doNotStrip "*/arm64-v8a/libSNPE.so"
doNotStrip "*/arm64-v8a/libsnpe-android.so"
}
```
## Tutorial
### AidLite SDK Demo in AidLux/Linux
1. After installing AidLite SDK, the demo program will download automatically.
```bash
# Demo files path
/usr/local/share/aidlite/examples
```
2. Use `ls` to show file structure
```bash
ls /usr/local/share/aidlite/examples
|__cpp
|__data
|__python
```
3. Run demo
**C++ demo**
```bash
sudo apt update
sudo apt-get install cmake -y
# Our sample program in [/usr/local/share/aidlite/examples/] directory.
# We recommend that you copy the sample program directory to your own working directory.
mkdir -p /home/aidlux/your_work_dir/ && cp -r /usr/local/share/aidlite/examples/ /home/aidlux/your_work_dir/
cd /home/aidlux/your_work_dir/examples/cpp/
# If you do not want to copy the sample program, then next few steps require Sudo permissions
mkdir -p build && cd build
cmake ..
make
# Run the resulting executable program
./snpe2_yolov5_multi
```
**Python demo**
```bash
sudo cp -r /usr/local/share/aidlite/examples /home/aidlux/examples
cd /home/aidlux/
sudo chown -R aidlux:aidlux ~/examples
cd ~/examples/python
python3 snpe2_yolov5_multi.py
```
### AidLite SDK Demo in Android
AidLite SDK provides a simple and runnable Android project demo, which includes three quantitative models:
- Unet (defect detection)
- ResNet18 (classification)
- YOLOv5s (target detection)
- CPU bind demo
Download Android project and run demo:
- [AidLux SDK Sample(SNPE1.61)](https://aidlux-files.oss-cn-shenzhen.aliyuncs.com/aid-sdk/sample/AidSDKSample(SNPE1.61).zip)
- [AidLux SDK Sample(SNPE2.10)](https://aidlux-files.oss-cn-shenzhen.aliyuncs.com/aid-sdk/sample/AidSDKSample(SNPE2.10).zip)
## API Documents
- [AidLite SDK C++](https://v2.docs.aidlux.com/sdk-api/aidlite-sdk/aidlite-c++)
- [AidLite SDK Python](https://v2.docs.aidlux.com/sdk-api/aidlite-sdk/aidlite-python)
- [AidLite SDK Android](https://v2.docs.aidlux.com/sdk-api/aidlite-sdk/aidlite-android)