Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ layer:
- file: ext_init.c
- file: profiler.c
- file: profiler.h
- file: cxx_stubs.cpp

- group: Ethos Interface
files:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ layer:
- file: ext_init.c
- file: profiler.c
- file: profiler.h
- file: cxx_stubs.cpp

- group: Ethos Interface
files:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1030,11 +1030,7 @@
// <3=> 640x480_RGB565
// <4=> 320x240_RGB565
// <5=> 320x320_RGB565
#if !IS_DATACAPTURE
#define RTE_MT9M114_CAMERA_SENSOR_MIPI_IMAGE_CONFIG 2
#else
#define RTE_MT9M114_CAMERA_SENSOR_MIPI_IMAGE_CONFIG 1
#endif
#define RTE_MT9M114_CAMERA_SENSOR_MIPI_IMAGE_CONFIG 3

// <o> select MT9M114 MIPI number of lanes in DPHY
// <i> defines select MT9M114 MIPI number of lanes in DPHY.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ LR_ROM __ROM_BASE NOCOMPRESS __ROM_SIZE { ; load region size_region
/* ExecuTorch large buffers */
* (.bss.input_data_sec)
* (.bss.activation_buf_sram)

* (.bss.pp_buf) ; Used for pre and post processing
/* Everything else */
.ANY (+RW +ZI)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ SECTIONS
*(.bss.lcd_frame_buf) /* LCD frame Buffer. */
*(.bss.camera_frame_buf) /* Camer Frame Buffer */
*(.bss.camera_frame_bayer_to_rgb_buf) /* (Optional) Camera Frame Buffer for Bayer to RGB Conversion. */
*(.bss.pp_buf)
} > SRAM0
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ LR_RAM0 __RAM0_BASE {

; NN Activation Tensor (activation buffer / tensor arena)
*.o (*activation_buf)

*.o (*bss.pp_buf)
.ANY (+RW +ZI)
}
#endif
Expand All @@ -103,7 +103,7 @@ LR_RAM0 __RAM0_BASE {
LR_ROM2 __ROM2_BASE __ROM2_SIZE {
ER_ROM2 +0 __ROM2_SIZE {
; NN Model Binary Representation
*.o (nn_model)
*.o (network_model_sec)

.ANY (+RO +XO)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ SECTIONS
. = ALIGN(32);
*(*ethos_cache_buf) /* Ethos-U Cache Area */
*(*activation_buf) /* NN Activation Tensor (activation buffer / tensor arena) */
*(*bss.pp_buf)
} > RAM1

/* Initialized buffers in fast access RAM */
Expand All @@ -331,7 +332,7 @@ SECTIONS

.rom2 :
{
*(*nn_model) /* NN Model Binary Representation */
*(network_model_sec) /* NN Model Binary Representation */
} > ROM2

.rom3 :
Expand Down
2 changes: 1 addition & 1 deletion RockPaperScissors/AppKit-E8_USB/SDS.cbuild-mlops.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cbuild-mlops:
ini: .cmsis/ensemble_vela.ini
options: --accelerator-config ethos-u85-256 --system-config RTSS_HE_SRAM_MRAM --memory-mode Shared_Sram
model:
clayer: ai_layer/ai_layer.clayer.yml
clayer: algorithm/ML/ai_layer/ai_layer.clayer.yml
name: RPS
hardware:
active: AppKit-E8-U85@HIL
Expand Down
6 changes: 3 additions & 3 deletions RockPaperScissors/AppKit-E8_USB/SDS.csolution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ solution:
variables:
- Board-Layer: $SolutionDir()$/Board/AppKit-E8_M55_HP/Board_HP-U85.clayer.yml
- SDSIO-Layer: $SolutionDir()$/sdsio/usb/sdsio_usb.clayer.yml
- AI-Layer: $SolutionDir()$/ai_layer/ai_layer.clayer.yml
- AI-Layer: $SolutionDir()$/algorithm/ML/ai_layer/ai_layer.clayer.yml
target-set:
- set: J-Link
debugger:
Expand Down Expand Up @@ -62,7 +62,7 @@ solution:
variables:
- Board-Layer: $SolutionDir()$/Board/Corstone-320/Board-U85.clayer.yml
- SDSIO-Layer: $SolutionDir()$/sdsio/fvp/sdsio_fvp.clayer.yml
- AI-Layer: $SolutionDir()$/ai_layer/ai_layer.clayer.yml
- AI-Layer: $SolutionDir()$/algorithm/ML/ai_layer/ai_layer.clayer.yml
target-set:
- set:
images:
Expand Down Expand Up @@ -105,4 +105,4 @@ solution:
target: AppKit-E8-U85@HIL # explicit target-type name (default: first target-type)
simulator:
# simulator target for testing
target: SSE-320-U85 # explicit target-type name (default: last target-type, check if debugger name: Arm-FVP)
target: SSE-320-U85 # explicit target-type name (default: last target-type, check if debugger name: Arm-FVP)
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ project:
define:
- OS_IDLE_THREAD_NAME: \"Idle\"
- OS_TIMER_THREAD_NAME: \"Timer\"
- ET_ARM_BAREMETAL_SCRATCH_TEMP_ALLOCATOR_POOL_SIZE: 0x100000
- ET_ARM_BAREMETAL_METHOD_ALLOCATOR_POOL_SIZE: 0x100000
- C10_USING_CUSTOM_GENERATED_MACROS
- ET_NUM_INFERENCES: 1
Expand All @@ -32,6 +31,17 @@ project:
- USE_PERFORMANCE_MONITOR
- USE_SEGGER_SYSVIEW

setups:
- setup: Scratch pool for non-simulator
not-for-context: +SSE-320-U85
define:
- ET_ARM_BAREMETAL_SCRATCH_TEMP_ALLOCATOR_POOL_SIZE: 0x172000

- setup: Scratch pool for simulator
for-context: +SSE-320-U85
define:
- ET_ARM_BAREMETAL_SCRATCH_TEMP_ALLOCATOR_POOL_SIZE: 0x253000

groups:
- group: Documentation
files:
Expand All @@ -47,11 +57,7 @@ project:
- file: arm_memory_allocator.cc
- file: arm_executor_runner.cc
- file: arm_executor_runner.h
- file: arm_perf_monitor.cpp
- file: arm_perf_monitor.h
- file: sysview_log.c
- file: image_processing_func.c
- file: image_processing_func.h

components:
- component: CMSIS:OS Tick:SysTick
Expand All @@ -67,6 +73,10 @@ project:
type: Board
- layer: $AI-Layer$
type: AI
- layer: ML/ML.clayer.yml
type: Image processing
- layer: ML/cil_layer/cil_layer.clayer.yml
type: Common Inference library

output:
type:
Expand Down
12 changes: 12 additions & 0 deletions RockPaperScissors/AppKit-E8_USB/algorithm/ML/ML.clayer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
layer:
type: ML
description: >
ML layer utilities. Contains shared ML-related helper functions
used by AI / Executorch layers such as image preprocessing.

groups:
- group: ML Utilities
files:
- file: image_processing_func.c
- file: image_processing_func.h
- file: model_config.h
75 changes: 75 additions & 0 deletions RockPaperScissors/AppKit-E8_USB/algorithm/ML/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Common Inference Library (CIL)

## Overview

The **Common Inference Library (CIL)** provides a unified interface for
**pre-processing** and **post-processing** of AI models such as **Image
Classification** and **Object Detection**.

Instead of writing model-specific processing code in every application,
CIL exposes two common APIs:

- `preprocess()`
- `postprocess()`

Based on the configured model, these APIs automatically invoke the
required internal processing functions.

---

## Components

| File | Description |
|---|---|
| `cil_process.a` | Prebuilt static library implementing pre-processing (resize, normalize, quantize) and post-processing (decode, NMS, format). Configured at build time for the target model category. |
| `cil_helper.h` | Public C API header. Provides `preprocess()`, `postprocess()`, and data structures (`detection_t`, `postprocess_data_t`). |
| `model_config.h` | Auto-generated header with model parameters - input dimensions (`MODEL_INPUT_WIDTH/HEIGHT/CHANNELS`), quantization scale/zero point, number of classes, labels, confidence threshold, and model category (`OBJECT_DETECTION` / `IMAGE_CLASSIFICATION`). |

The AI Layer (runner code in the board's `algorithm/` folder) ties these together
by calling the CIL APIs and delivering results through the SDS framework.

---

## Examples

For a **Image Classification** model:

**Preprocess** - Resize image, ImageNet normalization, tensor formatting
**Postprocess** - Softmax, argmax, confidence score

For an **Object Detection** model:

**Preprocess** - Resize / letterbox, quantization (if required)
**Postprocess** - Bounding box decoding, Non-Maximum Suppression (NMS), detection result formatting

---

## Benefits

- Common API for multiple AI models
- Eliminates duplicate processing code
- Easy integration of new models
- Simplifies application development
- Modular and reusable design

---

## Typical Flow

```
Input Image
preprocess()
Model Inference
postprocess()
Application Result
```

The application only calls the common APIs, while CIL internally
performs the model-specific preprocessing and postprocessing steps.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ layer:

packs:
- pack: PyTorch::ExecuTorch
path: ../../../packs/PyTorch.ExecuTorch.1.1.0-rc1-build.12
path: ../../../../../packs/PyTorch.ExecuTorch.1.1.0-rc1-build.12

define:
- ET_LOG_ENABLED : 0
Expand Down
Loading