Majid Al-RaimiReference sheet

COE 592Lecture 00Reference

Reference sheet

Course overview compressed onto one page: the definitions, formulas and numbers to have in your head before a quiz or exam.

Course facts and week one

Everything the deck states about the course, the instructor and the first evening. Part 01: The instructor and edge AI in practice, Part 02: Course takeaways and getting started

Facts as stated on slides 1, 2, 9, 10, 12 and the course registry

Course
COE 592 Machine Learning on Embedded Systems, term T261
Instructor
Dr. Abdul Jabbar Siddiqui, Computer Engineering, KFUPM; SERV Lab lead; SDAIA-KFUPM JRC-AI scholar
Degrees
PhD uOttawa 2021, MASc uOttawa 2015, BSc KFUPM 2012; NRC Canada 2020 to 2022
Meetings
Monday and Wednesday, 20:10 to 21:25, Building 59, Room 2004
Icebreaker
Name, educational background, work background
Survey
https://forms.cloud.microsoft/r/5ssu8gkcS9
Syllabus, grading, deliverables
On Blackboard only; not in the deck
  1. Fill in the survey and introduce yourself with the three items.
  2. Pick a device tier first; its memory budget is an input to model selection, not an output.
  3. Pick a candidate model that fits or is one or two optimizations from fitting; record parameters and float32 size.
  4. Start a metrics log before the first optimization. A baseline taken after changes is not a baseline.
WhenWhat to record
Week 1Device tier and its flash, SRAM or RAM budget from the datasheet
Week 1Candidate model, parameter count, float32 weight size
Week 1Baseline accuracy on a held-out set you never change
First run on hardwareLatency per inference and peak memory as the runtime reports them
Every optimizationThe same numbers again next to the baseline, plus what it cost
Starter metrics log

SERV

Secure, Efficient, Robust Vision: the lab name is the syllabus in miniature. Part 01

LetterWordCourse themeExample in the deck
SSecureAdversarial machine learning, intrusion detectionPNet-IDS (slide 6)
EEfficientCompression, pruning, quantization, nano detectorsEcoWeedNet (slide 4), PNet-IDS (slide 6)
RRobustRain, noise, blur, distribution shiftYOLO-RAW (slide 5)
VVisionCameras, thermal imagers, LiDAR as inputSlides 3 to 8
SERV mapped onto the course

Inspection rigs: shrink the model or ship the data

A UAV lifts a fixed mass, and every gram of sensor or computer is a gram less battery. Two options exist: run a model small enough on board, or ship raw data. The bandwidth arithmetic rules out the second. Part 01

SensorMeasuresGood atWeak atData rate
Visual (RGB) cameraReflected visible lightColour and textureDarkness, rain, glareHighest
Thermal (IR) cameraEmitted infrared, so temperatureHot bearings, people at nightNo colour, low resolutionModerate
LiDARPulsed-laser time of flight, so rangeGeometry, clearance, 3D point cloudsSparse at range, cost, weightHigh
GPS receiverPosition and timeGeoreferencing frames and pointsNothing about the sceneNegligible
The four modalities on the slide 3 rigs

Five-camera rig, worked numbers

Assumption
5 cameras at 1080p, 8 Mbit/s each (illustrative)
Stream leaving the rig
5 × 8 = 40 Mbit/s
One hour of driving
40 × 3600 = 144,000 Mbit, about 18 GB
Upload at 5 Mbit/s
144,000 / 5 = 28,800 s, about 8 hours per hour recorded
Satyanarayanan 2017
12,000 users at 1080p need about 100 Gbit/s ingress; a million users need 8.5 Tbit/s

Nano detectors: efficiency measured

YOLO size classes n, s, m, l, x share one architecture and differ in width and depth. Figures are Ultralytics, COCO validation at 640 px. Part 01

ModelParametersFLOPsmAP50-95CPU ONNXT4 TensorRT
YOLO11n2.6M6.5B39.556.1 ms1.5 ms
YOLO12n2.6M7.5B40.6not listed1.64 ms
YOLO11m20.1M68.1B51.5183.2 ms4.7 ms
YOLO11x56.9M195.3B54.7462.8 ms11.3 ms
YOLO size classes

Nano versus medium, and EcoWeedNet's result

Parameters
20.1 / 2.6 ≈ 7.7x fewer in YOLO11n
FLOPs
68.1 / 6.5 ≈ 10.5x fewer per image
CPU latency
183.2 / 56.1 ≈ 3.3x lower; below the FLOP ratio because small models leave hardware idle
Price
51.5 − 39.5 = 12.0 mAP50-95 points
EcoWeedNet
95.2% mAP@0.5 on CottonWeedDet12 with about 4.21% of YOLOv4 parameters and 6.59% of its GFLOPs
NumberMeasuresUnitKind
ParametersSize, so memorymillions (M)Metric
FLOPsCompute per inferencebillions (B) or GFLOPsMetric
LatencyTime per inference on a named devicemsMetric
mAPDetection quality on a datasetpercent or pointsMetric
GradCAM++ heatmapWhich pixels drove a class scorenoneAttribution, not a metric
What each number measures

Rain scene: robustness measured

YOLOv5-m (21.2M parameters, 49.0B FLOPs) against YOLO-RAW on rainy, Gaussian-noise and motion-blur test sets. Gulls numbered top to bottom in the YOLO-RAW panel. Part 01

ObjectYOLOv5-mYOLO-RAW
Gull 1 (top left)no boxBird 0.50
Gull 2 (centre)UAV 0.29 (false positive)Bird 0.63
Gull 3no boxBird 0.54
Gull 4no boxBird 0.73
Gull 5 (bottom)Bird 0.35Bird 0.37 (approximate)
Real drone, rain fieldUAV 0.90UAV 0.93
Every label on slide 5
precision=TPTP+FP,recall=TPTP+FN\text{precision} = \frac{TP}{TP + FP}, \qquad \text{recall} = \frac{TP}{TP + FN}
The two numbers a confidence threshold trades against each other

Can a threshold fix the baseline?

Ultralytics default
0.25
At 0.30
YOLOv5-m loses the false UAV and nothing else, but still sees one bird in five
At 0.60
YOLOv5-m reports nothing; YOLO-RAW has lost three of five correct birds
Rule
A threshold slices the confidence mass a model produced. A better model moves that mass.

PNet-IDS: line rate on a gateway

A network-based IDS (NIST SP 800-94) running on the gateway CPU that forwards the packets. The deadline is set by the link, not the designer. IEEE Access 2025, DOI 10.1109/ACCESS.2025.3575705. Part 01

tbudget=1packets/s=Lpacket×8Rt_{\text{budget}} = \frac{1}{\text{packets/s}} = \frac{L_{\text{packet}} \times 8}{R}
Time per packet on a link of rate R bits per second

Line-rate arithmetic (illustrative numbers)

Packets per second
100 × 10^6 / (500 × 8) = 25,000 on a 100 Mbit/s link with 500-byte packets
Budget per packet
1 / 25,000 = 40 µs
Heavy model
10 MFLOPs at 1 GFLOP/s is 10 ms, about 250x too slow
Light model
0.02 MFLOPs at 1 GFLOP/s is 20 µs, inside the budget
Generalizable
Accuracy held under traffic distribution shift, via knowledge distillation (student reproduces a teacher)
Benchmarks
BoT-IoT and CIC-IDS2017; wins are fewer parameters, fewer FLOPs, smaller size at maintained accuracy

Physics sets the deadline

Distance travelled during the reply latency is the safety margin lost. Deadline first, then accuracy. Part 01

dlost=v×tlatencyd_{\text{lost}} = v \times t_{\text{latency}}
Metres of travel before the detector answers
ScenarioSpeedTravel per latencyWorked numberCost of a miss
Shuttle at a T-intersection10 m/s1 m per 100 ms200 ms cloud round trip is 2 m of travelA pedestrian is struck
Wagon past a wayside camera15 m/s1.5 m per 100 ms33 ms per frame at 30 fps, wagon moves 0.5 mA defect leaves the yard
Two safety-critical edge inference problems

Five takeaways as one loop

Measure, optimize, compare, explore, deploy, then measure again. Deep Compression (Han, Mao and Dally, 2016) is the canonical worked loop. Part 02

PillarVerbQuestionExample
1 Measure efficiencyMeasureHow big, slow, hungry is the baseline?AlexNet 240 MB, 61 M parameters, 32-bit
2 AccelerateOptimizeWhich technique shrinks the cost that hurts most?Prune 9x, quantize to 5 bits, Huffman code
3 Analyse trade-offsCompareWhat did each step cost in accuracy or effort?35x smaller, no accuracy loss, after retraining
4 Track the frontierExploreWhat has research or industry done since?MCUNet, TinyTL, training under 256 KB
5 Build and deployDeployDoes it really run on the target hardware?3x to 4x speedup, 3x to 7x energy efficiency
Pillar, verb, question, Deep Compression example

Efficiency metrics and the size formula

Seven metrics that can disagree: a pruned model can be smaller yet no faster on hardware that cannot skip zeros. Part 02

MetricWhat it countsUnit
Parameter countLearnable weights and biasesM
Model sizeParameters × bits per weight / 8MB or KB
Peak memoryWeights plus the largest activation tensors at onceMB or KB
ComputeMACs or FLOPs per inferenceMMACs or GFLOPs
LatencyTime from one input to its outputms
ThroughputInferences per secondinferences/s
EnergyJoules per inference or average powermJ or mW
Efficiency metrics (preview of later lectures)
size (bytes)=Nparams×b8\text{size (bytes)} = \frac{N_{\text{params}} \times b}{8}
N parameters at b bits each; MB means one million bytes
BitsCalculationSizePico (2 MB)?Nano 33 BLE Sense (1 MB)?
32-bit3,000,000 × 32 / 812 MBNoNo
16-bit3,000,000 × 16 / 86 MBNoNo
8-bit3,000,000 × 8 / 83 MBNoNo
4-bit3,000,000 × 4 / 81.5 MBYesNo
3 M parameters at four bit widths against two flash budgets

Inference versus training on device

ItemInferenceTraining
WeightsYesYes
Current activationsYesYes
Stored activations for the backward passNoYes, the bottleneck (TinyTL)
Gradients for every weightNoYes
Optimizer stateNoYes
LiteRT for MicrocontrollersSupportedNot supported
What each holds in memory

Device tiers

Datasheet capacities, not what is free once the runtime is loaded. MCUNet reached over 70% ImageNet top-1 on a microcontroller, after the whole loop on a purpose-built architecture. Part 02

TierBoardMemoryTypically runs
MicrocontrollerArduino Nano 33 BLE Sense Rev2 (nRF52840)1 MB flash, 256 KB SRAMKeyword spotting, gesture, tiny classifiers
MicrocontrollerRaspberry Pi Pico / Pico 22 MB flash, 264 KB SRAM / 4 MB, 520 KBSame class, more headroom
Single-board computerRaspberry Pi 4 Model B1 to 8 GB LPDDR4Quantized MobileNet-class vision, small detectors
GPU moduleJetson Orin Nano Super8 GB LPDDR5, 102 GB/s, 67 INT8 TOPSReal-time detection, small transformers, fine-tuning
One example board per tier

Slide errata and reading notes

Answer with the corrected fact; do not attribute results to uncaptioned photographs. Part 01, Part 02

What the slides get wrong or leave out

Slide 2
Degree punctuation is inconsistent, (UOttawa 2021) versus (UOttawa, 2015). JRC is unexpanded: SDAIA-KFUPM Joint Research Center for AI.
Slide 3
No caption, no citation. Describe the rig (RGB, thermal, LiDAR, GPS); attribute no measured result.
Slide 5
RAW is never expanded, on the slide or in the paper. The fifth YOLO-RAW label is occluded and reads about Bird 0.37.
Slides 7, 8
Photographs with no paper and no result. Cite FHWA HRT-18-044 and the NRC rail review for the problem class only.
Slide 11
"Resource-constraint platforms" should be "resource-constrained". Spelling mixes British "Analyse" with American "Optimize".
Slide 12
Only "View on Blackboard". No grading weights, exam dates, textbook or office hours are in the deck.