public SpecifiedIndex(int... indexes) { this.indexes = LongUtils.toLongs(indexes); }
/** * Calculate the shape for the given set of indices and offsets. * <p/> * The shape is defined as (for each dimension) * the difference between the end index + 1 and * the begin index * <p/> * If specified, this will check for whether any of the indices are >= to end - 1 * and if so, prune it down * * @param shape the original shape * @param indices the indices to calculate the shape for * @return the shape for the given indices */ public static int[] shape(int[] shape, INDArrayIndex... indices) { return LongUtils.toInts(shape(LongUtils.toLongs(shape), indices)); }
@Override public INDArray subArray(ShapeOffsetResolution resolution) { Nd4j.getCompressor().autoDecompress(this); long[] offsets = resolution.getOffsets(); int[] shape = LongUtils.toInts(resolution.getShapes()); int[] stride = LongUtils.toInts(resolution.getStrides()); // if (offset() + resolution.getOffset() >= Integer.MAX_VALUE) // throw new IllegalArgumentException("Offset of array can not be >= Integer.MAX_VALUE"); long offset = (offset() + resolution.getOffset()); int n = shape.length; // FIXME: shapeInfo should be used here if (shape.length < 1) return create(Nd4j.createBufferDetached(shape)); if (offsets.length != n) throw new IllegalArgumentException("Invalid offset " + Arrays.toString(offsets)); if (stride.length != n) throw new IllegalArgumentException("Invalid stride " + Arrays.toString(stride)); if (shape.length == rank() && Shape.contentEquals(shape, shapeOf())) { if (ArrayUtil.isZero(offsets)) { return this; } else { throw new IllegalArgumentException("Invalid subArray offsets"); } } char newOrder = Shape.getOrder(shape, stride, 1); return create(data, Arrays.copyOf(shape, shape.length), stride, offset, newOrder); }
int[] shape = LongUtils.toInts(resolution.getShapes());
public SpecifiedIndex(int... indexes) { this.indexes = LongUtils.toLongs(indexes); }
/** * Calculate the shape for the given set of indices and offsets. * <p/> * The shape is defined as (for each dimension) * the difference between the end index + 1 and * the begin index * <p/> * If specified, this will check for whether any of the indices are >= to end - 1 * and if so, prune it down * * @param shape the original shape * @param indices the indices to calculate the shape for * @return the shape for the given indices */ public static int[] shape(int[] shape, INDArrayIndex... indices) { return LongUtils.toInts(shape(LongUtils.toLongs(shape), indices)); }
@Override public INDArray subArray(ShapeOffsetResolution resolution) { long[] offsets = resolution.getOffsets(); int[] shape = LongUtils.toInts(resolution.getShapes()); int[] stride = LongUtils.toInts(resolution.getStrides()); int[] flags = resolution.getFixed(); flags = updateFlags(flags, shape); long offset = (int) (offset() + resolution.getOffset()); int newRank = shape.length; long[] sparseOffsets = createSparseOffsets(offset); int[] newAxis = createHiddenDimensions(resolution.getPrependAxis()); if (offset() + resolution.getOffset() >= Integer.MAX_VALUE) throw new IllegalArgumentException("Offset of array can not be >= Integer.MAX_VALUE"); if (offsets.length != newRank) throw new IllegalArgumentException("Invalid offset " + Arrays.toString(offsets)); if (stride.length != newRank) throw new IllegalArgumentException("Invalid stride " + Arrays.toString(stride)); if (shape.length == rank() && Shape.contentEquals(shape, shapeOf())) { if (ArrayUtil.isZero(offsets)) { return this; } else { throw new IllegalArgumentException("Invalid subArray offsets"); } } DataBuffer newSparseInformation = Nd4j.getSparseInfoProvider().createSparseInformation(flags, sparseOffsets, newAxis, underlyingRank()); return create(values, indices, newSparseInformation, Arrays.copyOf(shape, shape.length)); }
int[] shape = LongUtils.toInts(resolution.getShapes()); int numSpecifiedIndex = 0;
LongPointer pointer = new LongPointer(LongUtils.toLongs(data)); Pointer srcPtr = new CudaPointer(pointer.address() + (dstOffset * elementSize));
int[] shape = LongUtils.toInts(resolution.getShapes()); int numSpecifiedIndex = 0; for (int i = 0; i < indexes.length; i++)
LongPointer pointer = new LongPointer(LongUtils.toLongs(data)); Pointer srcPtr = new CudaPointer(pointer.address() + (dstOffset * elementSize));
int[] shape = LongUtils.toInts(resolution.getShapes()); int numSpecifiedIndex = 0;
int[] shape = LongUtils.toInts(resolution.getShapes()); int numSpecifiedIndex = 0; for (int i = 0; i < indexes.length; i++)