use of org.apache.sysml.test.integration.TestConfiguration in project incubator-systemml by apache.
the class VarianceTest method setUp.
@Override
public void setUp() {
TestUtils.clearAssertionInformation();
TestConfiguration config = new TestConfiguration(TEST_CLASS_DIR, TEST_NAME);
addTestConfiguration(TEST_NAME, config);
}
use of org.apache.sysml.test.integration.TestConfiguration in project incubator-systemml by apache.
the class AppendMatrixTest method commonAppendTest.
/**
* @param platform
* @param rows
* @param cols1
* @param cols2
* @param sparse
*/
public void commonAppendTest(RUNTIME_PLATFORM platform, int rows, int cols1, int cols2, boolean sparse, AppendMethod forcedAppendMethod) {
TestConfiguration config = getAndLoadTestConfiguration(TEST_NAME);
RUNTIME_PLATFORM prevPlfm = rtplatform;
double sparsity = (sparse) ? sparsity2 : sparsity1;
boolean sparkConfigOld = DMLScript.USE_LOCAL_SPARK_CONFIG;
try {
if (forcedAppendMethod != null) {
BinaryOp.FORCED_APPEND_METHOD = forcedAppendMethod;
}
rtplatform = platform;
if (rtplatform == RUNTIME_PLATFORM.SPARK)
DMLScript.USE_LOCAL_SPARK_CONFIG = true;
config.addVariable("rows", rows);
config.addVariable("cols", cols1);
/* This is for running the junit test the new way, i.e., construct the arguments directly */
String RI_HOME = SCRIPT_DIR + TEST_DIR;
fullDMLScriptName = RI_HOME + TEST_NAME + ".dml";
programArgs = new String[] { "-args", input("A"), Long.toString(rows), Long.toString(cols1), input("B"), Long.toString(cols2), output("C") };
fullRScriptName = RI_HOME + TEST_NAME + ".R";
rCmd = "Rscript" + " " + fullRScriptName + " " + inputDir() + " " + expectedDir();
Random rand = new Random(System.currentTimeMillis());
double[][] A = getRandomMatrix(rows, cols1, min, max, sparsity, System.currentTimeMillis());
writeInputMatrix("A", A, true);
sparsity = rand.nextDouble();
double[][] B = getRandomMatrix(rows, cols2, min, max, sparsity, System.currentTimeMillis());
writeInputMatrix("B", B, true);
boolean exceptionExpected = false;
int expectedCompiledMRJobs = (rtplatform == RUNTIME_PLATFORM.HADOOP) ? 2 : 1;
int expectedExecutedMRJobs = (rtplatform == RUNTIME_PLATFORM.HADOOP) ? 2 : 0;
runTest(true, exceptionExpected, null, expectedCompiledMRJobs);
runRScript(true);
Assert.assertEquals("Wrong number of executed MR jobs.", expectedExecutedMRJobs, Statistics.getNoOfExecutedMRJobs());
for (String file : config.getOutputFiles()) {
HashMap<CellIndex, Double> dmlfile = readDMLMatrixFromHDFS(file);
HashMap<CellIndex, Double> rfile = readRMatrixFromFS(file);
TestUtils.compareMatrices(dmlfile, rfile, epsilon, file + "-DML", file + "-R");
}
} finally {
// reset execution platform
rtplatform = prevPlfm;
DMLScript.USE_LOCAL_SPARK_CONFIG = sparkConfigOld;
BinaryOp.FORCED_APPEND_METHOD = null;
}
}
use of org.apache.sysml.test.integration.TestConfiguration in project incubator-systemml by apache.
the class AppendMatrixTest method setUp.
@Override
public void setUp() {
TestUtils.clearAssertionInformation();
addTestConfiguration(TEST_NAME, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME, new String[] { "C" }));
}
use of org.apache.sysml.test.integration.TestConfiguration in project incubator-systemml by apache.
the class CentralMomentTest method setUp.
@Override
public void setUp() {
TestUtils.clearAssertionInformation();
addTestConfiguration(TEST_NAME, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME, new String[] { "R" }));
}
use of org.apache.sysml.test.integration.TestConfiguration in project incubator-systemml by apache.
the class RightIndexingMatrixTest method runRightIndexingTest.
public void runRightIndexingTest(ExecType et, boolean sparse, long rl, long ru, long cl, long cu) {
RUNTIME_PLATFORM platformOld = rtplatform;
switch(et) {
case MR:
rtplatform = RUNTIME_PLATFORM.HADOOP;
break;
case SPARK:
rtplatform = RUNTIME_PLATFORM.SPARK;
break;
default:
rtplatform = RUNTIME_PLATFORM.HYBRID;
break;
}
boolean sparkConfigOld = DMLScript.USE_LOCAL_SPARK_CONFIG;
if (rtplatform == RUNTIME_PLATFORM.SPARK)
DMLScript.USE_LOCAL_SPARK_CONFIG = true;
try {
TestConfiguration config = getTestConfiguration(TEST_NAME);
double sparsity = sparse ? sparsity2 : sparsity1;
config.addVariable("rows", rows);
config.addVariable("cols", cols);
config.addVariable("rowstart", rl);
config.addVariable("rowend", ru);
config.addVariable("colstart", cl);
config.addVariable("colend", cu);
loadTestConfiguration(config);
String RI_HOME = SCRIPT_DIR + TEST_DIR;
fullDMLScriptName = RI_HOME + TEST_NAME + ".dml";
programArgs = new String[] { "-explain", "-args", input("A"), Long.toString(rows), Long.toString(cols), Long.toString(rl), Long.toString(ru), Long.toString(cl), Long.toString(cu), output("B"), output("C"), output("D") };
fullRScriptName = RI_HOME + TEST_NAME + ".R";
rCmd = "Rscript" + " " + fullRScriptName + " " + inputDir() + " " + rl + " " + ru + " " + cl + " " + cu + " " + expectedDir();
double[][] A = getRandomMatrix(rows, cols, min, max, sparsity, System.currentTimeMillis());
writeInputMatrix("A", A, true);
// run tests
runTest(true, false, null, -1);
runRScript(true);
// compare results
for (String file : config.getOutputFiles()) {
HashMap<CellIndex, Double> dmlfile = readDMLMatrixFromHDFS(file);
HashMap<CellIndex, Double> rfile = readRMatrixFromFS(file);
TestUtils.compareMatrices(dmlfile, rfile, epsilon, file + "-DML", file + "-R");
}
} finally {
rtplatform = platformOld;
DMLScript.USE_LOCAL_SPARK_CONFIG = sparkConfigOld;
}
}
Aggregations