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 types BiTensorOpDispatcher and BiTensorOpDispatcher.
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

    Fields
    Modifier and Type
    Field
    Description
    protected static final int
    Default cache size for dispatchers.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    BiTensorOpDispatcher(int cacheSize)
    Creates a matrix multiplication dispatcher with the specified cacheSize.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected final R
    dispatch_(T a, U b)
    Dispatches the matrix multiplication problem to the proper function and updates the cache if needed.
    protected abstract BiFunction<T,U,R>
    getFunc(Shape aShape, Shape bShape, int data1Length, int data2Length)
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_CACHE_SIZE

      protected static final int DEFAULT_CACHE_SIZE
      Default 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_

      protected final R dispatch_(T a, U b)
      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

      protected abstract void validateShapes(Shape aShape, Shape bShape)
      Validates the shapes are valid for the operation.
      Parameters:
      aShape - Shape of first tensor in the operation.
      bShape - Shape of second tensor in the operation.
    • getFunc

      protected abstract BiFunction<T,U,R> getFunc(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.