Search in sources :

Example 6 with FunctionCallCP

use of org.apache.sysml.lops.FunctionCallCP in project systemml by apache.

the class Dag method getOutputInfo.

/**
 * Method that determines the output format for a given node.
 *
 * @param node low-level operator
 * @param cellModeOverride override mode
 * @return output info
 */
private static OutputInfo getOutputInfo(Lop node, boolean cellModeOverride) {
    if ((node.getDataType() == DataType.SCALAR && node.getExecType() == ExecType.CP) || node instanceof FunctionCallCP)
        return null;
    OutputInfo oinfo = null;
    OutputParameters oparams = node.getOutputParameters();
    if (oparams.isBlocked()) {
        if (!cellModeOverride)
            oinfo = OutputInfo.BinaryBlockOutputInfo;
        else {
            // output format is overridden, for example, due to recordReaderInstructions in the job
            oinfo = OutputInfo.BinaryCellOutputInfo;
            // which stores the outputInfo.
            try {
                oparams.setDimensions(oparams.getNumRows(), oparams.getNumCols(), -1, -1, oparams.getNnz(), oparams.getUpdateType());
            } catch (HopsException e) {
                throw new LopsException(node.printErrorLocation() + "error in getOutputInfo in Dag ", e);
            }
        }
    } else {
        if (oparams.getFormat() == Format.TEXT || oparams.getFormat() == Format.MM)
            oinfo = OutputInfo.TextCellOutputInfo;
        else if (oparams.getFormat() == Format.CSV) {
            oinfo = OutputInfo.CSVOutputInfo;
        } else {
            oinfo = OutputInfo.BinaryCellOutputInfo;
        }
    }
    /* Instead of following hardcoding, one must get this information from Lops */
    if (node.getType() == Type.SortKeys && node.getExecType() == ExecType.MR) {
        if (((SortKeys) node).getOpType() == SortKeys.OperationTypes.Indexes)
            oinfo = OutputInfo.BinaryBlockOutputInfo;
        else
            oinfo = OutputInfo.OutputInfoForSortOutput;
    } else if (node.getType() == Type.CombineBinary) {
        // Output format of CombineBinary (CB) depends on how the output is consumed
        CombineBinary combine = (CombineBinary) node;
        if (combine.getOperation() == org.apache.sysml.lops.CombineBinary.OperationTypes.PreSort) {
            oinfo = OutputInfo.OutputInfoForSortInput;
        } else if (combine.getOperation() == org.apache.sysml.lops.CombineBinary.OperationTypes.PreCentralMoment || combine.getOperation() == org.apache.sysml.lops.CombineBinary.OperationTypes.PreCovUnweighted || combine.getOperation() == org.apache.sysml.lops.CombineBinary.OperationTypes.PreGroupedAggUnweighted) {
            oinfo = OutputInfo.WeightedPairOutputInfo;
        }
    } else if (node.getType() == Type.CombineTernary) {
        oinfo = OutputInfo.WeightedPairOutputInfo;
    } else if (node.getType() == Type.CentralMoment || node.getType() == Type.CoVariance) {
        // CMMR always operate in "cell mode",
        // and the output is always in cell format
        oinfo = OutputInfo.BinaryCellOutputInfo;
    }
    return oinfo;
}
Also used : OutputInfo(org.apache.sysml.runtime.matrix.data.OutputInfo) CombineBinary(org.apache.sysml.lops.CombineBinary) OutputParameters(org.apache.sysml.lops.OutputParameters) LopsException(org.apache.sysml.lops.LopsException) FunctionCallCP(org.apache.sysml.lops.FunctionCallCP) HopsException(org.apache.sysml.hops.HopsException)

Aggregations

FunctionCallCP (org.apache.sysml.lops.FunctionCallCP)6 Lop (org.apache.sysml.lops.Lop)4 OutputParameters (org.apache.sysml.lops.OutputParameters)4 ArrayList (java.util.ArrayList)2 HopsException (org.apache.sysml.hops.HopsException)2 CombineBinary (org.apache.sysml.lops.CombineBinary)2 Data (org.apache.sysml.lops.Data)2 FunctionCallCPSingle (org.apache.sysml.lops.FunctionCallCPSingle)2 ExecType (org.apache.sysml.lops.LopProperties.ExecType)2 LopsException (org.apache.sysml.lops.LopsException)2 Instruction (org.apache.sysml.runtime.instructions.Instruction)2 MRJobInstruction (org.apache.sysml.runtime.instructions.MRJobInstruction)2 CPInstruction (org.apache.sysml.runtime.instructions.cp.CPInstruction)2 VariableCPInstruction (org.apache.sysml.runtime.instructions.cp.VariableCPInstruction)2 MatrixCharacteristics (org.apache.sysml.runtime.matrix.MatrixCharacteristics)2 OutputInfo (org.apache.sysml.runtime.matrix.data.OutputInfo)2