Class ArrowSerde


  • public class ArrowSerde
    extends Object
    • Constructor Detail

      • ArrowSerde

        public ArrowSerde()
    • Method Detail

      • fromTensor

        public static INDArray fromTensor​(org.apache.arrow.flatbuf.Tensor tensor)
        Convert a Tensor to an INDArray
        Parameters:
        tensor - the input tensor
        Returns:
        the equivalent INDArray
      • toTensor

        public static org.apache.arrow.flatbuf.Tensor toTensor​(INDArray arr)
        Convert an INDArray to an arrow Tensor
        Parameters:
        arr - the array to convert
        Returns:
        the equivalent Tensor
      • addDataForArr

        public static int addDataForArr​(com.google.flatbuffers.FlatBufferBuilder bufferBuilder,
                                        INDArray arr)
        Create a Buffer representing the location metadata of the actual data contents for the ndarrays' DataBuffer
        Parameters:
        bufferBuilder - the buffer builder in use
        arr - 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 given INDArray data type to the proper data type for the tensor.
        Parameters:
        bufferBuilder - the buffer builder in use
        arr - 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 use
        arr - the input array
        Returns:
      • getArrowStrides

        public static long[] getArrowStrides​(INDArray arr)
        Get the strides of this INDArray multiplieed by the element size. This is the Tensor and 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 nd4j DataType from
        elementSize - the element size
        Returns:
        the data buffer type