Class NativeND4JCUDASparseTensorBackend

java.lang.Object
org.episteme.nativ.mathematics.linearalgebra.tensors.backends.NativeND4JCUDASparseTensorBackend
All Implemented Interfaces:
TensorBackend, TensorProvider, AlgorithmProvider, Backend, ComputeBackend

@AutoService({TensorBackend.class,AlgorithmProvider.class}) public class NativeND4JCUDASparseTensorBackend extends Object implements TensorBackend
NativeND4J Sparse Tensor backend.

This backend implements sparse tensor operations using ND4J on CUDA. Delegation to fallbacks is strictly prohibited by architectural rules.

  • Constructor Details

    • NativeND4JCUDASparseTensorBackend

      public NativeND4JCUDASparseTensorBackend()
  • Method Details

    • 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
      Specified by:
      isAvailable in interface TensorBackend
    • zeros

      public <T> Tensor<T> zeros(Class<T> elementType, int... shape)
      Description copied from interface: TensorBackend
      Creates a tensor with the given shape, filled with zeros.
      Specified by:
      zeros in interface TensorBackend
      Specified by:
      zeros in interface TensorProvider
      Type Parameters:
      T - the element type
      Parameters:
      elementType - the class of field elements
      shape - the tensor shape
      Returns:
      zero-initialized tensor
    • ones

      public <T> Tensor<T> ones(Class<T> elementType, int... shape)
      Description copied from interface: TensorBackend
      Creates a tensor with the given shape, filled with ones.
      Specified by:
      ones in interface TensorBackend
      Specified by:
      ones in interface TensorProvider
      Type Parameters:
      T - the element type
      Parameters:
      elementType - the class of field elements
      shape - the tensor shape
      Returns:
      one-initialized tensor
    • create

      public <T> Tensor<T> create(T[] data, int... shape)
      Description copied from interface: TensorBackend
      Creates a tensor from a flat array and shape.
      Specified by:
      create in interface TensorBackend
      Specified by:
      create in interface TensorProvider
      Type Parameters:
      T - the element type
      Parameters:
      data - the flat data array
      shape - the tensor shape
      Returns:
      tensor with given data
    • supportsGPU

      public boolean supportsGPU()
      Description copied from interface: TensorBackend
      Returns true if this provider supports GPU acceleration.
      Specified by:
      supportsGPU in interface TensorBackend
      Returns:
      true if GPU is available
    • getName

      public String getName()
      Description copied from interface: TensorBackend
      Returns the name of this provider.
      Specified by:
      getName in interface AlgorithmProvider
      Specified by:
      getName in interface Backend
      Specified by:
      getName in interface TensorBackend
      Specified by:
      getName in interface TensorProvider
      Returns:
      provider name (e.g., "Native", "ND4J", "DJL")
    • getPriority

      public int getPriority()
      Description copied from interface: TensorBackend
      Returns the priority of this provider (higher = preferred).

      Used for automatic selection when multiple providers are available.

      Specified by:
      getPriority in interface AlgorithmProvider
      Specified by:
      getPriority in interface Backend
      Specified by:
      getPriority in interface TensorBackend
      Returns:
      priority (0-100, default native = 50)
    • supportsParallelOps

      public boolean supportsParallelOps()
      Description copied from interface: ComputeBackend
      Checks if this backend supports parallel operations.
      Specified by:
      supportsParallelOps in interface ComputeBackend
      Returns:
      true if parallel execution is supported
    • 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
    • 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
    • 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
    • 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