def testDecompressShapeInference(self): with ops.Graph().as_default(): for compression_type in ["ZLIB", "GZIP", ""]: with self.cached_session(): in_bytes = array_ops.placeholder(dtypes.string, shape=[2]) decompressed = parsing_ops.decode_compressed( in_bytes, compression_type=compression_type) self.assertEqual([2], decompressed.get_shape().as_list())
def testDecompressWithRaw(self): for compression_type in ["ZLIB", "GZIP", ""]: with self.test_session(): in_bytes = array_ops.placeholder(dtypes.string, shape=[None]) decompressed = parsing_ops.decode_compressed( in_bytes, compression_type=compression_type) decode = parsing_ops.decode_raw(decompressed, out_type=dtypes.int16) result = decode.eval( feed_dict={in_bytes: [self._compress(b"AaBC", compression_type)]}) self.assertAllEqual( [[ord("A") + ord("a") * 256, ord("B") + ord("C") * 256]], result)
def testDecompress(self): for compression_type in ["ZLIB", "GZIP", ""]: with self.test_session(): in_bytes = array_ops.placeholder(dtypes.string, shape=[2]) decompressed = parsing_ops.decode_compressed( in_bytes, compression_type=compression_type) self.assertEqual([2], decompressed.get_shape().as_list()) result = decompressed.eval( feed_dict={in_bytes: [self._compress(b"AaAA", compression_type), self._compress(b"bBbb", compression_type)]}) self.assertAllEqual([b"AaAA", b"bBbb"], result)
def testDecompressWithRaw(self): for compression_type in ["ZLIB", "GZIP", ""]: with self.cached_session(): in_bytes = array_ops.placeholder(dtypes.string, shape=[None]) decompressed = parsing_ops.decode_compressed( in_bytes, compression_type=compression_type) decode = parsing_ops.decode_raw(decompressed, out_type=dtypes.int16) result = decode.eval( feed_dict={in_bytes: [self._compress(b"AaBC", compression_type)]}) self.assertAllEqual( [[ord("A") + ord("a") * 256, ord("B") + ord("C") * 256]], result)
def testDecompress(self): for compression_type in ["ZLIB", "GZIP", ""]: with self.cached_session(): in_bytes = array_ops.placeholder(dtypes.string, shape=[2]) decompressed = parsing_ops.decode_compressed( in_bytes, compression_type=compression_type) self.assertEqual([2], decompressed.get_shape().as_list()) result = decompressed.eval( feed_dict={in_bytes: [self._compress(b"AaAA", compression_type), self._compress(b"bBbb", compression_type)]}) self.assertAllEqual([b"AaAA", b"bBbb"], result)
def decode(in_bytes, compression_type=compression_type): decompressed = parsing_ops.decode_compressed( in_bytes, compression_type) return parsing_ops.decode_raw(decompressed, out_type=dtypes.int16)
def decode(in_bytes, compression_type=compression_type): return parsing_ops.decode_compressed( in_bytes, compression_type=compression_type)