1# Description:
2#   Contains ops for image manipulation.
3
4licenses(["notice"])  # Apache 2.0
5
6exports_files(["LICENSE"])
7
8package(default_visibility = ["//visibility:public"])
9
10load(
11    "//tensorflow:tensorflow.bzl",
12    "tf_cc_test",
13    "tf_custom_op_library",
14    "tf_gen_op_libs",
15    "tf_gen_op_wrapper_py",
16    "tf_kernel_library",
17    "tf_py_test",
18)
19load("//tensorflow:tensorflow.bzl", "cuda_py_test")
20load("//tensorflow:tensorflow.bzl", "tf_custom_op_py_library")
21
22tf_custom_op_library(
23    name = "python/ops/_image_ops.so",
24    srcs = [
25        "kernels/bipartite_match_op.cc",
26        "kernels/image_ops.cc",
27        "kernels/image_ops.h",
28        "kernels/segmentation_ops.cc",
29        "kernels/segmentation_ops.h",
30        "ops/image_ops.cc",
31    ],
32    gpu_srcs = [
33        "kernels/image_ops_gpu.cu.cc",
34        "kernels/image_ops.h",
35    ],
36)
37
38tf_kernel_library(
39    name = "image_ops_kernels",
40    srcs = [
41        "kernels/bipartite_match_op.cc",
42        "kernels/image_ops.cc",
43        "kernels/image_ops.h",
44        "kernels/segmentation_ops.cc",
45        "kernels/segmentation_ops.h",
46    ],
47    gpu_srcs = [
48        "kernels/image_ops_gpu.cu.cc",
49        "kernels/image_ops.h",
50    ],
51    deps = [
52        "//tensorflow/core:framework",
53        "//tensorflow/core:lib",
54        "//third_party/eigen3",
55    ],
56    alwayslink = 1,
57)
58
59tf_gen_op_libs(
60    op_lib_names = ["image_ops"],
61)
62
63tf_gen_op_wrapper_py(
64    name = "image_ops",
65    deps = [":image_ops_op_lib"],
66)
67
68tf_custom_op_py_library(
69    name = "image_py",
70    srcs = [
71        "__init__.py",
72        "python/ops/image_ops.py",
73    ],
74    dso = [":python/ops/_image_ops.so"],
75    kernels = [
76        ":image_ops_kernels",
77        ":image_ops_op_lib",
78    ],
79    srcs_version = "PY2AND3",
80    deps = [
81        ":image_ops",
82        "//tensorflow/contrib/util:util_py",
83        "//tensorflow/python:array_ops",
84        "//tensorflow/python:common_shapes",
85        "//tensorflow/python:constant_op",
86        "//tensorflow/python:control_flow_ops",
87        "//tensorflow/python:framework_for_generated_wrappers",
88        "//tensorflow/python:linalg_ops",
89        "//tensorflow/python:math_ops",
90        "//tensorflow/python:platform",
91        "//tensorflow/python:util",
92    ],
93)
94
95cuda_py_test(
96    name = "image_ops_test",
97    size = "medium",
98    srcs = ["python/kernel_tests/image_ops_test.py"],
99    additional_deps = [
100        ":distort_image_py",
101        ":image_py",
102        ":single_image_random_dot_stereograms_py",
103        "//third_party/py/numpy",
104        "//tensorflow/python:array_ops",
105        "//tensorflow/python:framework_for_generated_wrappers",
106        "//tensorflow/python:framework_test_lib",
107        "//tensorflow/python:math_ops",
108        "//tensorflow/python:platform_test",
109    ],
110)
111
112tf_custom_op_library(
113    name = "python/ops/_distort_image_ops.so",
114    srcs = [
115        "kernels/adjust_hsv_in_yiq_op.cc",
116        "kernels/adjust_hsv_in_yiq_op.h",
117        "ops/distort_image_ops.cc",
118    ],
119    gpu_srcs = [
120        "kernels/adjust_hsv_in_yiq_op_gpu.cu.cc",
121        "kernels/adjust_hsv_in_yiq_op.h",
122    ],
123    deps = [
124        "//tensorflow/core/kernels:gpu_util_hdrs",
125    ],
126)
127
128tf_cc_test(
129    name = "adjust_hsv_in_yiq_op_test",
130    size = "small",
131    srcs = [
132        "kernels/adjust_hsv_in_yiq_op.h",
133        "kernels/adjust_hsv_in_yiq_op_test.cc",
134    ],
135    deps = [
136        "//tensorflow/core:framework",
137        "//tensorflow/core:test",
138        "//tensorflow/core:test_main",
139        "//tensorflow/core:testlib",
140        "//tensorflow/core/kernels:ops_testutil",
141        "//tensorflow/core/kernels:ops_util",
142        "//third_party/eigen3",
143    ],
144)
145
146tf_gen_op_libs(
147    op_lib_names = ["distort_image_ops"],
148)
149
150tf_gen_op_wrapper_py(
151    name = "distort_image_ops",
152    deps = [":distort_image_ops_op_lib"],
153)
154
155py_library(
156    name = "distort_image_py",
157    srcs = [
158        "__init__.py",
159        "python/ops/distort_image_ops.py",
160    ],
161    data = [":python/ops/_distort_image_ops.so"],
162    srcs_version = "PY2AND3",
163    deps = [
164        ":distort_image_ops",
165        ":single_image_random_dot_stereograms_py",
166        "//tensorflow/contrib/util:util_py",
167        "//tensorflow/python:framework_for_generated_wrappers",
168        "//tensorflow/python:image_ops",
169        "//tensorflow/python:platform",
170        "//tensorflow/python:random_ops",
171        "//tensorflow/python:util",
172    ],
173)
174
175cuda_py_test(
176    name = "distort_image_ops_test",
177    size = "medium",
178    srcs = ["python/kernel_tests/distort_image_ops_test.py"],
179    additional_deps = [
180        ":distort_image_py",
181        ":image_py",
182        ":single_image_random_dot_stereograms_py",
183        "//third_party/py/numpy",
184        "//tensorflow/python:client",
185        "//tensorflow/python:client_testlib",
186        "//tensorflow/python:control_flow_ops",
187        "//tensorflow/python:framework_for_generated_wrappers",
188        "//tensorflow/python:framework_test_lib",
189        "//tensorflow/python:math_ops",
190        "//tensorflow/python:platform_test",
191        "//tensorflow/python:random_ops",
192        "//tensorflow/python:variables",
193        "//tensorflow/core:protos_all_py",
194    ],
195)
196
197tf_py_test(
198    name = "segmentation_test",
199    size = "medium",
200    srcs = ["python/kernel_tests/segmentation_test.py"],
201    additional_deps = [
202        ":distort_image_py",
203        ":image_py",
204        "//tensorflow/python:array_ops",
205        "//tensorflow/python:framework_for_generated_wrappers",
206        "//tensorflow/python:framework_test_lib",
207        "//tensorflow/python:math_ops",
208        "//tensorflow/python:platform_test",
209    ],
210)
211
212tf_custom_op_library(
213    name = "python/ops/_single_image_random_dot_stereograms.so",
214    srcs = [
215        "kernels/single_image_random_dot_stereograms_ops.cc",
216        "ops/single_image_random_dot_stereograms_ops.cc",
217    ],
218    deps = [
219        "@protobuf_archive//:protobuf",
220    ],
221)
222
223tf_gen_op_libs(
224    op_lib_names = ["single_image_random_dot_stereograms_ops"],
225)
226
227tf_gen_op_wrapper_py(
228    name = "single_image_random_dot_stereograms_ops",
229    deps = [":single_image_random_dot_stereograms_ops_op_lib"],
230)
231
232cc_library(
233    name = "image_ops_cc",
234    srcs = ["ops/image_ops.cc"],
235    deps = [
236        ":image_ops_kernels",
237        "//tensorflow/core:framework",
238    ],
239    alwayslink = 1,
240)
241
242py_library(
243    name = "single_image_random_dot_stereograms_py",
244    srcs = glob(["python/ops/single*.py"]) + ["__init__.py"],
245    data = [":python/ops/_single_image_random_dot_stereograms.so"],
246    srcs_version = "PY2AND3",
247    deps = [
248        ":image_py",
249        ":single_image_random_dot_stereograms_ops",
250        "//tensorflow/contrib/util:util_py",
251        "//tensorflow/python:framework_ops",
252        "//tensorflow/python:platform",
253        "//tensorflow/python:util",
254    ],
255)
256
257cuda_py_test(
258    name = "single_image_random_dot_stereograms_ops_test",
259    size = "medium",
260    srcs = ["python/kernel_tests/single_image_random_dot_stereograms_ops_test.py"],
261    additional_deps = [
262        ":distort_image_py",
263        ":image_py",
264        ":single_image_random_dot_stereograms_py",
265        "//third_party/py/numpy",
266        "//tensorflow/python:array_ops",
267        "//tensorflow/python:framework_for_generated_wrappers",
268        "//tensorflow/python:framework_test_lib",
269        "//tensorflow/python:math_ops",
270        "//tensorflow/python:platform_test",
271    ],
272)
273
274filegroup(
275    name = "all_files",
276    srcs = glob(
277        ["**/*"],
278        exclude = [
279            "**/METADATA",
280            "**/OWNERS",
281        ],
282    ),
283    visibility = ["//tensorflow:__subpackages__"],
284)
285