public abstract class BaseDataBuffer extends Object implements DataBuffer
DataBuffer.AllocationMode, DataBuffer.TypeEx| Modifier and Type | Field and Description |
|---|---|
protected DataBuffer.AllocationMode |
allocationMode |
protected boolean |
attached |
protected boolean |
constant |
protected byte |
elementSize |
protected org.bytedeco.javacpp.indexer.Indexer |
indexer |
protected long |
length |
protected long |
offset |
protected DataBuffer |
originalBuffer |
protected long |
originalOffset |
protected MemoryWorkspace |
parentWorkspace |
protected org.bytedeco.javacpp.Pointer |
pointer |
protected AtomicBoolean |
referenced |
protected boolean |
released |
static String |
TO_STRING_MAX_ELEMENTS
Deprecated.
|
protected DataType |
type |
protected long |
underlyingLength |
protected long |
workspaceGenerationId |
protected DataBuffer |
wrappedDataBuffer |
| Modifier | Constructor and Description |
|---|---|
|
BaseDataBuffer() |
protected |
BaseDataBuffer(DataBuffer underlyingBuffer,
long length,
long offset)
Meant for creating another view of a buffer
|
|
BaseDataBuffer(org.bytedeco.javacpp.Pointer pointer,
org.bytedeco.javacpp.indexer.Indexer indexer,
long length)
Meant for creating another view of a buffer
|
| Modifier and Type | Method and Description |
|---|---|
void |
addReferencing(String id)
Deprecated.
|
long |
address()
Returns the address of the pointer
|
abstract org.bytedeco.javacpp.Pointer |
addressPointer()
Returns the address of the pointer wrapped in a Pointer
|
DataBuffer.AllocationMode |
allocationMode()
Allocation mode for buffers
|
Object |
array()
Returns the backing array
of this buffer (if there is one)
|
byte[] |
asBytes()
Raw byte array storage
|
double[] |
asDouble()
Return the buffer as a double array
Relative to the datatype, this will either be a copy
or a reference.
|
float[] |
asFloat()
Return the buffer as a float array
Relative to the datatype, this will either be a copy
or a reference.
|
int[] |
asInt()
Return the buffer as an int array
Relative to the datatype, this will either be a copy
or a reference.
|
long[] |
asLong()
Return the buffer as an long array
Relative to the datatype, this will either be a copy
or a reference.
|
ByteBuffer |
asNio()
Returns a view of this as an
nio byte buffer
|
DoubleBuffer |
asNioDouble()
Returns a view of this as an
nio byte buffer
|
FloatBuffer |
asNioFloat()
Returns a view of this as an
nio byte buffer
|
IntBuffer |
asNioInt()
Returns a view of this as an
nio byte buffer
|
LongBuffer |
asNioLong() |
void |
assign(DataBuffer... buffers)
Assign the given data buffers to this buffer
|
void |
assign(DataBuffer data)
Assign the contents of this buffer
to this buffer
|
void |
assign(long[] indices,
double[] data,
boolean contiguous)
Assign the given elements to the given indices
|
void |
assign(long[] indices,
double[] data,
boolean contiguous,
long inc)
Assign the given elements to the given indices
|
void |
assign(long[] indices,
float[] data,
boolean contiguous)
Assign the given elements to the given indices
|
void |
assign(long[] indices,
float[] data,
boolean contiguous,
long inc)
Assign the given elements to the given indices
|
void |
assign(long[] offsets,
long[] strides,
DataBuffer... buffers)
Assign the given buffers to this buffer
based on the given offsets and strides.
|
void |
assign(long[] offsets,
long[] strides,
long n,
DataBuffer... buffers)
Assign the given buffers to this buffer
based on the given offsets and strides.
|
void |
assign(Number value)
Assign the given value to the buffer
|
void |
assign(Number value,
long offset)
Assign the given value to the buffer
starting at offset
|
long |
capacity() |
void |
close()
This method releases exclusive off-heap resources uses by this DataBuffer instance.
|
boolean |
closeable()
This method checks, if this DataBuffer instalce can use close() method
|
void |
copyAtStride(DataBuffer buf,
long n,
long stride,
long yStride,
long offset,
long yOffset)
Copies from
the given buffer
at the specified stride
for up to n elements
|
abstract DataBuffer |
create(double[] data)
Create the data buffer
with respect to the given byte buffer
|
abstract DataBuffer |
create(float[] data)
Create the data buffer
with respect to the given byte buffer
|
abstract DataBuffer |
create(int[] data)
Create the data buffer
with respect to the given byte buffer
|
protected abstract DataBuffer |
create(long length)
Create with length
|
DataType |
dataType()
The data opType of the buffer
|
void |
destroy()
release all resources for this buffer
|
boolean |
dirty()
Deprecated.
|
protected void |
doReadObject(ObjectInputStream s) |
DataBuffer |
dup()
Return a copy of this buffer
|
boolean |
equals(Object o) |
protected void |
fillPointerWithZero() |
void |
flush()
Flush the data buffer
|
static short |
fromFloat(float v) |
double |
getDouble(long i)
Get element i in the buffer as a double
|
double[] |
getDoublesAt(long offset,
int length)
Get the doubles at a particular offset
|
double[] |
getDoublesAt(long offset,
long inc,
int length)
Get the doubles at a particular offset
|
protected abstract double |
getDoubleUnsynced(long index) |
int |
getElementSize()
The number of bytes for each individual element
|
float |
getFloat(long i)
Get element i in the buffer as a double
|
float[] |
getFloatsAt(long offset,
int length)
Get the doubles at a particular offset
|
float[] |
getFloatsAt(long offset,
long inc,
int length)
Get the doubles at a particular offset
|
protected abstract float |
getFloatUnsynced(long index) |
long |
getGenerationId() |
int |
getInt(long i)
Get the int at the specified index
|
int[] |
getIntsAt(long offset,
int length)
Get the ints at a particular offset
|
int[] |
getIntsAt(long offset,
long inc,
int length)
Get the ints at a particular offset
|
protected abstract int |
getIntUnsynced(long index) |
long |
getLong(long i)
Get element i in the buffer as long value
|
long[] |
getLongsAt(long offset,
int length)
Get the longs at a particular offset
|
long[] |
getLongsAt(long offset,
long inc,
int length)
Get the long at a particular offset
|
protected abstract long |
getLongUnsynced(long index) |
Number |
getNumber(long i)
Get element i in the buffer as a double
|
MemoryWorkspace |
getParentWorkspace()
This method returns Workspace this DataBuffer is attached to
|
protected short |
getShort(long i)
Special method for
|
int |
hashCode() |
org.bytedeco.javacpp.indexer.Indexer |
indexer()
Returns the indexer for the buffer
|
protected abstract void |
initTypeAndSize()
Initialize the opType of this buffer
|
boolean |
isAttached()
This method returns True, if this DataBuffer is attached to some workspace.
|
boolean |
isConstant()
This method returns whether this DataBuffer is constant, or not.
|
boolean |
isInScope()
This method checks, if given attached INDArray is still in scope of its parent Workspace
|
boolean |
isPersist()
Deprecated.
|
long |
length()
Returns the length of the buffer
|
protected void |
markReleased() |
long |
offset()
Returns the offset of the buffer
|
DataBuffer |
originalDataBuffer()
Original DataBuffer.
|
long |
originalOffset()
Returns the offset of the buffer relative to originalDataBuffer
|
void |
persist()
Deprecated.
|
protected void |
pickReferent(BaseDataBuffer referent) |
long |
platformAddress()
Returns the address of platform-specific pointer:
- for native backend that'll be host pointer
- for cuda backend that'll be device pointer
|
org.bytedeco.javacpp.Pointer |
pointer()
Returns an underlying pointer if one exists
|
abstract void |
pointerIndexerByCurrentType(DataType currentType) |
void |
put(long i,
boolean element) |
void |
put(long i,
double element)
Assign an element in the buffer to the specified index
|
void |
put(long i,
float element)
Assign an element in the buffer to the specified index
|
void |
put(long i,
int element)
Assign an element in the buffer to the specified index
|
void |
put(long i,
long element) |
void |
putByDestinationType(long i,
Number element,
DataType globalType) |
void |
read(DataInputStream s,
@NonNull DataBuffer.AllocationMode allocMode,
long len,
@NonNull DataType dtype) |
void |
read(InputStream is,
DataBuffer.AllocationMode allocationMode,
long length,
DataType dataType)
Write this buffer to the input stream.
|
protected void |
readContent(DataInputStream s,
DataType sourceType,
DataType thisType) |
static Triple<DataBuffer.AllocationMode,Long,DataType> |
readHeader(@NonNull InputStream is) |
abstract DataBuffer |
reallocate(long length)
Reallocate the native memory of the buffer
|
Collection<String> |
references()
Deprecated.
|
protected void |
release() |
void |
removeReferencing(String id)
Deprecated.
|
boolean |
sameUnderlyingData(DataBuffer buffer)
Returns true if the underlying data source
is the same for both buffers (referential equals)
|
void |
setConstant(boolean reallyConstant)
This method allows you to mark databuffer as constant.
|
void |
setData(boolean[] data) |
void |
setData(byte[] data) |
void |
setData(double[] data)
Set the data for this buffer
|
void |
setData(float[] data)
Set the data for this buffer
|
void |
setData(int[] data)
Set the data for this buffer
|
void |
setData(long[] data)
Set the data for this buffer
|
void |
setData(short[] data) |
protected void |
setIndexer(org.bytedeco.javacpp.indexer.Indexer indexer) |
protected void |
setNioBuffer() |
abstract void |
syncToPrimary()
This method synchronizes host memory
|
abstract void |
syncToSpecial()
This method synchronizes device memory
|
float |
toFloat(int hbits) |
String |
toString() |
DataBuffer |
underlyingDataBuffer()
Underlying buffer:
This is meant for a data buffer
to be a view of another data buffer
|
long |
underlyingLength()
Returns the length of the buffer
|
void |
unPersist()
Deprecated.
|
boolean |
wasClosed()
This method checks if array or its buffer was closed before
|
protected ByteBuffer |
wrappedBuffer() |
void |
write(DataOutputStream out) |
void |
write(OutputStream dos)
Write this buffer to the output stream
|
public static String TO_STRING_MAX_ELEMENTS
ND4JSystemProperties.DATABUFFER_TO_STRING_MAX_ELEMENTSprotected DataType type
protected long length
protected long underlyingLength
protected long offset
protected byte elementSize
protected transient DataBuffer wrappedDataBuffer
protected transient long workspaceGenerationId
protected DataBuffer.AllocationMode allocationMode
protected transient org.bytedeco.javacpp.indexer.Indexer indexer
protected transient org.bytedeco.javacpp.Pointer pointer
protected transient boolean attached
protected transient MemoryWorkspace parentWorkspace
protected transient DataBuffer originalBuffer
protected transient long originalOffset
protected transient boolean constant
protected transient boolean released
protected transient AtomicBoolean referenced
public BaseDataBuffer()
public BaseDataBuffer(org.bytedeco.javacpp.Pointer pointer,
org.bytedeco.javacpp.indexer.Indexer indexer,
long length)
pointer - the underlying buffer to create a view fromindexer - the indexer for the pointerlength - the length of the viewprotected BaseDataBuffer(DataBuffer underlyingBuffer, long length, long offset)
underlyingBuffer - the underlying buffer to create a view fromlength - the length of the viewoffset - the offset for the viewprotected abstract void initTypeAndSize()
public int getElementSize()
DataBuffergetElementSize in interface DataBufferpublic long getGenerationId()
getGenerationId in interface DataBufferprotected void setIndexer(org.bytedeco.javacpp.indexer.Indexer indexer)
protected void pickReferent(BaseDataBuffer referent)
public DataBuffer originalDataBuffer()
originalDataBuffer in interface DataBufferprotected void setNioBuffer()
public org.bytedeco.javacpp.indexer.Indexer indexer()
indexer in interface DataBufferpublic org.bytedeco.javacpp.Pointer pointer()
DataBufferpointer in interface DataBufferpublic DataBuffer underlyingDataBuffer()
DataBufferunderlyingDataBuffer in interface DataBufferpublic long offset()
DataBufferoffset in interface DataBufferpublic DataBuffer.AllocationMode allocationMode()
DataBufferallocationMode in interface DataBuffer@Deprecated public void persist()
DataBufferpersist in interface DataBuffer@Deprecated public boolean isPersist()
DataBufferisPersist in interface DataBuffer@Deprecated public void unPersist()
DataBufferunPersist in interface DataBufferprotected void fillPointerWithZero()
public void copyAtStride(DataBuffer buf, long n, long stride, long yStride, long offset, long yOffset)
DataBuffercopyAtStride in interface DataBufferbuf - the data buffer to copy fromn - the number of elements to copystride - the stride to copy at@Deprecated public void removeReferencing(String id)
DataBufferremoveReferencing in interface DataBufferid - the id to remove@Deprecated public Collection<String> references()
DataBufferreferences in interface DataBufferpublic abstract org.bytedeco.javacpp.Pointer addressPointer()
DataBufferaddressPointer in interface DataBufferpublic long address()
DataBufferaddress in interface DataBuffer@Deprecated public void addReferencing(String id)
DataBufferaddReferencing in interface DataBufferid - the id to referencepublic void assign(long[] indices,
float[] data,
boolean contiguous,
long inc)
DataBufferassign in interface DataBufferindices - the indices to assigndata - the data to assigncontiguous - whether the indices are contiguous or notinc - the number to increment by when assigningpublic void setData(int[] data)
DataBuffersetData in interface DataBufferdata - the data for this bufferpublic void setData(float[] data)
DataBuffersetData in interface DataBufferdata - the data for this bufferpublic void setData(double[] data)
DataBuffersetData in interface DataBufferdata - the data for this bufferpublic void setData(long[] data)
DataBuffersetData in interface DataBufferdata - the data for this bufferpublic void setData(byte[] data)
setData in interface DataBufferpublic void setData(short[] data)
setData in interface DataBufferpublic void setData(boolean[] data)
setData in interface DataBufferpublic void assign(long[] indices,
double[] data,
boolean contiguous,
long inc)
DataBufferassign in interface DataBufferindices - the indices to assigndata - the data to assigncontiguous - whether the data is contiguous or notinc - the number to increment by when assigningpublic void assign(DataBuffer data)
DataBufferassign in interface DataBufferdata - the data to assignpublic void assign(long[] indices,
float[] data,
boolean contiguous)
DataBufferassign in interface DataBufferindices - the indices to assigndata - the data to assigncontiguous - whether the indices are contiguous or notpublic void assign(long[] indices,
double[] data,
boolean contiguous)
DataBufferassign in interface DataBufferindices - the indices to assigndata - the data to assigncontiguous - whether the data is contiguous or notpublic long underlyingLength()
DataBufferunderlyingLength in interface DataBufferpublic long length()
DataBufferlength in interface DataBufferpublic void assign(Number value)
DataBufferassign in interface DataBuffervalue - the value to assignpublic double[] getDoublesAt(long offset,
long inc,
int length)
DataBuffergetDoublesAt in interface DataBufferoffset - the offset to startinc - the increment to uselength - the length of the arraypublic double[] getDoublesAt(long offset,
int length)
DataBuffergetDoublesAt in interface DataBufferoffset - the offset to startlength - the length of the arraypublic float[] getFloatsAt(long offset,
int length)
DataBuffergetFloatsAt in interface DataBufferoffset - the offset to startlength - the length of the arraypublic float[] getFloatsAt(long offset,
long inc,
int length)
DataBuffergetFloatsAt in interface DataBufferoffset - the offset to startinc - the increment to uselength - the length of the arraypublic long[] getLongsAt(long offset,
int length)
DataBuffergetLongsAt in interface DataBufferoffset - the offset to startlength - the length of the arraypublic long[] getLongsAt(long offset,
long inc,
int length)
DataBuffergetLongsAt in interface DataBufferoffset - the offset to startinc - the increment to uselength - the length of the arraypublic int[] getIntsAt(long offset,
int length)
DataBuffergetIntsAt in interface DataBufferoffset - the offset to startlength - the length of the arraypublic int[] getIntsAt(long offset,
long inc,
int length)
DataBuffergetIntsAt in interface DataBufferoffset - the offset to startinc - the increment to uselength - the length of the arraypublic DataBuffer dup()
DataBufferdup in interface DataBufferprotected abstract DataBuffer create(long length)
length - a databuffer of the same opType as
this with the given lengthpublic abstract DataBuffer create(double[] data)
data - the buffer to createpublic abstract DataBuffer create(float[] data)
data - the buffer to createpublic abstract DataBuffer create(int[] data)
data - the buffer to createpublic void assign(long[] offsets,
long[] strides,
DataBuffer... buffers)
DataBufferassign in interface DataBufferoffsets - the offsets to usestrides - the strides to usebuffers - the buffers to assign data frompublic byte[] asBytes()
DataBufferasBytes in interface DataBufferpublic float[] asFloat()
DataBufferasFloat in interface DataBufferpublic double[] asDouble()
DataBufferasDouble in interface DataBufferpublic int[] asInt()
DataBufferasInt in interface DataBufferpublic long[] asLong()
DataBufferasLong in interface DataBufferpublic double getDouble(long i)
DataBuffergetDouble in interface DataBufferi - the element to getFloatpublic long getLong(long i)
DataBuffergetLong in interface DataBufferprotected short getShort(long i)
i - public static short fromFloat(float v)
v - public float getFloat(long i)
DataBuffergetFloat in interface DataBufferi - the element to getFloatpublic int getInt(long i)
DataBuffergetInt in interface DataBufferi - the int at the specified indexpublic Number getNumber(long i)
DataBuffergetNumber in interface DataBufferi - the element to getFloatpublic abstract void pointerIndexerByCurrentType(DataType currentType)
public void put(long i,
float element)
DataBufferput in interface DataBufferi - the indexelement - the element to assignpublic void put(long i,
double element)
DataBufferput in interface DataBufferi - the indexelement - the element to assignpublic void put(long i,
int element)
DataBufferput in interface DataBufferi - the indexelement - the element to assignpublic void put(long i,
boolean element)
put in interface DataBufferpublic void put(long i,
long element)
put in interface DataBuffer@Deprecated public boolean dirty()
DataBufferdirty in interface DataBufferpublic boolean sameUnderlyingData(DataBuffer buffer)
DataBuffersameUnderlyingData in interface DataBufferbuffer - whether the buffer is the same underlying data or notprotected ByteBuffer wrappedBuffer()
public IntBuffer asNioInt()
DataBufferasNioInt in interface DataBufferpublic LongBuffer asNioLong()
asNioLong in interface DataBufferpublic DoubleBuffer asNioDouble()
DataBufferasNioDouble in interface DataBufferpublic FloatBuffer asNioFloat()
DataBufferasNioFloat in interface DataBufferpublic ByteBuffer asNio()
DataBufferasNio in interface DataBufferpublic void assign(Number value, long offset)
DataBufferassign in interface DataBuffervalue - assign the value to setoffset - the offset to start atpublic void write(OutputStream dos)
DataBufferwrite in interface DataBufferdos - the output stream to writepublic void read(InputStream is, DataBuffer.AllocationMode allocationMode, long length, DataType dataType)
DataBufferread in interface DataBufferis - the inpus tream to write topublic void flush()
DataBufferflush in interface DataBufferpublic void assign(long[] offsets,
long[] strides,
long n,
DataBuffer... buffers)
DataBufferassign in interface DataBufferoffsets - the offsets to usestrides - the strides to usen - the number of elements to operate onbuffers - the buffers to assign data frompublic void assign(DataBuffer... buffers)
DataBufferassign in interface DataBufferbuffers - the buffers to assignpublic void destroy()
DataBufferdestroy in interface DataBufferpublic DataType dataType()
dataType in interface DataBufferprotected void doReadObject(ObjectInputStream s)
public static Triple<DataBuffer.AllocationMode,Long,DataType> readHeader(@NonNull @NonNull InputStream is)
public void read(DataInputStream s, @NonNull @NonNull DataBuffer.AllocationMode allocMode, long len, @NonNull @NonNull DataType dtype)
read in interface DataBufferprotected void readContent(DataInputStream s, DataType sourceType, DataType thisType)
protected abstract double getDoubleUnsynced(long index)
protected abstract float getFloatUnsynced(long index)
protected abstract long getLongUnsynced(long index)
protected abstract int getIntUnsynced(long index)
public void write(DataOutputStream out) throws IOException
write in interface DataBufferIOExceptionpublic float toFloat(int hbits)
public Object array()
DataBufferarray in interface DataBufferpublic long originalOffset()
originalOffset in interface DataBufferpublic boolean isConstant()
isConstant in interface DataBufferpublic void setConstant(boolean reallyConstant)
setConstant in interface DataBufferreallyConstant - public boolean isAttached()
isAttached in interface DataBufferpublic boolean isInScope()
PLEASE NOTE: if this INDArray isn't attached to any Workspace, this method will return true
isInScope in interface DataBufferpublic MemoryWorkspace getParentWorkspace()
DataBuffergetParentWorkspace in interface DataBufferpublic abstract DataBuffer reallocate(long length)
DataBufferreallocate in interface DataBufferlength - the new length of the bufferpublic long capacity()
capacity in interface DataBufferpublic boolean closeable()
DataBuffercloseable in interface DataBufferprotected void markReleased()
public void close()
DataBufferclose in interface AutoCloseableclose in interface DataBufferprotected void release()
public long platformAddress()
DataBufferplatformAddress in interface DataBufferpublic boolean wasClosed()
DataBufferwasClosed in interface DataBufferpublic abstract void syncToPrimary()
public abstract void syncToSpecial()
Copyright © 2021. All rights reserved.