Search in sources :

Example 6 with VariableCPInstruction

use of org.apache.sysml.runtime.instructions.cp.VariableCPInstruction in project incubator-systemml by apache.

the class Dag method collapseAssignvarAndRmvarInstructions.

private static ArrayList<Instruction> collapseAssignvarAndRmvarInstructions(ArrayList<Instruction> insts) {
    ArrayList<Instruction> ret = new ArrayList<>();
    Iterator<Instruction> iter = insts.iterator();
    while (iter.hasNext()) {
        Instruction inst = iter.next();
        if (iter.hasNext() && inst instanceof VariableCPInstruction && ((VariableCPInstruction) inst).isAssignVariable()) {
            VariableCPInstruction inst1 = (VariableCPInstruction) inst;
            Instruction inst2 = iter.next();
            if (inst2 instanceof VariableCPInstruction && ((VariableCPInstruction) inst2).isRemoveVariableNoFile() && inst1.getInput1().getName().equals(((VariableCPInstruction) inst2).getInput1().getName())) {
                ret.add(VariableCPInstruction.prepareMoveInstruction(inst1.getInput1().getName(), inst1.getInput2().getName()));
            } else {
                ret.add(inst1);
                ret.add(inst2);
            }
        } else {
            ret.add(inst);
        }
    }
    return ret;
}
Also used : VariableCPInstruction(org.apache.sysml.runtime.instructions.cp.VariableCPInstruction) ArrayList(java.util.ArrayList) MRJobInstruction(org.apache.sysml.runtime.instructions.MRJobInstruction) CPInstruction(org.apache.sysml.runtime.instructions.cp.CPInstruction) Instruction(org.apache.sysml.runtime.instructions.Instruction) VariableCPInstruction(org.apache.sysml.runtime.instructions.cp.VariableCPInstruction)

Example 7 with VariableCPInstruction

use of org.apache.sysml.runtime.instructions.cp.VariableCPInstruction in project incubator-systemml by apache.

the class Dag method createPackedRmvarInstructions.

private static ArrayList<Instruction> createPackedRmvarInstructions(ArrayList<Instruction> insts) {
    ArrayList<Instruction> ret = new ArrayList<>();
    ArrayList<String> currRmVar = new ArrayList<>();
    for (Instruction inst : insts) {
        if (inst instanceof VariableCPInstruction && ((VariableCPInstruction) inst).isRemoveVariableNoFile()) {
            // collect all subsequent rmvar instructions
            currRmVar.add(((VariableCPInstruction) inst).getInput1().getName());
        } else {
            // construct packed rmvar instruction
            if (!currRmVar.isEmpty()) {
                ret.add(VariableCPInstruction.prepareRemoveInstruction(currRmVar.toArray(new String[0])));
                currRmVar.clear();
            }
            // add other instruction
            ret.add(inst);
        }
    }
    // construct last packed rmvar instruction
    if (!currRmVar.isEmpty()) {
        ret.add(VariableCPInstruction.prepareRemoveInstruction(currRmVar.toArray(new String[0])));
    }
    return ret;
}
Also used : VariableCPInstruction(org.apache.sysml.runtime.instructions.cp.VariableCPInstruction) ArrayList(java.util.ArrayList) MRJobInstruction(org.apache.sysml.runtime.instructions.MRJobInstruction) CPInstruction(org.apache.sysml.runtime.instructions.cp.CPInstruction) Instruction(org.apache.sysml.runtime.instructions.Instruction) VariableCPInstruction(org.apache.sysml.runtime.instructions.cp.VariableCPInstruction)

Aggregations

VariableCPInstruction (org.apache.sysml.runtime.instructions.cp.VariableCPInstruction)7 ArrayList (java.util.ArrayList)3 Instruction (org.apache.sysml.runtime.instructions.Instruction)3 MRJobInstruction (org.apache.sysml.runtime.instructions.MRJobInstruction)3 CPInstruction (org.apache.sysml.runtime.instructions.cp.CPInstruction)3 DataGenCPInstruction (org.apache.sysml.runtime.instructions.cp.DataGenCPInstruction)2 FunctionCallCPInstruction (org.apache.sysml.runtime.instructions.cp.FunctionCallCPInstruction)2 StringInitCPInstruction (org.apache.sysml.runtime.instructions.cp.StringInitCPInstruction)2 HashMap (java.util.HashMap)1 MatrixObject (org.apache.sysml.runtime.controlprogram.caching.MatrixObject)1 AggregateTernaryCPInstruction (org.apache.sysml.runtime.instructions.cp.AggregateTernaryCPInstruction)1 AggregateUnaryCPInstruction (org.apache.sysml.runtime.instructions.cp.AggregateUnaryCPInstruction)1 BinaryCPInstruction (org.apache.sysml.runtime.instructions.cp.BinaryCPInstruction)1 MMTSJCPInstruction (org.apache.sysml.runtime.instructions.cp.MMTSJCPInstruction)1 MultiReturnBuiltinCPInstruction (org.apache.sysml.runtime.instructions.cp.MultiReturnBuiltinCPInstruction)1 ParameterizedBuiltinCPInstruction (org.apache.sysml.runtime.instructions.cp.ParameterizedBuiltinCPInstruction)1 UnaryCPInstruction (org.apache.sysml.runtime.instructions.cp.UnaryCPInstruction)1 AggregateOperationTypes (org.apache.sysml.runtime.matrix.operators.CMOperator.AggregateOperationTypes)1