- java.lang.Object
-
- org.tensorflow.ndarray.buffer.DataBuffers
-
public final class DataBuffers extends Object
Helper class for creatingDataBufferinstances.
-
-
Constructor Summary
Constructors Constructor Description DataBuffers()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BooleanDataBufferof(boolean... values)Create a buffer from an array of booleans into a data buffer.static BooleanDataBufferof(boolean[] array, boolean readOnly, boolean makeCopy)Create a buffer from an array of booleans into a data buffer.static ByteDataBufferof(byte... values)Create a buffer from an array of bytes into a data buffer.static ByteDataBufferof(byte[] array, boolean readOnly, boolean makeCopy)Create a buffer from an array of bytes into a data buffer.static DoubleDataBufferof(double... values)Create a buffer from an array of doubles into a data buffer.static DoubleDataBufferof(double[] array, boolean readOnly, boolean makeCopy)Create a buffer from an array of doubles into a data buffer.static FloatDataBufferof(float... values)Create a buffer from an array of floats into a data buffer.static FloatDataBufferof(float[] array, boolean readOnly, boolean makeCopy)Create a buffer from an array of floats into a data buffer.static IntDataBufferof(int... values)Create a buffer from an array of ints into a data buffer.static IntDataBufferof(int[] array, boolean readOnly, boolean makeCopy)Create a buffer from an array of ints into a data buffer.static LongDataBufferof(long... values)Create a buffer from an array of longs into a data buffer.static LongDataBufferof(long[] array, boolean readOnly, boolean makeCopy)Create a buffer from an array of longs into a data buffer.static ShortDataBufferof(short... values)Create a buffer from an array of shorts into a data buffer.static ShortDataBufferof(short[] array, boolean readOnly, boolean makeCopy)Create a buffer from an array of shorts into a data buffer.static ByteDataBufferof(ByteBuffer buf)Wraps a JDK NIOByteBufferinto a data buffer.static DoubleDataBufferof(DoubleBuffer buf)Wraps a JDK NIODoubleBufferinto a data buffer.static FloatDataBufferof(FloatBuffer buf)Wraps a JDK NIOFloatBufferinto a data buffer.static IntDataBufferof(IntBuffer buf)Wraps a JDK NIOIntBufferinto a data buffer.static LongDataBufferof(LongBuffer buf)Wraps a JDK NIOLongBufferinto a data buffer.static ShortDataBufferof(ShortBuffer buf)Wraps a JDK NIOShortBufferinto a data buffer.static <T> DataBuffer<T>of(T[] array, boolean readOnly, boolean makeCopy)Create a buffer from an array of objects into a data buffer.static BooleanDataBufferofBooleans(long size)Creates a buffer of booleans that can store up tosizevaluesstatic ByteDataBufferofBytes(long size)Creates a buffer of bytes that can store up tosizevaluesstatic DoubleDataBufferofDoubles(long size)Creates a buffer of doubles that can store up tosizevaluesstatic FloatDataBufferofFloats(long size)Creates a buffer of floats that can store up tosizevaluesstatic IntDataBufferofInts(long size)Creates a buffer of integers that can store up tosizevaluesstatic LongDataBufferofLongs(long size)Creates a buffer of longs that can store up tosizevaluesstatic <T> DataBuffer<T>ofObjects(Class<T> type, long size)Creates a buffer of references to objects of typeclazz` that can store up to `sizevalues.static <T> DataBuffer<T>ofObjects(T... values)Create a buffer from an array of objects into a data buffer.static ShortDataBufferofShorts(long size)Creates a buffer of shorts that can store up tosizevalues
-
-
-
Method Detail
-
ofBytes
public static ByteDataBuffer ofBytes(long size)
Creates a buffer of bytes that can store up tosizevalues- Parameters:
size- size of the buffer to allocate- Returns:
- a new buffer
-
ofLongs
public static LongDataBuffer ofLongs(long size)
Creates a buffer of longs that can store up tosizevalues- Parameters:
size- size of the buffer to allocate- Returns:
- a new buffer
-
ofInts
public static IntDataBuffer ofInts(long size)
Creates a buffer of integers that can store up tosizevalues- Parameters:
size- size of the buffer to allocate- Returns:
- a new buffer
-
ofShorts
public static ShortDataBuffer ofShorts(long size)
Creates a buffer of shorts that can store up tosizevalues- Parameters:
size- size of the buffer to allocate- Returns:
- a new buffer
-
ofDoubles
public static DoubleDataBuffer ofDoubles(long size)
Creates a buffer of doubles that can store up tosizevalues- Parameters:
size- size of the buffer to allocate- Returns:
- a new buffer
-
ofFloats
public static FloatDataBuffer ofFloats(long size)
Creates a buffer of floats that can store up tosizevalues- Parameters:
size- size of the buffer to allocate- Returns:
- a new buffer
-
ofBooleans
public static BooleanDataBuffer ofBooleans(long size)
Creates a buffer of booleans that can store up tosizevalues- Parameters:
size- size of the buffer to allocate- Returns:
- a new buffer
-
ofObjects
public static <T> DataBuffer<T> ofObjects(Class<T> type, long size)
Creates a buffer of references to objects of typeclazz` that can store up to `sizevalues.- Type Parameters:
T- data type- Parameters:
type- the type of object stored in this buffersize- size of the buffer to allocate- Returns:
- a new buffer
-
of
public static FloatDataBuffer of(float... values)
Create a buffer from an array of floats into a data buffer.The returned buffer allows read and write operations and share the memory of the source array, which is equivalent to call
of(values, false, false}- Parameters:
values- float values- Returns:
- a new buffer
-
of
public static ByteDataBuffer of(byte... values)
Create a buffer from an array of bytes into a data buffer.The returned buffer allows read and write operations and share the memory of the source array, which is equivalent to call
of(values, false, false}- Parameters:
values- byte values- Returns:
- a new buffer
-
of
public static LongDataBuffer of(long... values)
Create a buffer from an array of longs into a data buffer.The returned buffer allows read and write operations and share the memory of the source array, which is equivalent to call
of(values, false, false}- Parameters:
values- long values- Returns:
- a new buffer
-
of
public static IntDataBuffer of(int... values)
Create a buffer from an array of ints into a data buffer.The returned buffer allows read and write operations and share the memory of the source array, which is equivalent to call
of(values, false, false}- Parameters:
values- int values- Returns:
- a new buffer
-
of
public static ShortDataBuffer of(short... values)
Create a buffer from an array of shorts into a data buffer.The returned buffer allows read and write operations and share the memory of the source array, which is equivalent to call
of(values, false, false}- Parameters:
values- short values- Returns:
- a new buffer
-
of
public static DoubleDataBuffer of(double... values)
Create a buffer from an array of doubles into a data buffer.The returned buffer allows read and write operations and share the memory of the source array, which is equivalent to call
of(array, false, false}- Parameters:
values- double values- Returns:
- a new buffer
-
of
public static BooleanDataBuffer of(boolean... values)
Create a buffer from an array of booleans into a data buffer.The returned buffer allows read and write operations and share the memory of the source array, which is equivalent to call
of(values, false, false}- Parameters:
values- booleans values- Returns:
- a new buffer
-
ofObjects
@SafeVarargs public static <T> DataBuffer<T> ofObjects(T... values)
Create a buffer from an array of objects into a data buffer.The returned buffer allows read and write operations and share the memory of the source array, which is equivalent to call
of(values, false, false}- Type Parameters:
T- data type- Parameters:
values- objects values- Returns:
- a new buffer
-
of
public static FloatDataBuffer of(float[] array, boolean readOnly, boolean makeCopy)
Create a buffer from an array of floats into a data buffer.- Parameters:
array- array of floatsreadOnly- true if the buffer created must be read-onlymakeCopy- true if the array must be copied, false will wrap the provided array- Returns:
- a new buffer
-
of
public static ByteDataBuffer of(byte[] array, boolean readOnly, boolean makeCopy)
Create a buffer from an array of bytes into a data buffer.- Parameters:
array- array of bytesreadOnly- true if the buffer created must be read-onlymakeCopy- true if the array must be copied, false will wrap the provided array- Returns:
- a new buffer
-
of
public static LongDataBuffer of(long[] array, boolean readOnly, boolean makeCopy)
Create a buffer from an array of longs into a data buffer.- Parameters:
array- array of longsreadOnly- true if the buffer created must be read-onlymakeCopy- true if the array must be copied, false will wrap the provided array- Returns:
- a new buffer
-
of
public static IntDataBuffer of(int[] array, boolean readOnly, boolean makeCopy)
Create a buffer from an array of ints into a data buffer.- Parameters:
array- array of intsreadOnly- true if the buffer created must be read-onlymakeCopy- true if the array must be copied, false will wrap the provided array- Returns:
- a new buffer
-
of
public static ShortDataBuffer of(short[] array, boolean readOnly, boolean makeCopy)
Create a buffer from an array of shorts into a data buffer.- Parameters:
array- array of shortsreadOnly- true if the buffer created must be read-onlymakeCopy- true if the array must be copied, false will wrap the provided array- Returns:
- a new buffer
-
of
public static DoubleDataBuffer of(double[] array, boolean readOnly, boolean makeCopy)
Create a buffer from an array of doubles into a data buffer.- Parameters:
array- array of doublesreadOnly- true if the buffer created must be read-onlymakeCopy- true if the array must be copied, false will wrap the provided array- Returns:
- a new buffer
-
of
public static BooleanDataBuffer of(boolean[] array, boolean readOnly, boolean makeCopy)
Create a buffer from an array of booleans into a data buffer.- Parameters:
array- array of booleansreadOnly- true if the buffer created must be read-onlymakeCopy- true if the array must be copied, false will wrap the provided array- Returns:
- a new buffer
-
of
public static <T> DataBuffer<T> of(T[] array, boolean readOnly, boolean makeCopy)
Create a buffer from an array of objects into a data buffer.- Type Parameters:
T- data type- Parameters:
array- array of objectsreadOnly- true if the buffer created must be read-onlymakeCopy- true if the array must be copied, false will wrap the provided array- Returns:
- a new buffer
-
of
public static ByteDataBuffer of(ByteBuffer buf)
Wraps a JDK NIOByteBufferinto a data buffer.- Parameters:
buf- buffer to wrap- Returns:
- a new buffer
-
of
public static IntDataBuffer of(IntBuffer buf)
Wraps a JDK NIOIntBufferinto a data buffer.- Parameters:
buf- buffer to wrap- Returns:
- a new buffer
-
of
public static ShortDataBuffer of(ShortBuffer buf)
Wraps a JDK NIOShortBufferinto a data buffer.- Parameters:
buf- buffer to wrap- Returns:
- a new buffer
-
of
public static LongDataBuffer of(LongBuffer buf)
Wraps a JDK NIOLongBufferinto a data buffer.- Parameters:
buf- buffer to wrap- Returns:
- a new buffer
-
of
public static FloatDataBuffer of(FloatBuffer buf)
Wraps a JDK NIOFloatBufferinto a data buffer.- Parameters:
buf- buffer to wrap- Returns:
- a new buffer
-
of
public static DoubleDataBuffer of(DoubleBuffer buf)
Wraps a JDK NIODoubleBufferinto a data buffer.- Parameters:
buf- buffer to wrap- Returns:
- a new buffer
-
-