nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/jita/constant/ProtectedCudaConstantHandler.java
@Override
    public DataBuffer relocateConstantSpace(DataBuffer dataBuffer) {
        // we always assume that data is sync, and valid on host side
        Integer deviceId = AtomicAllocator.getInstance().getDeviceId();
        ensureMaps(deviceId);

        if (dataBuffer instanceof CudaIntDataBuffer) {
            int[] data = dataBuffer.asInt();
            return getConstantBuffer(data);
        } else if (dataBuffer instanceof CudaFloatDataBuffer) {
            float[] data = dataBuffer.asFloat();
            return getConstantBuffer(data);
        } else if (dataBuffer instanceof CudaDoubleDataBuffer) {
            double[] data = dataBuffer.asDouble();
            return getConstantBuffer(data);
        } else if (dataBuffer instanceof CudaHalfDataBuffer) {
            float[] data = dataBuffer.asFloat();
            return getConstantBuffer(data);
        } else if (dataBuffer instanceof CudaLongDataBuffer) {
            long[] data = dataBuffer.asLong();
            return getConstantBuffer(data);
        }

        throw new IllegalStateException("Unknown CudaDataBuffer opType");
    }
@Override
    public DataBuffer relocateConstantSpace(DataBuffer dataBuffer) {
        // we always assume that data is sync, and valid on host side
        Integer deviceId = AtomicAllocator.getInstance().getDeviceId();
        ensureMaps(deviceId);

        if (dataBuffer instanceof CudaIntDataBuffer) {
            int[] data = dataBuffer.asInt();
            return getConstantBuffer(data);
        } else if (dataBuffer instanceof CudaFloatDataBuffer) {
            float[] data = dataBuffer.asFloat();
            return getConstantBuffer(data);
        } else if (dataBuffer instanceof CudaDoubleDataBuffer) {
            double[] data = dataBuffer.asDouble();
            return getConstantBuffer(data);
        } else if (dataBuffer instanceof CudaHalfDataBuffer) {
            float[] data = dataBuffer.asFloat();
            return getConstantBuffer(data);
        } else if (dataBuffer instanceof CudaLongDataBuffer) {
            long[] data = dataBuffer.asLong();
            return getConstantBuffer(data);
        }

        throw new IllegalStateException("Unknown CudaDataBuffer opType");
    }
@ Override public DataBuffer relocateConstantSpace ( DataBuffer dataBuffer ) { // we always assume that data is sync, and valid on host side Integer deviceId = AtomicAllocator . getInstance ( ) . getDeviceId ( ) ; ensureMaps ( deviceId ) ; if ( dataBuffer instanceof CudaIntDataBuffer ) { int [ ] data = dataBuffer . asInt ( ) ; return getConstantBuffer ( data ) ; } else if ( dataBuffer instanceof CudaFloatDataBuffer ) { float [ ] data = dataBuffer . asFloat ( ) ; return getConstantBuffer ( data ) ; } else if ( dataBuffer instanceof CudaDoubleDataBuffer ) { double [ ] data = dataBuffer . asDouble ( ) ; return getConstantBuffer ( data ) ; } else if ( dataBuffer instanceof CudaHalfDataBuffer ) { float [ ] data = dataBuffer . asFloat ( ) ; return getConstantBuffer ( data ) ; } else if ( dataBuffer instanceof CudaLongDataBuffer ) { long [ ] data = dataBuffer . asLong ( ) ; return getConstantBuffer ( data ) ; } throw new IllegalStateException ( "Unknown CudaDataBuffer opType" ) ; }
PLEASE NOTE: This method implementation is hardware-dependant.
PLEASE NOTE: This method does NOT allow concurrent use of any array

@param dataBuffer
@return
PLEASE NOTE : This method implementation is hardware - dependant . PLEASE NOTE : This method does NOT allow concurrent use of any array