Class LibMatrixAgg
java.lang.Object
org.apache.sysds.runtime.matrix.data.LibMatrixAgg
MB:
Library for matrix aggregations including ak+, uak+ for all
combinations of dense and sparse representations, and corrections.
Those are performance-critical operations because they are used
on combiners/reducers of important operations like tsmm, mvmult,
indexing, but also basic sum/min/max/mean, row*, col*, etc. Specific
handling is especially required for all non sparse-safe operations
in order to prevent unnecessary worse asymptotic behavior.
This library currently covers the following opcodes:
ak+, uak+, uark+, uack+, uasqk+, uarsqk+, uacsqk+,
uamin, uarmin, uacmin, uamax, uarmax, uacmax,
ua*, uamean, uarmean, uacmean, uavar, uarvar, uacvar,
uarimax, uaktrace, cumk+, cummin, cummax, cum*, tak+,
cm, cov
TODO next opcode extensions: a+, colindexmax
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaggregateBinaryMatrix(MatrixBlock in, MatrixBlock aggVal, MatrixBlock aggCorr, boolean deep) Core incremental matrix aggregate (ak+) as used in mapmult, tsmm, cpmm, etc.static voidaggregateBinaryMatrix(MatrixBlock in, MatrixBlock aggVal, AggregateOperator aop) Core incremental matrix aggregate (ak+) as used for uack+ and acrk+.static CmCovObjectaggregateCmCov(MatrixBlock in1, MatrixBlock in2, MatrixBlock in3, ValueFunction fn) Single threaded Covariance and Central Moment operations CM = Central Moment COV = Covariancestatic CmCovObjectaggregateCmCov(MatrixBlock in1, MatrixBlock in2, MatrixBlock in3, ValueFunction fn, int k) Multi threaded Covariance and Central Moment operations CM = Central Moment COV = Covariancestatic MatrixBlockaggregateTernary(MatrixBlock in1, MatrixBlock in2, MatrixBlock in3, MatrixBlock ret, AggregateTernaryOperator op) static MatrixBlockaggregateTernary(MatrixBlock in1, MatrixBlock in2, MatrixBlock in3, MatrixBlock ret, AggregateTernaryOperator op, int k) static voidaggregateUnaryMatrix(MatrixBlock in, MatrixBlock out, AggregateUnaryOperator uaop) static voidaggregateUnaryMatrix(MatrixBlock in, MatrixBlock out, AggregateUnaryOperator uaop, boolean allowReformatToSparse) static voidaggregateUnaryMatrix(MatrixBlock in, MatrixBlock out, AggregateUnaryOperator uaop, int k) static MatrixBlockaggregateUnaryMatrix(AggregateUnaryOperator op, MatrixBlock in, MatrixValue result, int blen, MatrixIndexes indexesIn, boolean inCP) static voidcountAgg(double[] a, int[] c, int[] aix, int ai, int len) static voidcountAgg(double[] a, int[] c, int ai, int len) static MatrixBlockcumaggregateUnaryMatrix(MatrixBlock in, MatrixBlock out, UnaryOperator uop) static MatrixBlockcumaggregateUnaryMatrix(MatrixBlock in, MatrixBlock out, UnaryOperator uop, double[] agg) static MatrixBlockcumaggregateUnaryMatrix(MatrixBlock in, MatrixBlock out, UnaryOperator uop, int k) static voidgroupedAggregate(MatrixBlock groups, MatrixBlock target, MatrixBlock weights, MatrixBlock result, int numGroups, Operator op) static voidgroupedAggregate(MatrixBlock groups, MatrixBlock target, MatrixBlock weights, MatrixBlock result, int numGroups, Operator op, int k) static booleanstatic booleanstatic MatrixBlockprepareAggregateUnaryOutput(MatrixBlock in, AggregateUnaryOperator op, MatrixValue result, int blen) static voidrecomputeIndexes(MatrixBlock out, AggregateUnaryOperator op, int blen, MatrixIndexes ix) Recompute outputs (e.g., maxindex or minindex) according to block indexes from MR.static booleansatisfiesMultiThreadingConstraints(MatrixBlock in, int k) static booleansatisfiesMultiThreadingConstraints(MatrixBlock in, MatrixBlock out, AggregateUnaryOperator uaop, int k)
-
Field Details
-
PAR_NUMCELL_THRESHOLD1
public static final long PAR_NUMCELL_THRESHOLD1- See Also:
-
-
Method Details
-
aggregateBinaryMatrix
public static void aggregateBinaryMatrix(MatrixBlock in, MatrixBlock aggVal, MatrixBlock aggCorr, boolean deep) Core incremental matrix aggregate (ak+) as used in mapmult, tsmm, cpmm, etc. Note that we try to keep the current aggVal and aggCorr in dense format in order to allow efficient access according to the dense/sparse input.- Parameters:
in- input matrixaggVal- current aggregate values (in/out)aggCorr- current aggregate correction (in/out)deep- deep copy flag
-
aggregateBinaryMatrix
Core incremental matrix aggregate (ak+) as used for uack+ and acrk+. Embedded correction values. DOES NOT EVALUATE SPARSITY SINCE IT IS USED IN INCREMENTAL AGGREGATION- Parameters:
in- matrix blockaggVal- aggregate operatoraop- aggregate operator
-
aggregateUnaryMatrix
public static MatrixBlock aggregateUnaryMatrix(AggregateUnaryOperator op, MatrixBlock in, MatrixValue result, int blen, MatrixIndexes indexesIn, boolean inCP) -
aggregateUnaryMatrix
public static void aggregateUnaryMatrix(MatrixBlock in, MatrixBlock out, AggregateUnaryOperator uaop) -
aggregateUnaryMatrix
public static void aggregateUnaryMatrix(MatrixBlock in, MatrixBlock out, AggregateUnaryOperator uaop, boolean allowReformatToSparse) -
aggregateUnaryMatrix
public static void aggregateUnaryMatrix(MatrixBlock in, MatrixBlock out, AggregateUnaryOperator uaop, int k) -
cumaggregateUnaryMatrix
public static MatrixBlock cumaggregateUnaryMatrix(MatrixBlock in, MatrixBlock out, UnaryOperator uop) -
cumaggregateUnaryMatrix
public static MatrixBlock cumaggregateUnaryMatrix(MatrixBlock in, MatrixBlock out, UnaryOperator uop, double[] agg) -
cumaggregateUnaryMatrix
public static MatrixBlock cumaggregateUnaryMatrix(MatrixBlock in, MatrixBlock out, UnaryOperator uop, int k) -
aggregateCmCov
public static CmCovObject aggregateCmCov(MatrixBlock in1, MatrixBlock in2, MatrixBlock in3, ValueFunction fn) Single threaded Covariance and Central Moment operations CM = Central Moment COV = Covariance- Parameters:
in1- Main input matrixin2- Second input matrixin3- Third input matrix (not output since output is returned)fn- Value function to apply- Returns:
- Central Moment or Covariance object
-
aggregateCmCov
public static CmCovObject aggregateCmCov(MatrixBlock in1, MatrixBlock in2, MatrixBlock in3, ValueFunction fn, int k) Multi threaded Covariance and Central Moment operations CM = Central Moment COV = Covariance- Parameters:
in1- Main input matrixin2- Second input matrixin3- Third input matrix (not output since output is returned)fn- Value function to applyk- Parallelization degree- Returns:
- Central Moment or Covariance object
-
aggregateTernary
public static MatrixBlock aggregateTernary(MatrixBlock in1, MatrixBlock in2, MatrixBlock in3, MatrixBlock ret, AggregateTernaryOperator op) -
aggregateTernary
public static MatrixBlock aggregateTernary(MatrixBlock in1, MatrixBlock in2, MatrixBlock in3, MatrixBlock ret, AggregateTernaryOperator op, int k) -
groupedAggregate
public static void groupedAggregate(MatrixBlock groups, MatrixBlock target, MatrixBlock weights, MatrixBlock result, int numGroups, Operator op) -
groupedAggregate
public static void groupedAggregate(MatrixBlock groups, MatrixBlock target, MatrixBlock weights, MatrixBlock result, int numGroups, Operator op, int k) -
isSupportedUnaryAggregateOperator
-
isSupportedUnaryOperator
-
satisfiesMultiThreadingConstraints
public static boolean satisfiesMultiThreadingConstraints(MatrixBlock in, MatrixBlock out, AggregateUnaryOperator uaop, int k) -
satisfiesMultiThreadingConstraints
-
recomputeIndexes
public static void recomputeIndexes(MatrixBlock out, AggregateUnaryOperator op, int blen, MatrixIndexes ix) Recompute outputs (e.g., maxindex or minindex) according to block indexes from MR. TODO: this should not be part of block operations but of the MR instruction.- Parameters:
out- matrix blockop- aggregate unary operatorblen- number of rows/cols in a blockix- matrix indexes
-
countAgg
public static void countAgg(double[] a, int[] c, int[] aix, int ai, int len) -
countAgg
public static void countAgg(double[] a, int[] c, int ai, int len) -
prepareAggregateUnaryOutput
public static MatrixBlock prepareAggregateUnaryOutput(MatrixBlock in, AggregateUnaryOperator op, MatrixValue result, int blen)
-