onnx-diagnostic: investigate onnx models

https://github.com/sdpython/onnx-diagnostic/actions/workflows/documentation.yml/badge.svg https://badge.fury.io/py/onnx-diagnostic.svg GitHub Issues MIT License size https://img.shields.io/badge/code%20style-black-000000.svg https://codecov.io/gh/sdpython/onnx-diagnostic/branch/main/graph/badge.svg?token=Wb9ZGDta8J

onnx-diagnostic is mostly to experiment ideas.

Source are sdpython/onnx-diagnostic.

Some usefuls tools

import torch
from onnx_diagnostic.helpers import string_type

inputs = (
    torch.rand((3, 4), dtype=torch.float16),
    [
        torch.rand((5, 6), dtype=torch.float16),
        torch.rand((5, 6, 7), dtype=torch.float16),
    ]
)

# with shapes
print(string_type(inputs, with_shape=True))
>>> (T10s3x4,#2[T10s5x6,T10s5x6x7])
import onnx
from onnx_diagnostic.helpers import onnx_dtype_name

itype = onnx.TensorProto.BFLOAT16
print(onnx_dtype_name(itype))
print(onnx_dtype_name(7))
>>> BFLOAT16
>>> INT64

onnx_diagnostic.helpers.max_diff(), …

The documentation was updated on:

    2025-03-21 16:21:51.924650

With the following versions:

    numpy: 2.2.4
    ml_dtypes: 0.5.1
    sklearn: 1.6.1
    onnx: 1.18.0
    onnxruntime: 1.21.0+cu126
    onnxscript: 0.3.0.dev20250301
    torch: 2.8.0.dev20250319+cu126
    transformers: 4.50.0.dev0
    timm: 1.0.14
    has_onnxruntime_training: True

Size of the package:

                              lines  chars
    ext dir                               
    .py                        3273  95405
        torch_export_patches    791  28231
        torch_models             72   2191

Older versions