4.2: MLE.2 ML Model Architecture
Process Definition
Purpose
MLE.2 Purpose: To establish an ML model architecture that satisfies the ML requirements.
Outcomes
| Outcome | Description |
|---|---|
| O1 | A ML architecture is developed |
| O2 | Hyperparameter ranges and initial values are determined as a basis for the training |
| O3 | Evaluation of ML architectural elements is conducted |
| O4 | Interfaces of the ML architectural elements are defined |
| O5 | Resource consumption objectives for the ML architectural elements are defined |
| O6 | Consistency and bidirectional traceability are established between the ML architectural elements and the ML requirements |
| O7 | The ML architecture is agreed and communicated to all affected parties |
Base Practices with AI Integration
| BP | Base Practice | AI Level | AI Application |
|---|---|---|---|
| BP1 | Develop ML architecture | L1-L2 | Architecture suggestions, model design |
| BP2 | Determine hyperparameter ranges and initial values | L2 | Hyperparameter optimization |
| BP3 | Analyze ML architectural elements | L2 | Architecture evaluation |
| BP4 | Define interfaces of the ML architectural elements | L2 | Interface generation |
| BP5 | Define resource consumption objectives | L2 | Resource estimation |
| BP6 | Ensure consistency and establish bidirectional traceability | L2 | Link generation, consistency checking |
| BP7 | Communicate agreed ML architecture | L1 | Documentation generation |
Architecture Patterns for Embedded ML
Pattern Selection Guide
The diagram below presents a decision framework for selecting ML architecture patterns based on task type, latency constraints, and available hardware resources.
Model Architecture Specification
Architecture Document Template
# ML Model Architecture Specification
architecture:
id: MLE-ARCH-001
name: ADAS Vehicle Detection Model
version: 2.1
status: approved
requirements:
- MLE-ADAS-001 # Vehicle detection performance
- MLE-ADAS-002 # Latency requirement
- MLE-ADAS-003 # Memory constraint
base_architecture: YOLOv8-nano
modification: "Quantization-aware training, pruned for automotive"
input_specification:
format: RGB image
resolution: [640, 384]
dtype: uint8
normalization: "[0, 255] → [0, 1]"
preprocessing:
- resize: "bilinear interpolation"
- normalize: "divide by 255"
output_specification:
format: Detection boxes + confidence
max_detections: 100
classes:
- vehicle_car
- vehicle_truck
- vehicle_motorcycle
- vehicle_bus
output_format:
boxes: "[N, 4] (x_center, y_center, width, height)"
scores: "[N] confidence scores"
classes: "[N] class indices"
model_structure:
backbone:
type: CSPDarknet-nano
layers: 24
channels: [16, 32, 64, 128]
activation: SiLU
neck:
type: PANet
feature_levels: [P3, P4, P5]
head:
type: Decoupled Head
anchors: anchor-free
outputs_per_level: 3
quantization:
type: INT8
calibration: "Post-training quantization"
calibration_dataset: "1000 representative samples"
accuracy_loss: "< 1% mAP drop"
resource_estimation:
parameters: 3.2M
flops: 8.7 GFLOPs
model_size:
fp32: 12.8 MB
int8: 3.2 MB
memory_footprint:
inference: 48 MB
peak: 64 MB
hardware_target:
platform: "NVIDIA Jetson Orin Nano" # Illustrative; adapt to project-specific target
accelerator: GPU
inference_time: 22ms
power: 7W
traceability:
requirements:
- id: MLE-ADAS-001
coverage: "Detection performance"
- id: MLE-ADAS-002
coverage: "Latency (22ms < 50ms)"
- id: MLE-ADAS-003
coverage: "Memory (64MB < 128MB)"
Model Component Specification
Layer-Level Documentation
The following diagram breaks down the ML model into its constituent layers and components, showing input/output shapes, parameter counts, and computational requirements at each stage.
Interface Specification
Input/Output Contract
Note: This C interface follows AUTOSAR conventions for consistency with embedded automotive software.
/**
* @file ml_detection_interface.h
* @brief ML Detection Model Interface
* @trace MLE-ARCH-001
*/
#ifndef ML_DETECTION_INTERFACE_H
#define ML_DETECTION_INTERFACE_H
#include "Std_Types.h"
/*===========================================================================*/
/* TYPE DEFINITIONS */
/*===========================================================================*/
/** @brief Input image format */
typedef struct {
uint8* data; /**< RGB pixel data */
uint16 width; /**< Image width (640) */
uint16 height; /**< Image height (384) */
uint8 channels; /**< Number of channels (3) */
} ML_ImageInput_t;
/** @brief Detection result */
typedef struct {
float32 x_center; /**< Box center X (normalized 0-1) */
float32 y_center; /**< Box center Y (normalized 0-1) */
float32 width; /**< Box width (normalized 0-1) */
float32 height; /**< Box height (normalized 0-1) */
float32 confidence; /**< Detection confidence (0-1) */
uint8 class_id; /**< Class index */
} ML_Detection_t;
/** @brief Inference result */
typedef struct {
ML_Detection_t detections[100]; /**< Detection array */
uint8 num_detections; /**< Number of valid detections */
uint32 inference_time_us; /**< Inference time in microseconds */
} ML_InferenceResult_t;
/*===========================================================================*/
/* API FUNCTIONS */
/*===========================================================================*/
/**
* @brief Initialize ML model
* @return E_OK on success
* @timing Initialization: ~500ms
* @trace MLE-ARCH-001
*/
Std_ReturnType ML_Detection_Init(void);
/**
* @brief Run inference on image
* @param input Input image
* @param result Output detections
* @return E_OK on success
* @timing Max 50ms inference time
* @trace MLE-ADAS-001, MLE-ADAS-002
*/
Std_ReturnType ML_Detection_Inference(
const ML_ImageInput_t* input,
ML_InferenceResult_t* result
);
/**
* @brief Get model information
* @param version Model version string
* @param params Parameter count
* @return E_OK on success
*/
Std_ReturnType ML_Detection_GetInfo(
char* version,
uint32* params
);
#endif /* ML_DETECTION_INTERFACE_H */
AI-Assisted Architecture Design
L2: Architecture Selection
AI Architecture Recommendation:
───────────────────────────────
Requirements Analysis:
• MLE-ADAS-001: Recall ≥ 99.9%, Precision ≥ 98%
• MLE-ADAS-002: Latency ≤ 50ms
• MLE-ADAS-003: Memory ≤ 128MB
Hardware Target:
• NVIDIA Jetson Orin Nano (GPU accelerated)
• Available memory: 128MB for ML
• Power budget: 10W
Recommended Architecture: YOLOv8-nano
─────────────────────────────────────
Rationale:
1. Real-time Performance
- Expected latency: ~22ms on target
- Well within 50ms requirement
2. Accuracy Profile
- mAP@0.5: 0.87 (baseline)
- With automotive fine-tuning: expected 0.90+
3. Memory Efficiency
- INT8 model: 3.2MB
- Inference memory: 48MB peak
4. Deployment Maturity
- TensorRT support available
- Automotive deployment references exist
Alternatives Considered:
────────────────────────
1. SSD MobileNet v2
- Pro: Smaller model
- Con: Lower accuracy (mAP 0.72)
- Decision: Accuracy insufficient
2. EfficientDet-D0
- Pro: Better accuracy (mAP 0.90)
- Con: Higher latency (~80ms)
- Decision: Latency exceeded
3. YOLOv8-small
- Pro: Higher accuracy (mAP 0.92)
- Con: 2x parameters, 2x memory
- Decision: Could be future upgrade if needed
Human Review Required:
□ Confirm architecture selection
□ Review quantization strategy
□ Approve resource allocation
Resource Estimation
Computation Analysis
The diagram below estimates the computational resources required for model inference on the target hardware, including memory footprint, FLOPS, and latency budget allocation.
Work Products
| WP ID | Work Product | AI Role |
|---|---|---|
| 04-08 | ML architecture description | Architecture suggestion |
| 17-64 | Interface specification | Interface generation |
| 13-64 | Resource analysis report | Estimation |
| 17-11 | Traceability record | Link generation |
Summary
MLE.2 ML Model Architecture:
- AI Level: L1-L2 (AI suggests, human selects)
- Primary AI Value: Architecture search, resource estimation
- Human Essential: Final architecture decision, constraints
- Key Outputs: Architecture specification, interface definition
- Focus: Embedded constraints (latency, memory, power)