HAGAHA Farsamada

ONNX iyo Model wada shaqayn

ONNX (Open Neural Network Exchange) is an open file format and operator standard for machine learning models, announced by Facebook and Microsoft in September 2017 and now governed by the Linux Foundation.

Dhageyso hagahanAI-waa laga sheekeeyay · ~8 min

Boggaan9 daqiiqo akhri
  1. Dulmar
  2. Qaadashada furaha
  3. quusid qoto dheer
  4. Exporting and checking a small PyTorch model
  5. Dhaqangelinta Adduunka-dhabta ah
  6. Mustaqbalka ONNX iyo Model wada shaqaynta
  7. Ku dhaqangelinta
  8. Ilaha iyo akhrin dheeraad ah
  9. Sii wad Sahaminta
  10. Su'aalaha soo noqnoqda

Dulmar

It lets a model trained in one framework, such as PyTorch, be saved as a portable computation graph and run by a different engine on servers, phones, browsers or specialized chips.

Qaadashada furaha

  1. ONNX is an open format that stores a trained model as a graph of standardized operators plus its weights, so different engines can run it.
  2. Facebook and Microsoft announced ONNX in September 2017, and it became a Linux Foundation AI graduate project in November 2019.
  3. Every ONNX model declares versioned operator sets, and any change to an operator's behavior must ship as a new operator version.
  4. ONNX Runtime splits a model across hardware execution providers such as CUDA, TensorRT, DirectML, OpenVINO and QNN, with CPU as the fallback.
  5. Models larger than the 2 GB Protocol Buffers limit store their weights in external data files next to the graph.

quusid qoto dheer

ONNX, the Open Neural Network Exchange, is a shared language for describing trained machine learning models. A model in ONNX form is a computation graph: a list of operations, such as matrix multiplication, convolution or softmax, connected by the tensors (multi-dimensional arrays of numbers) that flow between them, together with the learned weights. Because the graph uses a standard set of operators with precisely defined behavior, any software that implements those operators can run the model, regardless of which framework trained it. This separation of training from deployment is what model interoperability means in practice.

The format is defined by the ONNX intermediate representation (IR) specification and stored as a Protocol Buffers file, a compact binary encoding developed by Google. The top-level object is a model, which records the IR version, the operator sets it relies on, metadata such as the producing tool, and the graph. The graph holds nodes, each naming an operator type, its inputs, its outputs and fixed attributes such as a convolution's kernel size. Initializers store constant tensors, usually the weights. Inputs and outputs are declared with a data type and shape, and a dimension can be a symbolic name such as batch_size instead of a fixed number. The specification requires nodes to be listed in topological order, so every value is produced before it is used, with no cycles, and every output name must be unique within a graph.

Versioning is the part of ONNX that makes long-term compatibility possible. Operators are grouped into operator sets, or opsets, identified by a domain and an integer version. The default domain covers neural network operators, and ONNX-ML adds operators for classical, non-neural machine learning algorithms. Every model must declare the opsets it uses. Under the versioning rules, any change to an operator's inputs, outputs, attributes, supported types or meaning is a breaking change that must appear as a new operator version in a new opset. A runtime that supports opset 17 therefore knows exactly what every operator in an opset 17 model does. The ONNX versioning table runs from ONNX 1.0, with IR version 3 and opset 1, to ONNX 1.23.0, with IR version 14 and opset 28.

ONNX began inside Facebook's PyTorch team under the name Toffee and was renamed and announced jointly by Facebook and Microsoft in September 2017. IBM, Huawei, Intel, AMD, Arm and Qualcomm later announced support, and in October 2017 Microsoft said it would bring its Cognitive Toolkit and Project Brainwave into the effort. On November 14, 2019, the format became a graduate project of the Linux Foundation's LF AI Foundation, which TechCrunch described as a step toward vendor-neutral governance, with more than 30 companies contributing code. The license moved from MIT to Apache 2.0. Only the format joined the foundation; ONNX Runtime, the inference engine Microsoft had open-sourced about a year earlier, stayed a separate Microsoft-led project.

In a typical workflow, a developer trains a model in PyTorch and calls torch.onnx.export. Since PyTorch 2.9, the default exporter is built on torch.export, which traces the model ahead of time into a graph of basic operations, removes most Python control flow and records shape constraints. The developer marks which dimensions may vary, such as batch size or text length, chooses an opset, and can ask the exporter to verify the result with ONNX Runtime. The resulting .onnx file is then loaded by a runtime. ONNX Runtime splits the graph among execution providers, plug-ins for specific hardware: each provider in a priority list claims the nodes it can run, and the default CPU provider runs whatever is left. Higher-level tools wrap this process; Hugging Face Optimum can export a Transformers model in one command, validate the outputs against the original, and split encoder-decoder models into separate files so the encoder runs once while the decoder loops.

ONNX is not the only way to move models around. Framework-native formats, such as PyTorch's saved programs, keep every framework feature but tie deployment to that framework's runtime. Vendor formats, such as compiled TensorRT engines, are faster on one family of hardware but are not portable. ONNX sits between them: broadly supported, with a stable specification, but limited to what its operators can express. Weight-only formats, which store tensors but not the computation graph, solve a different problem: sharing parameters for use in a framework that already knows the architecture.

The limits are real. Not every framework operation has an ONNX equivalent, so custom layers may need custom operators that only some runtimes support. Dynamic behavior is hard to capture: PyTorch's documentation notes that loops are not exported directly and points to explicit control-flow operators instead. If dynamic dimensions are not declared, the exporter freezes the example input's shapes, so a text model may only accept one length. Protocol Buffers files are limited to 2 GB, so larger models store their weights as external data files beside the graph. Optimizations can reduce portability: Optimum warns that some ONNX Runtime-specific graph optimizations produce files that OpenVINO or TensorRT cannot run. Small numerical differences between runtimes are normal, which is why exporters compare outputs within a tolerance instead of expecting exact matches.

In practice ONNX costs nothing to use: the format, the onnx Python package and ONNX Runtime are open source. The real costs are engineering time to make a model export cleanly, testing on each target runtime, and keeping the opset version aligned with what the deployment engine supports. ONNX Runtime offers APIs for Python, C#, JavaScript, Java and C++, among others, and runs on Linux, Windows, macOS, iOS, Android and in web browsers.

04Tusaale la shaqeeyay

Exporting and checking a small PyTorch model

  1. Build or load a small PyTorch image classifier and put it in evaluation mode.

  2. Call torch.onnx.export with an example input of shape 1 by 3 by 224 by 224, and declare the batch dimension as dynamic using dynamic_shapes.

  3. Open the saved file with the onnx Python package and run its checker to confirm the graph is valid.

  4. Load the file in ONNX Runtime with the provider list CUDAExecutionProvider then CPUExecutionProvider.

  5. Feed the same random input with a batch of 4 to both PyTorch and ONNX Runtime.

  6. Compare outputs element by element and confirm the largest absolute difference is below a small tolerance such as 0.0001.

Maxay ku tusaysaa

The learner has a portable .onnx file that accepts any batch size and produces the same predictions as the PyTorch model within a numerical tolerance. If the batch of 4 fails, the dynamic dimension was not declared, which is the most common export mistake.

Dhaqangelinta Adduunka-dhabta ah

Microsoft products: the ONNX Runtime website says the engine powers AI features in Windows, Office, Azure Cognitive Services and Bing, running models that were exported to the ONNX format.

Hugging Face models: the command optimum-cli export onnx --model gpt2 gpt2_onnx/ exports a Transformers model, then checks that the ONNX outputs match the original within a tolerance such as 0.0001.

Hardware portability: one ONNX file can run on Nvidia GPUs through the CUDA or TensorRT execution providers, on Windows GPUs through DirectML, on Intel hardware through OpenVINO, or on Qualcomm chips through QNN.

In-browser and mobile inference: ONNX Runtime Web runs exported models inside a web browser, and ONNX Runtime Mobile targets Android and iOS apps, so no Python installation is needed on the device.

Framework handoff: Hugging Face's documentation gives the example of exporting a model trained in PyTorch to ONNX and then importing it into Nvidia TensorRT or Intel OpenVINO for optimized serving.

Mustaqbalka ONNX iyo Model wada shaqaynta

The ONNX specification keeps expanding to cover newer workloads. The IR documentation records multi-device configuration support added in IR version 11, and the type list now includes 8-bit, 6-bit, 4-bit and 2-bit numeric formats used for compressed models, reflecting the shift toward running quantized language models on local hardware. The versioning table shows opset 28 shipping with ONNX 1.23.0. On the tooling side, PyTorch moved its default exporter to the torch.export-based path in version 2.9, deprecated older options such as dynamic_axes for that path, and removed the fallback to the older exporter in version 2.11. That transition aims to make exports more faithful to the original program, but models that rely on Python-level control flow still need rewriting with explicit control-flow operators. Open questions include how well a static graph format can represent large generative models whose inference involves caches, variable-length loops and sampling, which tools such as onnxruntime-genai and Optimum handle partly outside the graph, and how to keep hardware-specific optimizations from fragmenting a format whose value depends on portability. The number of execution providers listed by ONNX Runtime, spanning CPUs, GPUs, NPUs and browsers, suggests that hardware vendors still treat ONNX as a common entry point, though support levels vary and several providers are marked as previews.

Ku dhaqangelinta

Maxay muhiim u tahay

  • Qiimaha iyo miisaaniyada. Go'aamada qaab-dhismeedku waxay horseedaan waxqabadka iyo kharashka hawlgalka sannadaha.
  • Go'aamo cad. Waxbarashada farsamada waxay ka caawisaa kooxaha inay doortaan xidhmo sax ah, ma aha oo kaliya kan ugu cusub.
  • Xakamaynta tayada. Doorashooyinka injineernimada ee wanaagsan waxay yareeyaan shilalka la isku halleyn karo ee wax soo saarka.

Iska ilaali

  • Hagaajinta hal bartilmaameed waxay qarin kartaa daciifnimada nidaamka ballaaran.
  • Kaabayaasha dhaqaalaha iyo dayactirka inta badan waa la dhayalsadaa.
  • Nabadgelyada iyo daldaloolada u fiirsashada ayaa kori kara marka nidaamyadu noqdaan kuwo aad u adag.

Tallaabooyinka xiga

  1. Qeex daahida, tayada, iyo bartilmaameedyada qiimaha ka hor inta aan la hirgelin.
  2. Benchmark marka la eego culeyska dhabta ah iyo xaaladaha xogta.
  3. La socodka qalabka khaladaadka, leexashada, iyo saamaynta isticmaalaha.
  4. U diyaari dib-u-noqoshada iyo dariiqyada jawaab-celinta dhacdada ka hor inta aanad miisaan.

Ilaha iyo akhrin dheeraad ah

  1. ONNX project, GitHubOpen Neural Network Exchange Intermediate Representation (ONNX IR) Specification
  2. ONNX project, GitHubONNX Versioning
  3. TechCrunchThe ONNX format becomes the newest Linux Foundation project
  4. ONNX Runtime documentationONNX Runtime Execution Providers
  5. MicrosoftONNX Runtime
  6. PyTorch documentationtorch.onnx
  7. Hugging FaceExport a model to ONNX with optimum.exporters.onnx
  8. WikipediaOpen Neural Network Exchange

Sii wad Sahaminta

Warqad bilaash ah

Hel warbixinta maalinlaha ah ee AI

Saddex sheeko oo la xaqiijiyay oo AI ah maalin kasta oo shaqo ah, oo lagu qoray Ingiriis fudud. Bilaash had iyo jeer, aan xayaysiis lahayn.

Hal iimayl maalin kasta oo shaqo ah. Ka bax hal gujin. Marna ma iibinno ama ma wadaagno ciwaankaaga.

Is tijaabi

Take the ONNX and Model Interoperability quiz

Fikrad degdeg ah oo ku saabsan jawaab kasta, iyo shahaado la wadaajin karo oo leh aqoonsi la xaqiijin karo markaad ka gudubto koorso.

Bilow kedis

Taageer waxbarashada AI bilaashka ah. AI Understanding waa 501(c)(3) aan faa'iido doon ahayn — xayaysiis la'aan, albaab lacag ah ma jiro, had iyo jeer. Samee deeq

Su'aalaha soo noqnoqda

What is ONNX and Model Interoperability?

ONNX (Open Neural Network Exchange) is an open file format and operator standard for machine learning models, announced by Facebook and Microsoft in September 2017 and now governed by the Linux Foundation. It lets a model trained in one framework, such as PyTorch, be saved as a portable computation graph and run by a different engine on servers, phones, browsers or specialized chips.

Mushkiladda xudunta u ah ee ONNX xalliso waa maxay?

ONNX waxay qeexdaa qaab la wadaago si moodeel lagu tababaray qaab qaabaysan loo geyn karo deegaan kale iyada oo aan dib loo qorin.

Sidee faylka ONNX u matalaa qaab?

Qaabka ONNX waa garaaf xisaabeed kaas oo noodhadhkiisu ay yihiin hawl-wadeeno la jaanqaadaya (sida Conv, MatMul, Relu) oo ay ku xidhan yihiin kiraystayaasha.

What does the acronym ONNX stand for?

ONNX is short for Open Neural Network Exchange, the open format and ecosystem for representing machine-learning models.

Waqtiga Runtime-ga ONNX, waa maxay 'bixiye bixiye'?

Bixiyeyaasha fulinta waa dhabarka dambe ee la xidhi karo (CPU, CUDA, TensorRT, iyo in ka badan) oo ONNX Runtime ay isticmaasho si ay u maamusho hawl wadeenada mid kastaa si fiican ayuu u taageeraa.

Muxuu qeexayaa nooca 'opset' (operator set) ee qaabka ONNX?

Nooca cusubi waxa uu qeexayaa qaabka la habeeyey iyo nooca hawl wadeenada moodelku ku tiirsan yahay, isaga oo hubinaya in runtimes ku habboon u fasiraan si sax ah.