Local-only dynamic loading and process-lifetime ONNX environment ownership. More...
#include "onnx_runtime.h"#include <onnxruntime_c_api.h>#include <dlfcn.h>#include <errno.h>#include <limits.h>#include <pthread.h>#include <stdio.h>#include <string.h>#include <sys/stat.h>#include <unistd.h>
Go to the source code of this file.
Functions | |
| bool | onnx_runtime_open (const char *library_directory, char *error, size_t capacity) |
| Initialize one process-lifetime runtime/environment using explicit local search roots. | |
| const OrtApi * | onnx_runtime_api (void) |
| Borrow the initialized API, without transferring release ownership. | |
| OrtEnv * | onnx_runtime_environment (void) |
| Borrow the environment retained until process exit. | |
Variables | |
| static pthread_mutex_t | runtime_mutex = PTHREAD_MUTEX_INITIALIZER |
| static const OrtApi * | runtime_api |
| static OrtEnv * | runtime_environment |
| static void * | runtime_library |
Detailed Description
Local-only dynamic loading and process-lifetime ONNX environment ownership.
Keeping one retained API avoids incompatible per-module loaders and dangling session callbacks.
Definition in file onnx_runtime.c.
Function Documentation
◆ onnx_runtime_api()
| const OrtApi * onnx_runtime_api | ( | void | ) |
Borrow the initialized API, without transferring release ownership.
- Returns
- Process-lifetime API, or NULL before successful open.
Definition at line 169 of file onnx_runtime.c.
◆ onnx_runtime_environment()
| OrtEnv * onnx_runtime_environment | ( | void | ) |
Borrow the environment retained until process exit.
- Returns
- Shared environment, or NULL before successful open.
Definition at line 177 of file onnx_runtime.c.
◆ onnx_runtime_open()
| bool onnx_runtime_open | ( | const char * | library_directory, |
| char * | error, | ||
| size_t | capacity ) |
Initialize one process-lifetime runtime/environment using explicit local search roots.
- Parameters
-
library_directory Optional final search directory; NULL/empty omits it. error Writable diagnostic buffer, cleared on success. capacity Available bytes in error, including its terminator.
- Returns
- True after initialization or when this process already owns a runtime.
The first existing candidate must work; falling back would hide broken packages. The library and environment stay alive so sessions never retain unloaded API pointers.
- Note
- Concurrent initialization is serialized; later calls reuse the selected runtime.
Definition at line 38 of file onnx_runtime.c.
Variable Documentation
◆ runtime_api
|
static |
Definition at line 34 of file onnx_runtime.c.
◆ runtime_environment
|
static |
Definition at line 35 of file onnx_runtime.c.
◆ runtime_library
|
static |
Definition at line 36 of file onnx_runtime.c.
◆ runtime_mutex
|
static |
Definition at line 33 of file onnx_runtime.c.