Class ReduceJoin


  • public class ReduceJoin
    extends CompositeTensorFunction
    An optimization for tensor expressions where a join immediately follows a reduce. Evaluating this as one operation is significantly more efficient than evaluating each separately. This implementation optimizes the case where the reduce is done on the same dimensions as the join. A particularly efficient evaluation is done if there is one common dimension that is joined and reduced on, which is a common case as it covers vector and matrix like multiplications.
    Author:
    lesters
    • Constructor Detail

      • ReduceJoin

        public ReduceJoin​(Reduce reduce,
                          Join join)
    • Method Detail

      • toPrimitive

        public PrimitiveTensorFunction toPrimitive()
        Description copied from class: TensorFunction
        Translate this function - and all of its arguments recursively - to a tree of primitive functions only.
        Specified by:
        toPrimitive in class TensorFunction
        Returns:
        a tree of primitive functions implementing this
      • canOptimize

        public boolean canOptimize​(Tensor a,
                                   Tensor b)
        Tests whether or not the reduce is over the join dimensions. The remaining logic in this class assumes this to be true. If no dimensions are given, the join must be on all tensor dimensions.
        Returns:
        true if the implementation can optimize evaluation given the two tensors.
      • toString

        public java.lang.String toString​(ToStringContext context)
        Description copied from class: TensorFunction
        Return a string representation of this context.
        Specified by:
        toString in class TensorFunction
        Parameters:
        context - a context which must be passed to all nested functions when requesting the string value