/** * Decompress several ndarrays * @param arrays */ public void autoDecompress(INDArray... arrays) { for (INDArray array : arrays) { autoDecompress(array); } }
/** * * @param array */ public void autoDecompress(INDArray array) { if (array.isCompressed()) decompressi(array); }
/** * In place compression of the passed in ndarray * with the default compression algorithm * @param array */ public void compressi(INDArray array) { compressi(array, getDefaultCompression()); }
/** * Compress the given data buffer * given the default compression algorithm * @param buffer the data buffer to compress * @return the compressed version of the data buffer */ public DataBuffer compress(DataBuffer buffer) { return compress(buffer, getDefaultCompression()); }
if (isCompress()) while (!message.getArr().isCompressed()) Nd4j.getCompressor().compressi(arr, "GZIP");
@Override public void initialize(@NonNull GradientsAccumulator accumulator) { this.accumulator = accumulator; compressor = Nd4j.getCompressor().getCompressor("THRESHOLD"); if (compressor == null) throw new ND4JIllegalStateException("Can't find Threshold compressor implementation!"); compressor.configure(threshold); }
return Nd4j.getCompressor().decompress(compressedBuffer);
public INDArray compress(INDArray array) { Nd4j.getExecutioner().commit(); return compress(array, getDefaultCompression()); }
/** * * @param img * @param kernel * @param stride * @param padding * @return */ public static INDArray im2col(INDArray img, int[] kernel, int[] stride, int[] padding) { Nd4j.getCompressor().autoDecompress(img); return im2col(img, kernel[0], kernel[1], stride[0], stride[1], padding[0], padding[1], 0, false); }
protected void checkForCompression(Op op) { // check for INT datatype arrays interceptIntDataType(op); if (op.x() != null && op.x().isCompressed()) Nd4j.getCompressor().decompressi(op.x()); if (op.y() != null && op.y().isCompressed()) Nd4j.getCompressor().decompressi(op.y()); if (op.z() != null && op.z().isCompressed()) Nd4j.getCompressor().decompressi(op.z()); }
/** * In place compression of the passed in ndarray * with the default compression algorithm * @param array */ public void compressi(INDArray array) { compressi(array, getDefaultCompression()); }
/** * Compress the given data buffer * given the default compression algorithm * @param buffer the data buffer to compress * @return the compressed version of the data buffer */ public DataBuffer compress(DataBuffer buffer) { return compress(buffer, getDefaultCompression()); }
/** * Replaces all elements in this ndarray that are matching give condition, with corresponding elements from given array * * @param arr * @param condition * @return */ @Override public INDArray replaceWhere(INDArray arr, Condition condition) { Nd4j.getCompressor().autoDecompress(this); BooleanIndexing.replaceWhere(this, arr, condition); return this; }
/** * Validate the data types * for the given operation * @param expectedType * @param op */ public static void validateDataType(DataBuffer.Type expectedType, Op op) { if (op.x() != null && op.x().data().dataType() == DataBuffer.Type.COMPRESSED) { Nd4j.getCompressor().decompressi(op.x()); } if (op.y() != null && op.y().data().dataType() == DataBuffer.Type.COMPRESSED) { Nd4j.getCompressor().decompressi(op.y()); } if (op.z() != null && op.z().data().dataType() == DataBuffer.Type.COMPRESSED) { Nd4j.getCompressor().decompressi(op.z()); } if (op.x() != null && op.x().data().dataType() != expectedType && op.x().data().dataType() != DataBuffer.Type.COMPRESSED) throw new ND4JIllegalStateException("op.X dataType is [" + op.x().data().dataType() + "] instead of expected [" + expectedType + "]"); if (op.z() != null && op.z().data().dataType() != expectedType && op.z().data().dataType() != DataBuffer.Type.COMPRESSED) throw new ND4JIllegalStateException("op.Z dataType is [" + op.z().data().dataType() + "] instead of expected [" + expectedType + "]"); if (op.y() != null && op.y().data().dataType() != expectedType) throw new ND4JIllegalStateException("op.Y dataType is [" + op.y().data().dataType() + "] instead of expected [" + expectedType + "]"); }
public INDArray compress(INDArray array) { Nd4j.getExecutioner().commit(); return compress(array, getDefaultCompression()); }
@Override public INDArray put(INDArrayIndex[] indices, Number element) { Nd4j.getCompressor().autoDecompress(this); INDArray get = get(indices); for (int i = 0; i < get.length(); i++) get.putScalar(i, element.doubleValue()); return this; }
/** * * @param array */ public void autoDecompress(INDArray array) { if (array.isCompressed()) decompressi(array); }
/** * Returns the (euclidean) distance. */ @Override public double distance2(INDArray other) { Nd4j.getCompressor().autoDecompress(this); return Nd4j.getExecutioner().execAndReturn(new EuclideanDistance(this, other)).getFinalResult().doubleValue(); }
protected void checkForCompression(Op op) { // check for INT datatype arrays interceptIntDataType(op); if (op.x() != null && op.x().isCompressed()) Nd4j.getCompressor().decompressi(op.x()); if (op.y() != null && op.y().isCompressed()) Nd4j.getCompressor().decompressi(op.y()); if (op.z() != null && op.z().isCompressed()) Nd4j.getCompressor().decompressi(op.z()); }
/** * Returns the (1-norm) distance. */ @Override public double distance1(INDArray other) { Nd4j.getCompressor().autoDecompress(this); return Nd4j.getExecutioner().execAndReturn(new ManhattanDistance(this, other)).getFinalResult().doubleValue(); }