janniklinde commented on code in PR #2361:
URL: https://github.com/apache/systemds/pull/2361#discussion_r2613913745
##########
src/main/java/org/apache/sysds/runtime/compress/lib/CLALibUnary.java:
##########
@@ -43,6 +49,70 @@ public static MatrixBlock
unaryOperations(CompressedMatrixBlock m, UnaryOperator
final boolean overlapping = m.isOverlapping();
final int r = m.getNumRows();
final int c = m.getNumColumns();
+
+ if(Builtin.isBuiltinCode(op.fn, BuiltinCode.CUMSUM,
BuiltinCode.ROWCUMSUM)) {
+ List<AColGroup> groups = m.getColGroups();
+ boolean allDDC = true;
+ for(AColGroup g : groups) {
+ if(g.getCompType() != CompressionType.DDC) {
+ allDDC = false;
+ break;
+ }
+ }
+
+ if(allDDC && !groups.isEmpty()) {
+ MatrixBlock uncompressed =
m.getUncompressed("CUMSUM/ROWCUMSUM requires uncompression",
op.getNumThreads());
+ MatrixBlock opResult =
uncompressed.unaryOperations(op, null);
+
+ List<AColGroup> convertedGroups = new
ArrayList<>(groups.size());
+ for(AColGroup g : groups) {
+ AColGroup converted = ((ColGroupDDC)
g).convertToDeltaDDC();
+ if(converted == null) {
+ allDDC = false;
+ break;
+ }
+ convertedGroups.add(converted);
+ }
+
+ if(allDDC) {
+ CompressedMatrixBlock ret = new
CompressedMatrixBlock(m.getNumRows(), m.getNumColumns());
+
ret.allocateColGroupList(convertedGroups);
+ ret.recomputeNonZeros();
+
+ MatrixBlock verifyDecompressed =
ret.getUncompressed("Verification", op.getNumThreads());
+ if(verifyDecompressed.equals(opResult))
{
+ return ret;
+ }
+ }
+ }
+
+ MatrixBlock uncompressed =
m.getUncompressed("CUMSUM/ROWCUMSUM requires uncompression",
op.getNumThreads());
+ MatrixBlock opResult = uncompressed.unaryOperations(op,
null);
+
+ CompressionSettingsBuilder csb = new
CompressionSettingsBuilder();
+ csb.clearValidCompression();
+ csb.setPreferDeltaEncoding(true);
+ csb.addValidCompression(CompressionType.DeltaDDC);
+ csb.addValidCompression(CompressionType.UNCOMPRESSED);
+ csb.setTransposeInput("false");
+ Pair<MatrixBlock, CompressionStatistics> compressedPair
= CompressedMatrixBlockFactory.compress(opResult, op.getNumThreads(), csb);
+ MatrixBlock compressedResult = compressedPair.getLeft();
+
+ if(compressedResult == null) {
+ compressedResult = opResult;
+ }
+
+ CompressedMatrixBlock finalResult;
+ if(compressedResult instanceof CompressedMatrixBlock) {
+ finalResult = (CompressedMatrixBlock)
compressedResult;
+ }
+ else {
+ finalResult =
CompressedMatrixBlockFactory.genUncompressedCompressedMatrixBlock(compressedResult);
+ }
+
+ return finalResult;
+ }
+
Review Comment:
In general, it might make more sense to put this branch below `if
(m.isEmpty())`...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]