public static ByteBuffer toByteBuffer ( INDArray arr ) { //subset and get rid of 1 off non 1 element wise stride cases if ( arr . isView ( ) ) arr = arr . dup ( ) ; if ( ! arr . isCompressed ( ) ) { ByteBuffer b3 = ByteBuffer . allocateDirect ( byteBufferSizeFor ( arr ) ) . order ( ByteOrder . nativeOrder ( ) ) ; doByteBufferPutUnCompressed ( arr , b3 , true ) ; return b3 ; } //compressed array else { ByteBuffer b3 = ByteBuffer . allocateDirect ( byteBufferSizeFor ( arr ) ) . order ( ByteOrder . nativeOrder ( ) ) ; doByteBufferPutCompressed ( arr , b3 , true ) ; return b3 ; } }
Convert an ndarray to an unsafe buffer for use by aeron