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 Hadoop SequenceFile support for tensorflow Dataset #19534

Closed
wants to merge 12 commits into from
3 changes: 3 additions & 0 deletions tensorflow/contrib/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ py_library(
"//tensorflow/contrib/gan",
"//tensorflow/contrib/graph_editor:graph_editor_py",
"//tensorflow/contrib/grid_rnn:grid_rnn_py",
"//tensorflow/contrib/hadoop",
"//tensorflow/contrib/hooks",
"//tensorflow/contrib/image:distort_image_py",
"//tensorflow/contrib/image:image_py",
Expand Down Expand Up @@ -139,6 +140,7 @@ cc_library(
"//tensorflow/contrib/coder:all_kernels",
"//tensorflow/contrib/data/kernels:dataset_kernels",
"//tensorflow/contrib/factorization/kernels:all_kernels",
"//tensorflow/contrib/hadoop:dataset_kernels",
"//tensorflow/contrib/input_pipeline:input_pipeline_ops_kernels",
"//tensorflow/contrib/layers:sparse_feature_cross_op_kernel",
"//tensorflow/contrib/nearest_neighbor:nearest_neighbor_ops_kernels",
Expand Down Expand Up @@ -168,6 +170,7 @@ cc_library(
"//tensorflow/contrib/data:dataset_ops_op_lib",
"//tensorflow/contrib/factorization:all_ops",
"//tensorflow/contrib/framework:all_ops",
"//tensorflow/contrib/hadoop:dataset_ops_op_lib",
"//tensorflow/contrib/input_pipeline:input_pipeline_ops_op_lib",
"//tensorflow/contrib/layers:sparse_feature_cross_op_op_lib",
"//tensorflow/contrib/nccl:nccl_ops_op_lib",
Expand Down
2 changes: 2 additions & 0 deletions tensorflow/contrib/cmake/python_modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ tensorflow/contrib/graph_editor/examples
tensorflow/contrib/grid_rnn
tensorflow/contrib/grid_rnn/python
tensorflow/contrib/grid_rnn/python/ops
tensorflow/contrib/hadoop/python
tensorflow/contrib/hadoop/python/ops
tensorflow/contrib/hooks
tensorflow/contrib/hooks/python
tensorflow/contrib/image
Expand Down
117 changes: 117 additions & 0 deletions tensorflow/contrib/hadoop/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package(default_visibility = ["//tensorflow:internal"])

licenses(["notice"]) # Apache 2.0

exports_files(["LICENSE"])

load(
"//tensorflow:tensorflow.bzl",
"tf_custom_op_library",
"tf_custom_op_py_library",
"tf_gen_op_libs",
"tf_gen_op_wrapper_py",
"tf_kernel_library",
"tf_py_test",
)

filegroup(
name = "test_data",
srcs = glob(["python/kernel_tests/testdata/*"]),
)

py_library(
name = "hadoop",
srcs = ["__init__.py"],
srcs_version = "PY2AND3",
deps = [
":dataset_ops",
],
)

tf_custom_op_library(
name = "_dataset_ops.so",
srcs = ["ops/dataset_ops.cc"],
deps = [
":dataset_kernels",
],
)

tf_gen_op_libs(
op_lib_names = ["dataset_ops"],
)

cc_library(
name = "dataset_kernels",
srcs = ["kernels/hadoop_dataset_ops.cc"],
deps = [
"//tensorflow/core:framework_headers_lib",
"//third_party/eigen3",
"@protobuf_archive//:protobuf_headers",
],
alwayslink = 1,
)

py_library(
name = "dataset_ops",
srcs = [
"python/ops/hadoop_dataset_ops.py",
],
srcs_version = "PY2AND3",
deps = [
":hadoop_op_loader",
"//tensorflow/python:dataset_ops_gen",
"//tensorflow/python:util",
"//tensorflow/python/data/ops:dataset_ops",
"//tensorflow/python/data/util:nest",
],
)

tf_gen_op_wrapper_py(
name = "gen_dataset_ops",
out = "python/ops/gen_dataset_ops.py",
deps = ["//tensorflow/contrib/hadoop:dataset_ops_op_lib"],
)

tf_kernel_library(
name = "dataset_ops_kernels",
deps = [
":dataset_kernels",
"//tensorflow/core:framework",
],
alwayslink = 1,
)

tf_custom_op_py_library(
name = "hadoop_op_loader",
srcs = ["python/ops/hadoop_op_loader.py"],
dso = ["//tensorflow/contrib/hadoop:_dataset_ops.so"],
kernels = [
":dataset_ops_kernels",
"//tensorflow/contrib/hadoop:dataset_ops_op_lib",
],
srcs_version = "PY2AND3",
deps = [
":gen_dataset_ops",
"//tensorflow/contrib/util:util_py",
"//tensorflow/python:platform",
],
)

tf_py_test(
name = "hadoop_test",
srcs = ["python/kernel_tests/hadoop_test.py"],
additional_deps = [
":hadoop",
"//third_party/py/numpy",
"//tensorflow/python:client_testlib",
"//tensorflow/python:framework",
"//tensorflow/python:framework_test_lib",
"//tensorflow/python:platform_test",
],
data = [
":test_data",
],
tags = [
"notap",
],
)
32 changes: 32 additions & 0 deletions tensorflow/contrib/hadoop/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2018 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Sequence File Dataset.

@@SequenceFileDataset
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from tensorflow.contrib.hadoop.python.ops.hadoop_dataset_ops import SequenceFileDataset

from tensorflow.python.util.all_util import remove_undocumented

_allowed_symbols = [
"SequenceFileDataset",
]

remove_undocumented(__name__)