public static boolean isContiguousInBuffer ( INDArray in ) { long length = in . length ( ) ; long dLength = in . data ( ) . length ( ) ; if ( length == dLength ) return true ; //full buffer, always contiguous char order = in . ordering ( ) ; long [ ] shape = in . shape ( ) ; long [ ] stridesIfContiguous ; if ( order == ' ' ) { stridesIfContiguous = ArrayUtil . calcStridesFortran ( shape ) ; } else if ( order == ' ' ) { stridesIfContiguous = ArrayUtil . calcStrides ( shape ) ; } else if ( order == ' ' ) { stridesIfContiguous = new long [ ] { 1 , 1 } ; } else { throw new RuntimeException ( "Invalid order: not c or f (is: " + order + ")" ) ; } return Arrays . equals ( in . stride ( ) , stridesIfContiguous ) ; }
Are the elements in the buffer contiguous for this NDArray?