Skip to content

TVM IR

The tvm-ir kind stores a Relax IR model produced by a tvm+build Run. Kind-specific fields, including source format, tensor signatures, and input handling, are documented with the creation functions.

The bundle contains model.relax.json, metadata.json and optional params.bin. Use the build action to convert ONNX/TFLite first; registering a Model does not convert the source or create an IR.

Create

Log

log_tvm_ir

Create and upload a TVM IR model entity.

Parameters:

Name Type Description Default
project str

Project name.

required
source SourcesOrListOfSources

Local Relax IR bundle containing model.relax.json and metadata.json; include params.bin when the weights are detached.

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
entry str

Relax entry function, for example main.

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
source_format TvmSourceFormat

Source format: auto, onnx, or tflite.

None
keep_params_in_input bool

Keep model weights as input variables in params.bin instead of folding them into the Relax IR.

None
sanitize_input_names bool

Sanitize input names when importing a model through the ONNX frontend.

None
**kwargs dict

Additional model specification parameters.

{}

Returns:

Type Description
ModelTvmIr

Created TVM IR model entity with uploaded files.

Examples:

Upload an IR bundle already produced by tvm+build. This does not convert ONNX:

import digitalhub as dh

model = dh.log_tvm_ir(
    project="my-project",
    name="resnet18-relax",
    source="./build/resnet18-ir/",
    source_format="onnx",
    entry="main",
)

Register

register_tvm_ir

Register a TVM IR model entity for an existing source.

Parameters:

Name Type Description Default
project str

Project name.

required
source SourcesOrListOfSources

Directory or URI of an existing Relax IR bundle, including its metadata.

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
entry str

Relax entry function, for example main.

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
source_format TvmSourceFormat

Source format: auto, onnx, or tflite.

None
keep_params_in_input bool

Keep model weights as input variables in params.bin instead of folding them into the Relax IR.

None
sanitize_input_names bool

Sanitize input names when importing a model through the ONNX frontend.

None
**kwargs dict

Additional model specification parameters.

{}

Returns:

Type Description
ModelTvmIr

Registered TVM IR model entity.

Examples:

Register a TVM IR model that already exists in remote storage:

import digitalhub as dh

model = dh.register_tvm_ir(
    project="my-project",
    name="registered-resnet18-relax",
    source="s3://my-bucket/models/resnet18-ir/",
    entry="main",
)

New

Create a Model reference to an already uploaded bundle; this call does not compile or upload files.

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="resnet18-relax",
    kind="tvm-ir",
    path="s3://my-bucket/models/resnet18-ir/",
    source_format="onnx",
    entry="main",
)

Retrieve and manage

Use the shared Model management reference to retrieve, update, or delete a TVM IR Model.

See the TVM runtime, including its build and compile workflows.