Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add correlation cost layer #207

Merged
merged 21 commits into from
Jul 30, 2019
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("//build_deps/tf_dependency:tf_configure.bzl", "tf_configure")
load("//build_deps/gpu:cuda_configure.bzl", "cuda_configure")


http_archive(
name = "cub_archive",
build_file = "//build_deps/gpu:cub.BUILD",
sha256 = "6bfa06ab52a650ae7ee6963143a0bbc667d6504822cbd9670369b598f18c58c3",
strip_prefix = "cub-1.8.0",
urls = [
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/NVlabs/cub/archive/1.8.0.zip",
"https://github.com/NVlabs/cub/archive/1.8.0.zip",
],
)

tf_configure(
name = "local_config_tf",
)
Expand Down
25 changes: 25 additions & 0 deletions build_deps/gpu/cub.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Description: CUB library which is a set of primitives for GPU programming.

load("@local_config_cuda//cuda:build_defs.bzl", "cuda_default_copts", "if_cuda")

package(
default_visibility = ["//visibility:public"],
)

licenses(["notice"]) # BSD

filegroup(
name = "cub_header_files",
srcs = glob([
"cub/**",
]),
)

cc_library(
name = "cub",
hdrs = if_cuda([":cub_header_files"]),
include_prefix = "gpu",
deps = [
"@local_config_cuda//cuda:cuda_headers",
],
)
1 change: 1 addition & 0 deletions tensorflow_addons/custom_ops/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
| Image | Ops for image manipulation |
| Seq2seq | Ops for seq2seq encoder-decoder framework |
| Text | Ops for text processing |
| Layers | Ops for model layers |
49 changes: 49 additions & 0 deletions tensorflow_addons/custom_ops/layers/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
licenses(["notice"]) # Apache 2.0

package(default_visibility = ["//visibility:public"])

load("@local_config_tf//:build_defs.bzl", "D_GLIBCXX_USE_CXX11_ABI")
load("@local_config_cuda//cuda:build_defs.bzl", "if_cuda_is_configured", "if_cuda")

cc_binary(
name = "_correlation_cost_ops.so",
srcs = [
"cc/kernels/correlation_cost_op.cc",
"cc/kernels/correlation_cost_op.h",
"cc/kernels/correlation_cost_op_gpu.cu.cc",
"cc/ops/correlation_cost_op.cc",
],
copts = [
"-pthread",
"-std=c++11",
D_GLIBCXX_USE_CXX11_ABI,
],
linkshared = 1,
deps = [
"@local_config_tf//:libtensorflow_framework",
"@local_config_tf//:tf_header_lib",
] + if_cuda_is_configured([":correlation_cost_ops_gpu"]),
)

cc_library(
name = "correlation_cost_ops_gpu",
srcs = [
"cc/kernels/correlation_cost_op.h",
"cc/kernels/correlation_cost_op_gpu.cu.cc",
],
copts = if_cuda_is_configured([
"-DGOOGLE_CUDA=1",
"-x cuda",
"-nvcc_options=relaxed-constexpr",
"-nvcc_options=ftz=true",
]),
deps = [
"@local_config_tf//:libtensorflow_framework",
"@local_config_tf//:tf_header_lib",
] + if_cuda_is_configured([
"@local_config_cuda//cuda:cuda_libs",
"@local_config_cuda//cuda:cuda_headers",
"@cub_archive//:cub",
]),
alwayslink = 1,
)
Loading