Repository: systemml Updated Branches: refs/heads/master 07650acf2 -> ab8cccdff
[MINOR] Fixes baseline sparsity estimators (layered graph, bitset) This patch fixes (1) the selection of bitset implementations according to input datasize, and (2) operation-specific API of the layered graph. Project: http://git-wip-us.apache.org/repos/asf/systemml/repo Commit: http://git-wip-us.apache.org/repos/asf/systemml/commit/ab8cccdf Tree: http://git-wip-us.apache.org/repos/asf/systemml/tree/ab8cccdf Diff: http://git-wip-us.apache.org/repos/asf/systemml/diff/ab8cccdf Branch: refs/heads/master Commit: ab8cccdff8465cf29acd4887b1009989a9e7c97f Parents: 07650ac Author: Matthias Boehm <[email protected]> Authored: Sun Oct 21 02:01:45 2018 +0200 Committer: Matthias Boehm <[email protected]> Committed: Sun Oct 21 02:01:45 2018 +0200 ---------------------------------------------------------------------- .../sysml/hops/estim/EstimatorBitsetMM.java | 18 +++++++++++++++--- .../sysml/hops/estim/EstimatorLayeredGraph.java | 2 ++ 2 files changed, 17 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/systemml/blob/ab8cccdf/src/main/java/org/apache/sysml/hops/estim/EstimatorBitsetMM.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/hops/estim/EstimatorBitsetMM.java b/src/main/java/org/apache/sysml/hops/estim/EstimatorBitsetMM.java index 99354fd..3d3c4f0 100644 --- a/src/main/java/org/apache/sysml/hops/estim/EstimatorBitsetMM.java +++ b/src/main/java/org/apache/sysml/hops/estim/EstimatorBitsetMM.java @@ -71,9 +71,9 @@ public class EstimatorBitsetMM extends SparsityEstimator if( isExactMetadataOp(op) ) return estimExactMetaData(m1.getMatrixCharacteristics(), m2.getMatrixCharacteristics(), op).getSparsity(); - BitsetMatrix m1Map = new BitsetMatrix1(m1); + BitsetMatrix m1Map = createBitset(m1); BitsetMatrix m2Map = (m1 == m2) ? //self product - m1Map : new BitsetMatrix1(m2); + m1Map : createBitset(m2); BitsetMatrix outMap = estimInternal(m1Map, m2Map, op); return OptimizerUtils.getSparsity(outMap.getNumRows(), outMap.getNumColumns(), outMap.getNonZeros()); @@ -83,7 +83,7 @@ public class EstimatorBitsetMM extends SparsityEstimator public double estim(MatrixBlock m, OpCode op) { if( isExactMetadataOp(op) ) return estimExactMetaData(m.getMatrixCharacteristics(), null, op).getSparsity(); - BitsetMatrix m1Map = new BitsetMatrix1(m); + BitsetMatrix m1Map = createBitset(m); BitsetMatrix outMap = estimInternal(m1Map, null, op); return OptimizerUtils.getSparsity(outMap.getNumRows(), outMap.getNumColumns(), outMap.getNonZeros()); @@ -199,6 +199,18 @@ public class EstimatorBitsetMM extends SparsityEstimator //protected abstract BitsetMatrix reshape(int rows, int cols, boolean byrow); } + public static BitsetMatrix createBitset(int m, int n) { + return (long)m*n < Integer.MAX_VALUE ? + new BitsetMatrix1(m, n) : //linearized long array + new BitsetMatrix2(m, n); //bitset per row + } + + public static BitsetMatrix createBitset(MatrixBlock in) { + return in.getLength() < Integer.MAX_VALUE ? + new BitsetMatrix1(in) : //linearized long array + new BitsetMatrix2(in); //bitset per row + } + /** * This class represents a boolean matrix and provides key operations. * In the interest of a cache-conscious matrix multiplication and reduced http://git-wip-us.apache.org/repos/asf/systemml/blob/ab8cccdf/src/main/java/org/apache/sysml/hops/estim/EstimatorLayeredGraph.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/hops/estim/EstimatorLayeredGraph.java b/src/main/java/org/apache/sysml/hops/estim/EstimatorLayeredGraph.java index 9fbc384..d76c165 100644 --- a/src/main/java/org/apache/sysml/hops/estim/EstimatorLayeredGraph.java +++ b/src/main/java/org/apache/sysml/hops/estim/EstimatorLayeredGraph.java @@ -62,6 +62,8 @@ public class EstimatorLayeredGraph extends SparsityEstimator { @Override public double estim(MatrixBlock m1, MatrixBlock m2, OpCode op) { + if( op == OpCode.MM ) + return estim(m1, m2); throw new NotImplementedException(); }
