UAT 462 Edge Artificial Intelligence for UAS
Worksheet 2 Convert, check and accelerate a model on the board
Objective
Export a model to ONNX, check that the output matches the original, see the effects of fusion and partitioning, time before and after acceleration on the real board, and summarise the operators that fall back to the CPU
Equipment and materials
- At least one target board the department has (SBC, GPU module or accelerator)
- The sample model the instructor sets, or the group's model
- Python with onnx and onnxruntime, and the vendor's compile tool if available
Safety
- A board under full load is hot; do not touch the heat sink while it runs
- Take anti-static precautions when handling boards, and power off before connecting cables or accessories
- Desk work, no flying
Steps
- Export the model to ONNX with an opset matching the board's runtime, run onnx.checker and compare with the original
- Run ONNX Runtime at different optimisation levels, save the optimised files and compare the node lists with Example 1
- Turn on profiling, sum time by operator name, find the three most time-consuming nodes and compute Amdahl's bound
- If an accelerator is available, compile with the vendor's tool, read the log for operators that fall back to the CPU and make a table with a fix plan following Example 2
- Time before and after fusion and the change to FP16 (20 warm-up runs, 200 measured, report p50 and p95)
- Summarise as a table: method, time, accuracy and CPU-fallback operators
Record of results
| Check | Value or result | Maximum difference from the original | Notes |
|---|---|---|---|
| Operator | Total time (ms) | Share of total time (%) | Provider that ran it |
|---|---|---|---|
| Method | p50 (ms) | p95 (ms) | Validation accuracy | CPU-fallback operators | Measurement conditions |
|---|---|---|---|---|---|
Questions
From Table 2, if the three most time-consuming nodes became 4 times faster, by how much at most could the total speed up by Amdahl's bound, and what if they became infinitely fast? What does this say about choosing what to tune?
How do the unsupported operators in Table 3 change the total time? Explain with single and multiple graph partitioning, and choose a fix that suits the group, with a reason.
Why deliver the original ONNX file rather than the optimised file, even though the optimised one is faster?
How much did the group's accuracy change with FP16? If it changed a lot, what is the likely cause, and what should you check about the runtime?
Why warm up for 20 runs before measuring, and why report p95 together with p50 instead of the mean?
Check before you hand in
What to hand in
- A checked ONNX file and the output-difference table
- Per-node time table and Amdahl's bound
- Table of unsupported operators with a fix plan
- Table of time before and after acceleration with the measurement conditions