Module 2/5 · Weeks 4–6 · 27 h

Model conversion and acceleration methods

UAT 462 Edge Artificial Intelligence for UAS

About 100 minDraft, awaiting reviewLast updated 3 October 2026

Lesson

By the end of this module you will be able to

  1. Explain the pipeline from training machine to board (export to ONNX, graph optimisation, compiling with the target's runtime or vendor compiler) and the role of the opset
  2. Build and inspect an ONNX graph in code, and confirm that fusing Conv, BatchNorm and ReLU does not change the output
  3. Analyse how an operator the accelerator does not support affects the time of the whole graph, compare multi-partition with prefix-only placement, and apply Amdahl's bound
  4. Explain the limits of FP16 (range, resolution, overflow) and why products should be accumulated at higher precision
  5. Compare stacked acceleration methods (fusion, lower numeric precision, smaller input) with the roofline model

Prerequisites: UAT 462 module 1 · UAT 306 Artificial Intelligence for UAS (modules 4 and 5)

Why this matters

A model trained in PyTorch on a GPU machine does not run on the board by itself. It must be converted to a format the target runtime can read, and a conversion rarely fails loudly. More often it passes and is slow, because some operators are unsupported and fall back to the CPU, or because the graph was never optimised. This module teaches how to convert, check and accelerate the case study’s WasteNet-S, confirming at every step that the output still matches the original and measuring how much faster it really is.

From the training machine to the board

The pipeline has six steps: train and evaluate on a strong machine and record the reference accuracy; export to ONNX and check that the output matches the original; optimise the graph; choose the target’s runtime or compiler; reduce numeric precision (module 3); and measure on the real board. Several systems fill the runtime step. The table summarises what the developers’ documentation states (checked; see the bibliography).

SystemWhat it doesWhat the documentation says to know
ONNX RuntimeRuns ONNX models through Execution Providers that connect to hardware libraries such as CUDA, TensorRT, OpenVINO, QNN, CoreML, NNAPI and XNNPACKThe provider list is ordered by priority: each node runs on the first provider that can run it, otherwise on the CPU
TensorRTCompiles a model from ONNX or PyTorch into an engine for NVIDIA GPUs, with FP32, FP16, BF16, FP8, INT8, FP4 and INT4 precisionHas a layer-fusion catalogue and explicit quantisation with Q/DQ nodes
OpenVINOA toolkit with NNCF for post-training quantisation, quantisation-aware training, weight compression and filter pruning of convolutional modelsThe documentation separates post-training from training-time reduction, which module 3 compares
LiteRT and Edge TPUConvert to TensorFlow Lite, then compile with edgetpu_compilerTensors must be 8-bit, of constant size and 1 to 3 dimensions; only supported operators are allowed; the compiler partitions the graph only once, at the first unsupported operator, and everything after it runs on the CPU

The last row matters most for design and shows its effect in Example 2.

ONNX: graph, operators and opset

ONNX is an interchange format that stores a model as a graph of nodes (operators) with constants (initializers) such as weights. An operator is identified by (domain, name, since-version), and an operator set (opset) is the set of operators of one domain at one version, whose version must increase when an operator is added, removed or changes meaning. A model declares the opsets it needs in the opset_import list. The empty domain ("") holds the standard ONNX operators; other domains are vendor extensions (ONNX versioning document). The consequence is that the runtime must support the declared opset: if the exporter uses an opset newer than the board’s runtime knows, the model will not load, so set the opset at export to match the target.

The ONNX Runtime documentation groups graph optimisation into three levels. Basic does constant folding, removes needless nodes, and fuses nodes such as Conv with Add, Conv with Mul, Conv with BatchNorm, and Relu with Clip. Extended runs after the graph is partitioned and applies to nodes assigned to the CPU, CUDA or ROCm provider. Layout changes the data layout for the CPU. An optimised file saved in offline mode is usable only on hardware compatible with the one it was saved on. The practice is to keep the original ONNX file as the deliverable and treat the optimised file as a by-product of the target machine.

The simplest fusion folds BatchNorm into the preceding Conv. At inference BatchNorm is a per-channel multiply and add, which merges into the weights: and ; then the node is dropped. The output is the same but faster, because the feature map need not pass through memory again, which matches the roofline of module 1.

Example 1 Build an ONNX graph and watch real fusion

Build a Conv, BatchNorm, Relu graph by hand (random weights), fold BatchNorm yourself with the formula and compare with the original. Then let ONNX Runtime optimise the graph at the basic and extended levels, read the node names of the saved files and check that the output does not change.

import numpy as np
import onnx
import onnxruntime as ort
from onnx import TensorProto, helper, numpy_helper

# build a tiny ONNX graph by hand with Conv, BatchNormalization and Relu (assumed, random weights)
rng = np.random.default_rng(485)
cin, cout = 8, 16
W = rng.normal(0, 0.2, (cout, cin, 3, 3)).astype(np.float32)
b = rng.normal(0, 0.1, cout).astype(np.float32)
gamma, beta = rng.uniform(0.5, 1.5, cout).astype(np.float32), rng.normal(0, 0.1, cout).astype(np.float32)
mean, var = rng.normal(0, 0.3, cout).astype(np.float32), rng.uniform(0.5, 2.0, cout).astype(np.float32)

def make_model(nodes, params):
    graph = helper.make_graph(nodes, "block", [helper.make_tensor_value_info("x", TensorProto.FLOAT, [1, cin, 32, 32])],
                              [helper.make_tensor_value_info("y", TensorProto.FLOAT, [1, cout, 32, 32])],
                              [numpy_helper.from_array(a, n) for n, a in params.items()])
    model = helper.make_model(graph, opset_imports=[helper.make_opsetid("", 17)])   # declare opset 17 of the standard domain
    model.ir_version = 9
    onnx.checker.check_model(model)
    return model

conv = helper.make_node("Conv", ["x", "W", "B"], ["c"], kernel_shape=[3, 3], pads=[1, 1, 1, 1])
bn = helper.make_node("BatchNormalization", ["c", "gamma", "beta", "mean", "var"], ["bn"], epsilon=1e-5)
relu = helper.make_node("Relu", ["bn"], ["y"])
original = make_model([conv, bn, relu], dict(W=W, B=b, gamma=gamma, beta=beta, mean=mean, var=var))
onnx.save(original, "original.onnx")
print("opset", original.opset_import[0].version, "| nodes", [n.op_type for n in original.graph.node])

# fold BatchNorm into the Conv weights by hand: W' = W * g / sqrt(var + eps), b' = (b - mean) * g / sqrt(var + eps) + beta
scale = gamma / np.sqrt(var + 1e-5)
folded = make_model([conv, helper.make_node("Relu", ["c"], ["y"])],
                    dict(W=W * scale[:, None, None, None], B=(b - mean) * scale + beta))
onnx.save(folded, "folded.onnx")

def run(path, level=ort.GraphOptimizationLevel.ORT_DISABLE_ALL, save_as=None):
    so = ort.SessionOptions()
    so.graph_optimization_level = level
    so.log_severity_level = 3
    if save_as:
        so.optimized_model_filepath = save_as
    return ort.InferenceSession(path, so, providers=["CPUExecutionProvider"])

x = rng.normal(0, 1, (1, cin, 32, 32)).astype(np.float32)
ref = run("original.onnx").run(None, {"x": x})[0]
print("hand-folded graph matches the original within 1e-5:", np.allclose(run("folded.onnx").run(None, {"x": x})[0], ref, atol=1e-5))
for name, level in (("basic", ort.GraphOptimizationLevel.ORT_ENABLE_BASIC), ("extended", ort.GraphOptimizationLevel.ORT_ENABLE_EXTENDED)):
    out = run("original.onnx", level, f"opt_{name}.onnx").run(None, {"x": x})[0]
    ops = [(n.domain + "." if n.domain else "") + n.op_type for n in onnx.load(f"opt_{name}.onnx").graph.node]   # name with domain (empty = ONNX standard)
    print(f"ONNX Runtime {name:8s} -> {ops}, same output within 1e-5: {np.allclose(out, ref, atol=1e-5)}")

fmap = 4 * cout * 32 * 32                                  # bytes of one float32 feature map
passes = {"original": 5, "basic": 3, "extended": 1}        # Conv writes once, BN reads and writes (2), Relu reads and writes (2)
for name, n in passes.items():
    print(f"{name:8s}: {n} pass{'es' if n > 1 else ''} over the feature map = {n * fmap // 1024} KiB of memory traffic")
opset 17 | nodes ['Conv', 'BatchNormalization', 'Relu']
hand-folded graph matches the original within 1e-5: True
ONNX Runtime basic    -> ['Conv', 'Relu'], same output within 1e-5: True
ONNX Runtime extended -> ['com.microsoft.FusedConv'], same output within 1e-5: True
original: 5 passes over the feature map = 320 KiB of memory traffic
basic   : 3 passes over the feature map = 192 KiB of memory traffic
extended: 1 pass over the feature map = 64 KiB of memory traffic

Every route gives the same output within , but the node count differs. The basic level folds BatchNorm, leaving Conv and Relu. The extended level merges everything into one node named FusedConv in the com.microsoft domain, an operator of a vendor extension and not standard ONNX, which is the reason for the practice above. The passes of the feature map through memory drop from 5 (Conv writes, BatchNorm reads and writes, Relu reads and writes) to 3 and then 1, which helps most for memory-bound layers.

Diagram of three graphs. Row one, the original Conv, BatchNorm and ReLU, passes through memory 5 times, 320 KiB. Row two, basic level, BatchNorm folded into Conv leaving Conv and ReLU, 3 passes, 192 KiB. Row three, extended level, the single node FusedConv, 1 pass, 64 KiB
Figure 1 The Conv, BatchNorm, ReLU graph before and after two levels of fusion

Unsupported operators and graph partitioning

An accelerator does not support every operator. When a graph contains an unsupported one the system must partition it: supported parts go to the accelerator, the rest run on the CPU, and every time data crosses the boundary it costs time ( per crossing). The total time is . Two approaches found in practice differ greatly. ONNX Runtime uses GetCapability() so that a provider takes only the nodes or sub-graphs it can run, so partitioning can happen many times across the graph. The Edge TPU compiler can partition only once, at the first unsupported operator; that operator and everything after it run on the CPU, and the compiler log shows the operators “Mapped to the CPU”.

Example 2 How much does one unsupported operator cost?

The detector graph has 12 parts (all timings assumed). The resize in the middle uses a mode the accelerator does not support, and nms is not on the accelerator at all. Crossing the CPU/accelerator boundary costs 1.5 ms each time. Compare four plans: everything on the CPU, prefix only (Edge TPU style), multi-partition (ONNX Runtime style), and resize rewritten to a supported mode.

# the exported detector graph: (name, accelerator ms, CPU ms, accelerator supports it) all assumed
graph = [("block1", 0.6, 12.0, True), ("block2", 0.8, 18.0, True), ("block3", 0.9, 22.0, True), ("block4", 0.8, 20.0, True),
         ("block5", 0.7, 20.0, True), ("block6", 0.6, 18.0, True), ("block7", 0.5, 16.0, True), ("resize", 0.4, 2.5, False),
         ("concat", 0.1, 0.8, True), ("head", 0.3, 6.0, True), ("decode", 0.1, 1.2, True), ("nms", 0.0, 4.0, False)]
HOP = 1.5                                       # cost of moving data across the CPU/accelerator boundary (ms), assumed

def latency(placement, g=graph):
    total, where, hops = 0.0, "cpu", 0          # the image starts in CPU memory
    for (name, acc, cpu, ok), dev in zip(g, placement):
        assert dev == "cpu" or ok, name
        total += acc if dev == "acc" else cpu
        if dev != where:
            total, where, hops = total + HOP, dev, hops + 1
    if where == "acc":                          # the result must come back to the CPU
        total, hops = total + HOP, hops + 1
    return total, hops

first_bad = next(i for i, g in enumerate(graph) if not g[3])
rewritten = [(n, a, c, True if n == "resize" else ok) for n, a, c, ok in graph]      # change resize to a mode the accelerator supports
plans = {"all on CPU": (["cpu"] * len(graph), graph),
         "prefix only (stop at first unsupported op)": (["acc"] * first_bad + ["cpu"] * (len(graph) - first_bad), graph),
         "multi-partition (any supported op)": (["acc" if g[3] else "cpu" for g in graph], graph),
         "resize rewritten, nms on CPU": (["cpu" if g[0] == "nms" else "acc" for g in graph], rewritten)}
base = latency(*[plans["all on CPU"][0]])[0]
for name, (plc, g) in plans.items():
    ms, hops = latency(plc, g)
    print(f"{name:44s} {ms:6.1f} ms  x{base / ms:4.1f}  boundary crossings {hops}")
cpu_left = sum(g[2] for g, d in zip(graph, plans["prefix only (stop at first unsupported op)"][0]) if d == "cpu")
print(f"prefix-only plan: the CPU still runs {cpu_left:.1f} ms, the accelerator {sum(g[1] for g in graph[:first_bad]):.1f} ms")
# Amdahl bound: accelerate the share p of the time by a factor s, the rest stays the same (transfers not counted)
acc_part = graph[:first_bad]
p = sum(g[2] for g in acc_part) / base
s = sum(g[2] for g in acc_part) / sum(g[1] for g in acc_part)
print(f"Amdahl for the prefix-only plan: p = {p:.3f}, s = {s:.1f}, bound x{1 / ((1 - p) + p / s):.1f}")
all on CPU                                    140.5 ms  x 1.0  boundary crossings 0
prefix only (stop at first unsupported op)     22.4 ms  x 6.3  boundary crossings 2
multi-partition (any supported op)             17.9 ms  x 7.8  boundary crossings 4
resize rewritten, nms on CPU                   12.8 ms  x11.0  boundary crossings 2
prefix-only plan: the CPU still runs 14.5 ms, the accelerator 4.9 ms
Amdahl for the prefix-only plan: p = 0.897, s = 25.7, bound x7.2

The prefix-only plan gives 6.3 times although the part the accelerator takes is 25.7 times faster than the CPU, because the resize in the middle forces the resize, concat, head, decode and nms, 14.5 ms in all, to stay on the CPU. Amdahl’s bound explains it: if is the share of time the accelerator takes and the speed-up it gives, the remaining caps the total at 7.2 times even when is 25.7 (Amdahl, 1967). Multi-partition improves to 7.8 times but crosses the boundary four times. The best route is to fix the resize (11.0 times), which requires checking the accuracy afterwards and perhaps a little retraining. Practical remedies: rewrite the operator into a supported form; move it into post-processing on the CPU (where nms normally lives); accept the CPU fallback if its time share is small; choose a model that uses only operators the target supports; or change the target.

Horizontal bars of time per image for four plans: all on CPU 140.5 milliseconds; prefix only 22.4 milliseconds, 6.3 times faster; multi-partition 17.9 milliseconds, 7.8 times faster; resize rewritten with nms on CPU 12.8 milliseconds, 11.0 times faster
Figure 2 Time per image of four placements of the graph on the accelerator and CPU

FP16 numeric precision

Many accelerators gain a lot from 16-bit numbers (FP16) instead of 32-bit, and the memory to read and write halves. Micikevicius et al. (2018) report that storing weights, activations and gradients in FP16 reduces the memory of a model by nearly two times, but a single-precision copy of the weights must be kept and the loss scaled so that small gradients do not vanish. That concerns training. For inference there are three cautions: FP16 has a narrow range (maximum 65,504), low resolution (epsilon about ), and very small values round to zero.

Example 3 Where does FP16 go wrong?

Compare a 4,096-element dot product (assumed) stored in FP32, stored in FP16 but accumulated in FP32, and stored and accumulated entirely in FP16. Then look at the overflow of a sum of squares and at a very small value.

import numpy as np

# limits of FP16 against FP32
for dt in (np.float16, np.float32):
    f = np.finfo(dt)
    print(f"{f.dtype}: max {float(f.max):.6g}, smallest normal {float(f.tiny):.3g}, machine epsilon {float(f.eps):.3g}")

# a 4096-element dot product (assumed) under different storage and accumulation choices
rng = np.random.default_rng(7)
x, w = rng.normal(0, 1, 4096).astype(np.float32), rng.normal(0, 1, 4096).astype(np.float32)
exact = float(np.dot(x.astype(np.float64), w.astype(np.float64)))
x16, w16 = x.astype(np.float16), w.astype(np.float16)
variants = {
    "fp32 storage, fp32 accumulate": float(np.dot(x, w)),
    "fp16 storage, fp32 accumulate": float(np.dot(x16.astype(np.float32), w16.astype(np.float32))),
    "fp16 storage, fp16 accumulate": float(np.add.accumulate((x16 * w16).astype(np.float16), dtype=np.float16)[-1])}
for name, val in variants.items():
    print(f"{name:32s} result {val:9.4f}, error {abs(val - exact):.4f}")
print(f"exact (float64) {exact:.4f}")

# overflow and underflow: accumulated squares and tiny values
act = np.full(4096, 12.0, dtype=np.float16)
print("sum of squares in fp16:", np.add.accumulate((act * act).astype(np.float16), dtype=np.float16)[-1],
      "| in fp32:", float(np.sum(act.astype(np.float32) ** 2)))
print("1e-8 stored in fp16:", np.float16(1e-8), "| 3e-8 stored in fp16:", np.float16(3e-8))
float16: max 65504, smallest normal 6.1e-05, machine epsilon 0.000977
float32: max 3.40282e+38, smallest normal 1.18e-38, machine epsilon 1.19e-07
fp32 storage, fp32 accumulate    result  -30.9021, error 0.0000
fp16 storage, fp32 accumulate    result  -30.9030, error 0.0010
fp16 storage, fp16 accumulate    result  -30.1094, error 0.7927
exact (float64) -30.9021
sum of squares in fp16: inf | in fp32: 589824.0
1e-8 stored in fp16: 0.0 | 3e-8 stored in fp16: 6e-08

Storing in FP16 but accumulating in FP32 is off by only 0.0010 from the exact −30.9021, while accumulating in FP16 is off by 0.79, nearly 800 times more, because as the sum grows the resolution of FP16 at that magnitude gets coarser and the small values added are rounded away. The sum of squares of 4,096 values of 12, which should be 589,824, overflows to inf in FP16, and becomes zero. Practice: check what precision the runtime accumulates at; beware of computations that sum many large values (such as the variance in BatchNorm if it has not been folded); and always evaluate the model’s accuracy after changing numeric precision.

Stacked acceleration, and measure before tuning

Acceleration methods work at three levels: graph level (fusion, removing needless nodes), numeric level (FP16, and INT8 in module 3) and model level (smaller input, a different architecture, module 3). The rule that always applies is measure before tuning. ONNX Runtime can record a profile with enable_profiling, producing a JSON file in which each node has its time (dur, in microseconds), operator name and the provider that ran it. Sorting by total time shows where to tune. Tuning a part that takes 5% of the time can reduce the total by at most 5%.

Example 4 How much does each method help when stacked?

Use the WasteNet-S layer table on an assumed GPU (peak FP32 1 TOPS, FP16 4 TOPS, INT8 8 TOPS, bandwidth 60 GB/s), computing each layer’s time with the roofline. If BatchNorm and ReLU are separate nodes they read and write the output map twice more. Compare five plans that stack methods one on another.

# the WasteNet-S layer table from module 1 (assumed)
layers = [("conv1", 3, 16, 3, 2), ("conv2", 16, 32, 3, 2), ("conv3", 32, 32, 3, 1), ("conv4", 32, 64, 3, 2),
          ("conv5", 64, 64, 3, 1), ("conv6", 64, 128, 3, 2), ("conv7", 128, 128, 3, 1), ("conv8", 128, 256, 3, 2),
          ("conv9", 256, 256, 3, 1), ("head", 256, 21, 1, 1)]

def per_layer(size):
    n, rows = size, []
    for name, cin, cout, k, s in layers:
        out = n // s
        rows.append((name, 2 * out * out * k * k * cin * cout, n * n * cin, out * out * cout, k * k * cin * cout))
        n = out
    return rows                                  # (name, operations, inputs, outputs, weights)

# an assumed GPU module: peak compute per precision, and bandwidth
PEAK = {4: 1.0e12, 2: 4.0e12, 1: 8.0e12}         # bytes per value -> ops/s
BW = 60e9

def total_ms(size, nbytes, fused):
    total = 0.0
    for name, ops, a_in, a_out, w in per_layer(size):
        traffic = (a_in + a_out + w) * nbytes
        t = max(ops / PEAK[nbytes], traffic / BW)
        if not fused and name != "head":         # separate BN and ReLU: two more read-and-write passes over the output
            t += 4 * a_out * nbytes / BW
        total += t
    return total * 1e3

plans = [("fp32, BN and ReLU as separate nodes", 640, 4, False), ("fp32, fused", 640, 4, True),
         ("fp16, fused", 640, 2, True), ("int8, fused", 640, 1, True), ("int8, fused, input 448", 448, 1, True)]
base = total_ms(*plans[0][1:])
for label, size, nbytes, fused in plans:
    ms = total_ms(size, nbytes, fused)
    print(f"{label:38s} {ms:6.2f} ms  speed-up x{base / ms:4.1f}")
fp32, BN and ReLU as separate nodes      4.29 ms  speed-up x 1.0
fp32, fused                              3.03 ms  speed-up x 1.4
fp16, fused                              0.83 ms  speed-up x 5.2
int8, fused                              0.42 ms  speed-up x10.3
int8, fused, input 448                   0.20 ms  speed-up x21.1

Fusion helps only 1.4 times because fp32 is still mostly compute-bound. Changing to fp16 helps both compute and bytes, giving 5.2 times; int8 gives 10.3 times; and reducing the input to 448 gives 21.1 times. But the price of each step differs. Fusion does not change the output. Lower numeric precision changes it slightly and the accuracy must be measured (module 3). Reducing the input shrinks objects in pixels (a 1.5 m pile becomes 11.7 pixels at input 448, from module 1), so it risks accuracy most. All figures come from an assumed device and are for comparing proportions only; always measure on the real board.

Horizontal bars of time per image of five plans on an assumed accelerator: fp32 with BN and ReLU separate 4.29 milliseconds; fp32 fused 3.03; fp16 fused 0.83; int8 fused 0.42; int8 fused at input 448 is 0.20 milliseconds, 21.1 times faster
Figure 3 Time per image on an assumed accelerator as methods are stacked

Module lab

Lab: convert, check and accelerate a model on the board

  1. Export the group’s model (or the sample model the instructor sets) to ONNX with the opset matching the board’s runtime. Run onnx.checker and compare the output with the original on the same input. Report the maximum difference.
  2. Run it in ONNX Runtime at different optimisation levels, save the optimised files, and compare the node lists with Example 1.
  3. Turn on ONNX Runtime profiling, sum the time by operator name, find the three nodes that take the most time, and compute Amdahl’s bound if those three became four times faster.
  4. If an accelerator is available (NPU or GPU), compile with the vendor’s tool, read the log to find operators that fall back to the CPU, and make a table of unsupported operators with a fix plan following Example 2.
  5. Measure on the real board before and after fusion and the change to FP16 (20 warm-up runs, then 200 measured, report p50 and p95) and compare with the proportions in Example 4.
  6. Summarise as a table: method, time, accuracy on the validation set, and operators that fell back to the CPU.

A board under full load gets hot; do not touch the heat sink while it runs. The work of this module is desk work, with no flying.

Common mistakes

Watch out

  • Treating a successful conversion as done, without checking how many operators fell back to the CPU
  • Not comparing the output with the original after export and after each graph optimisation
  • Using an opset newer than the board’s runtime knows, so the model will not load
  • Delivering the optimised file instead of the original, though it is tied to a specific runtime and hardware
  • Accumulating in FP16 and meeting errors or overflow that are hard to trace
  • Tuning a part that takes little time without profiling first
  • Timing the first run, which includes loading and memory allocation

Summary

  • The pipeline: export ONNX, compare outputs, optimise the graph, compile with the target’s tool, reduce numeric precision, and measure on the board; keep the original file as the deliverable
  • The opset must match the runtime. Fusing, such as folding BatchNorm into Conv, leaves the output unchanged but reduces memory traffic
  • Unsupported operators partition the graph. The Edge TPU partitions once, ONNX Runtime many times. The total time is and Amdahl caps the gain at
  • FP16 halves the bytes but has a limited range and resolution; accumulate at higher precision and check the model’s accuracy
  • Measure before tuning, and stack methods in order of risk to accuracy: fusion, then numeric precision, then smaller input

Check your understanding

  1. A float32 feature map of 1 × 32 × 56 × 56 passes through memory how many KiB when Conv, BatchNorm and ReLU are separate (5 passes), against when merged into one node (1 pass)?
  2. A one-channel Conv has weight and , followed by BatchNorm with , , , (ignore ). Find and .
  3. The accelerable part takes 85% of the total time and is made 20 times faster. By what factor is the total faster?
  4. A graph has 6 parts in a row, each taking 10 ms on the CPU and 1 ms on the accelerator. Part 4 is unsupported and each boundary crossing costs 2 ms. What is the total time of the prefix-only plan and of the multi-partition plan? (The image starts on the CPU and the result must return to the CPU.)
  5. What happens when 70,000 and are stored in FP16?
Answers
  1. One map is bytes = 392 KiB. Original: KiB; merged: 392 KiB (1,568 KiB less)
  2. , so and
  3. times
  4. Prefix only: parts 1 to 3 on the accelerator (), parts 4 to 6 on the CPU (), two crossings (): ms. Multi-partition: parts 1 to 3 on the accelerator (3), part 4 on the CPU (10), parts 5 to 6 on the accelerator (2), four crossings (): ms. All on the CPU takes 60 ms
  5. 70,000 exceeds the maximum 65,504 and becomes inf; is smaller than the smallest positive FP16 value (about ) so it becomes 0

Key formulas

Folding BatchNorm into Conv
Time of a partitioned graph
Amdahl bound

Key references

  1. ONNX. ONNX versioning (IR and operator set versions). ONNX documentation. link
  2. Microsoft. ONNX Runtime documentation. link
  3. Microsoft. Execution providers. ONNX Runtime documentation. link
  4. Microsoft. Graph optimizations. ONNX Runtime documentation. link
  5. NVIDIA. NVIDIA TensorRT documentation. link
  6. NVIDIA. Layer fusion catalog. NVIDIA TensorRT documentation. link
  7. OpenVINO. Model optimization (NNCF). OpenVINO documentation. link
  8. Coral. TensorFlow models on the Edge TPU (model requirements and compilation). Coral documentation. link
  9. Micikevicius, P., Narang, S., Alben, J., Diamos, G., Elsen, E., Garcia, D., Ginsburg, B., Houston, M., Kuchaiev, O., Venkatesh, G., & Wu, H. (2018). Mixed precision training. In International Conference on Learning Representations (ICLR 2018) (arXiv:1710.03740). link
  10. Amdahl, G. M. (1967). Validity of the single processor approach to achieving large scale computing capabilities. In Proceedings of the April 18–20, 1967, Spring Joint Computer Conference (AFIPS '67 Spring) (pp. 483–485). ACM. link
  11. Williams, S., Waterman, A., & Patterson, D. (2009). Roofline: An insightful visual performance model for multicore architectures. Communications of the ACM, 52(4), 65–76. link

Further reading

Study the assigned knowledge units in advance, review media and take the module quiz

In class / field

Lab or field practice from worksheets with a safety checklist

Learning evidence: Checked worksheets and quiz results

Module quiz

This is a formative self-check, not a graded exam

Knowledge domain: Artificial intelligence and computer vision · Sensors and embedded systems