Class NativeCPUTensorBackend
java.lang.Object
org.episteme.nativ.mathematics.tensors.backends.NativeCPUTensorBackend
- All Implemented Interfaces:
TensorProvider, AlgorithmProvider, Backend, ComputeBackend, CPUBackend, NativeBackend
@AutoService({Backend.class,ComputeBackend.class,CPUBackend.class,NativeBackend.class,TensorProvider.class})
public class NativeCPUTensorBackend
extends Object
implements TensorProvider, CPUBackend, NativeBackend
Native CPU Tensor Backend using Project Panama (FFM) for native acceleration.
Attempts to load 'dnnl' (oneDNN) or 'mkl_rt' for acceleration.
If not found, it falls back to Java-based off-heap operations (via NativeTensor).
Implements CPUBackend and NativeBackend.
- Since:
- 1.2
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> Tensor<T> create(T[] data, int... shape) Creates an execution context for running operations.Returns a description of the backend.getId()Returns the unique identifier for this backend (e.g., "javafx", "jmol", "cuda").Returns metadata about the provider's performance and capabilities.getName()Returns the display name for UI presentation.Returns the name of the native library this backend depends on.intReturns the execution priority (higher is better).booleanChecks if the provider is available in the current environment.booleanisLoaded()Checks if the native library is loaded and available.<T> Tensor<T> voidshutdown()Called when the provider is no longer needed (e.g., application shutdown).<T> Tensor<T> Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface AlgorithmProvider
description, scoreMethods inherited from interface Backend
getAlgorithmProviders, getStatusMessage, isExplicitlyDisabledMethods inherited from interface ComputeBackend
createBackendMethods inherited from interface CPUBackend
getAcceleratorType, getType, supportsComplexNumbers, supportsFloatingPoint, supportsParallelOpsMethods inherited from interface TensorProvider
getAlgorithmType
-
Constructor Details
-
NativeCPUTensorBackend
public NativeCPUTensorBackend()
-
-
Method Details
-
isLoaded
public boolean isLoaded()Description copied from interface:NativeBackendChecks if the native library is loaded and available.- Specified by:
isLoadedin interfaceNativeBackend- Returns:
- true if the native library has been successfully loaded
-
getNativeLibraryName
Description copied from interface:NativeBackendReturns the name of the native library this backend depends on.- Specified by:
getNativeLibraryNamein interfaceNativeBackend- Returns:
- library name (e.g., "openblas", "cuda", "fftw3")
-
getId
-
getName
Description copied from interface:BackendReturns the display name for UI presentation.- Specified by:
getNamein interfaceAlgorithmProvider- Specified by:
getNamein interfaceBackend- Specified by:
getNamein interfaceTensorProvider
-
getDescription
Description copied from interface:BackendReturns a description of the backend.- Specified by:
getDescriptionin interfaceBackend- Specified by:
getDescriptionin interfaceComputeBackend
-
isAvailable
public boolean isAvailable()Description copied from interface:AlgorithmProviderChecks if the provider is available in the current environment.- Specified by:
isAvailablein interfaceAlgorithmProvider- Specified by:
isAvailablein interfaceBackend
-
getPriority
public int getPriority()Description copied from interface:AlgorithmProviderReturns the execution priority (higher is better).- Specified by:
getPriorityin interfaceAlgorithmProvider- Specified by:
getPriorityin interfaceBackend
-
createContext
Description copied from interface:ComputeBackendCreates 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:
createContextin interfaceComputeBackend- Returns:
- new execution context
-
zeros
- Specified by:
zerosin interfaceTensorProvider
-
ones
- Specified by:
onesin interfaceTensorProvider
-
create
- Specified by:
createin interfaceTensorProvider
-
shutdown
public void shutdown()Description copied from interface:AlgorithmProviderCalled when the provider is no longer needed (e.g., application shutdown). Use this to release local resources or close native segments.- Specified by:
shutdownin interfaceAlgorithmProvider- Specified by:
shutdownin interfaceBackend
-
getMetadata
Description copied from interface:AlgorithmProviderReturns metadata about the provider's performance and capabilities. This can be used for advanced matching in the ProviderSelector.- Specified by:
getMetadatain interfaceAlgorithmProvider- Returns:
- a map of metadata keys and values
-