nd4j-serde/nd4j-arrow/src/main/java/org/nd4j/arrow/ArrowSerde.java
public static INDArray fromTensor(Tensor tensor) {
        byte b = tensor.typeType();
        int[] shape = new int[tensor.shapeLength()];
        int[] stride = new int[tensor.stridesLength()];
        for(int i = 0; i < shape.length; i++) {
            shape[i] = (int) tensor.shape(i).size();
            stride[i] = (int) tensor.strides(i);
        }

        int length = ArrayUtil.prod(shape);
        Buffer buffer = tensor.data();
        if(buffer == null) {
            throw new ND4JIllegalStateException("Buffer was not serialized properly.");
        }
        //deduce element size
        int elementSize = (int) buffer.length() / length;
        //nd4j strides aren't  based on element size
        for(int i = 0; i < stride.length; i++) {
            stride[i] /= elementSize;
        }

        DataBuffer.Type  type = typeFromTensorType(b,elementSize);
        DataBuffer dataBuffer = DataBufferStruct.createFromByteBuffer(tensor.getByteBuffer(),(int) tensor.data().offset(),type,length,elementSize);
        INDArray arr = Nd4j.create(dataBuffer,shape);
        arr.setShapeAndStride(shape,stride);
        return arr;
    }
public static INDArray fromTensor(Tensor tensor) {
        byte b = tensor.typeType();
        int[] shape = new int[tensor.shapeLength()];
        int[] stride = new int[tensor.stridesLength()];
        for(int i = 0; i < shape.length; i++) {
            shape[i] = (int) tensor.shape(i).size();
            stride[i] = (int) tensor.strides(i);
        }

        int length = ArrayUtil.prod(shape);
        Buffer buffer = tensor.data();
        if(buffer == null) {
            throw new ND4JIllegalStateException("Buffer was not serialized properly.");
        }
        //deduce element size
        int elementSize = (int) buffer.length() / length;
        //nd4j strides aren't  based on element size
        for(int i = 0; i < stride.length; i++) {
            stride[i] /= elementSize;
        }

        DataBuffer.Type  type = typeFromTensorType(b,elementSize);
        DataBuffer dataBuffer = DataBufferStruct.createFromByteBuffer(tensor.getByteBuffer(),(int) tensor.data().offset(),type,length,elementSize);
        INDArray arr = Nd4j.create(dataBuffer,shape);
        arr.setShapeAndStride(shape,stride);
        return arr;
    }
public static INDArray fromTensor ( Tensor tensor ) { byte b = tensor . typeType ( ) ; int [ ] shape = new int [ tensor . shapeLength ( ) ] ; int [ ] stride = new int [ tensor . stridesLength ( ) ] ; for ( int i = 0 ; i < shape . length ; i ++ ) { shape [ i ] = ( int ) tensor . shape ( i ) . size ( ) ; stride [ i ] = ( int ) tensor . strides ( i ) ; } int length = ArrayUtil . prod ( shape ) ; Buffer buffer = tensor . data ( ) ; if ( buffer == null ) { throw new ND4JIllegalStateException ( "Buffer was not serialized properly." ) ; } //deduce element size int elementSize = ( int ) buffer . length ( ) / length ; //nd4j strides aren't  based on element size for ( int i = 0 ; i < stride . length ; i ++ ) { stride [ i ] /= elementSize ; } DataBuffer . Type type = typeFromTensorType ( b , elementSize ) ; DataBuffer dataBuffer = DataBufferStruct . createFromByteBuffer ( tensor . getByteBuffer ( ) , ( int ) tensor . data ( ) . offset ( ) , type , length , elementSize ) ; INDArray arr = Nd4j . create ( dataBuffer , shape ) ; arr . setShapeAndStride ( shape , stride ) ; return arr ; }
Convert a {@link Tensor}
to an {@link INDArray}
@param tensor the input tensor
@return the equivalent {@link INDArray}
Convert a {