use of org.nd4j.linalg.api.ops.impl.scalar.ScalarAdd in project nd4j by deeplearning4j.
the class GridExecutionerTest method isMatchingMetaOp4.
@Test
public void isMatchingMetaOp4() throws Exception {
CudaGridExecutioner executioner = new CudaGridExecutioner();
INDArray arrayX = Nd4j.create(10);
INDArray arrayY = Nd4j.create(10);
Set opA = new Set(arrayX, arrayY, arrayX, arrayX.length());
ScalarAdd opB = new ScalarAdd(arrayX, 10f);
executioner.exec(opA);
assertEquals(CudaGridExecutioner.MetaType.INVERTED_PREDICATE, executioner.getMetaOpType(opB));
}
use of org.nd4j.linalg.api.ops.impl.scalar.ScalarAdd in project nd4j by deeplearning4j.
the class GridExecutionerTest method testGridFlowFlush2.
@Test
public void testGridFlowFlush2() throws Exception {
CudaGridExecutioner executioner = new CudaGridExecutioner();
INDArray arrayX = Nd4j.create(10);
INDArray arrayX2 = Nd4j.create(10);
INDArray arrayY = Nd4j.create(new float[] { 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f });
INDArray exp = Nd4j.create(new float[] { 3f, 3f, 3f, 3f, 3f, 3f, 3f, 3f, 3f, 3f });
INDArray exp2 = Nd4j.create(new float[] { 10f, 10f, 10f, 10f, 10f, 10f, 10f, 10f, 10f, 10f });
Set opA = new Set(arrayX, arrayY, arrayX, arrayX.length());
executioner.exec(opA);
assertEquals(1, executioner.getQueueLength());
ScalarAdd opB = new ScalarAdd(arrayX2, 10f);
executioner.exec(opB);
assertEquals(0, executioner.getQueueLength());
assertEquals(arrayY, arrayX);
assertEquals(exp2, arrayX2);
}
use of org.nd4j.linalg.api.ops.impl.scalar.ScalarAdd in project nd4j by deeplearning4j.
the class GridExecutionerTest method testGridPerformance1.
// ///////////////////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////////////////
/*
Performance test for combined op
*/
// ///////////////////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////////////////
@Test
public void testGridPerformance1() throws Exception {
CudaGridExecutioner executioner = new CudaGridExecutioner();
INDArray arrayX = Nd4j.create(1024);
INDArray arrayY = Nd4j.create(1024);
Set opA = new Set(arrayX, arrayY, arrayX, arrayX.length());
ScalarAdd opB = new ScalarAdd(arrayX, 2f);
long time1 = System.nanoTime();
for (int x = 0; x < 1000000; x++) {
executioner.exec(opA);
executioner.exec(opB);
}
long time2 = System.nanoTime();
System.out.println("Execution time Meta: " + ((time2 - time1) / 1000000));
}
use of org.nd4j.linalg.api.ops.impl.scalar.ScalarAdd in project nd4j by deeplearning4j.
the class GridExecutionerTest method testGridFlow1.
// /////////////////////////////////////////////////////////////////////////
/*/////////////////////////////////////////////////////////////////////////
GridFlow tests are checking how ops are getting queued upon exec() calls
*/
// ///////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////
@Test
public void testGridFlow1() throws Exception {
CudaGridExecutioner executioner = new CudaGridExecutioner();
assertEquals(0, executioner.getQueueLength());
INDArray array = Nd4j.create(10);
ScalarAdd opA = new ScalarAdd(array, 10f);
executioner.exec(opA);
long time1 = System.nanoTime();
Max opB = new Max(array);
executioner.exec(opB);
assertEquals(0, executioner.getQueueLength());
long time2 = System.nanoTime();
opB = new Max(array);
executioner.exec(opB);
long time3 = System.nanoTime();
assertEquals(0, executioner.getQueueLength());
long firstExec = time2 - time1;
long secondExec = time3 - time2;
System.out.println("First exec time: " + firstExec);
System.out.println("Second exec time: " + secondExec);
System.out.println("Array: " + array);
}
use of org.nd4j.linalg.api.ops.impl.scalar.ScalarAdd in project nd4j by deeplearning4j.
the class GridExecutionerTest method isMatchingMetaOp3.
@Test
public void isMatchingMetaOp3() throws Exception {
CudaGridExecutioner executioner = new CudaGridExecutioner();
INDArray array = Nd4j.create(10);
ScalarAdd opA = new ScalarAdd(array, 10f);
Max opB = new Max(array);
executioner.exec(opA);
assertEquals(CudaGridExecutioner.MetaType.NOT_APPLICABLE, executioner.getMetaOpType(opB));
}
Aggregations