Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:Onnx Onnx Model Merging

From Leeroopedia


Knowledge Sources
Domains Model_Composition, Graph_Transformation
Last Updated 2026-02-10 00:00 GMT

Overview

A composition mechanism that combines two ONNX models into a single model by connecting specified outputs of the first model to inputs of the second model.

Description

Model merging is the core operation of ONNX model composition. Given two models and an I/O map specifying how to connect them, the merge operation creates a single unified model containing all nodes, initializers, and metadata from both source models. The merged graph's inputs are the union of both models' inputs (minus those consumed by the I/O map), and the outputs are the union of both models' outputs (minus those feeding into the I/O map).

The operation also handles opset compatibility (requiring both models to use the same opset versions), optional namespace prefixing (to avoid name collisions), metadata property merging, and local function merging. The resulting model is automatically validated via checker.check_model.

Usage

Use this principle when you need to create a pipeline of two ONNX models (e.g., a feature extractor followed by a classifier), combine a preprocessing model with a main model, or construct complex model architectures from independently trained components.

Theoretical Basis

Model merging creates a composed graph:

Failed to parse (syntax error): {\displaystyle G_{\text{merged}} = G_1 \cup G_2 \text{ with } \text{io\_map} \text{ connecting edges} }

The composition process:

  1. Validate opset compatibility between models
  2. Apply optional namespace prefixes
  3. Merge graph nodes, initializers, and value infos
  4. Connect edges according to io_map
  5. Compute final input/output sets
  6. Validate the merged model

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment