Search in sources :

Example 11 with AllocationShape

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);
}
Also used : AllocationShape(org.nd4j.jita.allocator.impl.AllocationShape) AllocationPoint(org.nd4j.jita.allocator.impl.AllocationPoint) Test(org.junit.Test)

Example 12 with AllocationShape

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;
}
Also used : AllocationShape(org.nd4j.jita.allocator.impl.AllocationShape)

Example 13 with AllocationShape

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;
}
Also used : AllocationShape(org.nd4j.jita.allocator.impl.AllocationShape)

Example 14 with AllocationShape

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;
}
Also used : AllocationShape(org.nd4j.jita.allocator.impl.AllocationShape)

Aggregations

AllocationShape (org.nd4j.jita.allocator.impl.AllocationShape)14 Test (org.junit.Test)6 AllocationPoint (org.nd4j.jita.allocator.impl.AllocationPoint)5 CudaPointer (org.nd4j.jita.allocator.pointers.CudaPointer)4 CudaContext (org.nd4j.linalg.jcublas.context.CudaContext)2 IOException (java.io.IOException)1 MemoryWorkspace (org.nd4j.linalg.api.memory.MemoryWorkspace)1 PagedPointer (org.nd4j.linalg.api.memory.pointers.PagedPointer)1 PointersPair (org.nd4j.linalg.api.memory.pointers.PointersPair)1 INDArray (org.nd4j.linalg.api.ndarray.INDArray)1 ND4JIllegalStateException (org.nd4j.linalg.exception.ND4JIllegalStateException)1 DummyWorkspace (org.nd4j.linalg.memory.abstracts.DummyWorkspace)1