Search in sources :

Example 11 with UnaryCP

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

the class TernaryOp method constructLopsCentralMoment.

/**
 * Method to construct LOPs when op = CENTRAILMOMENT.
 */
private void constructLopsCentralMoment() {
    if (_op != OpOp3.CENTRALMOMENT)
        throw new HopsException("Unexpected operation: " + _op + ", expecting " + OpOp3.CENTRALMOMENT);
    ExecType et = optFindExecType();
    if (et == ExecType.MR) {
        CombineBinary combine = CombineBinary.constructCombineLop(OperationTypes.PreCentralMoment, 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());
        CentralMoment cm = new CentralMoment(combine, getInput().get(2).constructLops(), DataType.MATRIX, getValueType(), et);
        cm.getOutputParameters().setDimensions(1, 1, 0, 0, -1);
        setLineNumbers(cm);
        UnaryCP unary1 = new UnaryCP(cm, HopsOpOp1LopsUS.get(OpOp1.CAST_AS_SCALAR), getDataType(), getValueType());
        unary1.getOutputParameters().setDimensions(0, 0, 0, 0, -1);
        setLineNumbers(unary1);
        setLops(unary1);
    } else // CP / SPARK
    {
        CentralMoment cm = new CentralMoment(getInput().get(0).constructLops(), getInput().get(1).constructLops(), getInput().get(2).constructLops(), getDataType(), getValueType(), et);
        cm.getOutputParameters().setDimensions(0, 0, 0, 0, -1);
        setLineNumbers(cm);
        setLops(cm);
    }
}
Also used : CombineBinary(org.apache.sysml.lops.CombineBinary) CentralMoment(org.apache.sysml.lops.CentralMoment) ExecType(org.apache.sysml.lops.LopProperties.ExecType) UnaryCP(org.apache.sysml.lops.UnaryCP)

Example 12 with UnaryCP

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

the class TernaryOp method constructLopsCovariance.

/**
 * Method to construct LOPs when op = COVARIANCE.
 */
private void constructLopsCovariance() {
    if (_op != OpOp3.COVARIANCE)
        throw new HopsException("Unexpected operation: " + _op + ", expecting " + OpOp3.COVARIANCE);
    ExecType et = optFindExecType();
    if (et == ExecType.MR) {
        // combineTertiary -> CoVariance -> CastAsScalar
        CombineTernary combine = CombineTernary.constructCombineLop(CombineTernary.OperationTypes.PreCovWeighted, getInput().get(0).constructLops(), getInput().get(1).constructLops(), getInput().get(2).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(), getInput().get(2).constructLops(), getDataType(), getValueType(), et);
        cov.getOutputParameters().setDimensions(0, 0, 0, 0, -1);
        setLineNumbers(cov);
        setLops(cov);
    }
}
Also used : CombineTernary(org.apache.sysml.lops.CombineTernary) CoVariance(org.apache.sysml.lops.CoVariance) ExecType(org.apache.sysml.lops.LopProperties.ExecType) UnaryCP(org.apache.sysml.lops.UnaryCP)

Example 13 with UnaryCP

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

the class UnaryOp method constructLopsIQM.

private Lop constructLopsIQM() {
    ExecType et = optFindExecType();
    Hop input = getInput().get(0);
    if (et == ExecType.MR) {
        CombineUnary combine = CombineUnary.constructCombineLop(input.constructLops(), DataType.MATRIX, getValueType());
        combine.getOutputParameters().setDimensions(input.getDim1(), input.getDim2(), input.getRowsInBlock(), input.getColsInBlock(), input.getNnz());
        SortKeys sort = SortKeys.constructSortByValueLop(combine, SortKeys.OperationTypes.WithoutWeights, DataType.MATRIX, ValueType.DOUBLE, ExecType.MR);
        // Sort dimensions are same as the first input
        sort.getOutputParameters().setDimensions(input.getDim1(), input.getDim2(), input.getRowsInBlock(), input.getColsInBlock(), input.getNnz());
        Data lit = Data.createLiteralLop(ValueType.DOUBLE, Double.toString(0.25));
        lit.setAllPositions(this.getFilename(), this.getBeginLine(), this.getBeginColumn(), this.getEndLine(), this.getEndColumn());
        PickByCount pick = new PickByCount(sort, lit, DataType.MATRIX, getValueType(), PickByCount.OperationTypes.RANGEPICK);
        pick.getOutputParameters().setDimensions(-1, -1, getRowsInBlock(), getColsInBlock(), -1);
        setLineNumbers(pick);
        PartialAggregate pagg = new PartialAggregate(pick, HopsAgg2Lops.get(Hop.AggOp.SUM), HopsDirection2Lops.get(Hop.Direction.RowCol), DataType.MATRIX, getValueType());
        setLineNumbers(pagg);
        // Set the dimensions of PartialAggregate LOP based on the
        // direction in which aggregation is performed
        pagg.setDimensionsBasedOnDirection(getDim1(), getDim2(), getRowsInBlock(), getColsInBlock());
        Group group1 = new Group(pagg, Group.OperationTypes.Sort, DataType.MATRIX, getValueType());
        group1.getOutputParameters().setDimensions(getDim1(), getDim2(), getRowsInBlock(), getColsInBlock(), getNnz());
        setLineNumbers(group1);
        Aggregate agg1 = new Aggregate(group1, HopsAgg2Lops.get(Hop.AggOp.SUM), DataType.MATRIX, getValueType(), ExecType.MR);
        agg1.getOutputParameters().setDimensions(getDim1(), getDim2(), getRowsInBlock(), getColsInBlock(), getNnz());
        agg1.setupCorrectionLocation(pagg.getCorrectionLocation());
        setLineNumbers(agg1);
        UnaryCP unary1 = new UnaryCP(agg1, HopsOpOp1LopsUS.get(OpOp1.CAST_AS_SCALAR), getDataType(), getValueType());
        unary1.getOutputParameters().setDimensions(0, 0, 0, 0, -1);
        setLineNumbers(unary1);
        Unary iqm = new Unary(sort, unary1, Unary.OperationTypes.MR_IQM, DataType.SCALAR, ValueType.DOUBLE, ExecType.CP);
        iqm.getOutputParameters().setDimensions(0, 0, 0, 0, -1);
        setLineNumbers(iqm);
        return iqm;
    } else {
        SortKeys sort = SortKeys.constructSortByValueLop(input.constructLops(), SortKeys.OperationTypes.WithoutWeights, DataType.MATRIX, ValueType.DOUBLE, et);
        sort.getOutputParameters().setDimensions(input.getDim1(), input.getDim2(), input.getRowsInBlock(), input.getColsInBlock(), input.getNnz());
        PickByCount pick = new PickByCount(sort, null, getDataType(), getValueType(), PickByCount.OperationTypes.IQM, et, true);
        pick.getOutputParameters().setDimensions(getDim1(), getDim2(), getRowsInBlock(), getColsInBlock(), getNnz());
        setLineNumbers(pick);
        return pick;
    }
}
Also used : PartialAggregate(org.apache.sysml.lops.PartialAggregate) CumulativePartialAggregate(org.apache.sysml.lops.CumulativePartialAggregate) SortKeys(org.apache.sysml.lops.SortKeys) Group(org.apache.sysml.lops.Group) PickByCount(org.apache.sysml.lops.PickByCount) CombineUnary(org.apache.sysml.lops.CombineUnary) MultiThreadedHop(org.apache.sysml.hops.Hop.MultiThreadedHop) ExecType(org.apache.sysml.lops.LopProperties.ExecType) Data(org.apache.sysml.lops.Data) PartialAggregate(org.apache.sysml.lops.PartialAggregate) CumulativeSplitAggregate(org.apache.sysml.lops.CumulativeSplitAggregate) Aggregate(org.apache.sysml.lops.Aggregate) CumulativePartialAggregate(org.apache.sysml.lops.CumulativePartialAggregate) CombineUnary(org.apache.sysml.lops.CombineUnary) Unary(org.apache.sysml.lops.Unary) UnaryCP(org.apache.sysml.lops.UnaryCP)

Aggregations

UnaryCP (org.apache.sysml.lops.UnaryCP)13 Group (org.apache.sysml.lops.Group)7 Lop (org.apache.sysml.lops.Lop)7 ExecType (org.apache.sysml.lops.LopProperties.ExecType)7 MultiThreadedHop (org.apache.sysml.hops.Hop.MultiThreadedHop)5 Aggregate (org.apache.sysml.lops.Aggregate)5 CombineBinary (org.apache.sysml.lops.CombineBinary)4 CombineUnary (org.apache.sysml.lops.CombineUnary)4 Unary (org.apache.sysml.lops.Unary)4 DataPartition (org.apache.sysml.lops.DataPartition)3 PartialAggregate (org.apache.sysml.lops.PartialAggregate)3 OperationTypes (org.apache.sysml.lops.Aggregate.OperationTypes)2 Binary (org.apache.sysml.lops.Binary)2 CentralMoment (org.apache.sysml.lops.CentralMoment)2 CoVariance (org.apache.sysml.lops.CoVariance)2 ConvolutionTransform (org.apache.sysml.lops.ConvolutionTransform)2 Data (org.apache.sysml.lops.Data)2 PickByCount (org.apache.sysml.lops.PickByCount)2 SortKeys (org.apache.sysml.lops.SortKeys)2 DataType (org.apache.sysml.parser.Expression.DataType)2