use of org.nd4j.linalg.api.ops.impl.scalar.ScalarAdd in project nd4j by deeplearning4j.
the class MetaOpTests method testPredicateReduce1.
/**
* Scalar + reduce along dimension
*
* @throws Exception
*/
@Test
public void testPredicateReduce1() throws Exception {
CudaGridExecutioner executioner = new CudaGridExecutioner();
INDArray arrayX = Nd4j.create(5, 5);
INDArray exp = Nd4j.create(new float[] { 2f, 2f, 2f, 2f, 2f });
ScalarAdd opA = new ScalarAdd(arrayX, 2.0f);
Max opB = new Max(arrayX);
OpDescriptor a = new OpDescriptor(opA);
OpDescriptor b = new OpDescriptor(opB, new int[] { 1 });
executioner.buildZ(opB, b.getDimensions());
ReduceMetaOp metaOp = new ReduceMetaOp(a, b);
executioner.prepareGrid(metaOp);
executioner.exec(metaOp);
INDArray result = opB.z();
assertNotEquals(null, result);
assertEquals(exp, result);
}
Aggregations