Kernel fusion combines adjacent operators into one optimized operator. By reducing intermediate operations and execution overhead, it can improve inference latency while preserving model behavior. section 4.3.3 section 10.4
Fusion operates on a computation graph rather than changing the model’s intended calculation. A graph optimizer can replace consecutive nodes with a semantics-preserving fused node, either automatically or through a custom operator. section 10.3 section 10.4
Practical fusion work typically includes these checks:
- Identify expensive or frequently executed operator sequences through profiling. section 10.4
- Replace compatible nodes with a fused implementation, such as combining EyeLike and Add into AddEyeLike. section 10.3
- Compare original and optimized outputs before claiming a speedup. section 10.3
- Benchmark representative inputs and deployment hardware because the benefit depends on execution costs. section 10.3 section 4.3.3
Fusing EyeLike and Add
An ONNX graph containing EyeLike followed by Add can replace both nodes with AddEyeLike. In the demonstrated benchmark, 10,000 runs took 1.142791 seconds before fusion and 0.863603 seconds afterward, while the maximum output difference was zero. section 10.3
Figure 10.12 Comparing part of the GPT-2 ONNX-converted model’s graph, before and after optimization, showing Skip Layer Normalization Fusion applied
Inspect a GPT-2 ONNX graph before and after Skip Layer Normalization Fusion to see how multiple transformer operations become one optimized operation. section 10.4

