Package org.nd4j.arrow
Class ArrowSerde
- java.lang.Object
-
- org.nd4j.arrow.ArrowSerde
-
public class ArrowSerde extends Object
-
-
Constructor Summary
Constructors Constructor Description ArrowSerde()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intaddDataForArr(com.google.flatbuffers.FlatBufferBuilder bufferBuilder, INDArray arr)Create aBufferrepresenting the location metadata of the actual data contents for the ndarrays'DataBufferstatic voidaddTypeTypeRelativeToNDArray(com.google.flatbuffers.FlatBufferBuilder bufferBuilder, INDArray arr)Convert the givenINDArraydata type to the proper data type for the tensor.static intcreateDims(com.google.flatbuffers.FlatBufferBuilder bufferBuilder, INDArray arr)Create the dimensions for the flatbuffer builderstatic INDArrayfromTensor(org.apache.arrow.flatbuf.Tensor tensor)Convert aTensorto anINDArraystatic long[]getArrowStrides(INDArray arr)Get the strides of thisINDArraymultiplieed by the element size.static org.apache.arrow.flatbuf.TensortoTensor(INDArray arr)Convert anINDArrayto an arrowTensorstatic DataTypetypeFromTensorType(byte type, int elementSize)Create thee databuffer type frm the given type, relative to the bytes in arrow in class:Type
-
-
-
Method Detail
-
fromTensor
public static INDArray fromTensor(org.apache.arrow.flatbuf.Tensor tensor)
Convert aTensorto anINDArray- Parameters:
tensor- the input tensor- Returns:
- the equivalent
INDArray
-
toTensor
public static org.apache.arrow.flatbuf.Tensor toTensor(INDArray arr)
Convert anINDArrayto an arrowTensor- Parameters:
arr- the array to convert- Returns:
- the equivalent
Tensor
-
addDataForArr
public static int addDataForArr(com.google.flatbuffers.FlatBufferBuilder bufferBuilder, INDArray arr)Create aBufferrepresenting the location metadata of the actual data contents for the ndarrays'DataBuffer- Parameters:
bufferBuilder- the buffer builder in usearr- the array to add the underlying data for- Returns:
- the offset added
-
addTypeTypeRelativeToNDArray
public static void addTypeTypeRelativeToNDArray(com.google.flatbuffers.FlatBufferBuilder bufferBuilder, INDArray arr)Convert the givenINDArraydata type to the proper data type for the tensor.- Parameters:
bufferBuilder- the buffer builder in usearr- the array to conver tthe data type for
-
createDims
public static int createDims(com.google.flatbuffers.FlatBufferBuilder bufferBuilder, INDArray arr)Create the dimensions for the flatbuffer builder- Parameters:
bufferBuilder- the buffer builder to usearr- the input array- Returns:
-
getArrowStrides
public static long[] getArrowStrides(INDArray arr)
Get the strides of thisINDArraymultiplieed by the element size. This is theTensorand numpy format- Parameters:
arr- the array to convert- Returns:
-
typeFromTensorType
public static DataType typeFromTensorType(byte type, int elementSize)
Create thee databuffer type frm the given type, relative to the bytes in arrow in class:Type- Parameters:
type- the type to create the nd4jDataTypefromelementSize- the element size- Returns:
- the data buffer type
-
-