diff options
author | 2017-03-30 11:52:01 -0800 | |
---|---|---|
committer | 2017-03-30 13:05:46 -0700 | |
commit | 63b2f999d3f22cfe915b89103faa1b0a1b1b7617 (patch) | |
tree | 593eed2cb1ab751cf9574e0a8ba804d20f661d93 /tensorflow | |
parent | 052e207e4f1076ac6b7464c01a67ecf4f986766d (diff) |
Enable snappy.
Fix implicit type cast bug in snappy_inputbuffer. Bitwise OR of unsigned int and signed char can cause unexpected issues so we explicitly cast it to unsigned char.
Change: 151737878
Diffstat (limited to 'tensorflow')
-rw-r--r-- | tensorflow/core/BUILD | 3 | ||||
-rw-r--r-- | tensorflow/core/lib/io/snappy/snappy_inputbuffer.cc | 5 | ||||
-rw-r--r-- | tensorflow/core/platform/posix/port.cc | 3 | ||||
-rw-r--r-- | tensorflow/core/platform/windows/port.cc | 2 | ||||
-rw-r--r-- | tensorflow/tools/lib_package/BUILD | 2 | ||||
-rw-r--r-- | tensorflow/tools/pip_package/BUILD | 1 | ||||
-rw-r--r-- | tensorflow/workspace.bzl | 12 |
7 files changed, 24 insertions, 4 deletions
diff --git a/tensorflow/core/BUILD b/tensorflow/core/BUILD index ad660e0100..8d3ea3999b 100644 --- a/tensorflow/core/BUILD +++ b/tensorflow/core/BUILD @@ -1251,7 +1251,7 @@ cc_library( "platform/tracing.h", ], copts = tf_copts(), - defines = tf_additional_lib_defines(), + defines = tf_additional_lib_defines() + ["SNAPPY"], linkopts = select({ "//tensorflow:freebsd": [], "//conditions:default": ["-ldl"], @@ -1262,6 +1262,7 @@ cc_library( ":protos_all_cc", "//third_party/eigen3", "//tensorflow/core/platform/default/build_config:platformlib", + "@snappy", "@zlib_archive//:zlib", ], ) diff --git a/tensorflow/core/lib/io/snappy/snappy_inputbuffer.cc b/tensorflow/core/lib/io/snappy/snappy_inputbuffer.cc index ac1ba72b16..39202e9237 100644 --- a/tensorflow/core/lib/io/snappy/snappy_inputbuffer.cc +++ b/tensorflow/core/lib/io/snappy/snappy_inputbuffer.cc @@ -129,7 +129,10 @@ Status SnappyInputBuffer::ReadCompressedBlockLength(uint32* length) { size_t readable = std::min(bytes_to_read, avail_in_); for (int i = 0; i < readable; i++) { - *length = (*length << 8) | next_in_[0]; + // The "unsigned char" type cast is intentional to avoid implicit type + // casting of the signed char to unsigned int during bitwise OR which + // causes weird overflow errors. + *length = (*length << 8) | static_cast<unsigned char>(next_in_[0]); bytes_to_read--; next_in_++; avail_in_--; diff --git a/tensorflow/core/platform/posix/port.cc b/tensorflow/core/platform/posix/port.cc index 91d612f233..e2b9c586c8 100644 --- a/tensorflow/core/platform/posix/port.cc +++ b/tensorflow/core/platform/posix/port.cc @@ -20,6 +20,7 @@ limitations under the License. #include "tensorflow/core/platform/cpu_info.h" #include "tensorflow/core/platform/logging.h" #include "tensorflow/core/platform/mem.h" +#include "tensorflow/core/platform/snappy.h" #include "tensorflow/core/platform/types.h" #if defined(__linux__) && !defined(__ANDROID__) #include <sched.h> @@ -29,7 +30,7 @@ limitations under the License. #include <string.h> #include <unistd.h> #ifdef SNAPPY -#include <snappy.h> +#include "snappy.h" #endif #if defined(__APPLE__) && defined(__MACH__) #include <thread> diff --git a/tensorflow/core/platform/windows/port.cc b/tensorflow/core/platform/windows/port.cc index b2167081a6..4a7eebbcdf 100644 --- a/tensorflow/core/platform/windows/port.cc +++ b/tensorflow/core/platform/windows/port.cc @@ -17,7 +17,7 @@ limitations under the License. #include <stdlib.h> #include <string.h> #ifdef SNAPPY -#include <snappy.h> +#include "snappy.h" #endif #include <Windows.h> diff --git a/tensorflow/tools/lib_package/BUILD b/tensorflow/tools/lib_package/BUILD index 77dfc5da3f..3e049724f6 100644 --- a/tensorflow/tools/lib_package/BUILD +++ b/tensorflow/tools/lib_package/BUILD @@ -93,6 +93,7 @@ genrule( "@local_config_sycl//sycl:LICENSE.text", "@png_archive//:LICENSE", "@protobuf//:LICENSE", + "@snappy//:COPYING", "@zlib_archive//:zlib.h", ], outs = ["include/tensorflow/c/LICENSE"], @@ -119,6 +120,7 @@ genrule( "@local_config_sycl//sycl:LICENSE.text", "@png_archive//:LICENSE", "@protobuf//:LICENSE", + "@snappy//:COPYING", "@zlib_archive//:zlib.h", ], outs = ["include/tensorflow/jni/LICENSE"], diff --git a/tensorflow/tools/pip_package/BUILD b/tensorflow/tools/pip_package/BUILD index c3a839030d..2a96e80ccb 100644 --- a/tensorflow/tools/pip_package/BUILD +++ b/tensorflow/tools/pip_package/BUILD @@ -113,6 +113,7 @@ filegroup( "@org_mozilla_bleach//:LICENSE", "@org_pocoo_werkzeug//:LICENSE", "@org_pythonhosted_markdown//:LICENSE.md", + "@snappy//:COPYING", "@zlib_archive//:zlib.h", ] + if_not_windows([ "@nccl_archive//:LICENSE.txt", diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl index f8dfd21f84..b4578d6860 100644 --- a/tensorflow/workspace.bzl +++ b/tensorflow/workspace.bzl @@ -487,6 +487,18 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""): ) temp_workaround_http_archive( + name = "snappy", + urls = [ + "http://bazel-mirror.storage.googleapis.com/github.com/google/snappy/archive/1.1.4.zip", + "https://github.com/google/snappy/archive/1.1.4.zip", + ], + sha256 = "6c74d2b663170d68184da353cdd71b5b7d57bc8888ef1e99b4929b5d680dba54", + strip_prefix = "snappy-1.1.4", + build_file = str(Label("//third_party:snappy.BUILD")), + repository = tf_repo_name, + ) + + temp_workaround_http_archive( name = "nccl_archive", urls = [ "http://bazel-mirror.storage.googleapis.com/github.com/nvidia/nccl/archive/024d1e267845f2ed06f3e2e42476d50f04a00ee6.tar.gz", |