/** * Returns the size of this array * along a particular dimension * * @param dimension the dimension to return from * @return the shape of the specified dimension */ @Override public long size(int dimension) { if (isScalar()) { if (dimension == 0 || dimension == 1 || dimension < 0) return (int) lengthLong(); else throw new IllegalArgumentException("Illegal dimension for scalar " + dimension); } if (dimension < 0) { return shapeOf().getInt(dimension + Shape.rank(javaShapeInformation)); } if (dimension >= rank()) throw new IllegalArgumentException("Invalid size: cannot get size of dimension " + dimension + " for rank " + rank() + " NDArray (array shape: " + Arrays.toString(this.shape()) + ")"); val _shapeInfo = shapeInfoDataBuffer(); val _shape = shapeOf(); return shapeOf().getInt(dimension); }
if (prod != this.lengthLong()){ throw new ND4JIllegalStateException("New shape length doesn't match original length: [" + prod + "] vs [" + this.lengthLong() + "]. Original shape: "+Arrays.toString(this.shape())+" New Shape: "+Arrays.toString(newShape));
if (this.lengthLong() != n.lengthLong()) return false;
DataBuffer buffer = Nd4j.createBuffer(this.lengthLong(), false); Nd4j.getMemoryManager().memcpy(buffer, this.data());
if (!isView()) { Nd4j.getExecutioner().commit(); DataBuffer buffer = Nd4j.createBuffer(this.lengthLong(), false); DataBuffer buffer = Nd4j.createBuffer(this.lengthLong(), false);
if (!this.isView()) { Nd4j.getExecutioner().commit(); DataBuffer buffer = Nd4j.createBuffer(this.lengthLong(), false); Nd4j.getMemoryManager().memcpy(buffer, this.data());
if (!this.isView()) { Nd4j.getExecutioner().commit(); DataBuffer buffer = Nd4j.createBuffer(this.lengthLong(), false); Nd4j.getMemoryManager().memcpy(buffer, this.data());
/** * Returns the size of this array * along a particular dimension * * @param dimension the dimension to return from * @return the shape of the specified dimension */ @Override public int size(int dimension) { if (isScalar()) { if (dimension == 0 || dimension == 1 || dimension < 0) return (int) lengthLong(); else throw new IllegalArgumentException("Illegal dimension for scalar " + dimension); } if (dimension < 0) { return shapeOf().getInt(dimension + Shape.rank(javaShapeInformation)); } if (dimension >= rank()) throw new IllegalArgumentException("Invalid size: cannot get size of dimension " + dimension + " for rank " + rank() + " NDArray (array shape: " + Arrays.toString(this.shape()) + ")"); return shapeOf().getInt(dimension); }
if (this.lengthLong() != n.lengthLong()) return false;
/** * This method pulls this INDArray into current Workspace. * * PLEASE NOTE: If there's no current Workspace - INDArray returned as is * * @return */ @Override public INDArray migrate() { MemoryWorkspace current = Nd4j.getMemoryManager().getCurrentWorkspace(); if (current == null) return this; INDArray copy = null; if (!this.isView()) { DataBuffer buffer = Nd4j.createBuffer(this.lengthLong(), false); Nd4j.getMemoryManager().memcpy(buffer, this.data()); copy = Nd4j.createArrayFromShapeBuffer(buffer, this.shapeInfoDataBuffer()); } else { copy = this.dup(this.ordering()); } return copy; }
DataBuffer buffer = Nd4j.createBuffer(this.lengthLong(), false); DataBuffer buffer = Nd4j.createBuffer(this.lengthLong(), false);
INDArray copy = null; if (!this.isView()) { DataBuffer buffer = Nd4j.createBuffer(this.lengthLong(), false); Nd4j.getMemoryManager().memcpy(buffer, this.data());
DataBuffer buffer = Nd4j.createBuffer(this.lengthLong(), false); Nd4j.getMemoryManager().memcpy(buffer, this.data());