diff --git a/farmhash.BUILD b/farmhash.BUILD new file mode 100644 index 00000000000..fe19e144303 --- /dev/null +++ b/farmhash.BUILD @@ -0,0 +1,21 @@ +package(default_visibility = ["//visibility:public"]) + +prefix_dir = "farmhash-34c13ddfab0e35422f4c3979f360635a8c050260" + +genrule( + name = "configure", + srcs = glob( + ["**/*"], + exclude = [prefix_dir + "/config.h"], + ), + outs = [prefix_dir + "/config.h"], + cmd = "pushd external/farmhash_archive/%s; workdir=$$(mktemp -d -t tmp.XXXXXXXXXX); cp -a * $$workdir; pushd $$workdir; ./configure; popd; popd; cp $$workdir/config.h $(@D); rm -rf $$workdir;" % prefix_dir, +) + +cc_library( + name = "farmhash", + srcs = [prefix_dir + "/src/farmhash.cc"], + hdrs = [prefix_dir + "/src/farmhash.h"] + [":configure"], + includes = [prefix_dir], + visibility = ["//visibility:public"] +) diff --git a/tensorflow/core/BUILD b/tensorflow/core/BUILD index bc97c964168..e70ccd8886b 100644 --- a/tensorflow/core/BUILD +++ b/tensorflow/core/BUILD @@ -199,6 +199,7 @@ cc_library( "lib/strings/stringprintf.h", "platform/env.h", "platform/file_system.h", + "platform/fingerprint.h", "platform/host_info.h", # TODO(josh11b): make internal "platform/init_main.h", "platform/logging.h", diff --git a/tensorflow/core/platform/default/build_config/BUILD b/tensorflow/core/platform/default/build_config/BUILD index d6ae6507dbe..d2ddc1f2cc1 100644 --- a/tensorflow/core/platform/default/build_config/BUILD +++ b/tensorflow/core/platform/default/build_config/BUILD @@ -33,20 +33,21 @@ tf_cuda_library( "//tensorflow/stream_executor", ] + select({ "//third_party/gpus/cuda:darwin": ["IOKit"], - "//conditions:default": [] + "//conditions:default": [], }), ) # OSX framework for device driver access cc_library( - name = "IOKit", - linkopts = ["-framework IOKit"], + name = "IOKit", + linkopts = ["-framework IOKit"], ) cc_library( name = "platformlib", copts = tf_copts(), deps = [ + "@farmhash_archive//:farmhash", "@jpeg_archive//:jpeg", "@png_archive//:png", "@re2//:re2", @@ -83,12 +84,12 @@ cc_library( linkopts = select({ "//third_party/gpus/cuda:darwin": [ "-Wl,-rpath,third_party/gpus/cuda/lib", - "-Wl,-rpath,third_party/gpus/cuda/extras/CUPTI/lib" + "-Wl,-rpath,third_party/gpus/cuda/extras/CUPTI/lib", ], "//conditions:default": [ "-Wl,-rpath,third_party/gpus/cuda/lib64", - "-Wl,-rpath,third_party/gpus/cuda/extras/CUPTI/lib64" - ] + "-Wl,-rpath,third_party/gpus/cuda/extras/CUPTI/lib64", + ], }), deps = [ "//third_party/gpus/cuda:cudart", diff --git a/tensorflow/core/platform/default/fingerprint.h b/tensorflow/core/platform/default/fingerprint.h new file mode 100644 index 00000000000..e752c265cee --- /dev/null +++ b/tensorflow/core/platform/default/fingerprint.h @@ -0,0 +1,29 @@ +/* Copyright 2016 Google Inc. 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 TENSORFLOW_CORE_PLATFORM_DEFAULT_FINGERPRINT_H_ +#define TENSORFLOW_CORE_PLATFORM_DEFAULT_FINGERPRINT_H_ + +#include "farmhash-34c13ddfab0e35422f4c3979f360635a8c050260/src/farmhash.h" + +namespace tensorflow { + +inline uint64 Fingerprint64(const string& s) { + return ::util::Fingerprint64(s); +} + +} // namespace tensorflow + +#endif // TENSORFLOW_CORE_PLATFORM_DEFAULT_FINGERPRINT_H_ diff --git a/tensorflow/core/platform/fingerprint.h b/tensorflow/core/platform/fingerprint.h new file mode 100644 index 00000000000..e66f137374a --- /dev/null +++ b/tensorflow/core/platform/fingerprint.h @@ -0,0 +1,35 @@ +/* Copyright 2016 Google Inc. 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 TENSORFLOW_CORE_PLATFORM_FINGERPRINT_H_ +#define TENSORFLOW_CORE_PLATFORM_FINGERPRINT_H_ + +#include "tensorflow/core/platform/types.h" + +namespace tensorflow { + +// This is a portable fingerprint interface for strings that will never change. +// However, it is not suitable for cryptography. +uint64 Fingerprint64(const string& s); + +} // namespace tensorflow + +#if defined(PLATFORM_GOOGLE) +#include "tensorflow/core/platform/google/fingerprint.h" +#else +#include "tensorflow/core/platform/default/fingerprint.h" +#endif + +#endif // TENSORFLOW_CORE_PLATFORM_FINGERPRINT_H_ diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl index 0ebcba2ac44..726ad629955 100644 --- a/tensorflow/workspace.bzl +++ b/tensorflow/workspace.bzl @@ -40,6 +40,18 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""): commit = "96d3acab46fbb03855ca22c2ee2bb9831ac8c83c", ) + native.new_http_archive( + name = "farmhash_archive", + url = "https://github.com/google/farmhash/archive/34c13ddfab0e35422f4c3979f360635a8c050260.zip", + sha256 = "e3d37a59101f38fd58fb799ed404d630f0eee18bfc2a2433910977cc8fea9c28", + build_file = path_prefix + "farmhash.BUILD", + ) + + native.bind( + name = "farmhash", + actual = "@farmhash//:farmhash", + ) + native.new_http_archive( name = "jpeg_archive", url = "http://www.ijg.org/files/jpegsrc.v9a.tar.gz",