Revert factoring out of decoder library build definition

This commit is contained in:
Reuben Morais 2021-07-23 14:50:49 +02:00
parent 7846f4602e
commit cbbdcbf246

View File

@ -52,6 +52,31 @@ OPENFST_INCLUDES_PLATFORM = select({
"//conditions:default": ["ctcdecode/third_party/openfst-1.6.7/src/include"], "//conditions:default": ["ctcdecode/third_party/openfst-1.6.7/src/include"],
}) })
DECODER_SOURCES = [
"alphabet.cc",
"alphabet.h",
"ctcdecode/ctc_beam_search_decoder.cpp",
"ctcdecode/ctc_beam_search_decoder.h",
"ctcdecode/decoder_utils.cpp",
"ctcdecode/decoder_utils.h",
"ctcdecode/path_trie.cpp",
"ctcdecode/path_trie.h",
"ctcdecode/scorer.cpp",
"ctcdecode/scorer.h",
] + OPENFST_SOURCES_PLATFORM
DECODER_INCLUDES = [
".",
"ctcdecode/third_party/ThreadPool",
"ctcdecode/third_party/object_pool",
] + OPENFST_INCLUDES_PLATFORM
DECODER_LINKOPTS = [
"-lm",
"-ldl",
"-pthread",
]
LINUX_LINKOPTS = [ LINUX_LINKOPTS = [
"-ldl", "-ldl",
"-pthread", "-pthread",
@ -100,32 +125,10 @@ cc_library(
cc_library( cc_library(
name = "decoder", name = "decoder",
srcs = [ srcs = DECODER_SOURCES,
"ctcdecode/ctc_beam_search_decoder.cpp", includes = DECODER_INCLUDES,
"ctcdecode/decoder_utils.cpp",
"ctcdecode/decoder_utils.h",
"ctcdecode/scorer.cpp",
"ctcdecode/path_trie.cpp",
"ctcdecode/path_trie.h",
"alphabet.cc",
] + OPENFST_SOURCES_PLATFORM,
hdrs = [
"ctcdecode/ctc_beam_search_decoder.h",
"ctcdecode/scorer.h",
"ctcdecode/decoder_utils.h",
"alphabet.h",
],
includes = [
".",
"ctcdecode/third_party/ThreadPool",
"ctcdecode/third_party/object_pool",
] + OPENFST_INCLUDES_PLATFORM,
deps = [":kenlm"], deps = [":kenlm"],
linkopts = [ linkopts = DECODER_LINKOPTS,
"-lm",
"-ldl",
"-pthread",
],
) )
cc_library( cc_library(
@ -147,7 +150,7 @@ cc_library(
"tfmodelstate.h", "tfmodelstate.h",
"tfmodelstate.cc", "tfmodelstate.cc",
], ],
}), }) + DECODER_SOURCES,
copts = tf_copts() + select({ copts = tf_copts() + select({
# -fvisibility=hidden is not required on Windows, MSCV hides all declarations by default # -fvisibility=hidden is not required on Windows, MSCV hides all declarations by default
"//tensorflow:windows": ["/w"], "//tensorflow:windows": ["/w"],
@ -169,7 +172,8 @@ cc_library(
"//native_client:rpi3-armv8": LINUX_LINKOPTS, "//native_client:rpi3-armv8": LINUX_LINKOPTS,
"//tensorflow:windows": [], "//tensorflow:windows": [],
"//conditions:default": [], "//conditions:default": [],
}) + tflite_linkopts(), }) + tflite_linkopts() + DECODER_LINKOPTS,
includes = DECODER_INCLUDES,
deps = select({ deps = select({
"//native_client:tflite": [ "//native_client:tflite": [
"//tensorflow/lite/kernels:builtin_ops", "//tensorflow/lite/kernels:builtin_ops",
@ -218,7 +222,7 @@ cc_library(
], ],
}) + if_cuda([ }) + if_cuda([
"//tensorflow/core:core", "//tensorflow/core:core",
]) + [":decoder"], ]) + [":kenlm"],
) )
tf_cc_shared_object( tf_cc_shared_object(
@ -280,9 +284,8 @@ cc_binary(
cc_binary( cc_binary(
name = "trie_load", name = "trie_load",
srcs = [ srcs = [
"alphabet.h",
"trie_load.cc", "trie_load.cc",
], ] + DECODER_SOURCES,
copts = ["-std=c++11"], copts = ["-std=c++11"],
deps = [":decoder"], linkopts = DECODER_LINKOPTS,
) )