DEV Community

Aman Bhawsar
Aman Bhawsar

Posted on

Building a Zero-Dependency Edge AI Inference Engine in C/AVX2 + Python

Can a standard Intel i5 CPU handle AI inference without an expensive GPU?

I wanted to explore this by building a lightweight Edge-AI inference engine from scratch using C, AVX2 and Python.

My focus was on three challenges: compute efficiency, memory bandwidth and real-world model compatibility.

  1. Bit-Sliced Ternary GEMM

I implemented ternary matrix multiplication using values {-1, 0, +1}.

Instead of traditional floating-point multiplication, the kernel uses bitwise operations and POPCNT.

Benchmark on an Intel i5 CPU:

380 GOP/s achieved

252 GOP/s with standard OpenBLAS in my test

Bit-exact results

  1. Delta-Frame Processing

For static-camera applications such as CCTV, safety monitoring and drones, most pixels often remain unchanged between frames.

I developed a gather-free INT8 delta-frame kernel that processes changed pixels instead of recomputing the entire frame.

In my tested workloads:

14×–124× speedup over the standard float BLAS baseline

Bit-exact results

  1. Testing with Real ONNX Models

I tested the engine against pretrained MobileNetV2 and CNN ONNX graphs, including:

Depthwise Convolution

BatchNorm folding

ReLU6

Residual connections

Maximum numerical difference against ONNX Runtime: 1.49e-07.

Why This Matters

This approach could be useful for:

Edge AI and industrial computer vision

CCTV and safety monitoring

Robotics and drones

NVIDIA Jetson deployments

CPU-based inference

Reducing cloud inference costs

I'm interested in collaborating with teams that already have PyTorch or ONNX models and want to optimize their inference pipelines.

I can benchmark one model layer initially and identify possible improvements in latency, memory usage and compute cost.

Question for the developer community:

Which bottleneck causes you the most trouble in production AI inference: compute, memory bandwidth, RAM usage or deployment complexity?

I'd love to hear your experiences.

edgeai #computervision #machinelearning #cpp #python #onnx #performance

Top comments (0)