Class ONNXRuntimeBackend
java.lang.Object
org.episteme.core.mathematics.ml.neural.backends.ONNXRuntimeBackend
- All Implemented Interfaces:
AlgorithmProvider, Backend
@AutoService({Backend.class,AlgorithmProvider.class})
public class ONNXRuntimeBackend
extends Object
implements Backend, AlgorithmProvider
Provider for running ONNX (Open Neural Network Exchange) models.
Allows executing pre-trained models (e.g., from PyTorch/TensorFlow) within Episteme.
Implements Backend and AlgorithmProvider for standardized discovery.
- Since:
- 2.0
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents a loaded ONNX model session. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates and returns the backend instance (or returns self if it is the backend).Returns the unique category of the algorithm.Returns a description of the backend.getId()Returns the unique identifier for this backend (e.g., "javafx", "jmol", "cuda").getName()Returns the display name for UI presentation.intReturns the priority for auto-selection (higher = preferred).getType()Returns the backend type category (e.g., "plotting", "molecular", "tensor", "math").booleanChecks if this backend is currently available (libraries loaded, etc.).Loads an ONNX model from the specified path.doublescore(OperationContext context) Scores this provider for a specific operation context.voidshutdown()Called when the application is shutting down or the backend is being replaced.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface AlgorithmProvider
description, getMetadataMethods inherited from interface Backend
getAlgorithmProviders, getStatusMessage, isExplicitlyDisabled
-
Constructor Details
-
ONNXRuntimeBackend
public ONNXRuntimeBackend()
-
-
Method Details
-
getType
-
getId
-
getName
-
getDescription
Description copied from interface:BackendReturns a description of the backend.- Specified by:
getDescriptionin interfaceBackend
-
isAvailable
public boolean isAvailable()Description copied from interface:BackendChecks if this backend is currently available (libraries loaded, etc.).Default implementation checks
Backend.isExplicitlyDisabled()and returns false if it is.- Specified by:
isAvailablein interfaceAlgorithmProvider- Specified by:
isAvailablein interfaceBackend
-
getPriority
public int getPriority()Description copied from interface:BackendReturns the priority for auto-selection (higher = preferred). Used when multiple backends are available.- Specified by:
getPriorityin interfaceAlgorithmProvider- Specified by:
getPriorityin interfaceBackend
-
getAlgorithmType
Description copied from interface:AlgorithmProviderReturns the unique category of the algorithm.- Specified by:
getAlgorithmTypein interfaceAlgorithmProvider
-
score
Description copied from interface:AlgorithmProviderScores this provider for a specific operation context.Higher scores indicate better suitability. Used by
ProviderSelectorfor context-aware selection.Default implementation returns
AlgorithmProvider.getPriority(), so existing providers behave identically without changes.- Specified by:
scorein interfaceAlgorithmProvider- Parameters:
context- the operation context (data size, hints, etc.)- Returns:
- suitability score (higher = better)
-
createBackend
Description copied from interface:BackendCreates and returns the backend instance (or returns self if it is the backend).- Specified by:
createBackendin interfaceBackend- Returns:
- The backend implementation object
-
loadModel
Loads an ONNX model from the specified path.- Parameters:
modelPath- path to .onnx file.- Returns:
- a runnable Model session.
-
shutdown
public void shutdown()Description copied from interface:BackendCalled when the application is shutting down or the backend is being replaced. Use this to release hardware resources, close file handles, or stop background threads.- Specified by:
shutdownin interfaceAlgorithmProvider- Specified by:
shutdownin interfaceBackend
-