public class BinarySerde extends Object
Constructor and Description |
---|
BinarySerde() |
Modifier and Type | Method and Description |
---|---|
static int |
byteBufferSizeFor(INDArray arr)
Returns the byte buffer size for the given
ndarray.
|
static void |
doByteBufferPutCompressed(INDArray arr,
ByteBuffer allocated,
boolean rewind)
Setup the given byte buffer
for serialization (note that this is for compressed INDArrays)
4 bytes for rank
4 bytes for data opType
shape information
codec information
data opType
|
static void |
doByteBufferPutUnCompressed(INDArray arr,
ByteBuffer allocated,
boolean rewind)
Setup the given byte buffer
for serialization (note that this is for uncompressed INDArrays)
4 bytes int for rank
4 bytes for data opType
shape buffer
data buffer
|
static INDArray |
readFromDisk(File readFrom)
Read an ndarray from disk
|
static DataBuffer |
readShapeFromDisk(File readFrom)
This method returns shape databuffer from saved earlier file
|
static INDArray |
toArray(ByteBuffer buffer)
Create an ndarray
from the unsafe buffer
|
static INDArray |
toArray(ByteBuffer buffer,
int offset)
Create an ndarray
from the unsafe buffer
|
protected static Pair<INDArray,ByteBuffer> |
toArrayAndByteBuffer(ByteBuffer buffer,
int offset)
Create an ndarray and existing bytebuffer
|
static ByteBuffer |
toByteBuffer(INDArray arr)
Convert an ndarray to an unsafe buffer
for use by aeron
|
static void |
writeArrayToDisk(INDArray arr,
File toWrite)
Write an ndarray to disk in
binary format
|
static void |
writeArrayToOutputStream(INDArray arr,
OutputStream outputStream)
Write an array to an output stream.
|
public static INDArray toArray(ByteBuffer buffer, int offset)
buffer
- the buffer to create the array frompublic static INDArray toArray(ByteBuffer buffer)
buffer
- the buffer to create the array fromprotected static Pair<INDArray,ByteBuffer> toArrayAndByteBuffer(ByteBuffer buffer, int offset)
buffer
- the buffer to create the arrays fromoffset
- position in buffer to create the arrays from.public static ByteBuffer toByteBuffer(INDArray arr)
arr
- the array to convertpublic static int byteBufferSizeFor(INDArray arr)
arr
- the array to compute the size forpublic static void doByteBufferPutUnCompressed(INDArray arr, ByteBuffer allocated, boolean rewind)
arr
- the array to setupallocated
- the byte buffer to setuprewind
- whether to rewind the byte buffer or ntpublic static void doByteBufferPutCompressed(INDArray arr, ByteBuffer allocated, boolean rewind)
arr
- the array to setupallocated
- the byte buffer to setuprewind
- whether to rewind the byte buffer or notpublic static void writeArrayToOutputStream(INDArray arr, OutputStream outputStream)
arr
- the array to writeoutputStream
- the output stream to write topublic static void writeArrayToDisk(INDArray arr, File toWrite) throws IOException
arr
- the array to writetoWrite
- the file tow rite toIOException
- on an I/O exception.public static INDArray readFromDisk(File readFrom) throws IOException
readFrom
- file to readIOException
- on an I/O exception.public static DataBuffer readShapeFromDisk(File readFrom) throws IOException
readFrom
- file to readIOException
- on an I/O exception.Copyright © 2020. All rights reserved.