CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-onnx

Open Neural Network Exchange for AI model interoperability and machine learning frameworks

Pending
Overview
Eval results
Files

version-conversion.mddocs/

Version Conversion

Convert ONNX models between different IR versions and operator set versions to maintain compatibility across framework versions. This module enables model migration and ensures compatibility with different ONNX runtime versions.

Capabilities

Version Conversion

Convert models between different ONNX versions with automatic operator and type updates.

def convert_version(model, target_version):
    """
    Convert ONNX model to target version.

    Parameters:
    - model: ModelProto to convert
    - target_version: Target ONNX opset version (integer)

    Returns:
    ModelProto: Converted model with updated operators and types

    Raises:
    ValueError: If conversion is not possible or target version is invalid
    RuntimeError: If conversion fails due to unsupported operators
    """

Usage Examples

Basic Version Conversion

import onnx
from onnx import version_converter

# Load model with older opset version
model = onnx.load_model("model_v11.onnx")
print(f"Original opset version: {model.opset_import[0].version}")

# Convert to newer version
try:
    converted_model = version_converter.convert_version(model, 14)
    print(f"Converted to opset version: {converted_model.opset_import[0].version}")
    
    # Validate converted model
    onnx.checker.check_model(converted_model)
    print("Conversion successful and model is valid!")
    
    # Save converted model
    onnx.save_model(converted_model, "model_v14.onnx")
    
except Exception as e:
    print(f"Conversion failed: {e}")

Install with Tessl CLI

npx tessl i tessl/pypi-onnx

docs

backend-integration.md

index.md

model-composition.md

model-construction.md

model-hub.md

model-io.md

model-validation.md

numpy-integration.md

operator-definitions.md

reference-implementation.md

shape-inference.md

text-processing.md

version-conversion.md

tile.json