use of org.apache.sysml.lops.PartialAggregate.CorrectionLocationType in project incubator-systemml by apache.
the class InstructionUtils method parseBasicAggregateUnaryOperator.
public static AggregateUnaryOperator parseBasicAggregateUnaryOperator(String opcode, int numThreads) {
AggregateUnaryOperator aggun = null;
if (opcode.equalsIgnoreCase("uak+")) {
AggregateOperator agg = new AggregateOperator(0, KahanPlus.getKahanPlusFnObject(), true, CorrectionLocationType.LASTCOLUMN);
aggun = new AggregateUnaryOperator(agg, ReduceAll.getReduceAllFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uark+")) {
// RowSums
AggregateOperator agg = new AggregateOperator(0, KahanPlus.getKahanPlusFnObject(), true, CorrectionLocationType.LASTCOLUMN);
aggun = new AggregateUnaryOperator(agg, ReduceCol.getReduceColFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uack+")) {
// ColSums
AggregateOperator agg = new AggregateOperator(0, KahanPlus.getKahanPlusFnObject(), true, CorrectionLocationType.LASTROW);
aggun = new AggregateUnaryOperator(agg, ReduceRow.getReduceRowFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uasqk+")) {
AggregateOperator agg = new AggregateOperator(0, KahanPlusSq.getKahanPlusSqFnObject(), true, CorrectionLocationType.LASTCOLUMN);
aggun = new AggregateUnaryOperator(agg, ReduceAll.getReduceAllFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uarsqk+")) {
// RowSums
AggregateOperator agg = new AggregateOperator(0, KahanPlusSq.getKahanPlusSqFnObject(), true, CorrectionLocationType.LASTCOLUMN);
aggun = new AggregateUnaryOperator(agg, ReduceCol.getReduceColFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uacsqk+")) {
// ColSums
AggregateOperator agg = new AggregateOperator(0, KahanPlusSq.getKahanPlusSqFnObject(), true, CorrectionLocationType.LASTROW);
aggun = new AggregateUnaryOperator(agg, ReduceRow.getReduceRowFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uamean")) {
// Mean
AggregateOperator agg = new AggregateOperator(0, Mean.getMeanFnObject(), true, CorrectionLocationType.LASTTWOCOLUMNS);
aggun = new AggregateUnaryOperator(agg, ReduceAll.getReduceAllFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uarmean")) {
// RowMeans
AggregateOperator agg = new AggregateOperator(0, Mean.getMeanFnObject(), true, CorrectionLocationType.LASTTWOCOLUMNS);
aggun = new AggregateUnaryOperator(agg, ReduceCol.getReduceColFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uacmean")) {
// ColMeans
AggregateOperator agg = new AggregateOperator(0, Mean.getMeanFnObject(), true, CorrectionLocationType.LASTTWOROWS);
aggun = new AggregateUnaryOperator(agg, ReduceRow.getReduceRowFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uavar")) {
// Variance
CM varFn = CM.getCMFnObject(AggregateOperationTypes.VARIANCE);
CorrectionLocationType cloc = CorrectionLocationType.LASTFOURCOLUMNS;
AggregateOperator agg = new AggregateOperator(0, varFn, true, cloc);
aggun = new AggregateUnaryOperator(agg, ReduceAll.getReduceAllFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uarvar")) {
// RowVariances
CM varFn = CM.getCMFnObject(AggregateOperationTypes.VARIANCE);
CorrectionLocationType cloc = CorrectionLocationType.LASTFOURCOLUMNS;
AggregateOperator agg = new AggregateOperator(0, varFn, true, cloc);
aggun = new AggregateUnaryOperator(agg, ReduceCol.getReduceColFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uacvar")) {
// ColVariances
CM varFn = CM.getCMFnObject(AggregateOperationTypes.VARIANCE);
CorrectionLocationType cloc = CorrectionLocationType.LASTFOURROWS;
AggregateOperator agg = new AggregateOperator(0, varFn, true, cloc);
aggun = new AggregateUnaryOperator(agg, ReduceRow.getReduceRowFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("ua+")) {
AggregateOperator agg = new AggregateOperator(0, Plus.getPlusFnObject());
aggun = new AggregateUnaryOperator(agg, ReduceAll.getReduceAllFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uar+")) {
// RowSums
AggregateOperator agg = new AggregateOperator(0, Plus.getPlusFnObject());
aggun = new AggregateUnaryOperator(agg, ReduceCol.getReduceColFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uac+")) {
// ColSums
AggregateOperator agg = new AggregateOperator(0, Plus.getPlusFnObject());
aggun = new AggregateUnaryOperator(agg, ReduceRow.getReduceRowFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("ua*")) {
AggregateOperator agg = new AggregateOperator(1, Multiply.getMultiplyFnObject());
aggun = new AggregateUnaryOperator(agg, ReduceAll.getReduceAllFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uamax")) {
AggregateOperator agg = new AggregateOperator(Double.NEGATIVE_INFINITY, Builtin.getBuiltinFnObject("max"));
aggun = new AggregateUnaryOperator(agg, ReduceAll.getReduceAllFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uamin")) {
AggregateOperator agg = new AggregateOperator(Double.POSITIVE_INFINITY, Builtin.getBuiltinFnObject("min"));
aggun = new AggregateUnaryOperator(agg, ReduceAll.getReduceAllFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uatrace")) {
AggregateOperator agg = new AggregateOperator(0, Plus.getPlusFnObject());
aggun = new AggregateUnaryOperator(agg, ReduceDiag.getReduceDiagFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uaktrace")) {
AggregateOperator agg = new AggregateOperator(0, KahanPlus.getKahanPlusFnObject(), true, CorrectionLocationType.LASTCOLUMN);
aggun = new AggregateUnaryOperator(agg, ReduceDiag.getReduceDiagFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uarmax")) {
AggregateOperator agg = new AggregateOperator(Double.NEGATIVE_INFINITY, Builtin.getBuiltinFnObject("max"));
aggun = new AggregateUnaryOperator(agg, ReduceCol.getReduceColFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uarimax")) {
AggregateOperator agg = new AggregateOperator(Double.NEGATIVE_INFINITY, Builtin.getBuiltinFnObject("maxindex"), true, CorrectionLocationType.LASTCOLUMN);
aggun = new AggregateUnaryOperator(agg, ReduceCol.getReduceColFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uarmin")) {
AggregateOperator agg = new AggregateOperator(Double.POSITIVE_INFINITY, Builtin.getBuiltinFnObject("min"));
aggun = new AggregateUnaryOperator(agg, ReduceCol.getReduceColFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uarimin")) {
AggregateOperator agg = new AggregateOperator(Double.POSITIVE_INFINITY, Builtin.getBuiltinFnObject("minindex"), true, CorrectionLocationType.LASTCOLUMN);
aggun = new AggregateUnaryOperator(agg, ReduceCol.getReduceColFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uacmax")) {
AggregateOperator agg = new AggregateOperator(Double.NEGATIVE_INFINITY, Builtin.getBuiltinFnObject("max"));
aggun = new AggregateUnaryOperator(agg, ReduceRow.getReduceRowFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uacmin")) {
AggregateOperator agg = new AggregateOperator(Double.POSITIVE_INFINITY, Builtin.getBuiltinFnObject("min"));
aggun = new AggregateUnaryOperator(agg, ReduceRow.getReduceRowFnObject(), numThreads);
}
return aggun;
}
use of org.apache.sysml.lops.PartialAggregate.CorrectionLocationType in project incubator-systemml by apache.
the class MatrixBlock method sumWithFn.
/**
* Wrapper method for reduceall-sum of a matrix using the given
* Kahan function for summation.
*
* @param kfunc A Kahan function object to use for summation.
* @return Sum of the values in the matrix with the given
* function applied.
*/
private double sumWithFn(KahanFunction kfunc) {
// construct operator
CorrectionLocationType corrLoc = CorrectionLocationType.LASTCOLUMN;
ReduceAll reduceAllObj = ReduceAll.getReduceAllFnObject();
AggregateOperator aop = new AggregateOperator(0, kfunc, true, corrLoc);
AggregateUnaryOperator auop = new AggregateUnaryOperator(aop, reduceAllObj);
// execute operation
MatrixBlock out = new MatrixBlock(1, 2, false);
LibMatrixAgg.aggregateUnaryMatrix(this, out, auop);
return out.quickGetValue(0, 0);
}
use of org.apache.sysml.lops.PartialAggregate.CorrectionLocationType in project systemml by apache.
the class UaggOuterChainInstruction method parseInstruction.
public static UaggOuterChainInstruction parseInstruction(String str) {
// check number of fields (2/3 inputs, output, type)
InstructionUtils.checkNumFields(str, 5);
// parse instruction parts (without exec type)
String[] parts = InstructionUtils.getInstructionParts(str);
AggregateUnaryOperator uaggop = InstructionUtils.parseBasicAggregateUnaryOperator(parts[1]);
BinaryOperator bop = InstructionUtils.parseBinaryOperator(parts[2]);
byte in1 = Byte.parseByte(parts[3]);
byte in2 = Byte.parseByte(parts[4]);
byte out = Byte.parseByte(parts[5]);
// derive aggregation operator from unary operator
String aopcode = InstructionUtils.deriveAggregateOperatorOpcode(parts[1]);
CorrectionLocationType corrLoc = InstructionUtils.deriveAggregateOperatorCorrectionLocation(parts[1]);
String corrExists = (corrLoc != CorrectionLocationType.NONE) ? "true" : "false";
AggregateOperator aop = InstructionUtils.parseAggregateOperator(aopcode, corrExists, corrLoc.toString());
return new UaggOuterChainInstruction(bop, uaggop, aop, in1, in2, out, str);
}
use of org.apache.sysml.lops.PartialAggregate.CorrectionLocationType in project systemml by apache.
the class MatrixBlock method sumWithFn.
/**
* Wrapper method for reduceall-sum of a matrix using the given
* Kahan function for summation.
*
* @param kfunc A Kahan function object to use for summation.
* @return Sum of the values in the matrix with the given
* function applied.
*/
private double sumWithFn(KahanFunction kfunc) {
// construct operator
CorrectionLocationType corrLoc = CorrectionLocationType.LASTCOLUMN;
ReduceAll reduceAllObj = ReduceAll.getReduceAllFnObject();
AggregateOperator aop = new AggregateOperator(0, kfunc, true, corrLoc);
AggregateUnaryOperator auop = new AggregateUnaryOperator(aop, reduceAllObj);
// execute operation
MatrixBlock out = new MatrixBlock(1, 2, false);
LibMatrixAgg.aggregateUnaryMatrix(this, out, auop);
return out.quickGetValue(0, 0);
}
use of org.apache.sysml.lops.PartialAggregate.CorrectionLocationType in project systemml by apache.
the class InstructionUtils method parseBasicAggregateUnaryOperator.
public static AggregateUnaryOperator parseBasicAggregateUnaryOperator(String opcode, int numThreads) {
AggregateUnaryOperator aggun = null;
if (opcode.equalsIgnoreCase("uak+")) {
AggregateOperator agg = new AggregateOperator(0, KahanPlus.getKahanPlusFnObject(), true, CorrectionLocationType.LASTCOLUMN);
aggun = new AggregateUnaryOperator(agg, ReduceAll.getReduceAllFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uark+")) {
// RowSums
AggregateOperator agg = new AggregateOperator(0, KahanPlus.getKahanPlusFnObject(), true, CorrectionLocationType.LASTCOLUMN);
aggun = new AggregateUnaryOperator(agg, ReduceCol.getReduceColFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uack+")) {
// ColSums
AggregateOperator agg = new AggregateOperator(0, KahanPlus.getKahanPlusFnObject(), true, CorrectionLocationType.LASTROW);
aggun = new AggregateUnaryOperator(agg, ReduceRow.getReduceRowFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uasqk+")) {
AggregateOperator agg = new AggregateOperator(0, KahanPlusSq.getKahanPlusSqFnObject(), true, CorrectionLocationType.LASTCOLUMN);
aggun = new AggregateUnaryOperator(agg, ReduceAll.getReduceAllFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uarsqk+")) {
// RowSums
AggregateOperator agg = new AggregateOperator(0, KahanPlusSq.getKahanPlusSqFnObject(), true, CorrectionLocationType.LASTCOLUMN);
aggun = new AggregateUnaryOperator(agg, ReduceCol.getReduceColFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uacsqk+")) {
// ColSums
AggregateOperator agg = new AggregateOperator(0, KahanPlusSq.getKahanPlusSqFnObject(), true, CorrectionLocationType.LASTROW);
aggun = new AggregateUnaryOperator(agg, ReduceRow.getReduceRowFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uamean")) {
// Mean
AggregateOperator agg = new AggregateOperator(0, Mean.getMeanFnObject(), true, CorrectionLocationType.LASTTWOCOLUMNS);
aggun = new AggregateUnaryOperator(agg, ReduceAll.getReduceAllFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uarmean")) {
// RowMeans
AggregateOperator agg = new AggregateOperator(0, Mean.getMeanFnObject(), true, CorrectionLocationType.LASTTWOCOLUMNS);
aggun = new AggregateUnaryOperator(agg, ReduceCol.getReduceColFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uacmean")) {
// ColMeans
AggregateOperator agg = new AggregateOperator(0, Mean.getMeanFnObject(), true, CorrectionLocationType.LASTTWOROWS);
aggun = new AggregateUnaryOperator(agg, ReduceRow.getReduceRowFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uavar")) {
// Variance
CM varFn = CM.getCMFnObject(AggregateOperationTypes.VARIANCE);
CorrectionLocationType cloc = CorrectionLocationType.LASTFOURCOLUMNS;
AggregateOperator agg = new AggregateOperator(0, varFn, true, cloc);
aggun = new AggregateUnaryOperator(agg, ReduceAll.getReduceAllFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uarvar")) {
// RowVariances
CM varFn = CM.getCMFnObject(AggregateOperationTypes.VARIANCE);
CorrectionLocationType cloc = CorrectionLocationType.LASTFOURCOLUMNS;
AggregateOperator agg = new AggregateOperator(0, varFn, true, cloc);
aggun = new AggregateUnaryOperator(agg, ReduceCol.getReduceColFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uacvar")) {
// ColVariances
CM varFn = CM.getCMFnObject(AggregateOperationTypes.VARIANCE);
CorrectionLocationType cloc = CorrectionLocationType.LASTFOURROWS;
AggregateOperator agg = new AggregateOperator(0, varFn, true, cloc);
aggun = new AggregateUnaryOperator(agg, ReduceRow.getReduceRowFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("ua+")) {
AggregateOperator agg = new AggregateOperator(0, Plus.getPlusFnObject());
aggun = new AggregateUnaryOperator(agg, ReduceAll.getReduceAllFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uar+")) {
// RowSums
AggregateOperator agg = new AggregateOperator(0, Plus.getPlusFnObject());
aggun = new AggregateUnaryOperator(agg, ReduceCol.getReduceColFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uac+")) {
// ColSums
AggregateOperator agg = new AggregateOperator(0, Plus.getPlusFnObject());
aggun = new AggregateUnaryOperator(agg, ReduceRow.getReduceRowFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("ua*")) {
AggregateOperator agg = new AggregateOperator(1, Multiply.getMultiplyFnObject());
aggun = new AggregateUnaryOperator(agg, ReduceAll.getReduceAllFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uamax")) {
AggregateOperator agg = new AggregateOperator(Double.NEGATIVE_INFINITY, Builtin.getBuiltinFnObject("max"));
aggun = new AggregateUnaryOperator(agg, ReduceAll.getReduceAllFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uamin")) {
AggregateOperator agg = new AggregateOperator(Double.POSITIVE_INFINITY, Builtin.getBuiltinFnObject("min"));
aggun = new AggregateUnaryOperator(agg, ReduceAll.getReduceAllFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uatrace")) {
AggregateOperator agg = new AggregateOperator(0, Plus.getPlusFnObject());
aggun = new AggregateUnaryOperator(agg, ReduceDiag.getReduceDiagFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uaktrace")) {
AggregateOperator agg = new AggregateOperator(0, KahanPlus.getKahanPlusFnObject(), true, CorrectionLocationType.LASTCOLUMN);
aggun = new AggregateUnaryOperator(agg, ReduceDiag.getReduceDiagFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uarmax")) {
AggregateOperator agg = new AggregateOperator(Double.NEGATIVE_INFINITY, Builtin.getBuiltinFnObject("max"));
aggun = new AggregateUnaryOperator(agg, ReduceCol.getReduceColFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uarimax")) {
AggregateOperator agg = new AggregateOperator(Double.NEGATIVE_INFINITY, Builtin.getBuiltinFnObject("maxindex"), true, CorrectionLocationType.LASTCOLUMN);
aggun = new AggregateUnaryOperator(agg, ReduceCol.getReduceColFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uarmin")) {
AggregateOperator agg = new AggregateOperator(Double.POSITIVE_INFINITY, Builtin.getBuiltinFnObject("min"));
aggun = new AggregateUnaryOperator(agg, ReduceCol.getReduceColFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uarimin")) {
AggregateOperator agg = new AggregateOperator(Double.POSITIVE_INFINITY, Builtin.getBuiltinFnObject("minindex"), true, CorrectionLocationType.LASTCOLUMN);
aggun = new AggregateUnaryOperator(agg, ReduceCol.getReduceColFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uacmax")) {
AggregateOperator agg = new AggregateOperator(Double.NEGATIVE_INFINITY, Builtin.getBuiltinFnObject("max"));
aggun = new AggregateUnaryOperator(agg, ReduceRow.getReduceRowFnObject(), numThreads);
} else if (opcode.equalsIgnoreCase("uacmin")) {
AggregateOperator agg = new AggregateOperator(Double.POSITIVE_INFINITY, Builtin.getBuiltinFnObject("min"));
aggun = new AggregateUnaryOperator(agg, ReduceRow.getReduceRowFnObject(), numThreads);
}
return aggun;
}
Aggregations