nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/jita/constant/ProtectedCudaConstantHandler.java
@Override
    public DataBuffer getConstantBuffer(float[] array) {
        //   logger.info("getConstantBuffer(float[]) called");
        ArrayDescriptor descriptor = new ArrayDescriptor(array);

        Integer deviceId = AtomicAllocator.getInstance().getDeviceId();

        ensureMaps(deviceId);

        if (!buffersCache.get(deviceId).containsKey(descriptor)) {
            // we create new databuffer
                 //logger.info("Creating new constant buffer...");
            DataBuffer buffer = Nd4j.createBufferDetached(array);

            if (constantOffsets.get(deviceId).get() + (array.length * Nd4j.sizeOfDataType()) < MAX_CONSTANT_LENGTH) {
                buffer.setConstant(true);
                // now we move data to constant memory, and keep happy
                moveToConstantSpace(buffer);

                buffersCache.get(deviceId).put(descriptor, buffer);

                bytes.addAndGet(array.length * Nd4j.sizeOfDataType());
            }
            return buffer;
        } // else logger.info("Reusing constant buffer...");

        return buffersCache.get(deviceId).get(descriptor);
    }
@Override
    public DataBuffer getConstantBuffer(float[] array) {
        //   logger.info("getConstantBuffer(float[]) called");
        ArrayDescriptor descriptor = new ArrayDescriptor(array);

        Integer deviceId = AtomicAllocator.getInstance().getDeviceId();

        ensureMaps(deviceId);

        if (!buffersCache.get(deviceId).containsKey(descriptor)) {
            // we create new databuffer
                 //logger.info("Creating new constant buffer...");
            DataBuffer buffer = Nd4j.createBufferDetached(array);

            if (constantOffsets.get(deviceId).get() + (array.length * Nd4j.sizeOfDataType()) < MAX_CONSTANT_LENGTH) {
                buffer.setConstant(true);
                // now we move data to constant memory, and keep happy
                moveToConstantSpace(buffer);

                buffersCache.get(deviceId).put(descriptor, buffer);

                bytes.addAndGet(array.length * Nd4j.sizeOfDataType());
            }
            return buffer;
        } // else logger.info("Reusing constant buffer...");

        return buffersCache.get(deviceId).get(descriptor);
    }
@ Override public DataBuffer getConstantBuffer ( float [ ] array ) { //   logger.info("getConstantBuffer(float[]) called"); ArrayDescriptor descriptor = new ArrayDescriptor ( array ) ; Integer deviceId = AtomicAllocator . getInstance ( ) . getDeviceId ( ) ; ensureMaps ( deviceId ) ; if ( ! buffersCache . get ( deviceId ) . containsKey ( descriptor ) ) { // we create new databuffer //logger.info("Creating new constant buffer..."); DataBuffer buffer = Nd4j . createBufferDetached ( array ) ; if ( constantOffsets . get ( deviceId ) . get ( ) + ( array . length * Nd4j . sizeOfDataType ( ) ) < MAX_CONSTANT_LENGTH ) { buffer . setConstant ( true ) ; // now we move data to constant memory, and keep happy moveToConstantSpace ( buffer ) ; buffersCache . get ( deviceId ) . put ( descriptor , buffer ) ; bytes . addAndGet ( array . length * Nd4j . sizeOfDataType ( ) ) ; } return buffer ; } // else logger.info("Reusing constant buffer..."); return buffersCache . get ( deviceId ) . get ( descriptor ) ; }
This method returns DataBuffer with contant equal to input array.

PLEASE NOTE: This method assumes that you'll never ever change values within result DataBuffer

@param array
@return
This method returns DataBuffer with contant equal to input array .