use of org.nd4j.jita.allocator.impl.AllocationShape in project nd4j by deeplearning4j.
the class CudaDirectProviderTest method mallocHost.
@Test
public void mallocHost() throws Exception {
CudaDirectProvider provider = new CudaDirectProvider();
AllocationShape shape = new AllocationShape(100000, 4, DataBuffer.Type.FLOAT);
AllocationPoint point = new AllocationPoint();
point.setShape(shape);
point.setPointers(provider.malloc(shape, point, AllocationStatus.HOST));
System.out.println("Allocated...");
Thread.sleep(1000);
provider.free(point);
System.out.println("Deallocated...");
Thread.sleep(1000);
}
use of org.nd4j.jita.allocator.impl.AllocationShape in project nd4j by deeplearning4j.
the class AllocationUtils method buildAllocationShape.
/**
* This method returns AllocationShape for specific array, that takes in account its real shape: offset, length, etc
*
* @param array
* @return
*/
public static AllocationShape buildAllocationShape(INDArray array) {
AllocationShape shape = new AllocationShape();
shape.setStride(array.elementWiseStride());
shape.setOffset(array.originalOffset());
shape.setDataType(array.data().dataType());
shape.setLength(array.length());
shape.setDataType(array.data().dataType());
return shape;
}
use of org.nd4j.jita.allocator.impl.AllocationShape in project nd4j by deeplearning4j.
the class AllocationUtils method buildAllocationShape.
/**
* This method returns AllocationShape for specific buffer, that takes in account its real shape: offset, length, etc
*
* @param buffer
* @return
*/
public static AllocationShape buildAllocationShape(JCudaBuffer buffer) {
AllocationShape shape = new AllocationShape();
shape.setStride(1);
shape.setOffset(buffer.originalOffset());
shape.setDataType(buffer.dataType());
shape.setLength(buffer.length());
return shape;
}
use of org.nd4j.jita.allocator.impl.AllocationShape in project nd4j by deeplearning4j.
the class AllocationUtils method buildAllocationShape.
/**
* This method returns AllocationShape for the whole DataBuffer.
*
* @param buffer
* @return
*/
public static AllocationShape buildAllocationShape(DataBuffer buffer) {
AllocationShape shape = new AllocationShape();
shape.setStride(1);
shape.setOffset(buffer.originalOffset());
shape.setDataType(buffer.dataType());
shape.setLength(buffer.length());
return shape;
}
Aggregations