Package com.yahoo.tensor.functions
Class Reduce<NAMETYPE extends Name>
java.lang.Object
com.yahoo.tensor.functions.TensorFunction<NAMETYPE>
com.yahoo.tensor.functions.PrimitiveTensorFunction<NAMETYPE>
com.yahoo.tensor.functions.Reduce<NAMETYPE>
The reduce tensor operation returns a tensor produced from the argument tensor where some dimensions
are collapsed to a single value using an aggregator function.
- Author:
- bratseth
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionReduce(TensorFunction<NAMETYPE> argument, Reduce.Aggregator aggregator) Creates a reduce function reducing all dimensionsReduce(TensorFunction<NAMETYPE> argument, Reduce.Aggregator aggregator, String dimension) Creates a reduce function reducing a single dimensionReduce(TensorFunction<NAMETYPE> argument, Reduce.Aggregator aggregator, List<String> dimensions) Creates a reduce function. -
Method Summary
Modifier and TypeMethodDescriptionargument()Returns the function arguments of this node in the order they are appliedevaluate(EvaluationContext<NAMETYPE> context) Evaluates this tensor.inthashCode()Returns a hashcode computed from the data in thisstatic TensorTypeoutputType(TensorType inputType, List<String> reduceDimensions) Translate this function - and all of its arguments recursively - to a tree of primitive functions only.toString(ToStringContext<NAMETYPE> context) Return a string representation of this context.type(TypeContext<NAMETYPE> context) Returns the type of the tensor this produces given the input types in the contextwithArguments(List<TensorFunction<NAMETYPE>> arguments) Returns a copy of this tensor function with the arguments replaced by the given list of arguments.Methods inherited from class com.yahoo.tensor.functions.TensorFunction
asScalarFunction, evaluate, toString, withTransformedFunctions
-
Constructor Details
-
Reduce
Creates a reduce function reducing all dimensions -
Reduce
Creates a reduce function reducing a single dimension -
Reduce
public Reduce(TensorFunction<NAMETYPE> argument, Reduce.Aggregator aggregator, List<String> dimensions) Creates a reduce function.- Parameters:
argument- the tensor to reduceaggregator- the aggregator function to usedimensions- the list of dimensions to remove. If an empty list is given, all dimensions are reduced, producing a dimensionless tensor (a scalar).- Throws:
IllegalArgumentException- if any of the tensor dimensions are not present in the input tensor
-
-
Method Details
-
outputType
-
argument
-
arguments
Description copied from class:TensorFunctionReturns the function arguments of this node in the order they are applied- Specified by:
argumentsin classTensorFunction<NAMETYPE extends Name>
-
withArguments
Description copied from class:TensorFunctionReturns a copy of this tensor function with the arguments replaced by the given list of arguments.- Specified by:
withArgumentsin classTensorFunction<NAMETYPE extends Name>
-
toPrimitive
Description copied from class:TensorFunctionTranslate this function - and all of its arguments recursively - to a tree of primitive functions only.- Specified by:
toPrimitivein classTensorFunction<NAMETYPE extends Name>- Returns:
- a tree of primitive functions implementing this
-
toString
Description copied from class:TensorFunctionReturn a string representation of this context.- Specified by:
toStringin classTensorFunction<NAMETYPE extends Name>- Parameters:
context- a context which must be passed to all nested functions when requesting the string value
-
type
Description copied from class:TensorFunctionReturns the type of the tensor this produces given the input types in the context- Specified by:
typein classTensorFunction<NAMETYPE extends Name>- Parameters:
context- a context which must be passed to all nexted functions when evaluating
-
evaluate
Description copied from class:TensorFunctionEvaluates this tensor.- Specified by:
evaluatein classTensorFunction<NAMETYPE extends Name>- Parameters:
context- a context which must be passed to all nested functions when evaluating
-
hashCode
public int hashCode()Description copied from class:TensorFunctionReturns a hashcode computed from the data in this- Specified by:
hashCodein classTensorFunction<NAMETYPE extends Name>
-