public abstract class BaseDataBuffer extends Object implements DataBuffer
DataBuffer.AllocationMode, DataBuffer.Type, 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 |
static String |
TO_STRING_MAX_ELEMENTS
Deprecated.
Use
ND4JSystemProperties.DATABUFFER_TO_STRING_MAX_ELEMENTS |
protected Long |
trackingPoint |
protected DataBuffer.Type |
type |
protected long |
underlyingLength |
protected long |
workspaceGenerationId |
protected DataBuffer |
wrappedDataBuffer |
| Modifier | Constructor and Description |
|---|---|
|
BaseDataBuffer() |
|
BaseDataBuffer(byte[] data,
long length) |
|
BaseDataBuffer(ByteBuffer buffer,
long length)
Create a data buffer from
the given length
|
|
BaseDataBuffer(ByteBuffer buffer,
long length,
long offset)
Create a data buffer from
the given length
|
protected |
BaseDataBuffer(DataBuffer underlyingBuffer,
long length,
long offset)
Meant for creating another view of a buffer
|
|
BaseDataBuffer(double[] data) |
|
BaseDataBuffer(double[] data,
boolean copy) |
|
BaseDataBuffer(double[] data,
boolean copy,
long offset) |
|
BaseDataBuffer(double[] data,
boolean copy,
long offset,
MemoryWorkspace workspace) |
|
BaseDataBuffer(double[] data,
boolean copy,
MemoryWorkspace workspace) |
|
BaseDataBuffer(float[] data) |
|
BaseDataBuffer(float[] data,
boolean copy) |
|
BaseDataBuffer(float[] data,
boolean copy,
long offset) |
|
BaseDataBuffer(float[] data,
boolean copy,
long offset,
MemoryWorkspace workspace) |
|
BaseDataBuffer(float[] data,
boolean copy,
MemoryWorkspace workspace) |
|
BaseDataBuffer(float[] data,
MemoryWorkspace workspace) |
|
BaseDataBuffer(int[] data) |
|
BaseDataBuffer(int[] data,
boolean copy) |
|
BaseDataBuffer(int[] data,
boolean copy,
long offset) |
|
BaseDataBuffer(int[] data,
boolean copy,
MemoryWorkspace workspace) |
|
BaseDataBuffer(int length,
int elementSize,
long offset) |
protected |
BaseDataBuffer(long length)
Instantiate a buffer with the given length
|
|
BaseDataBuffer(long[] data,
boolean copy) |
|
BaseDataBuffer(long[] data,
boolean copy,
MemoryWorkspace workspace) |
protected |
BaseDataBuffer(long length,
boolean initialize) |
protected |
BaseDataBuffer(long length,
boolean initialize,
MemoryWorkspace workspace) |
|
BaseDataBuffer(long length,
int elementSize) |
|
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
|
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 |
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
|
DataBuffer.Type |
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) |
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
|
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
|
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
|
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
|
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
|
Long |
getTrackingPoint()
Returns tracking point for Allocator
PLEASE NOTE: Suitable & meaningful only for specific backends
|
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
|
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.
|
org.bytedeco.javacpp.Pointer |
pointer()
Returns an underlying pointer if one exists
|
void |
pointerIndexerByGlobalType(DataBuffer.Type currentType) |
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 |
putByGlobalType(long i,
Number element,
DataBuffer.Type globalType) |
void |
read(DataInputStream s) |
void |
read(InputStream is)
Write this buffer to the input stream.
|
protected void |
readContent(DataInputStream s,
DataBuffer.Type currentType,
DataBuffer.Type globalType) |
DataBuffer |
reallocate(long length)
Reallocate the native memory of the buffer
|
Collection<String> |
references()
Deprecated.
|
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(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
|
protected void |
setIndexer(org.bytedeco.javacpp.indexer.Indexer indexer) |
protected void |
setNioBuffer() |
void |
setTrackingPoint(Long trackingPoint)
Sets tracking point used by Allocator
PLEASE NOTE: Suitable & meaningful only for specific backends
|
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.
|
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 DataBuffer.Type 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.Pointer pointer
protected transient org.bytedeco.javacpp.indexer.Indexer indexer
protected transient boolean attached
protected transient MemoryWorkspace parentWorkspace
protected transient DataBuffer originalBuffer
protected transient long originalOffset
protected transient Long trackingPoint
protected transient boolean constant
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 viewpublic BaseDataBuffer(float[] data,
boolean copy,
long offset)
data - copy - public BaseDataBuffer(float[] data,
boolean copy,
long offset,
MemoryWorkspace workspace)
public BaseDataBuffer(float[] data,
boolean copy)
data - copy - public BaseDataBuffer(float[] data,
boolean copy,
MemoryWorkspace workspace)
public BaseDataBuffer(double[] data,
boolean copy,
MemoryWorkspace workspace)
public BaseDataBuffer(int[] data,
boolean copy,
MemoryWorkspace workspace)
public BaseDataBuffer(long[] data,
boolean copy,
MemoryWorkspace workspace)
public BaseDataBuffer(double[] data,
boolean copy,
long offset)
data - copy - public BaseDataBuffer(double[] data,
boolean copy,
long offset,
MemoryWorkspace workspace)
public BaseDataBuffer(double[] data,
boolean copy)
data - copy - public BaseDataBuffer(int[] data,
boolean copy,
long offset)
data - copy - public BaseDataBuffer(int[] data,
boolean copy)
data - copy - public BaseDataBuffer(long[] data,
boolean copy)
data - copy - public BaseDataBuffer(double[] data)
data - public BaseDataBuffer(int[] data)
data - public BaseDataBuffer(float[] data)
data - public BaseDataBuffer(float[] data,
MemoryWorkspace workspace)
public BaseDataBuffer(int length,
int elementSize,
long offset)
length - elementSize - public BaseDataBuffer(long length,
int elementSize)
length - elementSize - public BaseDataBuffer(ByteBuffer buffer, long length, long offset)
buffer - length - public BaseDataBuffer(ByteBuffer buffer, long length)
buffer - length - public BaseDataBuffer(byte[] data,
long length)
data - length - protected BaseDataBuffer(long length)
length - the length of the bufferprotected BaseDataBuffer(long length,
boolean initialize)
protected BaseDataBuffer(long length,
boolean initialize,
MemoryWorkspace workspace)
protected abstract void initTypeAndSize()
public int getElementSize()
DataBuffergetElementSize in interface DataBufferpublic long getGenerationId()
getGenerationId in interface DataBufferprotected void setIndexer(org.bytedeco.javacpp.indexer.Indexer indexer)
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 DataBufferpublic 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 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 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 void pointerIndexerByGlobalType(DataBuffer.Type currentType)
public void putByGlobalType(long i,
Number element,
DataBuffer.Type globalType)
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,
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)
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 DataBuffer.Type dataType()
dataType in interface DataBufferprotected void doReadObject(ObjectInputStream s)
public void read(DataInputStream s)
read in interface DataBufferprotected void readContent(DataInputStream s, DataBuffer.Type currentType, DataBuffer.Type globalType)
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 Long getTrackingPoint()
getTrackingPoint in interface DataBufferpublic void setTrackingPoint(Long trackingPoint)
setTrackingPoint in interface DataBuffertrackingPoint - public 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 DataBuffer reallocate(long length)
reallocate in interface DataBufferlength - the new length of the bufferpublic long capacity()
capacity in interface DataBufferCopyright © 2018. All rights reserved.