Scripts2026年7月19日·1 分钟阅读

ONNX Runtime — Cross-Platform High-Performance ML Inference

A cross-platform inference and training accelerator from Microsoft that runs ONNX models on CPUs, GPUs, and specialized hardware with optimized execution providers for production deployment.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
ONNX Runtime
直接安装命令
npx -y tokrepo@latest install 919bbca2-8349-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

ONNX Runtime (ORT) is Microsoft's production inference engine for machine learning models in the ONNX (Open Neural Network Exchange) format. It provides hardware-accelerated inference across different platforms and devices, serving as the bridge between training frameworks like PyTorch and TensorFlow and optimized deployment environments.

What ONNX Runtime Does

  • Runs ONNX models with automatic graph optimizations for faster inference
  • Supports 20+ execution providers including CUDA, TensorRT, DirectML, and CoreML
  • Provides C, C++, Python, C#, Java, JavaScript, and Objective-C APIs
  • Enables on-device inference for mobile (Android/iOS) and edge deployments
  • Includes training acceleration with optimized gradient computation via ORTModule

Architecture Overview

ORT loads an ONNX graph, applies graph optimizations (constant folding, operator fusion, memory planning), partitions nodes across available execution providers, and executes the optimized graph. Each execution provider implements a subset of ONNX operators using hardware-specific APIs. The session-based API allows concurrent inference with thread-safe model execution.

Self-Hosting & Configuration

  • Install platform-specific wheels via pip or language-specific package managers
  • Export models to ONNX from PyTorch using torch.onnx.export or from TensorFlow via tf2onnx
  • Configure execution providers and session options for hardware targeting
  • Use ONNX Runtime Model Optimizer (ORT Model Optimizer) for further quantization and pruning
  • Deploy on serverless platforms, containers, or edge devices with the same model file

Key Features

  • Automatic graph optimizations that accelerate inference without model changes
  • Quantization support (INT8, FP16) with minimal accuracy loss for deployment
  • Cross-platform binary size optimization for mobile deployment (under 1MB core)
  • ONNX Runtime Extensions for pre/post-processing operators in the same graph
  • Broad hardware support from NVIDIA GPUs to Apple Neural Engine to Qualcomm NPUs

Comparison with Similar Tools

  • TensorRT — NVIDIA-only with deeper GPU optimization; ORT is cross-platform with TensorRT as one backend
  • TFLite — mobile-focused for TensorFlow models; ORT handles any ONNX model on mobile
  • PyTorch (eager) — training-first with higher inference overhead; ORT is optimized for production serving
  • Triton Inference Server — orchestrates multiple models; ORT is the inference engine underneath
  • OpenVINO — Intel-optimized; ORT supports Intel hardware plus many other targets

FAQ

Q: Which frameworks can export to ONNX? A: PyTorch, TensorFlow, scikit-learn, XGBoost, LightGBM, Keras, and many others have ONNX exporters.

Q: Does ONNX Runtime support transformer models? A: Yes. It includes specialized optimizations for transformer architectures including attention fusion and Flash Attention integration.

Q: Can I use it for training, not just inference? A: Yes. ORTModule wraps PyTorch modules to accelerate training with the same graph optimizations used for inference.

Q: What is the performance improvement over native PyTorch? A: Typical speedups range from 1.5x to 4x for inference depending on the model architecture and hardware target.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产