[SYSTEMML-1640] Fix codegen row aggregate types / empty input handling This patch makes the following two improvements for robustness, which resolve issues with ARIMA and Cspline:
(1) Hardened row aggregate type selection, in order to handle special cases with squared inputs, where we cannot use the output dimensions to choose between row and column aggregates. (2) Handling of empty side inputs in dot product vector operations. Such empty inputs might occur because we try to avoid unnecessary dense allocation of empty inputs. Project: http://git-wip-us.apache.org/repos/asf/incubator-systemml/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-systemml/commit/52a0a7f0 Tree: http://git-wip-us.apache.org/repos/asf/incubator-systemml/tree/52a0a7f0 Diff: http://git-wip-us.apache.org/repos/asf/incubator-systemml/diff/52a0a7f0 Branch: refs/heads/master Commit: 52a0a7f0d6631bf5f9733b9fd83ee91bae8edadf Parents: cb2d9ac Author: Matthias Boehm <[email protected]> Authored: Sun May 28 17:13:38 2017 -0700 Committer: Matthias Boehm <[email protected]> Committed: Sun May 28 17:13:38 2017 -0700 ---------------------------------------------------------------------- .../org/apache/sysml/hops/codegen/template/TemplateUtils.java | 4 +++- .../org/apache/sysml/runtime/codegen/LibSpoofPrimitives.java | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/52a0a7f0/src/main/java/org/apache/sysml/hops/codegen/template/TemplateUtils.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/hops/codegen/template/TemplateUtils.java b/src/main/java/org/apache/sysml/hops/codegen/template/TemplateUtils.java index 2059e17..e8e3901 100644 --- a/src/main/java/org/apache/sysml/hops/codegen/template/TemplateUtils.java +++ b/src/main/java/org/apache/sysml/hops/codegen/template/TemplateUtils.java @@ -239,7 +239,9 @@ public class TemplateUtils public static RowType getRowType(Hop output, Hop input) { if( HopRewriteUtils.isEqualSize(output, input) ) return RowType.NO_AGG; - else if( output.getDim1()==input.getDim1() && output.getDim2()==1 ) + else if( output.getDim1()==input.getDim1() && output.getDim2()==1 + && !(output instanceof AggBinaryOp && HopRewriteUtils + .isTransposeOfItself(output.getInput().get(0),input))) return RowType.ROW_AGG; else if( output.getDim1()==input.getDim2() && output.getDim2()==1 ) return RowType.COL_AGG_T; http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/52a0a7f0/src/main/java/org/apache/sysml/runtime/codegen/LibSpoofPrimitives.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/codegen/LibSpoofPrimitives.java b/src/main/java/org/apache/sysml/runtime/codegen/LibSpoofPrimitives.java index 1b4369f..d0f71ce 100644 --- a/src/main/java/org/apache/sysml/runtime/codegen/LibSpoofPrimitives.java +++ b/src/main/java/org/apache/sysml/runtime/codegen/LibSpoofPrimitives.java @@ -48,10 +48,14 @@ public class LibSpoofPrimitives // forwarded calls to LibMatrixMult public static double dotProduct(double[] a, double[] b, int ai, int bi, int len) { + if( a == null || b == null ) + return 0; return LibMatrixMult.dotProduct(a, b, ai, bi, len); } public static double dotProduct(double[] a, double[] b, int[] aix, int ai, int bi, int len) { + if( a == null || b == null ) + return 0; return LibMatrixMult.dotProduct(a, b, aix, ai, bi, len); }
