Automatically format BUILD file with buildifier
This commit is contained in:
parent
c730102867
commit
47b9b71776
@ -1,15 +1,20 @@
|
||||
# Description: Deepspeech native client library.
|
||||
|
||||
load("@org_tensorflow//tensorflow:tensorflow.bzl",
|
||||
"tf_cc_shared_object", "if_cuda")
|
||||
|
||||
load("@org_tensorflow//tensorflow/lite:build_def.bzl",
|
||||
"tflite_copts", "tflite_linkopts")
|
||||
load(
|
||||
"@org_tensorflow//tensorflow:tensorflow.bzl",
|
||||
"if_cuda",
|
||||
"tf_cc_shared_object",
|
||||
)
|
||||
load(
|
||||
"@org_tensorflow//tensorflow/lite:build_def.bzl",
|
||||
"tflite_copts",
|
||||
"tflite_linkopts",
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "tflite",
|
||||
define_values = {
|
||||
"runtime": "tflite"
|
||||
"runtime": "tflite",
|
||||
},
|
||||
)
|
||||
|
||||
@ -17,23 +22,34 @@ genrule(
|
||||
name = "workspace_status",
|
||||
outs = ["workspace_status.cc"],
|
||||
cmd = "$(location :gen_workspace_status.sh) >$@",
|
||||
tools = [":gen_workspace_status.sh"],
|
||||
local = 1,
|
||||
stamp = 1,
|
||||
tools = [":gen_workspace_status.sh"],
|
||||
)
|
||||
|
||||
KENLM_SOURCES = glob(["kenlm/lm/*.cc", "kenlm/util/*.cc", "kenlm/util/double-conversion/*.cc",
|
||||
"kenlm/lm/*.hh", "kenlm/util/*.hh", "kenlm/util/double-conversion/*.h"],
|
||||
exclude = ["kenlm/*/*test.cc", "kenlm/*/*main.cc"])
|
||||
KENLM_SOURCES = glob(
|
||||
[
|
||||
"kenlm/lm/*.cc",
|
||||
"kenlm/util/*.cc",
|
||||
"kenlm/util/double-conversion/*.cc",
|
||||
"kenlm/lm/*.hh",
|
||||
"kenlm/util/*.hh",
|
||||
"kenlm/util/double-conversion/*.h",
|
||||
],
|
||||
exclude = [
|
||||
"kenlm/*/*test.cc",
|
||||
"kenlm/*/*main.cc",
|
||||
],
|
||||
)
|
||||
|
||||
OPENFST_SOURCES_PLATFORM = select({
|
||||
"//tensorflow:windows": glob(["ctcdecode/third_party/openfst-1.6.9-win/src/lib/*.cc"]),
|
||||
"//conditions:default": glob(["ctcdecode/third_party/openfst-1.6.7/src/lib/*.cc"]),
|
||||
"//tensorflow:windows": glob(["ctcdecode/third_party/openfst-1.6.9-win/src/lib/*.cc"]),
|
||||
"//conditions:default": glob(["ctcdecode/third_party/openfst-1.6.7/src/lib/*.cc"]),
|
||||
})
|
||||
|
||||
OPENFST_INCLUDES_PLATFORM = select({
|
||||
"//tensorflow:windows": ["ctcdecode/third_party/openfst-1.6.9-win/src/include"],
|
||||
"//conditions:default": ["ctcdecode/third_party/openfst-1.6.7/src/include"],
|
||||
"//tensorflow:windows": ["ctcdecode/third_party/openfst-1.6.9-win/src/include"],
|
||||
"//conditions:default": ["ctcdecode/third_party/openfst-1.6.7/src/include"],
|
||||
})
|
||||
|
||||
LINUX_LINKOPTS = [
|
||||
@ -41,52 +57,63 @@ LINUX_LINKOPTS = [
|
||||
"-pthread",
|
||||
"-Wl,-Bsymbolic",
|
||||
"-Wl,-Bsymbolic-functions",
|
||||
"-Wl,-export-dynamic"
|
||||
"-Wl,-export-dynamic",
|
||||
]
|
||||
|
||||
cc_library(
|
||||
name = "decoder",
|
||||
srcs = ["ctcdecode/ctc_beam_search_decoder.cpp",
|
||||
"ctcdecode/decoder_utils.cpp",
|
||||
"ctcdecode/decoder_utils.h",
|
||||
"ctcdecode/scorer.cpp",
|
||||
"ctcdecode/path_trie.cpp",
|
||||
"ctcdecode/path_trie.h"] + KENLM_SOURCES + OPENFST_SOURCES_PLATFORM,
|
||||
hdrs = ["ctcdecode/ctc_beam_search_decoder.h",
|
||||
"ctcdecode/scorer.h"],
|
||||
includes = [".",
|
||||
"ctcdecode/third_party/ThreadPool",
|
||||
"kenlm"] + OPENFST_INCLUDES_PLATFORM,
|
||||
srcs = [
|
||||
"ctcdecode/ctc_beam_search_decoder.cpp",
|
||||
"ctcdecode/decoder_utils.cpp",
|
||||
"ctcdecode/decoder_utils.h",
|
||||
"ctcdecode/scorer.cpp",
|
||||
"ctcdecode/path_trie.cpp",
|
||||
"ctcdecode/path_trie.h",
|
||||
] + KENLM_SOURCES + OPENFST_SOURCES_PLATFORM,
|
||||
hdrs = [
|
||||
"ctcdecode/ctc_beam_search_decoder.h",
|
||||
"ctcdecode/scorer.h",
|
||||
],
|
||||
defines = ["KENLM_MAX_ORDER=6"],
|
||||
includes = [
|
||||
".",
|
||||
"ctcdecode/third_party/ThreadPool",
|
||||
"kenlm",
|
||||
] + OPENFST_INCLUDES_PLATFORM,
|
||||
)
|
||||
|
||||
tf_cc_shared_object(
|
||||
name = "libdeepspeech.so",
|
||||
srcs = ["deepspeech.cc",
|
||||
"deepspeech.h",
|
||||
"alphabet.h",
|
||||
"modelstate.h",
|
||||
"modelstate.cc",
|
||||
"workspace_status.h",
|
||||
"workspace_status.cc"] +
|
||||
select({
|
||||
"//native_client:tflite": [
|
||||
"tflitemodelstate.h",
|
||||
"tflitemodelstate.cc"
|
||||
],
|
||||
"//conditions:default": [
|
||||
"tfmodelstate.h",
|
||||
"tfmodelstate.cc"
|
||||
]}),
|
||||
srcs = [
|
||||
"deepspeech.cc",
|
||||
"deepspeech.h",
|
||||
"alphabet.h",
|
||||
"modelstate.h",
|
||||
"modelstate.cc",
|
||||
"workspace_status.h",
|
||||
"workspace_status.cc",
|
||||
] + select({
|
||||
"//native_client:tflite": [
|
||||
"tflitemodelstate.h",
|
||||
"tflitemodelstate.cc",
|
||||
],
|
||||
"//conditions:default": [
|
||||
"tfmodelstate.h",
|
||||
"tfmodelstate.cc",
|
||||
],
|
||||
}),
|
||||
copts = select({
|
||||
# -fvisibility=hidden is not required on Windows, MSCV hides all declarations by default
|
||||
"//tensorflow:windows": ["/w"],
|
||||
# -Wno-sign-compare to silent a lot of warnings from tensorflow itself,
|
||||
# which makes it harder to see our own warnings
|
||||
"//conditions:default": ["-Wno-sign-compare", "-fvisibility=hidden"],
|
||||
"//conditions:default": [
|
||||
"-Wno-sign-compare",
|
||||
"-fvisibility=hidden",
|
||||
],
|
||||
}) + select({
|
||||
"//native_client:tflite": [ "-DUSE_TFLITE" ],
|
||||
"//conditions:default": [ "-UUSE_TFLITE" ]
|
||||
"//native_client:tflite": ["-DUSE_TFLITE"],
|
||||
"//conditions:default": ["-UUSE_TFLITE"],
|
||||
}) + tflite_copts(),
|
||||
linkopts = select({
|
||||
"//tensorflow:macos": [],
|
||||
@ -94,7 +121,7 @@ tf_cc_shared_object(
|
||||
"//tensorflow:rpi3": LINUX_LINKOPTS + ["-l:libstdc++.a"],
|
||||
"//tensorflow:rpi3-armv8": LINUX_LINKOPTS + ["-l:libstdc++.a"],
|
||||
"//tensorflow:windows": [],
|
||||
"//conditions:default": []
|
||||
"//conditions:default": [],
|
||||
}) + tflite_linkopts(),
|
||||
deps = select({
|
||||
"//native_client:tflite": [
|
||||
@ -108,62 +135,70 @@ tf_cc_shared_object(
|
||||
### => Trying to be more fine-grained
|
||||
### Use bin/ops_in_graph.py to list all the ops used by a frozen graph.
|
||||
### CPU only build, libdeepspeech.so file size reduced by ~50%
|
||||
"//tensorflow/core/kernels:spectrogram_op", # AudioSpectrogram
|
||||
"//tensorflow/core/kernels:bias_op", # BiasAdd
|
||||
"//tensorflow/contrib/rnn:lstm_ops_kernels", # BlockLSTM
|
||||
"//tensorflow/core/kernels:cast_op", # Cast
|
||||
"//tensorflow/core/kernels:concat_op", # ConcatV2
|
||||
"//tensorflow/core/kernels:constant_op", # Const, Placeholder
|
||||
"//tensorflow/core/kernels:shape_ops", # ExpandDims, Shape
|
||||
"//tensorflow/core/kernels:gather_nd_op", # GatherNd
|
||||
"//tensorflow/core/kernels:identity_op", # Identity
|
||||
"//tensorflow/core/kernels:immutable_constant_op", # ImmutableConst (used in memmapped models)
|
||||
"//tensorflow/core/kernels:spectrogram_op", # AudioSpectrogram
|
||||
"//tensorflow/core/kernels:bias_op", # BiasAdd
|
||||
"//tensorflow/contrib/rnn:lstm_ops_kernels", # BlockLSTM
|
||||
"//tensorflow/core/kernels:cast_op", # Cast
|
||||
"//tensorflow/core/kernels:concat_op", # ConcatV2
|
||||
"//tensorflow/core/kernels:constant_op", # Const, Placeholder
|
||||
"//tensorflow/core/kernels:shape_ops", # ExpandDims, Shape
|
||||
"//tensorflow/core/kernels:gather_nd_op", # GatherNd
|
||||
"//tensorflow/core/kernels:identity_op", # Identity
|
||||
"//tensorflow/core/kernels:immutable_constant_op", # ImmutableConst (used in memmapped models)
|
||||
"//tensorflow/core/kernels:deepspeech_cwise_ops", # Less, Minimum, Mul
|
||||
"//tensorflow/core/kernels:matmul_op", # MatMul
|
||||
"//tensorflow/core/kernels:reduction_ops", # Max
|
||||
"//tensorflow/core/kernels:mfcc_op", # Mfcc
|
||||
"//tensorflow/core/kernels:no_op", # NoOp
|
||||
"//tensorflow/core/kernels:pack_op", # Pack
|
||||
"//tensorflow/core/kernels:sequence_ops", # Range
|
||||
"//tensorflow/core/kernels:relu_op", # Relu
|
||||
"//tensorflow/core/kernels:reshape_op", # Reshape
|
||||
"//tensorflow/core/kernels:softmax_op", # Softmax
|
||||
"//tensorflow/core/kernels:tile_ops", # Tile
|
||||
"//tensorflow/core/kernels:transpose_op", # Transpose
|
||||
"//tensorflow/core/kernels:matmul_op", # MatMul
|
||||
"//tensorflow/core/kernels:reduction_ops", # Max
|
||||
"//tensorflow/core/kernels:mfcc_op", # Mfcc
|
||||
"//tensorflow/core/kernels:no_op", # NoOp
|
||||
"//tensorflow/core/kernels:pack_op", # Pack
|
||||
"//tensorflow/core/kernels:sequence_ops", # Range
|
||||
"//tensorflow/core/kernels:relu_op", # Relu
|
||||
"//tensorflow/core/kernels:reshape_op", # Reshape
|
||||
"//tensorflow/core/kernels:softmax_op", # Softmax
|
||||
"//tensorflow/core/kernels:tile_ops", # Tile
|
||||
"//tensorflow/core/kernels:transpose_op", # Transpose
|
||||
# And we also need the op libs for these ops used in the model:
|
||||
"//tensorflow/core:audio_ops_op_lib", # AudioSpectrogram, Mfcc
|
||||
"//tensorflow/contrib/rnn:lstm_ops_op_lib", # BlockLSTM
|
||||
"//tensorflow/core:math_ops_op_lib", # Cast, Less, Max, MatMul, Minimum, Range
|
||||
"//tensorflow/core:array_ops_op_lib", # ConcatV2, Const, ExpandDims, Fill, GatherNd, Identity, Pack, Placeholder, Reshape, Tile, Transpose
|
||||
"//tensorflow/core:no_op_op_lib", # NoOp
|
||||
"//tensorflow/core:nn_ops_op_lib", # Relu, Softmax, BiasAdd
|
||||
"//tensorflow/core:audio_ops_op_lib", # AudioSpectrogram, Mfcc
|
||||
"//tensorflow/contrib/rnn:lstm_ops_op_lib", # BlockLSTM
|
||||
"//tensorflow/core:math_ops_op_lib", # Cast, Less, Max, MatMul, Minimum, Range
|
||||
"//tensorflow/core:array_ops_op_lib", # ConcatV2, Const, ExpandDims, Fill, GatherNd, Identity, Pack, Placeholder, Reshape, Tile, Transpose
|
||||
"//tensorflow/core:no_op_op_lib", # NoOp
|
||||
"//tensorflow/core:nn_ops_op_lib", # Relu, Softmax, BiasAdd
|
||||
# And op libs for these ops brought in by dependencies of dependencies to silence unknown OpKernel warnings:
|
||||
"//tensorflow/core:dataset_ops_op_lib", # UnwrapDatasetVariant, WrapDatasetVariant
|
||||
"//tensorflow/core:sendrecv_ops_op_lib", # _HostRecv, _HostSend, _Recv, _Send
|
||||
"//tensorflow/core:dataset_ops_op_lib", # UnwrapDatasetVariant, WrapDatasetVariant
|
||||
"//tensorflow/core:sendrecv_ops_op_lib", # _HostRecv, _HostSend, _Recv, _Send
|
||||
],
|
||||
}) + if_cuda([
|
||||
"//tensorflow/core:core",
|
||||
"//tensorflow/core:core",
|
||||
]) + [":decoder"],
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "generate_trie",
|
||||
srcs = [
|
||||
"generate_trie.cpp",
|
||||
"alphabet.h",
|
||||
],
|
||||
"alphabet.h",
|
||||
"generate_trie.cpp",
|
||||
],
|
||||
copts = ["-std=c++11"],
|
||||
linkopts = ["-lm", "-ldl", "-pthread"],
|
||||
linkopts = [
|
||||
"-lm",
|
||||
"-ldl",
|
||||
"-pthread",
|
||||
],
|
||||
deps = [":decoder"],
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "trie_load",
|
||||
srcs = [
|
||||
"trie_load.cc",
|
||||
"alphabet.h",
|
||||
],
|
||||
"alphabet.h",
|
||||
"trie_load.cc",
|
||||
],
|
||||
copts = ["-std=c++11"],
|
||||
linkopts = ["-lm", "-ldl", "-pthread"],
|
||||
linkopts = [
|
||||
"-lm",
|
||||
"-ldl",
|
||||
"-pthread",
|
||||
],
|
||||
deps = [":decoder"],
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user