Skip to content

ONNX

The onnx kind stores an ONNX model. Kind-specific fields, including tensor signatures and the operator-set version, are documented with the creation functions.

Create

Log

log_onnx

Create and upload an ONNX model entity.

Parameters:

Name Type Description Default
project str

Project name.

required
source SourcesOrListOfSources

Local ONNX model source path or paths.

required
name str

Entity name. If omitted, it is inferred from source.

None
drop_existing bool

Whether to drop an existing entity with the same name.

False
path str

Destination path. If omitted, it is generated.

None
description str

Human-readable entity description.

None
labels list[str]

Entity labels.

None
version str

Entity version.

None
framework str

Model framework.

None
algorithm str

Model algorithm.

None
parameters dict

Model parameters.

None
inputs list[dict]

Input tensor signatures. Each item can define name (str), dtype (str), shape (list[int]), scale (list[float]), zero_point (list[int]), and quantized_dimension (int).

None
outputs list[dict]

Output tensor signatures, with the same fields as inputs.

None
opset int

ONNX operator-set version.

None
**kwargs dict

Additional model specification parameters.

{}

Returns:

Type Description
ModelOnnx

Created ONNX model entity with uploaded files.

Examples:

Log a local ONNX model:

import digitalhub as dh

model = dh.log_onnx(
    project="my-project",
    name="image-classifier",
    source="./models/image-classifier.onnx",
    opset=17,
)

Register

register_onnx

Register an ONNX model entity for an existing source.

Parameters:

Name Type Description Default
project str

Project name.

required
source SourcesOrListOfSources

Path or URI of the existing ONNX model.

required
name str

Entity name. If omitted, it is inferred from source.

None
uuid str

Entity identifier.

None
version str

Entity version.

None
description str

Human-readable entity description.

None
labels list[str]

Entity labels.

None
embedded bool

Whether to embed the entity specification in the project specification.

False
extensions list[dict]

Entity extensions.

None
framework str

Model framework.

None
algorithm str

Model algorithm.

None
parameters dict

Model parameters.

None
inputs list[dict]

Input tensor signatures. Each item can define name (str), dtype (str), shape (list[int]), scale (list[float]), zero_point (list[int]), and quantized_dimension (int).

None
outputs list[dict]

Output tensor signatures, with the same fields as inputs.

None
opset int

ONNX operator-set version.

None
**kwargs dict

Additional model specification parameters.

{}

Returns:

Type Description
ModelOnnx

Registered ONNX model entity.

Examples:

Register an ONNX model that already exists in remote storage:

import digitalhub as dh

model = dh.register_onnx(
    project="my-project",
    name="registered-image-classifier",
    source="s3://my-bucket/models/image-classifier.onnx",
    opset=17,
)

New

new_model

Create a new model entity in the backend.

Parameters:

Name Type Description Default
project str

Project name.

required
name str

Entity name.

required
kind str

Entity kind.

required
uuid str

Entity identifier.

None
version str

Entity version.

None
description str

Human-readable entity description.

None
labels list[str]

Entity labels.

None
embedded bool

Whether to embed the entity specification in the project specification.

False
path str

Entity path on the local file system or remote storage. It is also the destination path for uploads.

None
extensions list[dict]

Entity extensions.

None
**kwargs dict

Additional entity specification parameters.

{}

Returns:

Type Description
Model

Created model entity.

import digitalhub as dh

model = dh.new_model(
    project="my-project",
    name="image-classifier",
    kind="onnx",
    path="s3://my-bucket/models/image-classifier.onnx",
    opset=17,
)

Retrieve and manage

Use the shared Model management reference to retrieve, update, or delete an ONNX Model.

ONNX models can be used as source models in the TVM build workflow. See the TVM runtime for the full workflow.