Search in sources :

Example 6 with CombineBinary

use of org.apache.sysml.lops.CombineBinary in project incubator-systemml by apache.

the class BinaryOp method constructLopsCovariance.

private void constructLopsCovariance(ExecType et) throws LopsException, HopsException {
    if (et == ExecType.MR) {
        // combineBinary -> CoVariance -> CastAsScalar
        CombineBinary combine = CombineBinary.constructCombineLop(OperationTypes.PreCovUnweighted, getInput().get(0).constructLops(), getInput().get(1).constructLops(), DataType.MATRIX, getValueType());
        combine.getOutputParameters().setDimensions(getInput().get(0).getDim1(), getInput().get(0).getDim2(), getInput().get(0).getRowsInBlock(), getInput().get(0).getColsInBlock(), getInput().get(0).getNnz());
        CoVariance cov = new CoVariance(combine, DataType.MATRIX, getValueType(), et);
        cov.getOutputParameters().setDimensions(1, 1, 0, 0, -1);
        setLineNumbers(cov);
        UnaryCP unary1 = new UnaryCP(cov, HopsOpOp1LopsUS.get(OpOp1.CAST_AS_SCALAR), getDataType(), getValueType());
        unary1.getOutputParameters().setDimensions(0, 0, 0, 0, -1);
        setLineNumbers(unary1);
        setLops(unary1);
    } else //CP/SPARK
    {
        CoVariance cov = new CoVariance(getInput().get(0).constructLops(), getInput().get(1).constructLops(), getDataType(), getValueType(), et);
        cov.getOutputParameters().setDimensions(0, 0, 0, 0, -1);
        setLineNumbers(cov);
        setLops(cov);
    }
}
Also used : CombineBinary(org.apache.sysml.lops.CombineBinary) CoVariance(org.apache.sysml.lops.CoVariance) UnaryCP(org.apache.sysml.lops.UnaryCP)

Example 7 with CombineBinary

use of org.apache.sysml.lops.CombineBinary in project incubator-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
	 * @throws LopsException if LopsException occurs
	 */
private static OutputInfo getOutputInfo(Lop node, boolean cellModeOverride) throws LopsException {
    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

CombineBinary (org.apache.sysml.lops.CombineBinary)7 ExecType (org.apache.sysml.lops.LopProperties.ExecType)3 PickByCount (org.apache.sysml.lops.PickByCount)3 SortKeys (org.apache.sysml.lops.SortKeys)3 UnaryCP (org.apache.sysml.lops.UnaryCP)3 Data (org.apache.sysml.lops.Data)2 LopsException (org.apache.sysml.lops.LopsException)2 DoubleWritable (org.apache.hadoop.io.DoubleWritable)1 IntWritable (org.apache.hadoop.io.IntWritable)1 HopsException (org.apache.sysml.hops.HopsException)1 Aggregate (org.apache.sysml.lops.Aggregate)1 CentralMoment (org.apache.sysml.lops.CentralMoment)1 CoVariance (org.apache.sysml.lops.CoVariance)1 CombineUnary (org.apache.sysml.lops.CombineUnary)1 FunctionCallCP (org.apache.sysml.lops.FunctionCallCP)1 Group (org.apache.sysml.lops.Group)1 Lop (org.apache.sysml.lops.Lop)1 OutputParameters (org.apache.sysml.lops.OutputParameters)1 PartialAggregate (org.apache.sysml.lops.PartialAggregate)1 Unary (org.apache.sysml.lops.Unary)1