OE Development Kit Samples Introduction

The algorithmic toolchain covers the key steps of model training (floating-point and quantization training, optional), conversion, performance/accuracy validation, deployment and inference. To facilitate your quick experience and learning, rich and comprehensive samples are provided in the OE Development Kit. To facilitate your understanding and use of these samples, this article will provide a detailed introduction to these samples.

First of all, after you obtain the OE development package, the directory structure of the unzipped samples package is shown below:

samples # Samples ├── ai_toolchain | ├── horizon_model_convert_sample # Floating-point model to fixed-point model conversion sample | ├── horizon_model_train_sample # Floating-point model training framework sample | └── model_zoo # Model library to hold source and runtime models for toolchain sample model compilation ├── model_zoo -> ai_toolchain/model_zoo └── ucp_tutorial # Unify Compute Platform UCP sample package, providing the necessary dependencies for UCP and related samples

The samples directory provides model training sample, floating-point to fixed-point model sample, and UCP related sample in the Unify Compute Platform. Below is a distribution of general processes and samples used at each stage of the toolchain:

oe_package_sample

Model Conversion Sample (horizon_model_convert_sample)

The toolchain provides model conversion samples in the samples/ai_toolchain/horizon_model_convert_sample folder, and the sample package directory structure is shown below:

├── 01_common # Calibration data, data loading, preprocessing code ├── 03_classification # Classification model conversion sample ├── 04_detection # Detection model conversion Sample ├── 07_segmentation # Segmentation model conversion sample

The OE package not only provides PTQ model conversion samples, but additionally contains one-click run scripts for model checking, calibration data preprocessing, conversion compilation, and inference.

Take 03_resnet50 in the horizon_model_convert_sample/03_classification directory as an example of the relevant script:

├── 00_init.sh # Get the calibration dataset and original model script corresponding to the sample ├── 01_check.sh # Model checking script ├── 02_preprocess.sh # Calibration data preprocessing script ├── 03_build.sh # Model quantization compilation script ├── 04_inference.sh # Single image inference script ├── 05_evaluate.sh # Accuracy evaluation script ├── resnet50_config.yaml # Model compilation yaml configuration file ├── postprocess.py # Model post-processing code ├── preprocess.py # Data preprocessing code └── README.cn.md

For a tutorial on how to use the PTQ model conversion sample, please refer to PTQ Model Conversion Samples section.

Unify Compute Platform Sample (ucp_tutorial)

The toolchain provides sample source code and running scripts for the Unify Compute Platform UCP in the samples/ai_toolchain/ucp_tutorial directory, and the sample package structure is shown below:

ucp_tutorial ├── deps_aarch64 # AArch64 Linux public dependency directory ├── deps_qnx # AArch64 QNX public dependency directory ├── deps_x86 # X86 simulation public dependency directory ├── dnn # DNN samples | ├── ai_benchmark # AI Benchmark sample | └── basic_samples # Model inference basic samples └── tools # Tools
  • deps_aarch64: AArch64 public dependency directory, containing UCP dependency library and header file, etc.

  • deps_x86: X86 simulation public dependency directory.

  • dnn: DNN samples, containing as below:

    • ai_benchmark provides performance and accuracy evaluation samples of common models for embedded application development. For detailed introduction and usage tutorial, please refer to the introduction in the section AI Benchmark User Guide.

    • basic_samples provides model inference related to the use of shallow and deep samples, designed to help you familiarize and learn the model inference related to the interface and a variety of advanced features, detailed introduction and use of the tutorial, please refer to the introduction in the section Basic Sample User Guide.

  • tools: The Unify Compute Platform UCP provides tools.