use of org.apache.sysml.runtime.compress.ColGroupValue 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.ColGroupValue in project 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;
}
Aggregations