High-Performance C++ AI, Simplified

Case Study: A 3.0x End-to-End Speedup for YOLOv8 with xInfer

In real-world applications like robotics and autonomous vehicles, the "model's FPS" is a lie. The true measure of performance is **end-to-end latency**: the wall-clock time from the moment a camera frame is captured to the moment you have a final, actionable result. This pipeline is often crippled by slow, CPU-based pre- and post-processing.

Today, we're publishing our first benchmark to show how `xInfer` solves this problem. We tested a complete object detection pipeline using the popular YOLOv8n model on a 1280x720 video frame. The results are not just an incremental improvement; they are a leap forward.

The Benchmark: End-to-End Latency

Hardware: NVIDIA RTX 4090 GPU, Intel Core i9-13900K CPU.

Implementation Pre-processing Inference Post-processing (NMS) Total Latency (ms) Relative Speedup
Python + PyTorch 2.8 ms (CPU) 7.5 ms (cuDNN) 1.2 ms (CPU) 11.5 ms 1x (Baseline)
C++ / LibTorch 2.5 ms (CPU) 6.8 ms (JIT) 1.1 ms (CPU) 10.4 ms 1.1x
C++ / xInfer 0.4 ms (GPU) 3.2 ms (TensorRT FP16) 0.2 ms (GPU) 3.8 ms 3.0x

Analysis: Why We Are 3x Faster

The results are clear. A standard C++/LibTorch implementation offers almost no real-world advantage over Python because it's stuck with the same fundamental bottlenecks. `xInfer` wins by attacking these bottlenecks directly:

1. Pre-processing: 7x Faster

The standard pipeline uses a chain of CPU-based OpenCV calls. `xInfer` uses a single, fused CUDA kernel in its preproc::ImageProcessor to perform the entire resize, pad, and normalize pipeline on the GPU. We eliminate the CPU and the slow data transfer.

2. Inference: 2.3x Faster

While LibTorch's JIT is good, `xInfer`'s builders::EngineBuilder leverages the full power of TensorRT's graph compiler and enables FP16 precision, which uses the GPU's Tensor Cores for a massive speedup.

3. Post-processing: 6x Faster

This is the killer feature. A standard implementation downloads thousands of potential bounding boxes to the CPU to perform Non-Maximum Suppression (NMS). `xInfer` uses a hyper-optimized, custom CUDA kernel from postproc::detection to perform NMS on the GPU. Only the final, filtered list of a few boxes is ever sent back to the CPU.

Conclusion: Performance is a Feature

For a real-time application that needs to run at 60 FPS (16.67 ms per frame), a baseline latency of 11.5 ms leaves very little room for any other application logic. An `xInfer`-powered application, with a latency of just 3.8 ms, has ample headroom.

This is the philosophy of `xInfer` in action. By providing a complete, GPU-native pipeline, we don't just make your application faster; we enable you to build products that were previously impossible.

Explore our object detection solution in the Model Zoo documentation.