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

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


The following commit(s) were added to refs/heads/master by this push:
     new 519b09d  [MINOR] Bug fixes and reuse of spoof instructions
519b09d is described below

commit 519b09d100216c92ae83eb4a6a42d5e684ba0dd2
Author: arnabp <arnab.ph...@tugraz.at>
AuthorDate: Sun Nov 8 15:00:09 2020 +0100

    [MINOR] Bug fixes and reuse of spoof instructions
    
    - This patch allows adding the lineage dags corresponding to
      the spoof instructions to lineage cache. With codegen
      autoencoder with batch wise preprocessing takes 330 seconds,
      where with codegen and lineage caching it takes 215 sescond.
    - This patch fixes the missing re-hashing of the lineage items
      after attaching the spoof lineage dags to the main dag.
    - Furthermore, this patch introduces a inner iteration counter
      for l2svm.
---
 scripts/builtin/l2svm.dml                                         | 8 ++++++--
 .../apache/sysds/runtime/instructions/cp/SpoofCPInstruction.java  | 5 +++++
 .../java/org/apache/sysds/runtime/lineage/LineageCacheConfig.java | 1 +
 src/main/java/org/apache/sysds/runtime/lineage/LineageItem.java   | 5 +++++
 .../java/org/apache/sysds/runtime/lineage/LineageItemUtils.java   | 8 ++++++++
 5 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/scripts/builtin/l2svm.dml b/scripts/builtin/l2svm.dml
index f411fb9..fd99109 100644
--- a/scripts/builtin/l2svm.dml
+++ b/scripts/builtin/l2svm.dml
@@ -48,7 +48,7 @@
 
 m_l2svm = function(Matrix[Double] X, Matrix[Double] Y, Boolean intercept = 
FALSE,
     Double epsilon = 0.001, Double lambda = 1, Integer maxIterations = 100, 
-    Boolean verbose = FALSE, Integer columnId = -1)
+    Integer maxii = 20, Boolean verbose = FALSE, Integer columnId = -1)
   return(Matrix[Double] model)
 {
   #check input parameter assertions
@@ -110,7 +110,8 @@ m_l2svm = function(Matrix[Double] X, Matrix[Double] Y, 
Boolean intercept = FALSE
     wd = lambda * sum(w * s)
     dd = lambda * sum(s * s)
     continue1 = TRUE
-    while(continue1){
+    iiter = 0
+    while(continue1 & iiter < maxii){
       tmp_Xw = Xw + step_sz*Xd
       out = 1 - Y * (tmp_Xw)
       sv = (out > 0)
@@ -119,6 +120,9 @@ m_l2svm = function(Matrix[Double] X, Matrix[Double] Y, 
Boolean intercept = FALSE
       h = dd + sum(Xd * sv * Xd)
       step_sz = step_sz - g/h
       continue1 = (g*g/h >= epsilon)
+      if(verbose)
+        print("Inner Iter:" + toString(iiter))
+      iiter = iiter + 1
     }
 
     #update weights
diff --git 
a/src/main/java/org/apache/sysds/runtime/instructions/cp/SpoofCPInstruction.java
 
b/src/main/java/org/apache/sysds/runtime/instructions/cp/SpoofCPInstruction.java
index f4e262e..6f47ed5 100644
--- 
a/src/main/java/org/apache/sysds/runtime/instructions/cp/SpoofCPInstruction.java
+++ 
b/src/main/java/org/apache/sysds/runtime/instructions/cp/SpoofCPInstruction.java
@@ -99,6 +99,11 @@ public class SpoofCPInstruction extends 
ComputationCPInstruction {
        
        @Override
        public Pair<String, LineageItem> getLineageItem(ExecutionContext ec) {
+               //return the lineage item if already traced once
+               LineageItem li = ec.getLineage().get(output.getName());
+               if (li != null)
+                       return Pair.of(output.getName(), li);
+
                //read and deepcopy the corresponding lineage DAG (pre-codegen)
                LineageItem LIroot = 
LineageCodegenItem.getCodegenLTrace(getOperatorClass().getName()).deepCopy();
                
diff --git 
a/src/main/java/org/apache/sysds/runtime/lineage/LineageCacheConfig.java 
b/src/main/java/org/apache/sysds/runtime/lineage/LineageCacheConfig.java
index 6a235b6..20c9b67 100644
--- a/src/main/java/org/apache/sysds/runtime/lineage/LineageCacheConfig.java
+++ b/src/main/java/org/apache/sysds/runtime/lineage/LineageCacheConfig.java
@@ -188,6 +188,7 @@ public class LineageCacheConfig
                        && !(inst instanceof ListIndexingCPInstruction);
                boolean rightop = (ArrayUtils.contains(REUSE_OPCODES, 
inst.getOpcode())
                        || (inst.getOpcode().equals("append") && 
isVectorAppend(inst, ec))
+                       || (inst.getOpcode().startsWith("spoof"))
                        || (inst instanceof DataGenCPInstruction) && 
((DataGenCPInstruction) inst).isMatrixCall());
                boolean updateInplace = (inst instanceof 
MatrixIndexingCPInstruction)
                        && 
ec.getMatrixObject(((ComputationCPInstruction)inst).input1).getUpdateType().isInPlace();
diff --git a/src/main/java/org/apache/sysds/runtime/lineage/LineageItem.java 
b/src/main/java/org/apache/sysds/runtime/lineage/LineageItem.java
index 90119cc..e34979d 100644
--- a/src/main/java/org/apache/sysds/runtime/lineage/LineageItem.java
+++ b/src/main/java/org/apache/sysds/runtime/lineage/LineageItem.java
@@ -102,6 +102,11 @@ public class LineageItem {
                return _data;
        }
        
+       public void fixHash() {
+               _hash = 0;
+               _hash = hashCode();
+       }
+
        public boolean isVisited() {
                return _visited;
        }
diff --git 
a/src/main/java/org/apache/sysds/runtime/lineage/LineageItemUtils.java 
b/src/main/java/org/apache/sysds/runtime/lineage/LineageItemUtils.java
index 1b1b558..268fd12 100644
--- a/src/main/java/org/apache/sysds/runtime/lineage/LineageItemUtils.java
+++ b/src/main/java/org/apache/sysds/runtime/lineage/LineageItemUtils.java
@@ -36,6 +36,7 @@ import org.apache.sysds.hops.BinaryOp;
 import org.apache.sysds.hops.Hop;
 import org.apache.sysds.hops.IndexingOp;
 import org.apache.sysds.hops.LiteralOp;
+import org.apache.sysds.hops.ParameterizedBuiltinOp;
 import org.apache.sysds.hops.ReorgOp;
 import org.apache.sysds.hops.TernaryOp;
 import org.apache.sysds.hops.UnaryOp;
@@ -212,6 +213,11 @@ public class LineageItemUtils {
                }
                else if (root instanceof IndexingOp)
                        li = new LineageItem(name, "rightIndex", LIinputs);
+               else if (root instanceof ParameterizedBuiltinOp) {
+                       String opcode = ((ParameterizedBuiltinOp) 
root).getOp().toString();
+                       if (opcode.equalsIgnoreCase("replace"))
+                               li = new LineageItem(name, opcode, LIinputs);
+               }
                else if (root instanceof SpoofFusedOp)
                        li = 
LineageCodegenItem.getCodegenLTrace(((SpoofFusedOp) root).getClassName());
                
@@ -375,6 +381,8 @@ public class LineageItemUtils {
                                rReplaceDagLeaves(li, newleaves);
                }
 
+               //fix the hash codes bottom-up, as the inputs have changed
+               root.fixHash();
                root.setVisited();
        }
 

Reply via email to