This is an automated email from the ASF dual-hosted git repository.
baunsgaard pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/systemds.git
The following commit(s) were added to refs/heads/main by this push:
new 374d60f [SYSTEMDS-3316] Command-line Seeding
374d60f is described below
commit 374d60f4e76a7b6e876be31ade691e6e3320bd8f
Author: baunsgaard <[email protected]>
AuthorDate: Tue Mar 15 17:09:24 2022 +0100
[SYSTEMDS-3316] Command-line Seeding
This commit adds a seed argument to the command-line interface.
The seed is to be used in CLA for seeding the compression to make the
compression reproducible across executions, but the see could be
used in other instances as well.
---
src/main/java/org/apache/sysds/api/DMLOptions.java | 13 +++++++++++--
src/main/java/org/apache/sysds/api/DMLScript.java | 3 +++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/apache/sysds/api/DMLOptions.java
b/src/main/java/org/apache/sysds/api/DMLOptions.java
index 55773ed..f2c3f56 100644
--- a/src/main/java/org/apache/sysds/api/DMLOptions.java
+++ b/src/main/java/org/apache/sysds/api/DMLOptions.java
@@ -75,8 +75,9 @@ public class DMLOptions {
public int fedWorkerPort = -1;
public int pythonPort = -1;
public boolean checkPrivacy = false; // Check
which privacy constraints are loaded and checked during federated execution
- public boolean federatedCompilation = false;
// Compile federated instructions based on input federation state and privacy
constraints.
- public boolean noFedRuntimeConversion = false;
// If activated, no runtime conversion of CP instructions to FED instructions
will be performed.
+ public boolean federatedCompilation = false; //
Compile federated instructions based on input federation state and privacy
constraints.
+ public boolean noFedRuntimeConversion = false; // If
activated, no runtime conversion of CP instructions to FED instructions will be
performed.
+ public int seed = -1; // The
general seed for the execution, if -1 random (system time).
public final static DMLOptions defaultOptions = new DMLOptions(null);
@@ -107,6 +108,7 @@ public class DMLOptions {
", w=" + fedWorker +
", federatedCompilation=" + federatedCompilation +
", noFedRuntimeConversion=" + noFedRuntimeConversion +
+ ", seed=" + seed +
'}';
}
@@ -293,6 +295,9 @@ public class DMLOptions {
dmlOptions.noFedRuntimeConversion = true;
}
+ if(line.hasOption("seed")){
+ dmlOptions.seed =
Integer.parseInt(line.getOptionValue("seed"));
+ }
return dmlOptions;
}
@@ -355,6 +360,9 @@ public class DMLOptions {
Option noFedRuntimeConversion = OptionBuilder
.withDescription("If activated, no runtime conversion
of CP instructions to FED instructions will be performed.")
.create("noFedRuntimeConversion");
+ Option commandlineSeed = OptionBuilder
+ .withDescription("A general seed for the execution
through the commandline")
+ .hasArg().create("seed");
options.addOption(configOpt);
options.addOption(cleanOpt);
@@ -370,6 +378,7 @@ public class DMLOptions {
options.addOption(checkPrivacy);
options.addOption(federatedCompilation);
options.addOption(noFedRuntimeConversion);
+ options.addOption(commandlineSeed);
// Either a clean(-clean), a file(-f), a script(-s) or
help(-help) needs to be specified
OptionGroup fileOrScriptOpt = new OptionGroup()
diff --git a/src/main/java/org/apache/sysds/api/DMLScript.java
b/src/main/java/org/apache/sysds/api/DMLScript.java
index c2ef42c..61ecdf6 100644
--- a/src/main/java/org/apache/sysds/api/DMLScript.java
+++ b/src/main/java/org/apache/sysds/api/DMLScript.java
@@ -137,6 +137,8 @@ public class DMLScript
// Enable eager CUDA free on rmvar
public static boolean EAGER_CUDA_FREE = false;
+ // Global seed
+ public static int SEED = -1;
// flag that indicates whether or not to suppress any prints to stdout
public static boolean _suppressPrint2Stdout = false;
@@ -257,6 +259,7 @@ public class DMLScript
LINEAGE_ESTIMATE = dmlOptions.lineage_estimate;
CHECK_PRIVACY = dmlOptions.checkPrivacy;
LINEAGE_DEBUGGER = dmlOptions.lineage_debugger;
+ SEED = dmlOptions.seed;
String fnameOptConfig = dmlOptions.configFile;
boolean isFile = dmlOptions.filePath != null;