Search in sources :

Example 1 with TestConfiguration

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

the class FullColAggregateTest 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" }));
    if (TEST_CACHE_ENABLED) {
        setOutAndExpectedDeletionDisabled(true);
    }
}
Also used : TestConfiguration(org.apache.sysml.test.integration.TestConfiguration)

Example 2 with TestConfiguration

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

the class FullGroupedAggregateMatrixTest method runGroupedAggregateOperationTest.

/**
	 * 
	 * @param testname
	 * @param type
	 * @param sparse
	 * @param instType
	 */
@SuppressWarnings("rawtypes")
private void runGroupedAggregateOperationTest(String testname, OpType type, boolean sparse, ExecType instType, int numCols) {
    //rtplatform for MR
    RUNTIME_PLATFORM platformOld = rtplatform;
    switch(instType) {
        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 {
        //determine script and function name
        String TEST_NAME = testname;
        int fn = type.ordinal();
        double sparsity = (sparse) ? sparsity1 : sparsity2;
        String TEST_CACHE_DIR = TEST_CACHE_ENABLED ? TEST_NAME + type.ordinal() + "_" + sparsity + "_" + numCols + "/" : "";
        boolean exceptionExpected = !TEST_NAME.equals(TEST_NAME1);
        TestConfiguration config = getTestConfiguration(TEST_NAME);
        loadTestConfiguration(config, TEST_CACHE_DIR);
        // 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", "-args", input("A"), input("B"), String.valueOf(fn), String.valueOf(numGroups), output("C") };
        fullRScriptName = HOME + TEST_NAME + ".R";
        rCmd = "Rscript" + " " + fullRScriptName + " " + inputDir() + " " + fn + " " + expectedDir();
        //generate actual dataset 
        double[][] A = getRandomMatrix(rows, numCols, -0.05, 1, sparsity, 7);
        writeInputMatrix("A", A, true);
        MatrixCharacteristics mc1 = new MatrixCharacteristics(rows, numCols, 1000, 1000);
        MapReduceTool.writeMetaDataFile(input("A.mtd"), ValueType.DOUBLE, mc1, OutputInfo.TextCellOutputInfo);
        double[][] B = TestUtils.round(getRandomMatrix(rows, 1, 1, numGroups, 1.0, 3));
        writeInputMatrix("B", B, true);
        MatrixCharacteristics mc2 = new MatrixCharacteristics(rows, 1, 1000, 1000);
        MapReduceTool.writeMetaDataFile(input("B.mtd"), ValueType.DOUBLE, mc2, OutputInfo.TextCellOutputInfo);
        //run tests
        Class cla = (exceptionExpected ? DMLException.class : null);
        runTest(true, exceptionExpected, cla, -1);
        //compare matrices 
        if (!exceptionExpected) {
            //run R script for comparison
            runRScript(true);
            //compare output matrices
            HashMap<CellIndex, Double> dmlfile = readDMLMatrixFromHDFS("C");
            HashMap<CellIndex, Double> rfile = readRMatrixFromFS("C");
            TestUtils.compareMatrices(dmlfile, rfile, eps, "Stat-DML", "Stat-R");
            //check dml output meta data
            checkDMLMetaDataFile("C", new MatrixCharacteristics(numGroups, numCols, 1, 1));
        }
    } catch (IOException ex) {
        ex.printStackTrace();
        throw new RuntimeException(ex);
    } finally {
        rtplatform = platformOld;
        DMLScript.USE_LOCAL_SPARK_CONFIG = sparkConfigOld;
    }
}
Also used : DMLException(org.apache.sysml.api.DMLException) TestConfiguration(org.apache.sysml.test.integration.TestConfiguration) IOException(java.io.IOException) MatrixCharacteristics(org.apache.sysml.runtime.matrix.MatrixCharacteristics) RUNTIME_PLATFORM(org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM) CellIndex(org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex) AfterClass(org.junit.AfterClass) BeforeClass(org.junit.BeforeClass)

Example 3 with TestConfiguration

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

the class FullGroupedAggregateMatrixTest method setUp.

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

Example 4 with TestConfiguration

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

the class FullGroupedAggregateTest method runGroupedAggregateOperationTest.

/* TODO weighted central moment in R
	@Test
	public void testGroupedAggMoment4DenseWeightsMR() 
	{
		runGroupedAggregateOperationTest(OpType.MOMENT4, false, true, false, ExecType.MR);
	}
	
	@Test
	public void testGroupedAggMoment4SparseWeightsMR() 
	{
		runGroupedAggregateOperationTest(OpType.MOMENT4, true, true, false, ExecType.MR);
	}
	*/
/**
	 * 
	 * @param sparseM1
	 * @param sparseM2
	 * @param instType
	 * @throws IOException 
	 */
private void runGroupedAggregateOperationTest(OpType type, boolean sparse, boolean weights, boolean transpose, ExecType instType) {
    //rtplatform for MR
    RUNTIME_PLATFORM platformOld = rtplatform;
    switch(instType) {
        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 {
        //determine script and function name
        String TEST_NAME = weights ? TEST_NAME2 : TEST_NAME1;
        int fn = type.ordinal();
        double sparsity = (sparse) ? sparsity1 : sparsity2;
        String TEST_CACHE_DIR = "";
        if (TEST_CACHE_ENABLED) {
            TEST_CACHE_DIR = TEST_NAME + type.ordinal() + "_" + sparsity + "_" + transpose + "/";
        }
        TestConfiguration config = getTestConfiguration(TEST_NAME);
        loadTestConfiguration(config, TEST_CACHE_DIR);
        // 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";
        if (!weights) {
            programArgs = new String[] { "-explain", "-args", input("A"), input("B"), Integer.toString(fn), output("C") };
        } else {
            programArgs = new String[] { "-args", input("A"), input("B"), input("C"), Integer.toString(fn), output("D") };
        }
        fullRScriptName = HOME + TEST_NAME + ".R";
        rCmd = "Rscript" + " " + fullRScriptName + " " + inputDir() + " " + fn + " " + expectedDir();
        //generate actual dataset 
        double[][] A = getRandomMatrix(transpose ? cols : rows, transpose ? rows : cols, -0.05, 1, sparsity, 7);
        writeInputMatrix("A", A, true);
        MatrixCharacteristics mc1 = new MatrixCharacteristics(transpose ? cols : rows, transpose ? rows : cols, 1000, 1000);
        MapReduceTool.writeMetaDataFile(input("A.mtd"), ValueType.DOUBLE, mc1, OutputInfo.TextCellOutputInfo);
        double[][] B = TestUtils.round(getRandomMatrix(rows, cols, 1, numGroups, 1.0, 3));
        writeInputMatrix("B", B, true);
        MatrixCharacteristics mc2 = new MatrixCharacteristics(rows, cols, 1000, 1000);
        MapReduceTool.writeMetaDataFile(input("B.mtd"), ValueType.DOUBLE, mc2, OutputInfo.TextCellOutputInfo);
        if (weights) {
            //currently we use integer weights due to our definition of weight as multiplicity
            double[][] C = TestUtils.round(getRandomMatrix(rows, cols, 1, maxWeight, 1.0, 3));
            writeInputMatrix("C", C, true);
            MatrixCharacteristics mc3 = new MatrixCharacteristics(rows, cols, 1000, 1000);
            MapReduceTool.writeMetaDataFile(input("C.mtd"), ValueType.DOUBLE, mc3, OutputInfo.TextCellOutputInfo);
        }
        //run tests
        runTest(true, false, null, -1);
        runRScript(true);
        //compare matrices 
        HashMap<CellIndex, Double> dmlfile = readDMLMatrixFromHDFS(weights ? "D" : "C");
        HashMap<CellIndex, Double> rfile = readRMatrixFromFS(weights ? "D" : "C");
        TestUtils.compareMatrices(dmlfile, rfile, eps, "Stat-DML", "Stat-R");
    } catch (IOException ex) {
        ex.printStackTrace();
        throw new RuntimeException(ex);
    } finally {
        rtplatform = platformOld;
        DMLScript.USE_LOCAL_SPARK_CONFIG = sparkConfigOld;
    }
}
Also used : TestConfiguration(org.apache.sysml.test.integration.TestConfiguration) IOException(java.io.IOException) MatrixCharacteristics(org.apache.sysml.runtime.matrix.MatrixCharacteristics) RUNTIME_PLATFORM(org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM) CellIndex(org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex)

Example 5 with TestConfiguration

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

the class MinTest method testScalar.

@Test
public void testScalar() {
    int scalar = 12;
    TestConfiguration config = getTestConfiguration(TEST_SCALAR);
    config.addVariable("scalar", scalar);
    createHelperMatrix();
    loadTestConfiguration(config);
    runTest(true, DMLException.class);
}
Also used : TestConfiguration(org.apache.sysml.test.integration.TestConfiguration) Test(org.junit.Test)

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