Skip to content

Commit

Permalink
Fix the PR migrations.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 268290664
  • Loading branch information
broken authored and tf-text-github-robot committed Sep 10, 2019
1 parent a8d9996 commit a5785cd
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 69 deletions.
2 changes: 0 additions & 2 deletions docs/index.md
Expand Up @@ -35,11 +35,9 @@ variable-length lists appropriate for text processing (e.g. characters may have
multi-byte encodings, words can be of varying lengths, sentences have different
numbers of tokens, documents have varying numbers of sentences, etc.).


In addition to basic text handling and tensor representations, tf.Text provides
library support for some feature engineering which includes constructing
n-grams, detecting token-level structure in text (wordshape), and projecting
features at one scale to another (e.g. constructing sentence-level
representations from token-level information). View the
[API DOCS](api_docs/python/index.md) for the full suite of available ops.

121 changes: 74 additions & 47 deletions tensorflow_text/BUILD
Expand Up @@ -15,6 +15,13 @@ load("//tensorflow_text:tftext.bzl", "py_tf_text_library")
# Public TF.Text library to import #
####################################

# Most TF users will want to add this as their dependency.
alias(
name = "tensorflow_text",
actual = ":ops",
visibility = ["//visibility:public"],
)

cc_library(
name = "ops_lib",
visibility = ["//visibility:public"],
Expand All @@ -30,7 +37,7 @@ cc_library(
)

py_library(
name = "tf-text",
name = "ops",
srcs = [
"__init__.py",
"python/__init__.py",
Expand All @@ -40,10 +47,6 @@ py_library(
"python/ops/__init__.py",
],
srcs_version = "PY2AND3",
visibility = [
"//tensorflow_text:__subpackages__",
"//third_party/py/tensorflow_text:__pkg__",
],
deps = [
":bert_tokenizer",
":constrained_sequence_op",
Expand All @@ -69,6 +72,14 @@ py_library(
],
)

build_test(
name = "tf-text-build-test",
targets = [
":ops",
":ops_lib",
],
)

##########################
# Individual tf.text ops #
##########################
Expand Down Expand Up @@ -136,10 +147,18 @@ py_test(
],
)

py_library(
py_tf_text_library(
name = "greedy_constrained_sequence_op",
srcs = ["python/ops/greedy_constrained_sequence_op.py"],
data = [":python/ops/_constrained_sequence_op.so"],
cc_op_kernels = [
":constrained_sequence_op",
],
deps = [
# python:array_ops tensorflow dep,
# python:dtypes tensorflow dep,
# python:framework_ops tensorflow dep,
# python/ops/ragged:ragged_tensor tensorflow dep,
],
)

py_test(
Expand Down Expand Up @@ -474,6 +493,44 @@ py_test(
],
)

py_library(
name = "todense_layer",
srcs = ["python/layers/todense.py"],
deps = [
# python:framework_ops tensorflow dep,
# python:sparse_ops tensorflow dep,
# python:sparse_tensor tensorflow dep,
# python/keras tensorflow dep, # fixdeps: keep
# python/keras:base_layer tensorflow dep,
# python/keras:layers_base tensorflow dep,
# python/ops/ragged:ragged_tensor tensorflow dep,
],
)

py_test(
name = "todense_test",
size = "large",
srcs = ["python/layers/todense_test.py"],
python_version = "PY2",
srcs_version = "PY2AND3",
deps = [
":todense_layer",
"@com_google_absl//absl/testing:parameterized",
# numpy dep,
# python:client_testlib tensorflow dep,
# python:dtypes tensorflow dep,
# python:framework_test_lib tensorflow dep,
# python:math_ops tensorflow dep,
# python:sparse_tensor tensorflow dep,
# python/data/ops:dataset_ops tensorflow dep,
# python/keras tensorflow dep,
# python/keras:backend tensorflow dep,
# python/keras:base_layer tensorflow dep,
# python/keras:layers_base tensorflow dep,
# python/ops/ragged:ragged_factory_ops tensorflow dep,
],
)

py_tf_text_library(
name = "unicode_script_tokenizer",
srcs = ["python/ops/unicode_script_tokenizer.py"],
Expand Down Expand Up @@ -511,10 +568,18 @@ py_test(
],
)

py_library(
py_tf_text_library(
name = "viterbi_constrained_sequence_op",
srcs = ["python/ops/viterbi_constrained_sequence_op.py"],
data = [":python/ops/_constrained_sequence_op.so"],
cc_op_kernels = [
":constrained_sequence_op",
],
deps = [
# python:array_ops tensorflow dep,
# python:dtypes tensorflow dep,
# python:framework_ops tensorflow dep,
# python/ops/ragged:ragged_tensor tensorflow dep,
],
)

py_test(
Expand Down Expand Up @@ -653,41 +718,3 @@ py_test(
# python:framework_test_lib tensorflow dep,
],
)

py_library(
name = "todense_layer",
srcs = ["python/layers/todense.py"],
deps = [
# python:framework_ops tensorflow dep,
# python:sparse_ops tensorflow dep,
# python:sparse_tensor tensorflow dep,
# python/keras tensorflow dep, # fixdeps: keep
# python/keras:base_layer tensorflow dep,
# python/keras:layers_base tensorflow dep,
# python/ops/ragged:ragged_tensor tensorflow dep,
],
)

py_test(
name = "todense_test",
size = "large",
srcs = ["python/layers/todense_test.py"],
python_version = "PY2",
srcs_version = "PY2AND3",
deps = [
":todense_layer",
"@com_google_absl//absl/testing:parameterized",
# numpy dep,
# python:client_testlib tensorflow dep,
# python:dtypes tensorflow dep,
# python:framework_test_lib tensorflow dep,
# python:math_ops tensorflow dep,
# python:sparse_tensor tensorflow dep,
# python/data/ops:dataset_ops tensorflow dep,
# python/keras tensorflow dep,
# python/keras:backend tensorflow dep,
# python/keras:base_layer tensorflow dep,
# python/keras:layers_base tensorflow dep,
# python/ops/ragged:ragged_factory_ops tensorflow dep,
],
)
50 changes: 30 additions & 20 deletions tensorflow_text/tftext.bzl
Expand Up @@ -9,26 +9,36 @@ def py_tf_text_library(
visibility = None,
cc_op_defs = [],
cc_op_kernels = []):
"""
Creates build rules for TF.Text ops as shared libraries.
"""Creates build rules for TF.Text ops as shared libraries.
Args:
name: The name for the python library target build by this rule.
srcs: Python source files for the Python library.
deps: Dependencies for the Python library.
visibility: Visibility for the Python library.
cc_op_defs: A list of c++ src files containing REGISTER_OP definitions.
cc_op_kernels: A list of c++ targets containing kernels that are used
by the Python library.
"""
binary_name = "python/ops/_" + name + ".so"
native.cc_binary(
name = binary_name,
srcs = cc_op_defs,
copts = [ "-pthread", "-std=c++11", ],
linkshared = 1,
deps = cc_op_kernels + [
"@local_config_tf//:libtensorflow_framework",
"@local_config_tf//:tf_header_lib",
],
)
if cc_op_defs:
native.cc_binary(
name = binary_name,
srcs = cc_op_defs,
copts = [ "-pthread", "-std=c++11", ],
linkshared = 1,
deps = cc_op_kernels + [
"@local_config_tf//:libtensorflow_framework",
"@local_config_tf//:tf_header_lib",
],
)

native.py_library(
name = name,
srcs = srcs,
srcs_version = "PY2AND3",
visibility = visibility,
data = [ ":" + binary_name ],
deps = deps,
)
if srcs:
native.py_library(
name = name,
srcs = srcs,
srcs_version = "PY2AND3",
visibility = visibility,
data = [ ":" + binary_name ],
deps = deps,
)

0 comments on commit a5785cd

Please sign in to comment.