ONNXPruner: ONNX-Based General Model Pruning Adapter

Dongdong Ren, Wenbin Li, Tianyu Ding, Lei Wang, Qi Fan, Jing Huo, Hongbing Pan, Yang Gao

TL;DR

ONNXPruner is a framework-agnostic model pruning adapter that uses the ONNX format to bridge the gap between different deep learning platforms and hardware. By introducing "node association trees," it automatically maps complex layer dependencies and evaluates filter importance across entire groups of connected nodes, leading to better performance and easier deployment across diverse architectures.

What Problem Does This Paper Address?

Deep neural networks (DNNs) are powerful but often too bulky for edge devices. Model pruning—the process of removing redundant parameters—is a go-to solution for compression. However, practitioners face two major hurdles:

  1. Framework Lock-in: Most pruning algorithms are hard-coded for specific frameworks like PyTorch or TensorFlow. Moving a pruned model from development to a specialized deployment platform often requires manual, labor-intensive re-implementation.
  2. The Cascading Effect: In modern architectures (like ResNets or Transformers), layers are intricately connected. Pruning one node often forces changes in several "associated" nodes. Existing methods often struggle to track these dependencies automatically or only evaluate filter importance based on a single layer, ignoring the "ripple effect" on subsequent parts of the network.

Methods

The authors propose ONNXPruner, which operates directly on the Open Neural Network Exchange (ONNX) format. This makes it a "universal adapter" that can take a model from any major framework and prepare it for any supported hardware.

The core technical innovations are:

  • Node Association Trees: Instead of treating layers as isolated units, ONNXPruner builds a hierarchical tree for every pruned node. It uses a "Node Attribute Library" to categorize operators (e.g., Conv is a root/leaf, Relu is a child to pass through) and automatically identifies all downstream nodes affected by a pruning decision.
  • Tree-level Evaluation: Standard pruning looks at a filter's weight in one layer (e.g., $\ell_1$-norm). ONNXPruner evaluates importance by looking at the entire tree. It calculates a joint importance score that considers both the filter being removed and the corresponding input channels in all associated downstream layers.
  • Four Pruning Structures: The paper formalizes how to calculate importance for four common connectivity patterns: one-to-one, one-to-many (feature reuse), many-to-one (residual connections), and many-to-many (hybrids).

Datasets

The researchers validated ONNXPruner across a wide range of tasks and standard benchmarks:

  • Image Classification: CIFAR-10, CIFAR-100, and the massive ImageNet dataset.
  • Semantic Segmentation: PASCAL VOC 2012.
  • Architectures: They tested everything from "classic" models like AlexNet and VGG to modern heavyweights like ResNet50, SqueezeNet, and even Vision Transformers (ViT).

Key Insights and Ideas

  • The "Neighborhood" Matters: The most significant "aha moment" is that evaluating a filter's importance in isolation is suboptimal. By considering the "node association tree," the pruner realizes that a filter might look unimportant in Layer A but be crucial for a specific feature in Layer B.
  • Automation via ONNX: By leveraging the standardized graph representation of ONNX, the authors created a tool that "just works" on over 35 types of DNN operators without needing custom code for every new model architecture.
  • Tree-Level vs. Node-Level: The paper shows a notable discrepancy (over 20% at low pruning rates) in which filters are chosen for removal when using tree-level evaluation versus traditional single-node evaluation. This suggests that traditional pruning has been "blind" to important structural dependencies.

Key Results

ONNXPruner consistently outperformed baseline pruning methods (like standard $\ell_1$, $\ell_2$, and Hrank) across all tested models:

  • Accuracy Gains: On VGG16 with CIFAR-10, ONNXPruner improved classification accuracy by 0.8% to 1.4% over standard baselines at various pruning rates.
  • ImageNet Efficiency: For ResNet50 on ImageNet, it achieved a higher pruned Top-1 accuracy (75.44%) with a smaller accuracy drop compared to the original unpruned model.
  • Versatility: It successfully pruned complex models like Vision Transformers (ViT) and segmentation networks (FCN, PSPNet) which are typically difficult to handle with generic tools.
  • Low Overhead: Constructing the association tree for a complex model like ResNet takes only about 1.93 seconds on a modern GPU, a negligible fraction of the total training/fine-tuning time.

Limitations and Future Work

While ONNXPruner is highly versatile, the authors note a few areas for growth:

  • Operator Support: While it supports over 35 operators, the library needs to expand to cover more niche or emerging layer types.
  • Recurrent Networks: The current version focuses primarily on CNNs and Transformers. Future work aims to better accommodate architectures like Bidirectional LSTMs or GRUs.
  • Efficiency: There is still room to further optimize the efficiency of the tree-level evaluation process for extremely deep or wide networks.

Summary updated

BibTeX
@article{ren2025onnxpruner,
  author = {Dongdong Ren and Wenbin Li and Tianyu Ding and Lei Wang and Qi Fan and Jing Huo and Hongbing Pan and Yang Gao},
  title = {{ONNXPruner: ONNX-Based General Model Pruning Adapter}},
  journal = {IEEE Trans. Pattern Anal. Mach. Intell.},
  year = {2025},
  doi = {10.1109/tpami.2025.3554560},
}
Figure