Package org.nd4j.linalg.compression
Class BasicNDArrayCompressor
- java.lang.Object
-
- org.nd4j.linalg.compression.BasicNDArrayCompressor
-
public class BasicNDArrayCompressor extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,NDArrayCompressor>
codecs
protected String
defaultCompression
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
autoDecompress(INDArray array)
void
autoDecompress(INDArray... arrays)
Decompress several ndarraysINDArray
compress(double[] array)
This method returns compressed INDArray instance which contains JVM array passed inINDArray
compress(float[] array)
This method returns compressed INDArray instance which contains JVM array passed inDataBuffer
compress(DataBuffer buffer)
Compress the given data buffer given the default compression algorithmDataBuffer
compress(DataBuffer buffer, String algorithm)
Compress the data buffer given a specified algorithmINDArray
compress(INDArray array)
INDArray
compress(INDArray array, String algorithm)
Returns a compressed version of the given ndarrayvoid
compressi(INDArray array)
In place compression of the passed in ndarray with the default compression algorithmvoid
compressi(INDArray array, String algorithm)
In place Compress the given ndarray with the given algorithmDataBuffer
decompress(DataBuffer buffer, DataType targetType)
Decompress the given databufferINDArray
decompress(INDArray array)
void
decompressi(INDArray array)
in place decompression of the given ndarray.Set<String>
getAvailableCompressors()
Get the set of available codecs for compressionNDArrayCompressor
getCompressor(@NonNull String name)
String
getDefaultCompression()
Get the default compression algorithm as a string.static BasicNDArrayCompressor
getInstance()
Get the ndarray compressor singletonprotected void
loadCompressors()
void
printAvailableCompressors()
Prints available compressors to standard outBasicNDArrayCompressor
setDefaultCompression(@NonNull String algorithm)
Set the default compression algorithm
-
-
-
Field Detail
-
codecs
protected Map<String,NDArrayCompressor> codecs
-
defaultCompression
protected String defaultCompression
-
-
Method Detail
-
loadCompressors
protected void loadCompressors()
-
getAvailableCompressors
public Set<String> getAvailableCompressors()
Get the set of available codecs for compression- Returns:
-
printAvailableCompressors
public void printAvailableCompressors()
Prints available compressors to standard out
-
getInstance
public static BasicNDArrayCompressor getInstance()
Get the ndarray compressor singleton- Returns:
-
setDefaultCompression
public BasicNDArrayCompressor setDefaultCompression(@NonNull @NonNull String algorithm)
Set the default compression algorithm- Parameters:
algorithm
- the algorithm to set- Returns:
-
getDefaultCompression
public String getDefaultCompression()
Get the default compression algorithm as a string. This is an all caps algorithm with a representation in the CompressionAlgorithm enum- Returns:
-
compress
public DataBuffer compress(DataBuffer buffer)
Compress the given data buffer given the default compression algorithm- Parameters:
buffer
- the data buffer to compress- Returns:
- the compressed version of the data buffer
-
compress
public DataBuffer compress(DataBuffer buffer, String algorithm)
Compress the data buffer given a specified algorithm- Parameters:
buffer
- the buffer to compressalgorithm
- the algorithm to compress use- Returns:
- the compressed data buffer
-
compressi
public void compressi(INDArray array)
In place compression of the passed in ndarray with the default compression algorithm- Parameters:
array
-
-
compress
public INDArray compress(INDArray array, String algorithm)
Returns a compressed version of the given ndarray- Parameters:
array
- the array to compressalgorithm
- the algorithm to compress with- Returns:
- a compressed copy of this ndarray
-
compressi
public void compressi(INDArray array, String algorithm)
In place Compress the given ndarray with the given algorithm- Parameters:
array
- the array to compressalgorithm
-
-
decompress
public DataBuffer decompress(DataBuffer buffer, DataType targetType)
Decompress the given databuffer- Parameters:
buffer
- the databuffer to compress- Returns:
- the decompressed databuffer
-
getCompressor
public NDArrayCompressor getCompressor(@NonNull @NonNull String name)
-
decompressi
public void decompressi(INDArray array)
in place decompression of the given ndarray. If the ndarray isn't compressed this will do nothing- Parameters:
array
- the array to decompressed if it is comprssed
-
autoDecompress
public void autoDecompress(INDArray... arrays)
Decompress several ndarrays- Parameters:
arrays
-
-
autoDecompress
public void autoDecompress(INDArray array)
- Parameters:
array
-
-
compress
public INDArray compress(float[] array)
This method returns compressed INDArray instance which contains JVM array passed in- Parameters:
array
-- Returns:
-
compress
public INDArray compress(double[] array)
This method returns compressed INDArray instance which contains JVM array passed in- Parameters:
array
-- Returns:
-
-