Skip to content

Commit

Permalink
Add farmhash fingerprint64 into hash.h and include corresponding depe…
Browse files Browse the repository at this point in the history
…ndencies.

Change: 122273744
  • Loading branch information
ysuematsu authored and tensorflower-gardener committed May 13, 2016
1 parent f24b027 commit 50fd130
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 6 deletions.
21 changes: 21 additions & 0 deletions farmhash.BUILD
Original file line number Diff line number Diff line change
@@ -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"]
)
1 change: 1 addition & 0 deletions tensorflow/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 7 additions & 6 deletions tensorflow/core/platform/default/build_config/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
29 changes: 29 additions & 0 deletions tensorflow/core/platform/default/fingerprint.h
Original file line number Diff line number Diff line change
@@ -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_
35 changes: 35 additions & 0 deletions tensorflow/core/platform/fingerprint.h
Original file line number Diff line number Diff line change
@@ -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_
12 changes: 12 additions & 0 deletions tensorflow/workspace.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 50fd130

Please sign in to comment.