Skip to content

Commit

Permalink
Updated to align with PSDK 10.01.00.02
Browse files Browse the repository at this point in the history
  • Loading branch information
junechul committed Nov 30, 2024
1 parent 539f86e commit 9b39876
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 36 deletions.
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,27 @@ BASE_IMAGE=ubuntu:20.04 ./docker_run.sh
BASE_IMAGE=debian:12.5 ./docker_run.sh
```

<!-- ======================================= -->
## Git Tags for the Source Git Repositories

All Git tags and parameters compatible with a specific Processor SDK release are captured in `scripts/config.yaml`. Each script parses the relevant Git tags and parameters from this YAML file. Please note that any instructions for parameter updates provided below are for informational purposes only.

<!-- ======================================= -->
## Build ONNX-RT from Source

All the commends below should be run **in the Docker container**.

### Prepare the source and update the build config

Update `PROTOBUF_VER` in `onnxrt_prepare.sh` by, e.g., checking "`git log`" at `onnxruntime/cmake/external/protobuf`. Currently it is set:
`PROTOBUF_VER=3.20.2`.


You can run the following in the Docker container for downloading source from git repo, applying patches, and downloading pre-built `protobuf`:
```bash
./onnxrt_prepare.sh
```

### Build
Update `PROTOBUF_VER` to match to the setting in `onnxrt_prepare.sh`. The following should be run in the Docker container with QEMU.

The following should be run in the Docker container.

(Optional) To build `protobuf` from source, run the following inside the container.
```bash
Expand All @@ -90,16 +93,16 @@ Update "`--path_to_protoc_exe`" in `onnxrt_build.sh` accordingly. To build ONNX-
```

Outputs:
- Shared lib: `$WORK_DIR/workarea/onnxruntime/build/Linux/Release/libonnxruntime.so.1.14.0+${TIDL_VER}`
- Wheel file: `$WORK_DIR/workarea/onnxruntime/build/Linux/Release/dist/onnxruntime_tidl-1.14.0+${TIDL_VER}-cp310-cp310-linux_aarch64.whl`
- Shared lib: `$WORK_DIR/workarea/onnxruntime/build/Linux/Release/libonnxruntime.so.1.15.0`
- Wheel file: `$WORK_DIR/workarea/onnxruntime/build/Linux/Release/dist/onnxruntime_tidl-1.15.0-cp310-cp310-linux_aarch64.whl`

### Package

```bash
./onnxrt_package.sh
```

Output tarball: `$WORK_DIR/workarea/onnx-1.14.0-ubuntu22.04_aarch64.tar.gz`
Output tarball: `$WORK_DIR/workarea/onnx-1.15.0-ubuntu22.04_aarch64.tar.gz`

<!-- ======================================= -->
## Build TFLite-RT from Source
Expand Down
12 changes: 8 additions & 4 deletions patches/onnxruntime/tool.cmake_ORG
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_PROCESSOR aarch64)
SET(tools /home/a0133185/ti/GIT_C7x_MMA_TIDL/c7x-mma-tidl/ti_dl/release/build_cloud/test/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu)
SET(CMAKE_SYSTEM_VERSION 1)
SET(CMAKE_C_COMPILER ${tools}/bin/aarch64-none-linux-gnu-gcc)
SET(CMAKE_CXX_COMPILER ${tools}/bin/aarch64-none-linux-gnu-g++)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

# Set the gcc and g++ toolchain
SET(sdk_path /home/abhay/ti-firmware-builder-j721s2-evm-10_01_00_01)
SET(CMAKE_C_COMPILER ${sdk_path}/toolchain/sysroots/x86_64-arago-linux/usr/bin/aarch64-oe-linux/aarch64-oe-linux-gcc)
SET(CMAKE_CXX_COMPILER ${sdk_path}/toolchain/sysroots/x86_64-arago-linux/usr/bin/aarch64-oe-linux/aarch64-oe-linux-g++)
SET(CMAKE_SYSROOT ${sdk_path}/targetfs)
include_directories (${sdk_path}/targetfs/usr/lib/python3.12/site-packages/numpy/core/include)
7 changes: 4 additions & 3 deletions scripts/collect_libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ fi

TARGET_DIR=$HOME/ubuntu22-deps

tidl_ver=$(get_yaml_value "onnxruntime" "tidl_ver")
onnx_ver=$(get_yaml_value "onnxruntime" "onnx_ver")
# tidl_ver=$(get_yaml_value "onnxruntime" "tidl_ver")

# rm -rf $TARGET_DIR
mkdir -p $TARGET_DIR

lib_files=(
# ONNX
"$HOME/osrt-build/workarea/onnxruntime/build/Linux/Release/dist/onnxruntime_tidl-1.14.0+${tidl_ver}-cp310-cp310-linux_aarch64.whl"
"$HOME/osrt-build/workarea/onnx-1.14.0+${tidl_ver}-ubuntu22.04_aarch64.tar.gz"
"$HOME/osrt-build/workarea/onnxruntime/build/Linux/Release/dist/onnxruntime_tidl-${onnx_ver}-cp310-cp310-linux_aarch64.whl"
"$HOME/osrt-build/workarea/onnx-${onnx_ver}+${tidl_ver}-ubuntu22.04_aarch64.tar.gz"
# TFLite
"$HOME/osrt-build/workarea/tensorflow/tensorflow/lite/tools/pip_package/gen/tflite_pip/python3/dist/tflite_runtime-2.12.0-cp310-cp310-linux_aarch64.whl"
"$HOME/osrt-build/workarea/tflite-2.12-ubuntu22.04_aarch64.tar.gz"
Expand Down
24 changes: 13 additions & 11 deletions scripts/config.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
# PSDK-Linux for EdgeAI: 10.01.00.01
# PSDK-Linux for EdgeAI: 10.01.00.02

# Below are for osrt-build. References:
# Below are for osrt-libs-build. References:
# https://git.ti.com/cgit/edgeai/meta-edgeai/tree/recipes-tisdk/ti-tidl/ti-tidl.bb?h=scarthgap
# https://git.ti.com/cgit/edgeai/meta-edgeai/tree/recipes-tisdk/ti-tidl/ti-tidl-osrt.bb?h=scarthgap
arm-tidl:
url: "https://git.ti.com/git/processor-sdk-vision/arm-tidl.git"
tag: "REL.PSDK.ANALYTICS.10.01.00.01"
tag: "REL.PSDK.ANALYTICS.10.01.00.02"
branch: "master"
commit: "78a9795ab5a4acb070f7ef91072114fdaf1e968e"
commit: "d165b9ba24c28d23c28bc2f3eed15edc2569ee76"

concerto:
url: "https://git.ti.com/git/processor-sdk/concerto.git"
tag: "REL.PSDK.ANALYTICS.10.01.00.01"
tag: "REL.PSDK.ANALYTICS.10.01.00.02"
branch: "main"
commit: "68d69c7d7623590b7f0311277708699428387709"
commit: "707b11afdbe5d0abb109a42b06828ba70f555bff"

# protobuf_ver_rel is typically the last two release numbers of protobuf_ver.
onnxruntime:
url: "https://github.com/TexasInstruments/onnxruntime.git"
tag: "None"
branch: "tidl-1.14"
commit: "b07b733888500a37064f560f3d61d5c8ab1201c7"
onnx_ver: "1.14.0"
branch: "tidl-1.15"
commit: "f145bec7bee26b9dfa43b3e07645ee1a5f8b8140"
onnx_ver: "1.15.0"
tidl_ver: "10000005"
protobuf_ver: "3.20.2"
protobuf_ver: "3.21.12"
protobuf_ver_rel: "21.12"

tensorflow:
url: "https://github.com/TexasInstruments/tensorflow.git"
Expand All @@ -46,5 +48,5 @@ ti-rpmsg-char:

vision-apps-lib-build:
url: "https://github.com/TexasInstruments-Sandbox/edgeai-vision-apps-lib-build/releases/download"
release: "10.01.00.01"
release: "10.01.00.02"
sdk_ver: "10.1.0"
3 changes: 1 addition & 2 deletions scripts/onnxrt_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ cd $WORK_DIR/workarea

## package into a tarball
onnx_ver=$(get_yaml_value "onnxruntime" "onnx_ver")
tidl_ver=$(get_yaml_value "onnxruntime" "tidl_ver")
pkg_dist=${BASE_IMAGE//:/}
DST_DIR="onnx-${onnx_ver}+${tidl_ver}-${pkg_dist}_aarch64"
LIB_DIR="onnxruntime/build/Linux/Release"
Expand All @@ -23,7 +22,7 @@ rm -rf "$DST_DIR"
mkdir -p "${DST_DIR}/onnxruntime"

# package .so
src_lib_file="${LIB_DIR}/libonnxruntime.so.${onnx_ver}+${tidl_ver}"
src_lib_file="${LIB_DIR}/libonnxruntime.so.${onnx_ver}"
if [ -f "$src_lib_file" ]; then
cp "$src_lib_file" "$DST_DIR"
else
Expand Down
14 changes: 7 additions & 7 deletions scripts/onnxrt_prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ git submodule init
git submodule update --init --recursive

# update tool.cmake
# TODO: eleminate this step. Instead pass env variables.
# TODO: eliminate this step. Instead pass env variables?
mv tool.cmake tool.cmake_ORG
cp ../../patches/onnxruntime/tool.cmake .

# pre-built protobuf
# update protobuf_ver by, e.g., "git log" at <onnxruntime>/cmake/external/protobuf
# install the protobuf
protobuf_ver=$(get_yaml_value "onnxruntime" "protobuf_ver")
zip_file="protoc-${protobuf_ver}-linux-aarch_64.zip"
protobuf_ver_rel=$(get_yaml_value "onnxruntime" "protobuf_ver_rel")
zip_file="protoc-${protobuf_ver_rel}-linux-aarch_64.zip"
cd $WORK_DIR/workarea
curl -O -L "https://github.com/protocolbuffers/protobuf/releases/download/v${protobuf_ver}/${zip_file}"
unzip "$zip_file" -d "onnxruntime/cmake/external/protoc-${protobuf_ver}-linux-aarch_64"
curl -O -L "https://github.com/protocolbuffers/protobuf/releases/download/v${protobuf_ver_rel}/${zip_file}" || { echo "Error: Failed to download $zip_file."; exit 1; }
unzip "$zip_file" -d "onnxruntime/cmake/external/protoc-${protobuf_ver}-linux-aarch_64" || { echo "Error: Failed to unzip $zip_file."; exit 1; }
rm "$zip_file"

# chmod
chmod -R a+w $WORK_DIR/workarea

cd $current_dir

echo "$(basename $0): Completed!"
echo "$(basename $0): Completed!"
4 changes: 2 additions & 2 deletions scripts/tidl_prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ fi
protobuf_ver=$(get_yaml_value "onnxruntime" "protobuf_ver")
REPO_DIR="${WORK_DIR}/workarea/protobuf-${protobuf_ver}"
if [ ! -d "$REPO_DIR" ]; then
tarball="protobuf-cpp-${protobuf_ver}.tar.gz"
wget -q "https://github.com/protocolbuffers/protobuf/releases/download/v${protobuf_ver}/${tarball}"
tarball="v${protobuf_ver}.tar.gz"
wget -q "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v${protobuf_ver}/${tarball}"
tar -xzf "${tarball}"
rm "${tarball}"
else
Expand Down

0 comments on commit 9b39876

Please sign in to comment.