Search in sources :

Example 21 with TestConfiguration

use of org.apache.sysml.test.integration.TestConfiguration in project incubator-systemml by apache.

the class FullAggregateTest method setUp.

@Override
public void setUp() {
    addTestConfiguration(TEST_NAME1, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME1, new String[] { "B" }));
    addTestConfiguration(TEST_NAME2, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME2, new String[] { "B" }));
    addTestConfiguration(TEST_NAME3, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME3, new String[] { "B" }));
    addTestConfiguration(TEST_NAME4, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME4, new String[] { "B" }));
    addTestConfiguration(TEST_NAME5, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME5, new String[] { "B" }));
    addTestConfiguration(TEST_NAME6, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME6, new String[] { "B" }));
    if (TEST_CACHE_ENABLED) {
        setOutAndExpectedDeletionDisabled(true);
    }
}
Also used : TestConfiguration(org.apache.sysml.test.integration.TestConfiguration)

Example 22 with TestConfiguration

use of org.apache.sysml.test.integration.TestConfiguration in project incubator-systemml by apache.

the class UnivariateStatsBase method testScaleWithR.

/**
	 * Shared test driver for tests of univariate statistics over continuous,
	 * scaled, but not weighted, data
	 * 
	 * @param sz
	 *            size of primary input vector
	 * @param rng
	 *            range of randomly-generated values to use
	 * @param sp
	 *            sparsity of generated data
	 * @param rt
	 *            backend platform to test
	 */
protected void testScaleWithR(SIZE sz, RANGE rng, SPARSITY sp, RUNTIME_PLATFORM rt) {
    RUNTIME_PLATFORM oldrt = rtplatform;
    rtplatform = rt;
    try {
        TestConfiguration config = getTestConfiguration("Scale");
        config.addVariable("rows1", sz.size);
        config.addVariable("rows2", rows2);
        loadTestConfiguration(config);
        // This is for running the junit test the new way, i.e., construct
        // the arguments directly
        String S_HOME = SCRIPT_DIR + TEST_DIR;
        fullDMLScriptName = S_HOME + "Scale" + ".dml";
        programArgs = new String[] { "-args", input("vector"), Integer.toString(sz.size), input("prob"), Integer.toString(rows2), output("mean"), output("std"), output("se"), output("var"), output("cv"), output("min"), output("max"), output("rng"), output("g1"), output("se_g1"), output("g2"), output("se_g2"), output("median"), output("iqm"), output("out_minus"), output("out_plus"), output("quantile") };
        fullRScriptName = S_HOME + "Scale" + ".R";
        rCmd = "Rscript" + " " + fullRScriptName + " " + inputDir() + " " + expectedDir();
        double[][] vector = getRandomMatrix(sz.size, 1, rng.min, rng.max, sp.sparsity, 20160124165501L);
        double[][] prob = getRandomMatrix(rows2, 1, 0, 1, 1, 20160124165502L);
        writeInputMatrix("vector", vector, true);
        writeInputMatrix("prob", prob, true);
        runTest(true, false, null, -1);
        runRScript(true);
        for (String file : config.getOutputFiles()) {
            // NOte that some files do not contain matrix, but just a single
            // scalar value inside
            HashMap<CellIndex, Double> dmlfile;
            HashMap<CellIndex, Double> rfile;
            if (file.endsWith(".scalar")) {
                file = file.replace(".scalar", "");
                dmlfile = readDMLScalarFromHDFS(file);
                rfile = readRScalarFromFS(file);
            } else {
                dmlfile = readDMLMatrixFromHDFS(file);
                rfile = readRMatrixFromFS(file);
            }
            TestUtils.compareMatrices(dmlfile, rfile, epsilon, file + "-DML", file + "-R");
        }
    } finally {
        rtplatform = oldrt;
    }
}
Also used : RUNTIME_PLATFORM(org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM) CellIndex(org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex) TestConfiguration(org.apache.sysml.test.integration.TestConfiguration)

Example 23 with TestConfiguration

use of org.apache.sysml.test.integration.TestConfiguration in project incubator-systemml by apache.

the class ParForBivariateStatsTest method runParForBivariateStatsTest.

/**
	 * 
	 * @param outer execution mode of outer parfor loop
	 * @param inner execution mode of inner parfor loop
	 * @param instType execution mode of instructions
	 */
private void runParForBivariateStatsTest(boolean parallel, PExecMode outer, PExecMode inner, ExecType instType) {
    //inst exec type, influenced via rows
    int rows = -1;
    if (instType == ExecType.CP)
        rows = rows1;
    else
        //if type MR
        rows = rows2;
    //script
    int scriptNum = -1;
    if (parallel) {
        if (inner == PExecMode.REMOTE_MR)
            scriptNum = 2;
        else if (outer == PExecMode.REMOTE_MR)
            scriptNum = 3;
        else if (outer == PExecMode.LOCAL)
            scriptNum = 1;
        else
            //optimized
            scriptNum = 4;
    } else {
        scriptNum = 0;
    }
    TestConfiguration config = getTestConfiguration(TEST_NAME);
    //config.addVariable("rows", rows);
    //config.addVariable("cols", cols);
    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 + scriptNum + ".dml";
    programArgs = new String[] { "-args", input("D"), input("S1"), input("S2"), input("K1"), input("K2"), output("bivarstats"), Integer.toString(rows), Integer.toString(cols), Integer.toString(cols2), Integer.toString(cols2 * cols2), Integer.toString((int) maxVal) };
    fullRScriptName = HOME + TEST_NAME + ".R";
    rCmd = "Rscript" + " " + fullRScriptName + " " + inputDir() + " " + Integer.toString((int) maxVal) + " " + expectedDir();
    //generate actual dataset
    double[][] D = getRandomMatrix(rows, cols, minVal, maxVal, 1, 7777);
    double[] Dkind = new double[cols];
    for (int i = 0; i < cols; i++) {
        //kind 1,2,3
        Dkind[i] = (i % 3) + 1;
        if (Dkind[i] != 1)
            //for ordinal and categorical vars
            round(D, i);
    }
    writeInputMatrix("D", D, true);
    //generate attribute sets		
    double[][] S1 = getRandomMatrix(1, cols2, 1, cols + 1 - eps, 1, 1112);
    double[][] S2 = getRandomMatrix(1, cols2, 1, cols + 1 - eps, 1, 1113);
    round(S1);
    round(S2);
    writeInputMatrix("S1", S1, true);
    writeInputMatrix("S2", S2, true);
    //generate kind for attributes (1,2,3)
    double[][] K1 = new double[1][cols2];
    double[][] K2 = new double[1][cols2];
    for (int i = 0; i < cols2; i++) {
        K1[0][i] = Dkind[(int) S1[0][i] - 1];
        K2[0][i] = Dkind[(int) S2[0][i] - 1];
    }
    writeInputMatrix("K1", K1, true);
    writeInputMatrix("K2", K2, true);
    boolean exceptionExpected = false;
    runTest(true, exceptionExpected, null, 92);
    runRScript(true);
    //compare matrices 
    for (String out : new String[] { "bivar.stats", "category.counts", "category.means", "category.variances" }) {
        HashMap<CellIndex, Double> dmlfile = readDMLMatrixFromHDFS("bivarstats/" + out);
        HashMap<CellIndex, Double> rfile = readRMatrixFromFS(out);
        TestUtils.compareMatrices(dmlfile, rfile, eps, "Stat-DML", "Stat-R");
    }
}
Also used : CellIndex(org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex) TestConfiguration(org.apache.sysml.test.integration.TestConfiguration)

Example 24 with TestConfiguration

use of org.apache.sysml.test.integration.TestConfiguration in project incubator-systemml by apache.

the class ParForCorrelationTestLarge method runParForCorrelationTest.

/**
	 * 
	 * @param outer execution mode of outer parfor loop
	 * @param inner execution mode of inner parfor loop
	 * @param instType execution mode of instructions
	 */
private void runParForCorrelationTest(PExecMode outer, PExecMode inner) {
    //script
    int scriptNum = -1;
    if (inner == PExecMode.REMOTE_MR)
        scriptNum = 2;
    else if (outer == PExecMode.REMOTE_MR)
        scriptNum = 3;
    else if (outer == PExecMode.LOCAL)
        scriptNum = 1;
    else
        //optimized
        scriptNum = 4;
    TestConfiguration config = getTestConfiguration(TEST_NAME);
    config.addVariable("rows", rows);
    config.addVariable("cols", cols);
    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 + scriptNum + ".dml";
    programArgs = new String[] { "-args", input("V"), Integer.toString(rows), Integer.toString(cols), output("PearsonR") };
    fullRScriptName = HOME + TEST_NAME + ".R";
    rCmd = "Rscript" + " " + fullRScriptName + " " + inputDir() + " " + expectedDir();
    long seed = System.nanoTime();
    double[][] V = getRandomMatrix(rows, cols, minVal, maxVal, 1.0, seed);
    writeInputMatrix("V", V, true);
    boolean exceptionExpected = false;
    runTest(true, exceptionExpected, null, -1);
    runRScript(true);
    //compare matrices
    HashMap<CellIndex, Double> dmlfile = readDMLMatrixFromHDFS("PearsonR");
    HashMap<CellIndex, Double> rfile = readRMatrixFromFS("Rout");
    TestUtils.compareMatrices(dmlfile, rfile, eps, "PearsonR-DML", "PearsonR-R");
}
Also used : CellIndex(org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex) TestConfiguration(org.apache.sysml.test.integration.TestConfiguration)

Example 25 with TestConfiguration

use of org.apache.sysml.test.integration.TestConfiguration in project incubator-systemml by apache.

the class ParForNaiveBayesTest method runParForNaiveBayesTest.

/**
	 * 
	 * @param outer
	 * @param instType
	 * @param smallMem
	 * @param sparse
	 */
private void runParForNaiveBayesTest(PExecMode outer, ExecType instType, boolean smallMem, boolean sparse) {
    int cols = (instType == ExecType.MR) ? cols2 : cols1;
    //inst exec type, influenced via rows
    RUNTIME_PLATFORM oldPlatform = rtplatform;
    rtplatform = (instType == ExecType.MR) ? RUNTIME_PLATFORM.HADOOP : RUNTIME_PLATFORM.HYBRID;
    //determine the script
    int scriptNum = -1;
    if (//constrained opt
    outer == PExecMode.LOCAL)
        //constrained opt
        scriptNum = 1;
    else if (//constrained opt
    outer == PExecMode.REMOTE_MR)
        //constrained opt
        scriptNum = 2;
    else if (//constrained opt
    outer == PExecMode.REMOTE_MR_DP)
        //constrained opt
        scriptNum = 3;
    else
        //opt
        scriptNum = 4;
    //invocation arguments
    TestConfiguration config = getTestConfiguration(TEST_NAME);
    config.addVariable("rows", rows);
    config.addVariable("cols", cols);
    loadTestConfiguration(config);
    String HOME = SCRIPT_DIR + TEST_DIR;
    fullDMLScriptName = HOME + TEST_NAME + scriptNum + ".dml";
    programArgs = new String[] { "-args", input("D"), input("C"), Integer.toString((int) maxVal), output("class_prior"), output("class_conditionals") };
    fullRScriptName = HOME + TEST_NAME + ".R";
    rCmd = "Rscript" + " " + fullRScriptName + " " + inputDir() + " " + Integer.toString((int) maxVal) + " " + expectedDir();
    //input data
    double[][] D = getRandomMatrix(rows, cols, -1, 1, sparse ? sparsity2 : sparsity1, 7);
    double[][] C = TestUtils.round(getRandomMatrix(rows, 1, minVal, maxVal, 1.0, 3));
    MatrixCharacteristics mc1 = new MatrixCharacteristics(rows, cols, -1, -1);
    writeInputMatrixWithMTD("D", D, true, mc1);
    MatrixCharacteristics mc2 = new MatrixCharacteristics(rows, 1, -1, -1);
    writeInputMatrixWithMTD("C", C, true, mc2);
    //set memory budget (to test automatic opt for remote_mr_dp)
    long oldmem = InfrastructureAnalyzer.getLocalMaxMemory();
    if (smallMem) {
        long mem = 1024 * 1024 * 8;
        InfrastructureAnalyzer.setLocalMaxMemory(mem);
    }
    try {
        //run the testcase (DML and R)
        runTest(true, false, null, -1);
        runRScript(true);
        //compare output matrices
        for (String out : new String[] { "class_prior", "class_conditionals" }) {
            HashMap<CellIndex, Double> dmlfile = readDMLMatrixFromHDFS(out);
            HashMap<CellIndex, Double> rfile = readRMatrixFromFS(out);
            TestUtils.compareMatrices(dmlfile, rfile, eps, "Stat-DML", "Stat-R");
        }
    } finally {
        rtplatform = oldPlatform;
        InfrastructureAnalyzer.setLocalMaxMemory(oldmem);
    }
}
Also used : RUNTIME_PLATFORM(org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM) CellIndex(org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex) TestConfiguration(org.apache.sysml.test.integration.TestConfiguration) MatrixCharacteristics(org.apache.sysml.runtime.matrix.MatrixCharacteristics)

Aggregations

TestConfiguration (org.apache.sysml.test.integration.TestConfiguration)781 Test (org.junit.Test)298 CellIndex (org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex)169 RUNTIME_PLATFORM (org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM)138 MatrixCharacteristics (org.apache.sysml.runtime.matrix.MatrixCharacteristics)48 IOException (java.io.IOException)18 MatrixBlock (org.apache.sysml.runtime.matrix.data.MatrixBlock)13 DMLRuntimeException (org.apache.sysml.runtime.DMLRuntimeException)10 Modulus (org.apache.sysml.runtime.functionobjects.Modulus)9 HashMap (java.util.HashMap)8 FrameBlock (org.apache.sysml.runtime.matrix.data.FrameBlock)8 Random (java.util.Random)6 DMLException (org.apache.sysml.api.DMLException)6 ValueType (org.apache.sysml.parser.Expression.ValueType)5 Date (java.util.Date)3 BufferedReader (java.io.BufferedReader)2 FileReader (java.io.FileReader)2 Connection (org.apache.sysml.api.jmlc.Connection)2 DMLConfig (org.apache.sysml.conf.DMLConfig)2 DMLProgram (org.apache.sysml.parser.DMLProgram)2