createWithCustomConfig static method
OrtSessionWrapper
createWithCustomConfig(
- String modelPath, {
- OnnxRuntime? runtime,
- required void configure(
- OrtProviders providers,
- Pointer<
OrtSessionOptions> options
Creates a session with a custom configuration callback for full control over session options and providers.
Implementation
static OrtSessionWrapper createWithCustomConfig(
String modelPath, {
OnnxRuntime? runtime,
required void Function(
OrtProviders providers,
Pointer<OrtSessionOptions> options,
)
configure,
}) {
final rt = runtime ?? OnnxRuntime.instance;
rt.ensureInitialized();
final wrapper = OrtSessionWrapper._(rt);
wrapper._sessionOptions = rt.createSessionOptions();
final providers = OrtProviders(rt);
configure(providers, wrapper._sessionOptions);
wrapper._session = rt.createSession(modelPath, wrapper._sessionOptions);
wrapper._inputNames = rt.getSessionInputNames(wrapper._session);
wrapper._outputNames = rt.getSessionOutputNames(wrapper._session);
return wrapper;
}