ONNX Runtime
Loading...
Searching...
No Matches
OrtModelPackageApi Struct Reference

Stable API table for model package workflows. More...

#include <onnxruntime_c_api.h>

Public Member Functions

OrtStatus * CreateModelPackageOptionsFromSessionOptions (const OrtEnv *env, const OrtSessionOptions *session_options, OrtModelPackageOptions **out)
 Create model package options from session options.
 
void ReleaseModelPackageOptions (OrtModelPackageOptions *input)
 Release model package options.
 
OrtStatus * CreateModelPackageContext (const char *package_root, OrtModelPackageContext **out)
 Open a model package.
 
void ReleaseModelPackageContext (OrtModelPackageContext *input)
 Release a model package context.
 
OrtStatus * ModelPackage_GetSchemaVersion (const OrtModelPackageContext *ctx, int64_t *out_version)
 Get the model package schema version.
 
OrtStatus * ModelPackage_GetComponentCount (const OrtModelPackageContext *ctx, size_t *out_count)
 Get the number of components in a model package.
 
OrtStatus * ModelPackage_GetComponentNames (const OrtModelPackageContext *ctx, const char *const **out_names, size_t *out_count)
 Get the component names in a model package.
 
OrtStatus * ModelPackage_GetVariantCount (const OrtModelPackageContext *ctx, const char *component_name, size_t *out_count)
 Get the number of variants for a component.
 
OrtStatus * ModelPackage_GetVariantNames (const OrtModelPackageContext *ctx, const char *component_name, const char *const **out_variant_names, size_t *out_count)
 Get the variant names for a component.
 
OrtStatus * ModelPackage_GetVariantEpName (const OrtModelPackageContext *ctx, const char *component_name, const char *variant_name, const char **out_ep)
 Get the execution provider name declared by a variant.
 
OrtStatus * ModelPackage_ResolveStringRef (const OrtModelPackageContext *ctx, const char *base_dir, const char *input, int must_exist, const char **out_path)
 Resolve a package path reference.
 
OrtStatus * SelectComponent (const OrtModelPackageContext *context, const char *component_name, const OrtModelPackageOptions *options, OrtModelPackageComponentContext **out)
 Select a component and resolve its best matching variant.
 
void ReleaseModelPackageComponentContext (OrtModelPackageComponentContext *input)
 Release a selected component context.
 
OrtStatus * ModelPackageComponent_GetSelectedVariantName (const OrtModelPackageComponentContext *ctx, const char **out_name)
 Get the selected variant name.
 
OrtStatus * ModelPackageComponent_GetSelectedVariantFolderPath (const OrtModelPackageComponentContext *ctx, const char **folder_path)
 Get the selected variant directory.
 
OrtStatus * CreateSession (const OrtEnv *env, OrtModelPackageComponentContext *context, const OrtSessionOptions *session_options, OrtSession **session)
 Create a session for the selected component variant.
 

Detailed Description

Stable API table for model package workflows.

A model package contains one or more components, each with variants targeting execution providers and devices. Obtain this table from OrtApi::GetModelPackageApi().

Typical usage creates model package options from session options, opens a package context, selects a component, and creates an OrtSession from the selected variant. Objects returned by this API must be released with the corresponding release function in this table.

Since
Version 1.31.

Member Function Documentation

◆ CreateModelPackageContext()

OrtStatus * OrtModelPackageApi::CreateModelPackageContext ( const char *  package_root,
OrtModelPackageContext **  out 
)

Open a model package.

Parses the package manifest and metadata rooted at package_root.

Parameters
[in]package_rootPath to the model package root directory.
[out]outReceives the created context. Release with ReleaseModelPackageContext().

Returns
If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.

Since
Version 1.31.

◆ CreateModelPackageOptionsFromSessionOptions()

OrtStatus * OrtModelPackageApi::CreateModelPackageOptionsFromSessionOptions ( const OrtEnv *  env,
const OrtSessionOptions *  session_options,
OrtModelPackageOptions **  out 
)

Create model package options from session options.

Captures the execution provider configuration used to select a component variant.

Parameters
[in]envThe ORT environment.
[in]session_optionsSession options containing the execution provider configuration.
[out]outReceives the created options. Release with ReleaseModelPackageOptions().

Returns
If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.

Since
Version 1.31.

◆ CreateSession()

OrtStatus * OrtModelPackageApi::CreateSession ( const OrtEnv *  env,
OrtModelPackageComponentContext *  context,
const OrtSessionOptions *  session_options,
OrtSession **  session 
)

Create a session for the selected component variant.

When session_options is NULL, ONNX Runtime creates fresh session options and applies the selected variant's session and provider options. When session_options is non-NULL, the caller's options are used and package provider options are not applied; package path-valued session options are still added when the caller did not provide them.

Parameters
[in]envThe ORT environment.
[in]contextThe selected component context.
[in]session_optionsOptional caller-provided session options.
[out]sessionReceives the created session. Release with OrtApi::ReleaseSession().

Returns
If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.

Since
Version 1.31.

◆ ModelPackage_GetComponentCount()

OrtStatus * OrtModelPackageApi::ModelPackage_GetComponentCount ( const OrtModelPackageContext *  ctx,
size_t *  out_count 
)

Get the number of components in a model package.

Parameters
[in]ctxThe model package context.
[out]out_countReceives the component count.

Returns
If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.

Since
Version 1.31.

◆ ModelPackage_GetComponentNames()

OrtStatus * OrtModelPackageApi::ModelPackage_GetComponentNames ( const OrtModelPackageContext *  ctx,
const char *const **  out_names,
size_t *  out_count 
)

Get the component names in a model package.

The returned array and UTF-8 strings are owned by ctx and remain valid until ctx is released.

Parameters
[in]ctxThe model package context.
[out]out_namesReceives the component name array, or NULL when the package has no components.
[out]out_countReceives the number of names in out_names.

Returns
If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.

Since
Version 1.31.

◆ ModelPackage_GetSchemaVersion()

OrtStatus * OrtModelPackageApi::ModelPackage_GetSchemaVersion ( const OrtModelPackageContext *  ctx,
int64_t *  out_version 
)

Get the model package schema version.

Parameters
[in]ctxThe model package context.
[out]out_versionReceives the schema version.

Returns
If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.

Since
Version 1.31.

◆ ModelPackage_GetVariantCount()

OrtStatus * OrtModelPackageApi::ModelPackage_GetVariantCount ( const OrtModelPackageContext *  ctx,
const char *  component_name,
size_t *  out_count 
)

Get the number of variants for a component.

Parameters
[in]ctxThe model package context.
[in]component_nameUTF-8 component name.
[out]out_countReceives the variant count.

Returns
If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.

Since
Version 1.31.

◆ ModelPackage_GetVariantEpName()

OrtStatus * OrtModelPackageApi::ModelPackage_GetVariantEpName ( const OrtModelPackageContext *  ctx,
const char *  component_name,
const char *  variant_name,
const char **  out_ep 
)

Get the execution provider name declared by a variant.

The returned UTF-8 string is owned by ctx and remains valid until ctx is released. out_ep is set to NULL when the variant does not declare an execution provider.

Parameters
[in]ctxThe model package context.
[in]component_nameUTF-8 component name.
[in]variant_nameUTF-8 variant name.
[out]out_epReceives the execution provider name or NULL.

Returns
If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.

Since
Version 1.31.

◆ ModelPackage_GetVariantNames()

OrtStatus * OrtModelPackageApi::ModelPackage_GetVariantNames ( const OrtModelPackageContext *  ctx,
const char *  component_name,
const char *const **  out_variant_names,
size_t *  out_count 
)

Get the variant names for a component.

The returned array and UTF-8 strings are owned by ctx and remain valid until ctx is released.

Parameters
[in]ctxThe model package context.
[in]component_nameUTF-8 component name.
[out]out_variant_namesReceives the variant name array, or NULL when the component has no variants.
[out]out_countReceives the number of names in out_variant_names.

Returns
If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.

Since
Version 1.31.

◆ ModelPackage_ResolveStringRef()

OrtStatus * OrtModelPackageApi::ModelPackage_ResolveStringRef ( const OrtModelPackageContext *  ctx,
const char *  base_dir,
const char *  input,
int  must_exist,
const char **  out_path 
)

Resolve a package path reference.

Resolves content-addressed sha256:<hex>[/path] references and package-relative paths. When must_exist is nonzero, the resolved path must exist. The returned UTF-8 path is owned by ctx and remains valid until the next call to this function on the same context or until ctx is released.

Parameters
[in]ctxThe model package context.
[in]base_dirBase directory for relative references, or NULL to use the package root.
[in]inputUTF-8 path reference to resolve.
[in]must_existNonzero to require that the resolved path exists.
[out]out_pathReceives the resolved UTF-8 path.

Returns
If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.

Since
Version 1.31.

◆ ModelPackageComponent_GetSelectedVariantFolderPath()

OrtStatus * OrtModelPackageApi::ModelPackageComponent_GetSelectedVariantFolderPath ( const OrtModelPackageComponentContext *  ctx,
const char **  folder_path 
)

Get the selected variant directory.

The returned path is owned by ctx and remains valid until ctx is released.

Parameters
[in]ctxThe selected component context.
[out]folder_pathReceives the selected variant directory path.

Returns
If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.

Since
Version 1.31.

◆ ModelPackageComponent_GetSelectedVariantName()

OrtStatus * OrtModelPackageApi::ModelPackageComponent_GetSelectedVariantName ( const OrtModelPackageComponentContext *  ctx,
const char **  out_name 
)

Get the selected variant name.

The returned UTF-8 string is owned by ctx and remains valid until ctx is released.

Parameters
[in]ctxThe selected component context.
[out]out_nameReceives the selected variant name.

Returns
If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.

Since
Version 1.31.

◆ ReleaseModelPackageComponentContext()

void OrtModelPackageApi::ReleaseModelPackageComponentContext ( OrtModelPackageComponentContext *  input)

Release a selected component context.

Parameters
[in]inputThe component context to release. May be NULL.
Since
Version 1.31.

◆ ReleaseModelPackageContext()

void OrtModelPackageApi::ReleaseModelPackageContext ( OrtModelPackageContext *  input)

Release a model package context.

Parameters
[in]inputThe context to release. May be NULL.
Since
Version 1.31.

◆ ReleaseModelPackageOptions()

void OrtModelPackageApi::ReleaseModelPackageOptions ( OrtModelPackageOptions *  input)

Release model package options.

Parameters
[in]inputThe options to release. May be NULL.
Since
Version 1.31.

◆ SelectComponent()

OrtStatus * OrtModelPackageApi::SelectComponent ( const OrtModelPackageContext *  context,
const char *  component_name,
const OrtModelPackageOptions *  options,
OrtModelPackageComponentContext **  out 
)

Select a component and resolve its best matching variant.

The returned component context is independent of context and must be released with ReleaseModelPackageComponentContext().

Parameters
[in]contextThe model package context.
[in]component_nameUTF-8 component name.
[in]optionsOptions that provide the execution provider configuration for variant selection.
[out]outReceives the selected component context.

Returns
If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.

Since
Version 1.31.