Hand-coding YOLO and ResNet in TensorRT, layer by obsessive layer
It hand-builds popular vision networks with raw TensorRT APIs so you can modify layers, inspect intermediate tensors, and avoid treating inference as a black box.

What it does
TensorRTx is a collection of reference implementations for running well-known computer vision models—ResNet, YOLO variants, MobileNet, ViT, and others—using NVIDIA’s TensorRT C++ API. Instead of converting PyTorch or TensorFlow graphs through an ONNX parser, you export weights to a plain-text .wts file and define every layer manually in code. The result is a compiled TensorRT engine that runs inference without the usual parser intermediaries.
The interesting bit
The project treats parser-free construction as a feature, not a burden: the author argues that hand-rolling the network makes it easier to merge layers, swap operations, or wire preprocessing directly into the graph, and to inspect intermediate tensors when things go wrong. It is essentially a hands-on textbook for how these networks map to TensorRT primitives.
Key highlights
- Covers dozens of models, from LeNet and AlexNet to YOLOv11, YOLOv9, ViT, and DETR, with weights often sourced from PyTorch reference repos.
- Uses a custom
.wtstext format to ferry weights from PyTorch/TensorFlow into the TensorRT builder. - Explicitly targets TensorRT 8.x as the stable compatibility sweet spot; TensorRT 7.x and 10.x are marked as not recommended, and some models are pinned to specific SDK versions.
- Includes newer experimental ports such as a YOLO11 example written in Tripy, NVIDIA’s newer Python programming model for TensorRT.
Caveats
- The top-level CMake build that compiles multiple subprojects at once is still under development, and the README warns that most subprojects are not adapted to it yet.
- Model support is fragmented across TensorRT versions; you need to check individual subfolder READMEs to see whether your SDK version matches.
Verdict
Grab this if you are optimizing inference pipelines and need to surgically alter a network graph beyond what an ONNX parser allows, or if you are trying to understand how modern CV architectures decompose into TensorRT layers. Skip it if you just want a one-click converter and do not care about the internals.
Frequently asked
- What is wang-xinyu/tensorrtx?
- It hand-builds popular vision networks with raw TensorRT APIs so you can modify layers, inspect intermediate tensors, and avoid treating inference as a black box.
- Is tensorrtx open source?
- Yes — wang-xinyu/tensorrtx is open source, released under the MIT license.
- What language is tensorrtx written in?
- wang-xinyu/tensorrtx is primarily written in C++.
- How popular is tensorrtx?
- wang-xinyu/tensorrtx has 7.8k stars on GitHub.
- Where can I find tensorrtx?
- wang-xinyu/tensorrtx is on GitHub at https://github.com/wang-xinyu/tensorrtx.