Search in sources :

Example 61 with AggregateOperator

use of org.apache.sysml.runtime.matrix.operators.AggregateOperator in project incubator-systemml by apache.

the class ReduceBase method processAggregateHelp.

// process one aggregate instruction
private void processAggregateHelp(long row, long col, MatrixValue value, AggregateInstruction instruction, boolean imbededCorrection) {
    AggregateOperator aggOp = (AggregateOperator) instruction.getOperator();
    // there should be just one value in cache.
    IndexedMatrixValue out = cachedValues.getFirst(instruction.output);
    IndexedMatrixValue correction = null;
    if (// && !imbededCorrection)
    aggOp.correctionExists) {
        correction = correctionCache.getFirst(instruction.output);
    }
    if (out == null) {
        out = cachedValues.holdPlace(instruction.output, valueClass);
        out.getIndexes().setIndexes(row, col);
        // System.out.println("out: "+out);
        if (// && !imbededCorrection)
        aggOp.correctionExists) {
            if (correction == null)
                correction = correctionCache.holdPlace(instruction.output, valueClass);
            OperationsOnMatrixValues.startAggregation(out.getValue(), correction.getValue(), aggOp, value.getNumRows(), value.getNumColumns(), value.isInSparseFormat(), imbededCorrection);
        } else
            OperationsOnMatrixValues.startAggregation(out.getValue(), null, aggOp, value.getNumRows(), value.getNumColumns(), value.isInSparseFormat(), imbededCorrection);
    }
    if (// && !imbededCorrection)
    aggOp.correctionExists)
        OperationsOnMatrixValues.incrementalAggregation(out.getValue(), correction.getValue(), value, (AggregateOperator) instruction.getOperator(), imbededCorrection);
    else
        OperationsOnMatrixValues.incrementalAggregation(out.getValue(), null, value, (AggregateOperator) instruction.getOperator(), imbededCorrection);
}
Also used : AggregateOperator(org.apache.sysml.runtime.matrix.operators.AggregateOperator)

Example 62 with AggregateOperator

use of org.apache.sysml.runtime.matrix.operators.AggregateOperator in project systemml by apache.

the class InstructionUtils method parseAggregateOperator.

public static AggregateOperator parseAggregateOperator(String opcode, String corrExists, String corrLoc) {
    AggregateOperator agg = null;
    if (opcode.equalsIgnoreCase("ak+") || opcode.equalsIgnoreCase("aktrace")) {
        boolean lcorrExists = (corrExists == null) ? true : Boolean.parseBoolean(corrExists);
        CorrectionLocationType lcorrLoc = (corrLoc == null) ? CorrectionLocationType.LASTCOLUMN : CorrectionLocationType.valueOf(corrLoc);
        agg = new AggregateOperator(0, KahanPlus.getKahanPlusFnObject(), lcorrExists, lcorrLoc);
    } else if (opcode.equalsIgnoreCase("asqk+")) {
        boolean lcorrExists = (corrExists == null) ? true : Boolean.parseBoolean(corrExists);
        CorrectionLocationType lcorrLoc = (corrLoc == null) ? CorrectionLocationType.LASTCOLUMN : CorrectionLocationType.valueOf(corrLoc);
        agg = new AggregateOperator(0, KahanPlusSq.getKahanPlusSqFnObject(), lcorrExists, lcorrLoc);
    } else if (opcode.equalsIgnoreCase("a+")) {
        agg = new AggregateOperator(0, Plus.getPlusFnObject());
    } else if (opcode.equalsIgnoreCase("a*")) {
        agg = new AggregateOperator(1, Multiply.getMultiplyFnObject());
    } else if (opcode.equalsIgnoreCase("arimax")) {
        agg = new AggregateOperator(Double.NEGATIVE_INFINITY, Builtin.getBuiltinFnObject("maxindex"), true, CorrectionLocationType.LASTCOLUMN);
    } else if (opcode.equalsIgnoreCase("amax")) {
        agg = new AggregateOperator(Double.NEGATIVE_INFINITY, Builtin.getBuiltinFnObject("max"));
    } else if (opcode.equalsIgnoreCase("amin")) {
        agg = new AggregateOperator(Double.POSITIVE_INFINITY, Builtin.getBuiltinFnObject("min"));
    } else if (opcode.equalsIgnoreCase("arimin")) {
        agg = new AggregateOperator(Double.POSITIVE_INFINITY, Builtin.getBuiltinFnObject("minindex"), true, CorrectionLocationType.LASTCOLUMN);
    } else if (opcode.equalsIgnoreCase("amean")) {
        boolean lcorrExists = (corrExists == null) ? true : Boolean.parseBoolean(corrExists);
        CorrectionLocationType lcorrLoc = (corrLoc == null) ? CorrectionLocationType.LASTTWOCOLUMNS : CorrectionLocationType.valueOf(corrLoc);
        agg = new AggregateOperator(0, KahanPlus.getKahanPlusFnObject(), lcorrExists, lcorrLoc);
    } else if (opcode.equalsIgnoreCase("avar")) {
        boolean lcorrExists = (corrExists == null) ? true : Boolean.parseBoolean(corrExists);
        CorrectionLocationType lcorrLoc = (corrLoc == null) ? CorrectionLocationType.LASTFOURCOLUMNS : CorrectionLocationType.valueOf(corrLoc);
        CM varFn = CM.getCMFnObject(AggregateOperationTypes.VARIANCE);
        agg = new AggregateOperator(0, varFn, lcorrExists, lcorrLoc);
    }
    return agg;
}
Also used : AggregateOperator(org.apache.sysml.runtime.matrix.operators.AggregateOperator) CM(org.apache.sysml.runtime.functionobjects.CM) CorrectionLocationType(org.apache.sysml.lops.PartialAggregate.CorrectionLocationType)

Example 63 with AggregateOperator

use of org.apache.sysml.runtime.matrix.operators.AggregateOperator in project systemml by apache.

the class InstructionUtils method parseAggregateTernaryOperator.

public static AggregateTernaryOperator parseAggregateTernaryOperator(String opcode, int numThreads) {
    CorrectionLocationType corr = opcode.equalsIgnoreCase("tak+*") ? CorrectionLocationType.LASTCOLUMN : CorrectionLocationType.LASTROW;
    AggregateOperator agg = new AggregateOperator(0, KahanPlus.getKahanPlusFnObject(), true, corr);
    IndexFunction ixfun = opcode.equalsIgnoreCase("tak+*") ? ReduceAll.getReduceAllFnObject() : ReduceRow.getReduceRowFnObject();
    return new AggregateTernaryOperator(Multiply.getMultiplyFnObject(), agg, ixfun, numThreads);
}
Also used : IndexFunction(org.apache.sysml.runtime.functionobjects.IndexFunction) AggregateOperator(org.apache.sysml.runtime.matrix.operators.AggregateOperator) AggregateTernaryOperator(org.apache.sysml.runtime.matrix.operators.AggregateTernaryOperator) CorrectionLocationType(org.apache.sysml.lops.PartialAggregate.CorrectionLocationType)

Example 64 with AggregateOperator

use of org.apache.sysml.runtime.matrix.operators.AggregateOperator in project systemml by apache.

the class UaggOuterChainCPInstruction method parseInstruction.

public static UaggOuterChainCPInstruction parseInstruction(String str) {
    String[] parts = InstructionUtils.getInstructionPartsWithValueType(str);
    String opcode = parts[0];
    if (opcode.equalsIgnoreCase(UAggOuterChain.OPCODE)) {
        AggregateUnaryOperator uaggop = InstructionUtils.parseBasicAggregateUnaryOperator(parts[1]);
        BinaryOperator bop = InstructionUtils.parseBinaryOperator(parts[2]);
        CPOperand in1 = new CPOperand(parts[3]);
        CPOperand in2 = new CPOperand(parts[4]);
        CPOperand out = new CPOperand(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 UaggOuterChainCPInstruction(bop, uaggop, aop, in1, in2, out, opcode, str);
    } else {
        throw new DMLRuntimeException("UaggOuterChainCPInstruction.parseInstruction():: Unknown opcode " + opcode);
    }
}
Also used : AggregateUnaryOperator(org.apache.sysml.runtime.matrix.operators.AggregateUnaryOperator) AggregateOperator(org.apache.sysml.runtime.matrix.operators.AggregateOperator) BinaryOperator(org.apache.sysml.runtime.matrix.operators.BinaryOperator) CorrectionLocationType(org.apache.sysml.lops.PartialAggregate.CorrectionLocationType) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException)

Example 65 with AggregateOperator

use of org.apache.sysml.runtime.matrix.operators.AggregateOperator in project systemml by apache.

the class ReduceBase method processAggregateHelp.

// process one aggregate instruction
private void processAggregateHelp(long row, long col, MatrixValue value, AggregateInstruction instruction, boolean imbededCorrection) {
    AggregateOperator aggOp = (AggregateOperator) instruction.getOperator();
    // there should be just one value in cache.
    IndexedMatrixValue out = cachedValues.getFirst(instruction.output);
    IndexedMatrixValue correction = null;
    if (// && !imbededCorrection)
    aggOp.correctionExists) {
        correction = correctionCache.getFirst(instruction.output);
    }
    if (out == null) {
        out = cachedValues.holdPlace(instruction.output, valueClass);
        out.getIndexes().setIndexes(row, col);
        // System.out.println("out: "+out);
        if (// && !imbededCorrection)
        aggOp.correctionExists) {
            if (correction == null)
                correction = correctionCache.holdPlace(instruction.output, valueClass);
            OperationsOnMatrixValues.startAggregation(out.getValue(), correction.getValue(), aggOp, value.getNumRows(), value.getNumColumns(), value.isInSparseFormat(), imbededCorrection);
        } else
            OperationsOnMatrixValues.startAggregation(out.getValue(), null, aggOp, value.getNumRows(), value.getNumColumns(), value.isInSparseFormat(), imbededCorrection);
    }
    if (// && !imbededCorrection)
    aggOp.correctionExists)
        OperationsOnMatrixValues.incrementalAggregation(out.getValue(), correction.getValue(), value, (AggregateOperator) instruction.getOperator(), imbededCorrection);
    else
        OperationsOnMatrixValues.incrementalAggregation(out.getValue(), null, value, (AggregateOperator) instruction.getOperator(), imbededCorrection);
}
Also used : AggregateOperator(org.apache.sysml.runtime.matrix.operators.AggregateOperator)

Aggregations

AggregateOperator (org.apache.sysml.runtime.matrix.operators.AggregateOperator)83 DMLRuntimeException (org.apache.sysml.runtime.DMLRuntimeException)34 AggregateBinaryOperator (org.apache.sysml.runtime.matrix.operators.AggregateBinaryOperator)32 MatrixBlock (org.apache.sysml.runtime.matrix.data.MatrixBlock)24 AggregateUnaryOperator (org.apache.sysml.runtime.matrix.operators.AggregateUnaryOperator)21 CPOperand (org.apache.sysml.runtime.instructions.cp.CPOperand)20 CorrectionLocationType (org.apache.sysml.lops.PartialAggregate.CorrectionLocationType)17 CompressedMatrixBlock (org.apache.sysml.runtime.compress.CompressedMatrixBlock)16 CM (org.apache.sysml.runtime.functionobjects.CM)15 CMOperator (org.apache.sysml.runtime.matrix.operators.CMOperator)14 KahanObject (org.apache.sysml.runtime.instructions.cp.KahanObject)10 WeightedCell (org.apache.sysml.runtime.matrix.data.WeightedCell)10 MatrixIndexes (org.apache.sysml.runtime.matrix.data.MatrixIndexes)8 BinaryOperator (org.apache.sysml.runtime.matrix.operators.BinaryOperator)8 Operator (org.apache.sysml.runtime.matrix.operators.Operator)8 ArrayList (java.util.ArrayList)6 SparkAggType (org.apache.sysml.hops.AggBinaryOp.SparkAggType)6 SparkExecutionContext (org.apache.sysml.runtime.controlprogram.context.SparkExecutionContext)6 CM_COV_Object (org.apache.sysml.runtime.instructions.cp.CM_COV_Object)6 MatrixCharacteristics (org.apache.sysml.runtime.matrix.MatrixCharacteristics)6