Search in sources :

Example 1 with ColGroup

use of org.apache.sysml.runtime.compress.ColGroup in project incubator-systemml by apache.

the class ConverterUtils method getUncompressedColBlock.

public static MatrixBlock getUncompressedColBlock(ColGroup group) {
    MatrixBlock ret = null;
    if (group instanceof ColGroupUncompressed) {
        ret = ((ColGroupUncompressed) group).getData();
    } else {
        ArrayList<ColGroup> tmpGroup = new ArrayList<ColGroup>(Arrays.asList(group));
        ColGroupUncompressed decompressedCols = new ColGroupUncompressed(tmpGroup);
        ret = decompressedCols.getData();
    }
    return ret;
}
Also used : MatrixBlock(org.apache.sysml.runtime.matrix.data.MatrixBlock) ColGroup(org.apache.sysml.runtime.compress.ColGroup) ArrayList(java.util.ArrayList) ColGroupUncompressed(org.apache.sysml.runtime.compress.ColGroupUncompressed)

Example 2 with ColGroup

use of org.apache.sysml.runtime.compress.ColGroup in project incubator-systemml by apache.

the class SpoofCellwise method executeCompressedAggSum.

private double executeCompressedAggSum(CompressedMatrixBlock a, SideInput[] b, double[] scalars, int m, int n, boolean sparseSafe, int rl, int ru) {
    KahanFunction kplus = (KahanFunction) getAggFunction();
    KahanObject kbuff = new KahanObject(0, 0);
    KahanObject kbuff2 = new KahanObject(0, 0);
    // special case: computation over value-tuples only
    if (sparseSafe && b.length == 0 && !a.hasUncompressedColGroup()) {
        // note: all remaining groups are guaranteed ColGroupValue
        boolean entireGrp = (rl == 0 && ru == a.getNumRows());
        int maxNumVals = a.getColGroups().stream().mapToInt(g -> ((ColGroupValue) g).getNumValues()).max().orElse(0);
        int[] counts = new int[maxNumVals];
        for (ColGroup grp : a.getColGroups()) {
            ColGroupValue grpv = (ColGroupValue) grp;
            counts = entireGrp ? grpv.getCounts(counts) : grpv.getCounts(rl, ru, counts);
            for (int k = 0; k < grpv.getNumValues(); k++) {
                kbuff2.set(0, 0);
                double in = grpv.sumValues(k, kplus, kbuff2);
                double out = genexec(in, b, scalars, m, n, -1, -1);
                kplus.execute3(kbuff, out, counts[k]);
            }
        }
    } else // general case of arbitrary side inputs
    {
        Iterator<IJV> iter = a.getIterator(rl, ru, !sparseSafe);
        while (iter.hasNext()) {
            IJV cell = iter.next();
            double val = genexec(cell.getV(), b, scalars, m, n, cell.getI(), cell.getJ());
            kplus.execute2(kbuff, val);
        }
    }
    return kbuff._sum;
}
Also used : ColGroup(org.apache.sysml.runtime.compress.ColGroup) IJV(org.apache.sysml.runtime.matrix.data.IJV) KahanFunction(org.apache.sysml.runtime.functionobjects.KahanFunction) KahanObject(org.apache.sysml.runtime.instructions.cp.KahanObject) ColGroupValue(org.apache.sysml.runtime.compress.ColGroupValue)

Example 3 with ColGroup

use of org.apache.sysml.runtime.compress.ColGroup in project incubator-systemml by apache.

the class ConverterUtils method copyColGroup.

/**
 * Copy col group instance with deep copy of column indices but
 * shallow copy of actual contents;
 *
 * @param group column group
 * @return column group (deep copy of indices but shallow copy of contents)
 */
public static ColGroup copyColGroup(ColGroup group) {
    ColGroup ret = null;
    // deep copy col indices
    int[] colIndices = Arrays.copyOf(group.getColIndices(), group.getNumCols());
    // create copy of column group
    if (group instanceof ColGroupUncompressed) {
        ColGroupUncompressed in = (ColGroupUncompressed) group;
        ret = new ColGroupUncompressed(colIndices, in.getNumRows(), in.getData());
    } else if (group instanceof ColGroupRLE) {
        ColGroupRLE in = (ColGroupRLE) group;
        ret = new ColGroupRLE(colIndices, in.getNumRows(), in.hasZeros(), in.getValues(), in.getBitmaps(), in.getBitmapOffsets());
    } else if (group instanceof ColGroupOLE) {
        ColGroupOLE in = (ColGroupOLE) group;
        ret = new ColGroupOLE(colIndices, in.getNumRows(), in.hasZeros(), in.getValues(), in.getBitmaps(), in.getBitmapOffsets());
    }
    return ret;
}
Also used : ColGroupOLE(org.apache.sysml.runtime.compress.ColGroupOLE) ColGroup(org.apache.sysml.runtime.compress.ColGroup) ColGroupRLE(org.apache.sysml.runtime.compress.ColGroupRLE) ColGroupUncompressed(org.apache.sysml.runtime.compress.ColGroupUncompressed)

Aggregations

ColGroup (org.apache.sysml.runtime.compress.ColGroup)3 ColGroupUncompressed (org.apache.sysml.runtime.compress.ColGroupUncompressed)2 ArrayList (java.util.ArrayList)1 ColGroupOLE (org.apache.sysml.runtime.compress.ColGroupOLE)1 ColGroupRLE (org.apache.sysml.runtime.compress.ColGroupRLE)1 ColGroupValue (org.apache.sysml.runtime.compress.ColGroupValue)1 KahanFunction (org.apache.sysml.runtime.functionobjects.KahanFunction)1 KahanObject (org.apache.sysml.runtime.instructions.cp.KahanObject)1 IJV (org.apache.sysml.runtime.matrix.data.IJV)1 MatrixBlock (org.apache.sysml.runtime.matrix.data.MatrixBlock)1