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 2f0a18e  [SYSTEMDS-3074] Lineage trace sinit instruction
2f0a18e is described below

commit 2f0a18e069a02d67043241f43c8d81055e1a4148
Author: arnabp <[email protected]>
AuthorDate: Wed Jul 28 01:19:00 2021 +0200

    [SYSTEMDS-3074] Lineage trace sinit instruction
    
    This patch adds lineage tracing and recompute
    from lineage supports for sinit instruction.
---
 .../instructions/cp/StringInitCPInstruction.java   | 15 +++++++++++++
 .../runtime/lineage/LineageRecomputeUtils.java     | 10 +++++++++
 .../functions/lineage/LineageTraceExecTest.java    |  7 ++++++
 .../functions/lineage/LineageTraceExec7.dml        | 25 ++++++++++++++++++++++
 4 files changed, 57 insertions(+)

diff --git 
a/src/main/java/org/apache/sysds/runtime/instructions/cp/StringInitCPInstruction.java
 
b/src/main/java/org/apache/sysds/runtime/instructions/cp/StringInitCPInstruction.java
index a025e19..7d056de 100644
--- 
a/src/main/java/org/apache/sysds/runtime/instructions/cp/StringInitCPInstruction.java
+++ 
b/src/main/java/org/apache/sysds/runtime/instructions/cp/StringInitCPInstruction.java
@@ -21,11 +21,16 @@ package org.apache.sysds.runtime.instructions.cp;
 
 import java.util.StringTokenizer;
 
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.sysds.common.Types.DataType;
+import org.apache.sysds.common.Types.ValueType;
 import org.apache.sysds.lops.DataGen;
 import org.apache.sysds.lops.Lop;
 import org.apache.sysds.runtime.DMLRuntimeException;
 import org.apache.sysds.runtime.controlprogram.context.ExecutionContext;
 import org.apache.sysds.runtime.instructions.InstructionUtils;
+import org.apache.sysds.runtime.lineage.LineageItem;
+import org.apache.sysds.runtime.lineage.LineageItemUtils;
 import org.apache.sysds.runtime.matrix.data.MatrixBlock;
 import org.apache.sysds.runtime.matrix.operators.Operator;
 
@@ -97,4 +102,14 @@ public class StringInitCPInstruction extends 
UnaryCPInstruction {
                //put output into symbol table
                ec.setMatrixOutput(outName, outBlk);
        }
+
+       @Override
+       public Pair<String, LineageItem> getLineageItem(ExecutionContext ec) {
+               CPOperand rlen = new CPOperand(String.valueOf(getRows()), 
ValueType.INT64, DataType.SCALAR, true);
+               CPOperand clen = new CPOperand(String.valueOf(getCols()), 
ValueType.INT64, DataType.SCALAR, true);
+               CPOperand data = new CPOperand(_data, ValueType.STRING, 
DataType.SCALAR, true);
+               return Pair.of(output.getName(), 
+                               new LineageItem(getOpcode(), 
LineageItemUtils.getLineage(ec, rlen, clen, data)));
+
+       }
 }
diff --git 
a/src/main/java/org/apache/sysds/runtime/lineage/LineageRecomputeUtils.java 
b/src/main/java/org/apache/sysds/runtime/lineage/LineageRecomputeUtils.java
index 3bf36a1..fe31b38 100644
--- a/src/main/java/org/apache/sysds/runtime/lineage/LineageRecomputeUtils.java
+++ b/src/main/java/org/apache/sysds/runtime/lineage/LineageRecomputeUtils.java
@@ -403,6 +403,16 @@ public class LineageRecomputeUtils {
                                                                
operands.put(item.getId(), operands.get(item.getInputs()[0].getId()));
                                                        break;
                                                }
+                                               case StringInit: {
+                                                       HashMap<String, Hop> 
params = new HashMap<>();
+                                                       
params.put(DataExpression.RAND_ROWS, operands.get(item.getInputs()[0].getId()));
+                                                       
params.put(DataExpression.RAND_COLS, operands.get(item.getInputs()[1].getId()));
+                                                       
params.put(DataExpression.RAND_MIN, operands.get(item.getInputs()[2].getId()));
+                                                       
params.put(DataExpression.RAND_MAX, operands.get(item.getInputs()[2].getId()));
+                                                       Hop datagen = new 
DataGenOp(OpOpDG.SINIT, new DataIdentifier("tmp"), params);
+                                                       
operands.put(item.getId(), datagen);
+                                                       break;
+                                               }
                                                default:
                                                        throw new 
DMLRuntimeException("Unsupported instruction "
                                                                + "type: " + 
ctype.name() + " (" + item.getOpcode() + ").");
diff --git 
a/src/test/java/org/apache/sysds/test/functions/lineage/LineageTraceExecTest.java
 
b/src/test/java/org/apache/sysds/test/functions/lineage/LineageTraceExecTest.java
index 4138f89..7e19d1d 100644
--- 
a/src/test/java/org/apache/sysds/test/functions/lineage/LineageTraceExecTest.java
+++ 
b/src/test/java/org/apache/sysds/test/functions/lineage/LineageTraceExecTest.java
@@ -43,6 +43,7 @@ public class LineageTraceExecTest extends LineageBase {
        protected static final String TEST_NAME4 = "LineageTraceExec4"; //rand 
- matrix result - unspecified seed
        protected static final String TEST_NAME5 = "LineageTraceExec5"; //rand 
- scalar result - unspecified seed
        protected static final String TEST_NAME6 = "LineageTraceExec6"; //nary 
rbind
+       protected static final String TEST_NAME7 = "LineageTraceExec7"; //sinit
        
        protected String TEST_CLASS_DIR = TEST_DIR + 
LineageTraceExecTest.class.getSimpleName() + "/";
        
@@ -62,6 +63,7 @@ public class LineageTraceExecTest extends LineageBase {
                addTestConfiguration( TEST_NAME4, new 
TestConfiguration(TEST_CLASS_DIR, TEST_NAME4, new String[] {"R"}) );
                addTestConfiguration( TEST_NAME5, new 
TestConfiguration(TEST_CLASS_DIR, TEST_NAME5, new String[] {"R"}) );
                addTestConfiguration( TEST_NAME6, new 
TestConfiguration(TEST_CLASS_DIR, TEST_NAME6, new String[] {"R"}) );
+               addTestConfiguration( TEST_NAME7, new 
TestConfiguration(TEST_CLASS_DIR, TEST_NAME7, new String[] {"R"}) );
        }
        
        @Test
@@ -93,6 +95,11 @@ public class LineageTraceExecTest extends LineageBase {
        public void testLineageTraceExec6() {
                testLineageTraceExec(TEST_NAME6);
        }
+
+       @Test
+       public void testLineageTraceExec7() {
+               testLineageTraceExec(TEST_NAME7);
+       }
        
        private void testLineageTraceExec(String testname) {
                LOG.debug("------------ BEGIN " + testname + "------------");
diff --git a/src/test/scripts/functions/lineage/LineageTraceExec7.dml 
b/src/test/scripts/functions/lineage/LineageTraceExec7.dml
new file mode 100644
index 0000000..6c20296
--- /dev/null
+++ b/src/test/scripts/functions/lineage/LineageTraceExec7.dml
@@ -0,0 +1,25 @@
+#-------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#-------------------------------------------------------------
+
+X = matrix("1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4", rows=4, cols=4);
+R = X + 1;
+write(R, $2);
+

Reply via email to