Class ONNXBackend

java.lang.Object
org.episteme.core.mathematics.ml.backends.ONNXBackend
All Implemented Interfaces:
AlgorithmProvider, Backend, ComputeBackend

@AutoService({Backend.class,ComputeBackend.class,AlgorithmProvider.class}) public class ONNXBackend extends Object implements ComputeBackend, AlgorithmProvider
ONNX Runtime inference backend.

Wraps the ONNX Runtime (ORT) Java API for running machine learning model inference. Available when the ai.onnxruntime library is on the classpath. Registers as a native-library-dependent backend. Implements ComputeBackend and AlgorithmProvider.

Since:
2.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
  • Constructor Details

    • ONNXBackend

      public ONNXBackend()
  • 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
      Specified by:
      getType in interface ComputeBackend
    • 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
      Specified by:
      getId in interface ComputeBackend
    • 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
      Specified by:
      getDescription in interface ComputeBackend
    • 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
    • getAcceleratorType

      public HardwareAccelerator getAcceleratorType()
      Description copied from interface: ComputeBackend
      Returns the type of hardware accelerator used by this backend.
      Specified by:
      getAcceleratorType in interface ComputeBackend
      Returns:
      the accelerator type
    • createContext

      public ExecutionContext createContext()
      Description copied from interface: ComputeBackend
      Creates an execution context for running operations.

      The context should be used within a try-with-resources block to ensure proper cleanup of resources.

      Specified by:
      createContext in interface ComputeBackend
      Returns:
      new execution context
    • 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
      Specified by:
      createBackend in interface ComputeBackend
      Returns:
      The backend implementation object
    • supportsFloatingPoint

      public boolean supportsFloatingPoint()
      Description copied from interface: ComputeBackend
      Checks if this backend supports floating-point arithmetic.
      Specified by:
      supportsFloatingPoint in interface ComputeBackend
      Returns:
      true if floating-point is supported
    • supportsComplexNumbers

      public boolean supportsComplexNumbers()
      Description copied from interface: ComputeBackend
      Checks if this backend supports complex number arithmetic.
      Specified by:
      supportsComplexNumbers in interface ComputeBackend
      Returns:
      true if complex numbers are supported
    • 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