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;
}
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;
}
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;
}
Aggregations