Class BiTensorOpDispatcher<T extends AbstractTensor<T,?,?>,U extends AbstractTensor<U,?,?>,R extends AbstractTensor<R,?,?>>
java.lang.Object
org.flag4j.linalg.ops.dispatch.BiTensorOpDispatcher<T,U,R>
- Type Parameters:
T
- Type of left tensor in tensor operation.U
- Type of right tensor in tensor operation.R
- Type of tensor resulting from the tensor operation on typesBiTensorOpDispatcher
andBiTensorOpDispatcher
.
- Direct Known Subclasses:
Cm128DeMatMultDispatcher
,Cm128DeMatVecMultDispatcher
,ReDeMatMultDispatcher
,ReDeMatVecMultDispatcher
public abstract class BiTensorOpDispatcher<T extends AbstractTensor<T,?,?>,U extends AbstractTensor<U,?,?>,R extends AbstractTensor<R,?,?>>
extends Object
Base class for all dispatchers which apply a binary tensor operation.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
Default cache size for dispatchers. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
BiTensorOpDispatcher
(int cacheSize) Creates a matrix multiplication dispatcher with the specified cacheSize. -
Method Summary
Modifier and TypeMethodDescriptionprotected final R
Dispatches the matrix multiplication problem to the proper function and updates the cache if needed.protected abstract BiFunction
<T, U, R> Computes the appropriate function to use when computing the tensor operation between two tensors.protected abstract void
validateShapes
(Shape aShape, Shape bShape) Validates the shapes are valid for the operation.
-
Field Details
-
DEFAULT_CACHE_SIZE
protected static final int DEFAULT_CACHE_SIZEDefault cache size for dispatchers.- See Also:
-
-
Constructor Details
-
BiTensorOpDispatcher
protected BiTensorOpDispatcher(int cacheSize) Creates a matrix multiplication dispatcher with the specified cacheSize.- Parameters:
cacheSize
- The size of the cache for this matrix multiplication dispatcher.
-
-
Method Details
-
dispatch_
Dispatches the matrix multiplication problem to the proper function and updates the cache if needed.- Parameters:
a
- First matrix in the matrix multiplication problem.b
- Second matrix multiplication problem- Returns:
- The result of the matrix multiplication problem.
-
validateShapes
-
getFunc
protected abstract BiFunction<T,U, getFuncR> (Shape aShape, Shape bShape, int data1Length, int data2Length) Computes the appropriate function to use when computing the tensor operation between two tensors.- Parameters:
aShape
- Shape of the first tensor in the operation.bShape
- Shape of the second tensor in the operation.data1Length
- Full length of the data array within the first tensor.data2Length
- Full length of the data array within the second tensor.- Returns:
- The appropriate function to use when computing the tensor operation.
-