You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@systemds.apache.org by ba...@apache.org on 2023/10/30 13:52:00 UTC

(systemds) branch main updated: [MINOR] Fix Empty Binary CLA Empty

This is an automated email from the ASF dual-hosted git repository.

baunsgaard pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/systemds.git


The following commit(s) were added to refs/heads/main by this push:
     new 3126e5f794 [MINOR] Fix Empty Binary CLA Empty
3126e5f794 is described below

commit 3126e5f794ffc46ca66a61ebce28999fd952b09f
Author: Sebastian Baunsgaard <ba...@apache.org>
AuthorDate: Mon Oct 30 14:49:01 2023 +0100

    [MINOR] Fix Empty Binary CLA Empty
    
    This commit fixes binary Matrix Vector/Matrix CLA operations to support
    empty sides in some edge case not supported yet, for instance <=.
---
 .../runtime/compress/lib/CLALibBinaryCellOp.java   | 30 +++++++++++++++++-----
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/sysds/runtime/compress/lib/CLALibBinaryCellOp.java b/src/main/java/org/apache/sysds/runtime/compress/lib/CLALibBinaryCellOp.java
index 13e5e3c938..ede9ca46aa 100644
--- a/src/main/java/org/apache/sysds/runtime/compress/lib/CLALibBinaryCellOp.java
+++ b/src/main/java/org/apache/sysds/runtime/compress/lib/CLALibBinaryCellOp.java
@@ -74,9 +74,14 @@ public final class CLALibBinaryCellOp {
 			ScalarOperator sop = new RightScalarOperator(op.fn, that.getValue(0, 0), op.getNumThreads());
 			return CLALibScalar.scalarOperations(sop, m1, result);
 		}
-		if(that.isEmpty())
+		else if(that.isEmpty())
 			return binaryOperationsEmpty(op, m1, that, result);
+		else
+			return binaryOperationsRightFiltered(op, m1, that, result);
+	}
 
+	private static MatrixBlock binaryOperationsRightFiltered(BinaryOperator op, CompressedMatrixBlock m1,
+		MatrixBlock that, MatrixBlock result) {
 		LibMatrixBincell.isValidDimensionsBinaryExtended(m1, that);
 
 		BinaryAccessType atype = LibMatrixBincell.getBinaryAccessTypeExtended(m1, that);
@@ -113,17 +118,16 @@ public final class CLALibBinaryCellOp {
 
 		final ValueFunction fn = op.fn;
 		if(fn instanceof Multiply)
-			result = CompressedMatrixBlockFactory.createConstant(m1Row, m1Col, 0);
+			return CompressedMatrixBlockFactory.createConstant(m1Row, m1Col, 0);
 		else if(fn instanceof Minus1Multiply)
-			result = CompressedMatrixBlockFactory.createConstant(m1Row, m1Col, 1);
+			return CompressedMatrixBlockFactory.createConstant(m1Row, m1Col, 1);
 		else if(fn instanceof Minus || fn instanceof Plus || fn instanceof MinusMultiply || fn instanceof PlusMultiply) {
 			CompressedMatrixBlock ret = new CompressedMatrixBlock();
 			ret.copy(m1);
 			return ret;
 		}
 		else
-			throw new NotImplementedException("Function Type: " + fn);
-		return result;
+			return binaryOperationsRightFiltered(op, m1, that, result);
 	}
 
 	private static MatrixBlock selectProcessingBasedOnAccessType(BinaryOperator op, CompressedMatrixBlock m1,
@@ -612,8 +616,11 @@ public final class CLALibBinaryCellOp {
 		}
 
 		private final void processRight(final int rl, final int ru) {
+
+			if(_m2.isEmpty())
+				processRightEmpty(rl, ru);
 			// all exec should have ret on left side
-			if(_m2.isInSparseFormat())
+			else if(_m2.isInSparseFormat())
 				processRightSparse(rl, ru);
 			else
 				processRightDense(rl, ru);
@@ -662,6 +669,17 @@ public final class CLALibBinaryCellOp {
 					retV[c] = _op.fn.execute(retV[c], m2V[c]);
 			}
 		}
+
+		private final void processRightEmpty(final int rl, final int ru) {
+			final DenseBlock rv = _ret.getDenseBlock();
+			final int cols = _ret.getNumColumns();
+			for(int r = rl; r < ru; r++) {
+				final double[] retV = rv.values(r);
+				int off = rv.pos(r);
+				for(int c = off; c < cols + off; c++)
+					retV[c] = _op.fn.execute(retV[c], 0);
+			}
+		}
 	}
 
 	private static class BinaryMVColLeftTask implements Callable<Integer> {