libnd4j/include/array/impl/DataBuffer.cpp
DataBuffer::DataBuffer(const void* hostBuffer, const DataType dataType, const size_t lenInBytes, memory::Workspace* workspace) {

        if (hostBuffer == nullptr)
            throw std::runtime_error("DataBuffer constructor: can't be initialized with nullptr host buffer !");
        if (lenInBytes == 0)
            throw std::runtime_error("DataBuffer constructor: can't be initialized with zero length !");

        _primaryBuffer  = nullptr;
        _specialBuffer  = nullptr;
        _lenInBytes     = lenInBytes;
        _dataType       = dataType;
        _workspace      = workspace;

        _deviceId = sd::AffinityManager::currentDeviceId();

        setCountersToZero();

        allocateBuffers();

        copyBufferFromHost(hostBuffer, lenInBytes);
    }
////////////////////////////////////////////////////////////////////////
// copies data from hostBuffer to own memory buffer
copies data from hostBuffer to own memory buffer
copies data from hostBuffer to own memory buffer
DataBuffer::DataBuffer(const void* hostBuffer, const DataType dataType, const size_t lenInBytes, memory::Workspace* workspace) {
        if (hostBuffer == nullptr)
            throw std::runtime_error("DataBuffer constructor: can't be initialized with nullptr host buffer !");
        if (lenInBytes == 0)
            throw std::runtime_error("DataBuffer constructor: can't be initialized with zero length !");
        _primaryBuffer  = nullptr;
        _specialBuffer  = nullptr;
        _lenInBytes     = lenInBytes;
        _dataType       = dataType;
        _workspace      = workspace;
        _deviceId = sd::AffinityManager::currentDeviceId();
        setCountersToZero();
        allocateBuffers();
        copyBufferFromHost(hostBuffer, lenInBytes);
    }
DataBuffer :: DataBuffer ( const void * hostBuffer , const DataType dataType , const size_t lenInBytes , memory :: Workspace * workspace ) { if ( hostBuffer == nullptr ) throw std :: runtime_error ( " " ) ; if ( lenInBytes == 0 ) throw std :: runtime_error ( " " ) ; _primaryBuffer = nullptr ; _specialBuffer = nullptr ; _lenInBytes = lenInBytes ; _dataType = dataType ; _workspace = workspace ; _deviceId = sd :: AffinityManager :: currentDeviceId ( ) ; setCountersToZero ( ) ; allocateBuffers ( ) ; copyBufferFromHost ( hostBuffer , lenInBytes ) ; }
copies data from hostBuffer to own memory buffer
copies data from hostBuffer to own memory buffer