Amit Patankar 56d41be853 Moved custom NumPy data types to :ndarray_tensor_types
Prior to this change qint*, quint* and resource were defined in Python
as a single-field struct arrays, e.g.

_np_qint8 = np.dtype([("qint8", np.int8)])

Several TensorFlow functions had to special-case struct arrays (which
otherwise have type NPY_VOID) and infer the real dtype from struct fields.

Having these data types defined and handled in C++ allows to minimize magic
on the Python/C++ boundary.

PiperOrigin-RevId: 286436332
Change-Id: I20581b6999efbea02aa0efeccaa2d8889ceadaf2
2019-12-19 12:03:54 -08:00

210 lines
5.1 KiB
Python

load("//tensorflow:tensorflow.bzl", "py_test")
package(
default_visibility = ["//tensorflow:internal"],
licenses = ["notice"], # Apache 2.0
)
exports_files(["LICENSE"])
py_library(
name = "nest",
srcs = ["nest.py"],
srcs_version = "PY2AND3",
deps = [
"//tensorflow/python:util",
"@six_archive//:six",
],
)
py_test(
name = "nest_test",
size = "small",
srcs = ["nest_test.py"],
python_version = "PY3",
srcs_version = "PY2AND3",
deps = [
":nest",
"//tensorflow/python:array_ops",
"//tensorflow/python:client_testlib",
"//tensorflow/python:framework_for_generated_wrappers",
"//tensorflow/python:math_ops",
"//tensorflow/python/ops/ragged",
"//third_party/py/numpy",
],
)
py_library(
name = "sparse",
srcs = ["sparse.py"],
srcs_version = "PY2AND3",
deps = [
":nest",
"//tensorflow/python:dtypes",
"//tensorflow/python:ops",
"//tensorflow/python:sparse_ops",
"//tensorflow/python:sparse_tensor",
"//tensorflow/python:tensor_shape",
"//tensorflow/python:util",
"@six_archive//:six",
],
)
py_test(
name = "sparse_test",
size = "small",
srcs = ["sparse_test.py"],
python_version = "PY3",
srcs_version = "PY2AND3",
deps = [
":nest",
":sparse",
"//tensorflow/python:client_testlib",
"//tensorflow/python:dtypes",
"//tensorflow/python:sparse_tensor",
"//tensorflow/python:tensor_shape",
],
)
py_library(
name = "structure",
srcs = ["structure.py"],
srcs_version = "PY2AND3",
deps = [
":nest",
"//tensorflow/python:dtypes",
"//tensorflow/python:framework_ops",
"//tensorflow/python:ops",
"//tensorflow/python:sparse_ops",
"//tensorflow/python:sparse_tensor",
"//tensorflow/python:tensor_array_ops",
"//tensorflow/python:tensor_shape",
"//tensorflow/python:tensor_util",
"//tensorflow/python:util",
"//tensorflow/python/ops/ragged",
"@wrapt",
],
)
py_test(
name = "structure_test",
size = "small",
srcs = ["structure_test.py"],
python_version = "PY3",
srcs_version = "PY2AND3",
deps = [
":nest",
":structure",
"//tensorflow/python:array_ops",
"//tensorflow/python:client_testlib",
"//tensorflow/python:constant_op",
"//tensorflow/python:dtypes",
"//tensorflow/python:framework_ops",
"//tensorflow/python:framework_test_lib",
"//tensorflow/python:sparse_tensor",
"//tensorflow/python:tensor_array_ops",
"//tensorflow/python:tensor_shape",
"//tensorflow/python:tensor_spec",
"//tensorflow/python:type_spec",
"//tensorflow/python:variables",
"//tensorflow/python/data/kernel_tests:test_base",
"//tensorflow/python/ops/ragged:ragged_factory_ops",
"//tensorflow/python/ops/ragged:ragged_tensor",
"//tensorflow/python/ops/ragged:ragged_tensor_value",
"//third_party/py/numpy",
"@absl_py//absl/testing:parameterized",
"@wrapt",
],
)
py_library(
name = "options",
srcs = ["options.py"],
srcs_version = "PY2AND3",
)
py_test(
name = "options_test",
size = "small",
srcs = ["options_test.py"],
python_version = "PY3",
srcs_version = "PY2AND3",
deps = [
":options",
"//tensorflow/python:client_testlib",
],
)
py_library(
name = "convert",
srcs = ["convert.py"],
srcs_version = "PY2AND3",
deps = [
"//tensorflow/python:constant_op",
"//tensorflow/python:dtypes",
"//tensorflow/python:framework_ops",
"//tensorflow/python:tensor_shape",
],
)
py_test(
name = "convert_test",
size = "small",
srcs = ["convert_test.py"],
python_version = "PY3",
srcs_version = "PY2AND3",
deps = [
":convert",
"//tensorflow/python:client_testlib",
"//tensorflow/python:framework_for_generated_wrappers",
"//tensorflow/python:util",
],
)
py_library(
name = "random_seed",
srcs = ["random_seed.py"],
srcs_version = "PY2AND3",
deps = [
"//tensorflow/python:constant_op",
"//tensorflow/python:dtypes",
"//tensorflow/python:framework",
],
)
py_test(
name = "random_seed_test",
size = "small",
srcs = ["random_seed_test.py"],
python_version = "PY3",
srcs_version = "PY2AND3",
deps = [
":random_seed",
"//tensorflow/python:client_testlib",
"//tensorflow/python:framework_for_generated_wrappers",
"//tensorflow/python:util",
],
)
py_library(
name = "traverse",
srcs = ["traverse.py"],
srcs_version = "PY2AND3",
deps = [
],
)
py_test(
name = "traverse_test",
size = "small",
srcs = ["traverse_test.py"],
python_version = "PY3",
srcs_version = "PY2AND3",
deps = [
":traverse",
"//tensorflow/python:client_testlib",
"//tensorflow/python:framework_for_generated_wrappers",
"//tensorflow/python/data/ops:dataset_ops",
],
)