UAT 462 Edge Artificial Intelligence for UAS

Worksheet 2 Convert, check and accelerate a model on the board

Lab 12 hAssesses CLO2, CLO3

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

  1. Export the model to ONNX with an opset matching the board's runtime, run onnx.checker and compare with the original
  2. Run ONNX Runtime at different optimisation levels, save the optimised files and compare the node lists with Example 1
  3. Turn on profiling, sum time by operator name, find the three most time-consuming nodes and compute Amdahl's bound
  4. 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
  5. Time before and after fusion and the change to FP16 (20 warm-up runs, 200 measured, report p50 and p95)
  6. Summarise as a table: method, time, accuracy and CPU-fallback operators

Record of results

Table 1 ONNX export and checks
CheckValue or resultMaximum difference from the originalNotes
Table 2 Time by operator from profiling
OperatorTotal time (ms)Share of total time (%)Provider that ran it
Table 3 Time before and after acceleration
Methodp50 (ms)p95 (ms)Validation accuracyCPU-fallback operatorsMeasurement conditions

Questions

  1. 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?

  2. 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.

  3. Why deliver the original ONNX file rather than the optimised file, even though the optimised one is faster?

  4. 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?

  5. 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

CLO2 Convert, accelerate, compress and quantise models for edge devices and check the effect on accuracy. CLO3 Measure and report time, energy and temperature on real hardware, interface sensors, and plan safe deployment. (CLOs are a web-team draft; the course owner sets the final ones.)

Instructors: answers and teaching notes for this worksheet are in the teaching pack