use of org.nd4j.jita.allocator.impl.AllocationPoint in project nd4j by deeplearning4j.
the class CudaFloatDataBufferTest method testDataCreation9.
@Test
public void testDataCreation9() throws Exception {
INDArray array = Nd4j.create(20);
AllocationPoint pointMain = ((BaseCudaDataBuffer) array.data()).getAllocationPoint();
AllocationPoint pointShape = ((BaseCudaDataBuffer) array.shapeInfoDataBuffer()).getAllocationPoint();
assertFalse(pointMain.isConstant());
assertTrue(pointShape.isConstant());
assertEquals(true, pointMain.isActualOnDeviceSide());
assertEquals(true, pointMain.isActualOnHostSide());
}
use of org.nd4j.jita.allocator.impl.AllocationPoint in project nd4j by deeplearning4j.
the class CudaFloatDataBufferTest method testDataCreation7.
@Test
public void testDataCreation7() throws Exception {
INDArray array = Nd4j.zeros(1500, 150);
AllocationPoint pointMain = ((BaseCudaDataBuffer) array.data()).getAllocationPoint();
AllocationPoint pointShape = ((BaseCudaDataBuffer) array.shapeInfoDataBuffer()).getAllocationPoint();
assertEquals(true, pointMain.isActualOnDeviceSide());
assertEquals(true, pointMain.isActualOnHostSide());
assertEquals(true, pointShape.isActualOnDeviceSide());
assertEquals(true, pointShape.isActualOnHostSide());
}
use of org.nd4j.jita.allocator.impl.AllocationPoint in project nd4j by deeplearning4j.
the class CudaFloatDataBufferTest method testDataCreation1.
@Test
public void testDataCreation1() throws Exception {
BaseCudaDataBuffer buffer = (BaseCudaDataBuffer) Nd4j.createBuffer(10);
AllocationPoint point = buffer.getAllocationPoint();
CudaContext context = AtomicAllocator.getInstance().getContextPool().acquireContextForDevice(0);
assertEquals(true, point.isActualOnHostSide());
buffer.put(0, 10f);
assertEquals(true, point.isActualOnHostSide());
assertEquals(false, point.isActualOnDeviceSide());
buffer.put(1, 10f);
assertEquals(true, point.isActualOnHostSide());
assertEquals(false, point.isActualOnDeviceSide());
AtomicAllocator.getInstance().getPointer(buffer, context);
assertEquals(true, point.isActualOnHostSide());
assertEquals(true, point.isActualOnDeviceSide());
System.out.println("AM ------------------------------------");
AtomicAllocator.getInstance().getHostPointer(buffer);
System.out.println("AN ------------------------------------");
assertEquals(true, point.isActualOnHostSide());
assertEquals(true, point.isActualOnDeviceSide());
}
use of org.nd4j.jita.allocator.impl.AllocationPoint in project nd4j by deeplearning4j.
the class CudaFloatDataBufferTest method testDataCreation6.
@Test
public void testDataCreation6() throws Exception {
INDArray array = Nd4j.create(new double[] { 0, 1, 2, 3 });
AllocationPoint pointMain = ((BaseCudaDataBuffer) array.data()).getAllocationPoint();
AllocationPoint pointShape = ((BaseCudaDataBuffer) array.shapeInfoDataBuffer()).getAllocationPoint();
assertEquals(true, pointShape.isActualOnDeviceSide());
assertEquals(true, pointShape.isActualOnHostSide());
assertEquals(true, pointMain.isActualOnDeviceSide());
assertEquals(false, pointMain.isActualOnHostSide());
assertEquals(AllocationStatus.DEVICE, pointMain.getAllocationStatus());
assertEquals(AllocationStatus.CONSTANT, pointShape.getAllocationStatus());
}
use of org.nd4j.jita.allocator.impl.AllocationPoint in project nd4j by deeplearning4j.
the class CudaFloatDataBufferTest method testDataCreation3.
@Test
public void testDataCreation3() throws Exception {
BaseCudaDataBuffer buffer = (BaseCudaDataBuffer) Nd4j.createBuffer(new float[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
AllocationPoint point = buffer.getAllocationPoint();
CudaContext context = AtomicAllocator.getInstance().getContextPool().acquireContextForDevice(0);
assertEquals(true, point.isActualOnDeviceSide());
assertEquals(false, point.isActualOnHostSide());
System.out.println("AX --------------------------");
buffer.put(0, 10f);
System.out.println("AZ --------------------------");
assertEquals(true, point.isActualOnHostSide());
assertEquals(false, point.isActualOnDeviceSide());
buffer.put(1, 10f);
assertEquals(true, point.isActualOnHostSide());
assertEquals(false, point.isActualOnDeviceSide());
AtomicAllocator.getInstance().getPointer(buffer, context);
assertEquals(true, point.isActualOnHostSide());
assertEquals(true, point.isActualOnDeviceSide());
System.out.println("AM ------------------------------------");
AtomicAllocator.getInstance().getHostPointer(buffer);
System.out.println("AN ------------------------------------");
assertEquals(true, point.isActualOnHostSide());
assertEquals(true, point.isActualOnDeviceSide());
assertEquals(AllocationStatus.DEVICE, point.getAllocationStatus());
}
Aggregations