use of org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex in project incubator-systemml by apache.
the class DynProjectTest method runDynProjectTest.
/**
* @param vector
* @param sparse
*/
private void runDynProjectTest(boolean vector, boolean sparse) {
double sparsity = sparse ? sparsity2 : sparsity1;
int cols = vector ? 1 : rows;
TestConfiguration config = getTestConfiguration(TEST_NAME);
config.addVariable("rows", rows);
loadTestConfiguration(config);
/* 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[] { "-args", input("X"), input("c"), Integer.toString(rows), Integer.toString(cols), Integer.toString(size), output("Y") };
rCmd = getRCmd(inputDir(), expectedDir());
long seed = System.nanoTime();
double[][] X = getRandomMatrix(rows, cols, 0, 1, sparsity, seed);
double[][] c = TestUtils.round(getRandomMatrix(1, size, 1 - 0.49, rows + 0.49, 1, seed));
writeInputMatrix("X", X, true);
writeInputMatrix("c", c, true);
runTest(true, false, null, -1);
runRScript(true);
// compare matrices
HashMap<CellIndex, Double> dmlfile = readDMLMatrixFromHDFS("Y");
HashMap<CellIndex, Double> rfile = readRMatrixFromFS("Y.mtx");
TestUtils.compareMatrices(dmlfile, rfile, eps, "DML", "R");
}
use of org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex in project incubator-systemml by apache.
the class OrderTest method runtestOrder.
private void runtestOrder(boolean asc) {
TestConfiguration config = getTestConfiguration(TEST_NAME);
config.addVariable("rows", rows);
config.addVariable("cols", cols);
loadTestConfiguration(config);
int sortcol = sc * (asc ? 1 : -1);
int namesuffix = (asc ? 1 : 2);
String HOME = SCRIPT_DIR + TEST_DIR;
fullDMLScriptName = HOME + TEST_NAME + namesuffix + ".dml";
programArgs = new String[] { "-args", input("A"), Integer.toString(rows), Integer.toString(cols), Integer.toString(sc), output("B") };
rCmd = getRCmd(inputDir(), Integer.toString(sortcol), expectedDir());
try {
long seed = System.nanoTime();
double[][] A = getRandomMatrix(rows, cols, 0, 1, sparsity, seed);
writeInputMatrix("A", A, true);
runTest(true, false, null, -1);
runRScript(true);
// check number of compiled and executed scripts (assumes IPA and recompile)
// reblock
Assert.assertEquals("Unexpected number of compiled MR jobs.", 1, Statistics.getNoOfCompiledMRJobs());
Assert.assertEquals("Unexpected number of executed MR jobs.", 0, Statistics.getNoOfExecutedMRJobs());
// compare matrices
HashMap<CellIndex, Double> dmlfile = readDMLMatrixFromHDFS("B");
HashMap<CellIndex, Double> rfile = readRMatrixFromFS("B.mtx");
TestUtils.compareMatrices(dmlfile, rfile, eps, "DML", "R");
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex in project incubator-systemml by apache.
the class FrameScalarCastingIntegratedTest method runFrameScalarCastingTest.
private void runFrameScalarCastingTest(ValueType vtIn, RUNTIME_PLATFORM et) {
RUNTIME_PLATFORM platformOld = rtplatform;
rtplatform = et;
boolean sparkConfigOld = DMLScript.USE_LOCAL_SPARK_CONFIG;
if (rtplatform == RUNTIME_PLATFORM.SPARK || rtplatform == RUNTIME_PLATFORM.HYBRID_SPARK)
DMLScript.USE_LOCAL_SPARK_CONFIG = true;
try {
getAndLoadTestConfiguration(TEST_NAME);
String HOME = SCRIPT_DIR + TEST_DIR;
fullDMLScriptName = HOME + TEST_NAME + ".dml";
programArgs = new String[] { "-stats", "-args", input("V"), output("R") };
// generate input data
switch(vtIn) {
case STRING:
MapReduceTool.writeStringToHDFS("foo", input("V"));
break;
case INT:
MapReduceTool.writeIntToHDFS(7, input("V"));
break;
case BOOLEAN:
MapReduceTool.writeBooleanToHDFS(true, input("V"));
break;
case DOUBLE:
MapReduceTool.writeDoubleToHDFS(7.3, input("V"));
break;
default:
throw new RuntimeException("Unsupported type: " + vtIn);
}
MapReduceTool.writeScalarMetaDataFile(input("V") + ".mtd", vtIn);
// run tests
runTest(true, false, null, -1);
// compare output
Assert.assertEquals(readDMLMatrixFromHDFS("R").get(new CellIndex(1, 1)), Double.valueOf(1));
if (et != RUNTIME_PLATFORM.SPARK) {
Assert.assertTrue(Statistics.getNoOfCompiledSPInst() == 0);
Assert.assertTrue(Statistics.getNoOfExecutedSPInst() == 0);
}
} catch (Exception ex) {
throw new RuntimeException(ex);
} finally {
rtplatform = platformOld;
DMLScript.USE_LOCAL_SPARK_CONFIG = sparkConfigOld;
}
}
use of org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex in project incubator-systemml by apache.
the class Jdk7IssueRightIndexingTest method runIndexingTest.
/**
* @param sparse
* @param et
*/
public void runIndexingTest(boolean sparse, ExecType et) {
RUNTIME_PLATFORM oldRTP = rtplatform;
try {
TestConfiguration config = getTestConfiguration(TEST_NAME);
if (et == ExecType.SPARK) {
rtplatform = RUNTIME_PLATFORM.SPARK;
} else {
rtplatform = (et == null) ? RUNTIME_PLATFORM.HYBRID : (et == ExecType.MR) ? RUNTIME_PLATFORM.HADOOP : RUNTIME_PLATFORM.SINGLE_NODE;
}
config.addVariable("rows", rows);
config.addVariable("cols", cols);
double sparsity = sparse ? sparsity2 : sparsity1;
String TEST_CACHE_DIR = "";
if (TEST_CACHE_ENABLED) {
TEST_CACHE_DIR = sparsity + "/";
}
loadTestConfiguration(config, TEST_CACHE_DIR);
String RI_HOME = SCRIPT_DIR + TEST_DIR;
fullDMLScriptName = RI_HOME + TEST_NAME + ".dml";
programArgs = new String[] { "-args", input("M"), output("R") };
fullRScriptName = RI_HOME + TEST_NAME + ".R";
rCmd = "Rscript" + " " + fullRScriptName + " " + inputDir() + " " + expectedDir();
// generate input data
double[][] M = getRandomMatrix(rows, cols, 0, 1, sparsity, 7);
writeInputMatrixWithMTD("M", M, true);
// run test
runTest(true, false, null, -1);
runRScript(true);
// compare results
HashMap<CellIndex, Double> dmlfile = readDMLMatrixFromHDFS("R");
HashMap<CellIndex, Double> rfile = readRMatrixFromFS("R");
TestUtils.compareMatrices(dmlfile, rfile, eps, "Stat-DML", "Stat-R");
} finally {
rtplatform = oldRTP;
}
}
use of org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex in project incubator-systemml by apache.
the class LeftIndexingScalarTest method runLeftIndexingTest.
private void runLeftIndexingTest(ExecType instType) {
// rtplatform for MR
RUNTIME_PLATFORM platformOld = rtplatform;
if (instType == ExecType.SPARK) {
rtplatform = RUNTIME_PLATFORM.SPARK;
} else {
rtplatform = (instType == ExecType.MR) ? RUNTIME_PLATFORM.HADOOP : RUNTIME_PLATFORM.HYBRID;
}
boolean sparkConfigOld = DMLScript.USE_LOCAL_SPARK_CONFIG;
if (rtplatform == RUNTIME_PLATFORM.SPARK)
DMLScript.USE_LOCAL_SPARK_CONFIG = true;
try {
TestConfiguration config = getTestConfiguration(TEST_NAME);
loadTestConfiguration(config);
String HOME = SCRIPT_DIR + TEST_DIR;
fullDMLScriptName = HOME + TEST_NAME + ".dml";
programArgs = new String[] { "-explain", "-args", input("A"), Long.toString(rows), Long.toString(cols), output("A") };
fullRScriptName = HOME + TEST_NAME + ".R";
rCmd = "Rscript" + " " + fullRScriptName + " " + inputDir() + " " + expectedDir();
double[][] A = getRandomMatrix(rows, cols, min, max, sparsity, System.currentTimeMillis());
writeInputMatrix("A", A, true);
runTest(true, false, null, -1);
runRScript(true);
HashMap<CellIndex, Double> dmlfile = readDMLMatrixFromHDFS("A");
HashMap<CellIndex, Double> rfile = readRMatrixFromFS("A");
TestUtils.compareMatrices(dmlfile, rfile, epsilon, "A-DML", "A-R");
checkDMLMetaDataFile("A", new MatrixCharacteristics(rows, cols, 1, 1));
} finally {
rtplatform = platformOld;
DMLScript.USE_LOCAL_SPARK_CONFIG = sparkConfigOld;
}
}
Aggregations