Java Code Examples for org.nd4j.linalg.api.ndarray.INDArray#isS()

The following examples show how to use org.nd4j.linalg.api.ndarray.INDArray#isS() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CudaAffinityManager.java    From deeplearning4j with Apache License 2.0 6 votes vote down vote up
@Override
public void ensureLocation(INDArray array, Location location) {
    // to location to ensure for empty array
    if (array.isEmpty() || array.isS())
        return;

    // let's make sure host pointer actually exists
    ((BaseCudaDataBuffer) array.data()).lazyAllocateHostPointer();

    val point = AtomicAllocator.getInstance().getAllocationPoint(array);
    switch (location) {
        case HOST: {
                AtomicAllocator.getInstance().synchronizeHostData(array);
            }
            break;
        case DEVICE:{
                AtomicAllocator.getInstance().getFlowController().synchronizeToDevice(point);
            }
            break;
        case EVERYWHERE:
        default: {
            AtomicAllocator.getInstance().synchronizeHostData(array);
            AtomicAllocator.getInstance().getFlowController().synchronizeToDevice(point);
        }
    }
}
 
Example 2
Source File: AtomicAllocator.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
/**
 * This method returns actual device pointer valid for specified INDArray
 *
 * @param array
 */
@Override
public Pointer getPointer(INDArray array, CudaContext context) {
    //    DataBuffer buffer = array.data().originalDataBuffer() == null ? array.data() : array.data().originalDataBuffer();
    if (array.isEmpty() || array.isS())
        throw new UnsupportedOperationException("Pew-pew");

    return memoryHandler.getDevicePointer(array.data(), context);
}
 
Example 3
Source File: AtomicAllocator.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
/**
 * This method should be called to make sure that data on host side is actualized
 *
 * @param array
 */
@Override
public void synchronizeHostData(INDArray array) {
    if (array.isEmpty() || array.isS())
        return;

    val buffer = array.data().originalDataBuffer() == null ? array.data() : array.data().originalDataBuffer();
    synchronizeHostData(buffer);
}