/** * Compute the offset for a given slice * @param arr the array to compute * the offset frm * @param slice the slice to compute the offset for * @return the offset for a given slice */ public static long offsetForSlice(INDArray arr, int slice) { return slice * lengthPerSlice(arr); }
/** * Return the length of a slice * @param arr the array to get the length of a slice for * @return the number of elements per slice in an array */ public static long lengthPerSlice(INDArray arr) { return lengthPerSlice(arr, 0); }
/** * Computes the tensors per slice * given a tensor shape and array * @param arr the array to get the tensors per slice for * @param tensorShape the desired tensor shape * @return the tensors per slice of an ndarray */ public static long tensorsPerSlice(INDArray arr, int[] tensorShape) { return lengthPerSlice(arr) / ArrayUtil.prod(tensorShape); }
public static long sliceOffsetForTensor(int index, INDArray arr, long[] tensorShape) { long tensorLength = ArrayUtil.prodLong(tensorShape); long lengthPerSlice = NDArrayMath.lengthPerSlice(arr); long offset = index * tensorLength / lengthPerSlice; return offset; }
/** * calculates the offset for a tensor * @param index * @param arr * @param tensorShape * @return */ public static long sliceOffsetForTensor(int index, INDArray arr, int[] tensorShape) { long tensorLength = ArrayUtil.prodLong(tensorShape); long lengthPerSlice = NDArrayMath.lengthPerSlice(arr); long offset = index * tensorLength / lengthPerSlice; return offset; }
long offset = index * tensorLength / NDArrayMath.lengthPerSlice(ret2); if (sliceIdx == 0 && length == NDArrayMath.lengthPerSlice(ret2)) { else if (length == NDArrayMath.lengthPerSlice(ret2)) { offset -= ret2.slices() * (offset / ret2.slices());
/** * Compute the offset for a given slice * @param arr the array to compute * the offset frm * @param slice the slice to compute the offset for * @return the offset for a given slice */ public static int offsetForSlice(INDArray arr, int slice) { return slice * lengthPerSlice(arr); }
/** * Return the length of a slice * @param arr the array to get the length of a slice for * @return the number of elements per slice in an array */ public static int lengthPerSlice(INDArray arr) { return lengthPerSlice(arr, 0); }
/** * Computes the tensors per slice * given a tensor shape and array * @param arr the array to get the tensors per slice for * @param tensorShape the desired tensor shape * @return the tensors per slice of an ndarray */ public static int tensorsPerSlice(INDArray arr, int[] tensorShape) { return lengthPerSlice(arr) / ArrayUtil.prod(tensorShape); }
/** * calculates the offset for a tensor * @param index * @param arr * @param tensorShape * @return */ public static int sliceOffsetForTensor(int index, INDArray arr, int[] tensorShape) { int tensorLength = ArrayUtil.prod(tensorShape); int lengthPerSlice = NDArrayMath.lengthPerSlice(arr); int offset = index * tensorLength / lengthPerSlice; return offset; }
long offset = index * tensorLength / NDArrayMath.lengthPerSlice(ret2); if (sliceIdx == 0 && length == NDArrayMath.lengthPerSlice(ret2)) { else if (length == NDArrayMath.lengthPerSlice(ret2)) { offset -= ret2.slices() * (offset / ret2.slices());