Repository: systemml Updated Branches: refs/heads/master 8ea38a1b1 -> 4e0c7f1c9
[MINOR] Cleanup redundant LinregCG algorithm test scripts Closes #678. Project: http://git-wip-us.apache.org/repos/asf/systemml/repo Commit: http://git-wip-us.apache.org/repos/asf/systemml/commit/4e0c7f1c Tree: http://git-wip-us.apache.org/repos/asf/systemml/tree/4e0c7f1c Diff: http://git-wip-us.apache.org/repos/asf/systemml/diff/4e0c7f1c Branch: refs/heads/master Commit: 4e0c7f1c98f444926fa0f69b13459220aac67de0 Parents: 8ea38a1 Author: j143 <[email protected]> Authored: Sat Oct 7 16:08:57 2017 -0700 Committer: Matthias Boehm <[email protected]> Committed: Sat Oct 7 16:08:57 2017 -0700 ---------------------------------------------------------------------- .../functions/compress/CompressedLinregCG.java | 24 ++++----- src/test/scripts/functions/compress/LinregCG.R | 57 -------------------- .../scripts/functions/compress/LinregCG.dml | 56 ------------------- 3 files changed, 11 insertions(+), 126 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/systemml/blob/4e0c7f1c/src/test/java/org/apache/sysml/test/integration/functions/compress/CompressedLinregCG.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/sysml/test/integration/functions/compress/CompressedLinregCG.java b/src/test/java/org/apache/sysml/test/integration/functions/compress/CompressedLinregCG.java index be62544..6e2ddef 100644 --- a/src/test/java/org/apache/sysml/test/integration/functions/compress/CompressedLinregCG.java +++ b/src/test/java/org/apache/sysml/test/integration/functions/compress/CompressedLinregCG.java @@ -55,6 +55,7 @@ public class CompressedLinregCG extends AutomatedTestBase private final static int intercept = 0; private final static double epsilon = 0.000000001; private final static double maxiter = 10; + private final static double regular = 0.001; @Override public void setUp() { @@ -103,20 +104,17 @@ public class CompressedLinregCG extends AutomatedTestBase TestConfiguration config = getTestConfiguration(TEST_NAME); /* This is for running the junit test the new way, i.e., construct the arguments directly */ - String HOME = SCRIPT_DIR + TEST_DIR; - fullDMLScriptName = HOME + TEST_NAME + ".dml"; - programArgs = new String[]{ "-explain","-stats", - "-args", HOME + INPUT_DIR + "X", - HOME + INPUT_DIR + "y", - String.valueOf(intercept), - String.valueOf(epsilon), - String.valueOf(maxiter), - HOME + OUTPUT_DIR + "w"}; - fullRScriptName = HOME + TEST_NAME + ".R"; + String HOME = SCRIPT_DIR + "functions/codegen/"; + fullDMLScriptName = "scripts/algorithms/LinearRegCG.dml"; + programArgs = new String[]{ "-explain", "-stats", "-nvargs", "X="+input("X"), "Y="+input("y"), + "icpt="+String.valueOf(intercept), "tol="+String.valueOf(epsilon), + "maxi="+String.valueOf(maxiter), "reg="+String.valueOf(regular), "B="+output("w")}; + + fullRScriptName = HOME + "Algorithm_LinregCG.R"; rCmd = "Rscript" + " " + fullRScriptName + " " + - HOME + INPUT_DIR + " " + + HOME + INPUT_DIR + " " + String.valueOf(intercept) + " " + String.valueOf(epsilon) + " " + - String.valueOf(maxiter) + " " + HOME + EXPECTED_DIR; + String.valueOf(maxiter) + " " + String.valueOf(regular) + HOME + EXPECTED_DIR; loadTestConfiguration(config); @@ -158,4 +156,4 @@ public class CompressedLinregCG extends AutomatedTestBase System.out.println("This test case overrides default configuration with " + TEST_CONF_FILE.getPath()); return TEST_CONF_FILE; } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/systemml/blob/4e0c7f1c/src/test/scripts/functions/compress/LinregCG.R ---------------------------------------------------------------------- diff --git a/src/test/scripts/functions/compress/LinregCG.R b/src/test/scripts/functions/compress/LinregCG.R deleted file mode 100644 index 5dcad95..0000000 --- a/src/test/scripts/functions/compress/LinregCG.R +++ /dev/null @@ -1,57 +0,0 @@ -#------------------------------------------------------------- -# -# 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. -# -#------------------------------------------------------------- - - -args <- commandArgs(TRUE) -options(digits=22) -library("Matrix") - -X = readMM(paste(args[1], "X.mtx", sep="")) -y = readMM(paste(args[1], "y.mtx", sep="")) - -intercept = as.integer(args[2]); -eps = as.double(args[3]); -maxiter = as.double(args[4]); - -if( intercept == 1 ){ - ones = matrix(1, nrow(X), 1); - X = cbind(X, ones); -} - -r = -(t(X) %*% y); -p = -r; -norm_r2 = sum(r * r); -w = matrix(0, ncol(X), 1); - -i = 0; -while(i < maxiter) { - q = ((t(X) %*% (X %*% p)) + eps * p); - alpha = norm_r2 / ((t(p) %*% q)[1:1]); - w = w + alpha * p; - old_norm_r2 = norm_r2; - r = r + alpha * q; - norm_r2 = sum(r * r); - beta = norm_r2 / old_norm_r2; - p = -r + beta * p; - i = i + 1; -} - -writeMM(as(w,"CsparseMatrix"), paste(args[5], "w", sep="")) http://git-wip-us.apache.org/repos/asf/systemml/blob/4e0c7f1c/src/test/scripts/functions/compress/LinregCG.dml ---------------------------------------------------------------------- diff --git a/src/test/scripts/functions/compress/LinregCG.dml b/src/test/scripts/functions/compress/LinregCG.dml deleted file mode 100644 index 8a9d990..0000000 --- a/src/test/scripts/functions/compress/LinregCG.dml +++ /dev/null @@ -1,56 +0,0 @@ -#------------------------------------------------------------- -# -# 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 = read($1); -y = read($2); -intercept = $3; -eps = $4; -maxiter = $5; - -if( intercept == 1 ){ - ones = matrix(1, nrow(X), 1); - X = cbind(X, ones); -} - -r = -(t(X) %*% y); -p = -r; -norm_r2 = sum(r * r); -w = matrix(0, rows = ncol(X), cols = 1); - -i = 0; -while(i < maxiter) { - q = ((t(X) %*% (X %*% p)) + eps * p); - alpha = norm_r2 / castAsScalar(t(p) %*% q); - w = w + alpha * p; - old_norm_r2 = norm_r2; - r = r + alpha * q; - norm_r2 = sum(r * r); - beta = norm_r2 / old_norm_r2; - p = -r + beta * p; - i = i + 1; -} - -write(w, $6); - - - -
