![]() |
ONNX Runtime
|
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. | |
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.
| OrtStatus * OrtModelPackageApi::CreateModelPackageContext | ( | const char * | package_root, |
| OrtModelPackageContext ** | out | ||
| ) |
Open a model package.
Parses the package manifest and metadata rooted at package_root.
| [in] | package_root | Path to the model package root directory. |
| [out] | out | Receives the created context. Release with ReleaseModelPackageContext(). |
| 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.
| [in] | env | The ORT environment. |
| [in] | session_options | Session options containing the execution provider configuration. |
| [out] | out | Receives the created options. Release with ReleaseModelPackageOptions(). |
| 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.
| [in] | env | The ORT environment. |
| [in] | context | The selected component context. |
| [in] | session_options | Optional caller-provided session options. |
| [out] | session | Receives the created session. Release with OrtApi::ReleaseSession(). |
| OrtStatus * OrtModelPackageApi::ModelPackage_GetComponentCount | ( | const OrtModelPackageContext * | ctx, |
| size_t * | out_count | ||
| ) |
Get the number of components in a model package.
| [in] | ctx | The model package context. |
| [out] | out_count | Receives the component count. |
| 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.
| [in] | ctx | The model package context. |
| [out] | out_names | Receives the component name array, or NULL when the package has no components. |
| [out] | out_count | Receives the number of names in out_names. |
| OrtStatus * OrtModelPackageApi::ModelPackage_GetSchemaVersion | ( | const OrtModelPackageContext * | ctx, |
| int64_t * | out_version | ||
| ) |
Get the model package schema version.
| [in] | ctx | The model package context. |
| [out] | out_version | Receives the schema version. |
| OrtStatus * OrtModelPackageApi::ModelPackage_GetVariantCount | ( | const OrtModelPackageContext * | ctx, |
| const char * | component_name, | ||
| size_t * | out_count | ||
| ) |
Get the number of variants for a component.
| [in] | ctx | The model package context. |
| [in] | component_name | UTF-8 component name. |
| [out] | out_count | Receives the variant count. |
| 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.
| [in] | ctx | The model package context. |
| [in] | component_name | UTF-8 component name. |
| [in] | variant_name | UTF-8 variant name. |
| [out] | out_ep | Receives the execution provider name or NULL. |
| 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.
| [in] | ctx | The model package context. |
| [in] | component_name | UTF-8 component name. |
| [out] | out_variant_names | Receives the variant name array, or NULL when the component has no variants. |
| [out] | out_count | Receives the number of names in out_variant_names. |
| 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.
| [in] | ctx | The model package context. |
| [in] | base_dir | Base directory for relative references, or NULL to use the package root. |
| [in] | input | UTF-8 path reference to resolve. |
| [in] | must_exist | Nonzero to require that the resolved path exists. |
| [out] | out_path | Receives the resolved UTF-8 path. |
| 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.
| [in] | ctx | The selected component context. |
| [out] | folder_path | Receives the selected variant directory path. |
| 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.
| [in] | ctx | The selected component context. |
| [out] | out_name | Receives the selected variant name. |
| void OrtModelPackageApi::ReleaseModelPackageComponentContext | ( | OrtModelPackageComponentContext * | input | ) |
Release a selected component context.
| [in] | input | The component context to release. May be NULL. |
| void OrtModelPackageApi::ReleaseModelPackageContext | ( | OrtModelPackageContext * | input | ) |
Release a model package context.
| [in] | input | The context to release. May be NULL. |
| void OrtModelPackageApi::ReleaseModelPackageOptions | ( | OrtModelPackageOptions * | input | ) |
Release model package options.
| [in] | input | The options to release. May be NULL. |
| 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().
| [in] | context | The model package context. |
| [in] | component_name | UTF-8 component name. |
| [in] | options | Options that provide the execution provider configuration for variant selection. |
| [out] | out | Receives the selected component context. |