Class ND4JBaseTensorBackend
java.lang.Object
org.episteme.nativ.mathematics.linearalgebra.tensors.backends.ND4JBaseTensorBackend
- All Implemented Interfaces:
TensorBackend, TensorProvider, AlgorithmProvider, Backend, ComputeBackend
- Direct Known Subclasses:
NativeND4JCUDATensorBackend, NativeND4JTensorBackend
Abstract base for ND4J-backed Tensor backends.
Sub-classes target specific ND4J device backends (native CPU, CUDA GPU).
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract booleanprotected booleanprotected long[]convertShape(int[] shape) <T> Tensor<T> create(T[] data, int... shape) Creates a tensor from a flat array and shape.Creates an execution context for running operations.protected abstract ExecutionContextfromINDArray(org.nd4j.linalg.api.ndarray.INDArray indArray) booleanChecks if this backend is currently available (libraries loaded, etc.).<T> Tensor<T> Creates a tensor with the given shape, filled with ones.abstract booleanReturns true if this provider supports GPU acceleration.booleanChecks if this backend supports parallel operations.org.nd4j.linalg.api.ndarray.INDArraytoINDArray(Tensor<Real> tensor) <T> Tensor<T> Creates a tensor with the given shape, filled with zeros.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface AlgorithmProvider
description, getMetadata, scoreMethods inherited from interface Backend
getAlgorithmProviders, getStatusMessage, isExplicitlyDisabledMethods inherited from interface ComputeBackend
createBackend, getAcceleratorType, getDescription, getId, getType, supportsComplexNumbers, supportsFloatingPointMethods inherited from interface TensorBackend
getName, getPriority, shutdownMethods inherited from interface TensorProvider
getAlgorithmType
-
Field Details
-
isAvailable
protected final boolean isAvailable
-
-
Constructor Details
-
ND4JBaseTensorBackend
protected ND4JBaseTensorBackend()
-
-
Method Details
-
checkAvailability
protected abstract boolean checkAvailability() -
supportsGPU
public abstract boolean supportsGPU()Description copied from interface:TensorBackendReturns true if this provider supports GPU acceleration.- Specified by:
supportsGPUin interfaceTensorBackend- Returns:
- true if GPU is available
-
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- Specified by:
isAvailablein interfaceTensorBackend
-
supportsParallelOps
public boolean supportsParallelOps()Description copied from interface:ComputeBackendChecks if this backend supports parallel operations.- Specified by:
supportsParallelOpsin interfaceComputeBackend- Returns:
- true if parallel execution is supported
-
checkCommonClasses
protected boolean checkCommonClasses() -
doGetContext
-
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
Description copied from interface:TensorBackendCreates a tensor with the given shape, filled with zeros.- Specified by:
zerosin interfaceTensorBackend- Specified by:
zerosin interfaceTensorProvider- Type Parameters:
T- the element type- Parameters:
elementType- the class of field elementsshape- the tensor shape- Returns:
- zero-initialized tensor
-
ones
Description copied from interface:TensorBackendCreates a tensor with the given shape, filled with ones.- Specified by:
onesin interfaceTensorBackend- Specified by:
onesin interfaceTensorProvider- Type Parameters:
T- the element type- Parameters:
elementType- the class of field elementsshape- the tensor shape- Returns:
- one-initialized tensor
-
create
Description copied from interface:TensorBackendCreates a tensor from a flat array and shape.- Specified by:
createin interfaceTensorBackend- Specified by:
createin interfaceTensorProvider- Type Parameters:
T- the element type- Parameters:
data- the flat data arrayshape- the tensor shape- Returns:
- tensor with given data
-
toINDArray
-
fromINDArray
-
convertShape
protected long[] convertShape(int[] shape)
-