use of org.apache.sysml.api.jmlc.Connection in project incubator-systemml by apache.
the class InputToStringTest method testScalartoString.
@Test
public void testScalartoString() throws DMLException {
try (Connection conn = new Connection()) {
PreparedScript pscript = conn.prepareScript("s = read(\"tmp\", data_type=\"scalar\"); print(toString(s));", new String[] { "s" }, new String[] {});
pscript.setScalar("s", 7);
pscript.executeScript();
}
}
use of org.apache.sysml.api.jmlc.Connection in project incubator-systemml by apache.
the class InputToStringTest method testFrametoString.
@Test
public void testFrametoString() throws DMLException {
try (Connection conn = new Connection()) {
PreparedScript pscript = conn.prepareScript("f = read(\"tmp\", data_type=\"frame\"); print(toString(f));", new String[] { "f" }, new String[] {});
pscript.setFrame("f", DataConverter.convertToFrameBlock(MatrixBlock.randOperations(7, 3, 1.0, 0, 1, "uniform", 7)), false);
pscript.executeScript();
}
}
use of org.apache.sysml.api.jmlc.Connection in project incubator-systemml by apache.
the class JMLCClonedPreparedScriptTest method runJMLCClonedTest.
private void runJMLCClonedTest(String script, int num, boolean clone) throws IOException {
int k = InfrastructureAnalyzer.getLocalParallelism();
boolean failed = false;
try (Connection conn = new Connection()) {
DMLScript.STATISTICS = true;
Statistics.reset();
PreparedScript pscript = conn.prepareScript(script, new String[] {}, new String[] { "out" }, false);
ExecutorService pool = Executors.newFixedThreadPool(k);
ArrayList<JMLCTask> tasks = new ArrayList<>();
for (int i = 0; i < num; i++) tasks.add(new JMLCTask(pscript, clone));
List<Future<Double>> taskrets = pool.invokeAll(tasks);
for (Future<Double> ret : taskrets) if (ret.get() != 700)
throw new RuntimeException("wrong results: " + ret.get());
pool.shutdown();
} catch (Exception ex) {
failed = true;
}
// check expected failure
Assert.assertTrue(failed == !clone || k == 1);
}
use of org.apache.sysml.api.jmlc.Connection in project incubator-systemml by apache.
the class JMLCInputOutputTest method testScalarOutputBoolean.
@Test
public void testScalarOutputBoolean() throws DMLException {
Connection conn = new Connection();
String str = "outBoolean = FALSE;\nwrite(outBoolean, './tmp/outBoolean');";
PreparedScript script = conn.prepareScript(str, new String[] {}, new String[] { "outBoolean" }, false);
boolean result = script.executeScript().getBoolean("outBoolean");
Assert.assertEquals(false, result);
conn.close();
}
use of org.apache.sysml.api.jmlc.Connection in project incubator-systemml by apache.
the class JMLCInputOutputTest method testScalarInputInt.
@Test
public void testScalarInputInt() throws IOException, DMLException {
Connection conn = new Connection();
String str = conn.readScript(baseDirectory + File.separator + "scalar-input.dml");
PreparedScript script = conn.prepareScript(str, new String[] { "inScalar1", "inScalar2" }, new String[] {}, false);
int inScalar1 = 2;
int inScalar2 = 3;
script.setScalar("inScalar1", inScalar1);
script.setScalar("inScalar2", inScalar2);
setExpectedStdOut("total:5");
script.executeScript();
conn.close();
}
Aggregations