Introducing common tf io compression options constants for RecordReader/RecordWriter
Change: 142479204
This commit is contained in:
parent
a02510a260
commit
80d9c58d62
@ -219,6 +219,7 @@ cc_library(
|
|||||||
"lib/hash/crc32c.h",
|
"lib/hash/crc32c.h",
|
||||||
"lib/histogram/histogram.h",
|
"lib/histogram/histogram.h",
|
||||||
"lib/io/buffered_inputstream.h",
|
"lib/io/buffered_inputstream.h",
|
||||||
|
"lib/io/compression.h",
|
||||||
"lib/io/inputstream_interface.h",
|
"lib/io/inputstream_interface.h",
|
||||||
"lib/io/path.h",
|
"lib/io/path.h",
|
||||||
"lib/io/proto_encode_helper.h",
|
"lib/io/proto_encode_helper.h",
|
||||||
|
27
tensorflow/core/lib/io/compression.cc
Normal file
27
tensorflow/core/lib/io/compression.cc
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
==============================================================================*/
|
||||||
|
|
||||||
|
#include "tensorflow/core/lib/io/compression.h"
|
||||||
|
|
||||||
|
namespace tensorflow {
|
||||||
|
namespace io {
|
||||||
|
namespace compression {
|
||||||
|
|
||||||
|
const char kNone[] = "";
|
||||||
|
const char kGzip[] = "GZIP";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
30
tensorflow/core/lib/io/compression.h
Normal file
30
tensorflow/core/lib/io/compression.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
==============================================================================*/
|
||||||
|
|
||||||
|
#ifndef THIRD_PARTY_TENSORFLOW_CORE_LIB_IO_COMPRESSION_H_
|
||||||
|
#define THIRD_PARTY_TENSORFLOW_CORE_LIB_IO_COMPRESSION_H_
|
||||||
|
|
||||||
|
namespace tensorflow {
|
||||||
|
namespace io {
|
||||||
|
namespace compression {
|
||||||
|
|
||||||
|
extern const char kNone[];
|
||||||
|
extern const char kGzip[];
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // THIRD_PARTY_TENSORFLOW_CORE_LIB_IO_COMPRESSION_H_
|
@ -20,6 +20,7 @@ limitations under the License.
|
|||||||
#include "tensorflow/core/lib/core/coding.h"
|
#include "tensorflow/core/lib/core/coding.h"
|
||||||
#include "tensorflow/core/lib/core/errors.h"
|
#include "tensorflow/core/lib/core/errors.h"
|
||||||
#include "tensorflow/core/lib/hash/crc32c.h"
|
#include "tensorflow/core/lib/hash/crc32c.h"
|
||||||
|
#include "tensorflow/core/lib/io/compression.h"
|
||||||
#include "tensorflow/core/lib/io/random_inputstream.h"
|
#include "tensorflow/core/lib/io/random_inputstream.h"
|
||||||
#include "tensorflow/core/platform/env.h"
|
#include "tensorflow/core/platform/env.h"
|
||||||
|
|
||||||
@ -37,7 +38,7 @@ RecordReaderOptions RecordReaderOptions::CreateRecordReaderOptions(
|
|||||||
#else
|
#else
|
||||||
options.zlib_options = io::ZlibCompressionOptions::DEFAULT();
|
options.zlib_options = io::ZlibCompressionOptions::DEFAULT();
|
||||||
#endif // IS_SLIM_BUILD
|
#endif // IS_SLIM_BUILD
|
||||||
} else if (compression_type == "GZIP") {
|
} else if (compression_type == compression::kGzip) {
|
||||||
options.compression_type = io::RecordReaderOptions::ZLIB_COMPRESSION;
|
options.compression_type = io::RecordReaderOptions::ZLIB_COMPRESSION;
|
||||||
#if defined(IS_SLIM_BUILD)
|
#if defined(IS_SLIM_BUILD)
|
||||||
LOG(ERROR) << "Compression is not supported but compression_type is set."
|
LOG(ERROR) << "Compression is not supported but compression_type is set."
|
||||||
@ -45,7 +46,7 @@ RecordReaderOptions RecordReaderOptions::CreateRecordReaderOptions(
|
|||||||
#else
|
#else
|
||||||
options.zlib_options = io::ZlibCompressionOptions::GZIP();
|
options.zlib_options = io::ZlibCompressionOptions::GZIP();
|
||||||
#endif // IS_SLIM_BUILD
|
#endif // IS_SLIM_BUILD
|
||||||
} else if (compression_type != "") {
|
} else if (compression_type != compression::kNone) {
|
||||||
LOG(ERROR) << "Unsupported compression_type:" << compression_type
|
LOG(ERROR) << "Unsupported compression_type:" << compression_type
|
||||||
<< ". No comprression will be used.";
|
<< ". No comprression will be used.";
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
|
|
||||||
#include "tensorflow/core/lib/core/coding.h"
|
#include "tensorflow/core/lib/core/coding.h"
|
||||||
#include "tensorflow/core/lib/hash/crc32c.h"
|
#include "tensorflow/core/lib/hash/crc32c.h"
|
||||||
|
#include "tensorflow/core/lib/io/compression.h"
|
||||||
#include "tensorflow/core/platform/env.h"
|
#include "tensorflow/core/platform/env.h"
|
||||||
|
|
||||||
namespace tensorflow {
|
namespace tensorflow {
|
||||||
@ -38,7 +39,7 @@ RecordWriterOptions RecordWriterOptions::CreateRecordWriterOptions(
|
|||||||
#else
|
#else
|
||||||
options.zlib_options = io::ZlibCompressionOptions::DEFAULT();
|
options.zlib_options = io::ZlibCompressionOptions::DEFAULT();
|
||||||
#endif // IS_SLIM_BUILD
|
#endif // IS_SLIM_BUILD
|
||||||
} else if (compression_type == "GZIP") {
|
} else if (compression_type == compression::kGzip) {
|
||||||
options.compression_type = io::RecordWriterOptions::ZLIB_COMPRESSION;
|
options.compression_type = io::RecordWriterOptions::ZLIB_COMPRESSION;
|
||||||
#if defined(IS_SLIM_BUILD)
|
#if defined(IS_SLIM_BUILD)
|
||||||
LOG(ERROR) << "Compression is not supported but compression_type is set."
|
LOG(ERROR) << "Compression is not supported but compression_type is set."
|
||||||
@ -46,7 +47,7 @@ RecordWriterOptions RecordWriterOptions::CreateRecordWriterOptions(
|
|||||||
#else
|
#else
|
||||||
options.zlib_options = io::ZlibCompressionOptions::GZIP();
|
options.zlib_options = io::ZlibCompressionOptions::GZIP();
|
||||||
#endif // IS_SLIM_BUILD
|
#endif // IS_SLIM_BUILD
|
||||||
} else if (compression_type != "") {
|
} else if (compression_type != compression::kNone) {
|
||||||
LOG(ERROR) << "Unsupported compression_type:" << compression_type
|
LOG(ERROR) << "Unsupported compression_type:" << compression_type
|
||||||
<< ". No comprression will be used.";
|
<< ". No comprression will be used.";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user