public static boolean contentEquals(long[] arr, DataBuffer other) { for (int i = 0; i < arr.length; i++) { if (other.getLong(i) != arr[i]) { return false; } } return true; }
/** * Get the shape from * the given int buffer * @param buffer the buffer to get the shape information for * @return */ public static DataBuffer shapeOf(DataBuffer buffer) { int rank = (int) buffer.getLong(0); return Nd4j.createBuffer(buffer, 1, rank); }
/** * Gets the rank given the shape info buffer * @param buffer the buffer to get the rank for * @return the rank for the shape buffer */ public static int length(DataBuffer buffer) { int ret = 1; val rr = buffer.asLong(); DataBuffer shape = Shape.shapeOf(buffer); int rank = Shape.rank(buffer); for (int i = 0; i < rank; i++) ret *= shape.getLong(i); return ret; }
val shape = Shape.shape(shapeInfo); val stride = Shape.stride(shapeInfo).asLong(); long offset = offset() + tadInfo.getSecond().getLong(index); INDArray toTad = Nd4j.create(data(), shape, stride, offset); BaseNDArray baseNDArray = (BaseNDArray) toTad;
int[] shape = Shape.shape(shapeInfo); int[] stride = Shape.stride(shapeInfo).asInt(); long offset = offset() + tadInfo.getSecond().getLong(index); INDArray toTad = Nd4j.create(data(), shape, stride, offset); BaseNDArray baseNDArray = (BaseNDArray) toTad;