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)
  • Constructor Details

    • ONNXRuntimeBackend

      public ONNXRuntimeBackend()
  • Method Details

    • getType

      public String getType()
      Description copied from interface: Backend
      Returns the backend type category (e.g., "plotting", "molecular", "tensor", "math").
      Specified by:
      getType in interface Backend
    • getId

      public String getId()
      Description copied from interface: Backend
      Returns the unique identifier for this backend (e.g., "javafx", "jmol", "cuda").
      Specified by:
      getId in interface Backend
    • getName

      public String getName()
      Description copied from interface: Backend
      Returns the display name for UI presentation.
      Specified by:
      getName in interface AlgorithmProvider
      Specified by:
      getName in interface Backend
    • getDescription

      public String getDescription()
      Description copied from interface: Backend
      Returns a description of the backend.
      Specified by:
      getDescription in interface Backend
    • isAvailable

      public boolean isAvailable()
      Description copied from interface: Backend
      Checks if this backend is currently available (libraries loaded, etc.).

      Default implementation checks Backend.isExplicitlyDisabled() and returns false if it is.

      Specified by:
      isAvailable in interface AlgorithmProvider
      Specified by:
      isAvailable in interface Backend
    • getPriority

      public int getPriority()
      Description copied from interface: Backend
      Returns the priority for auto-selection (higher = preferred). Used when multiple backends are available.
      Specified by:
      getPriority in interface AlgorithmProvider
      Specified by:
      getPriority in interface Backend
    • getAlgorithmType

      public String getAlgorithmType()
      Description copied from interface: AlgorithmProvider
      Returns the unique category of the algorithm.
      Specified by:
      getAlgorithmType in interface AlgorithmProvider
    • score

      public double score(OperationContext context)
      Description copied from interface: AlgorithmProvider
      Scores this provider for a specific operation context.

      Higher scores indicate better suitability. Used by ProviderSelector for context-aware selection.

      Default implementation returns AlgorithmProvider.getPriority(), so existing providers behave identically without changes.

      Specified by:
      score in interface AlgorithmProvider
      Parameters:
      context - the operation context (data size, hints, etc.)
      Returns:
      suitability score (higher = better)
    • createBackend

      public Object createBackend()
      Description copied from interface: Backend
      Creates and returns the backend instance (or returns self if it is the backend).
      Specified by:
      createBackend in interface Backend
      Returns:
      The backend implementation object
    • loadModel

      public ONNXRuntimeBackend.ONNXSession loadModel(Path modelPath)
      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: Backend
      Called 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:
      shutdown in interface AlgorithmProvider
      Specified by:
      shutdown in interface Backend