• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14# ==============================================================================
15
16# pylint: disable=unused-import
17"""Import names of Tensor Flow standard Ops."""
18
19from __future__ import absolute_import
20from __future__ import division
21from __future__ import print_function
22
23import sys as _sys
24
25# Imports the following modules so that @RegisterGradient get executed.
26from tensorflow.python.ops import array_grad
27from tensorflow.python.ops import data_flow_grad
28from tensorflow.python.ops import manip_grad
29from tensorflow.python.ops import math_grad
30from tensorflow.python.ops import manip_grad
31from tensorflow.python.ops import sparse_grad
32from tensorflow.python.ops import spectral_grad
33from tensorflow.python.ops import state_grad
34from tensorflow.python.ops import tensor_array_grad
35from tensorflow.python.util.all_util import remove_undocumented
36
37
38# go/tf-wildcard-import
39# pylint: disable=wildcard-import
40from tensorflow.python.ops.array_ops import *
41from tensorflow.python.ops.check_ops import *
42from tensorflow.python.ops.clip_ops import *
43from tensorflow.python.ops.special_math_ops import *
44# TODO(vrv): Switch to import * once we're okay with exposing the module.
45from tensorflow.python.ops.confusion_matrix import confusion_matrix
46from tensorflow.python.ops.control_flow_ops import Assert
47from tensorflow.python.ops.control_flow_ops import case
48from tensorflow.python.ops.control_flow_ops import cond
49from tensorflow.python.ops.control_flow_ops import group
50from tensorflow.python.ops.control_flow_ops import no_op
51from tensorflow.python.ops.control_flow_ops import tuple  # pylint: disable=redefined-builtin
52# pylint: enable=redefined-builtin
53from tensorflow.python.ops.control_flow_ops import while_loop
54from tensorflow.python.ops.data_flow_ops import *
55from tensorflow.python.ops.functional_ops import *
56from tensorflow.python.ops.gradients import *
57from tensorflow.python.ops.histogram_ops import *
58from tensorflow.python.ops.init_ops import *
59from tensorflow.python.ops.io_ops import *
60from tensorflow.python.ops.linalg_ops import *
61from tensorflow.python.ops.logging_ops import Print
62from tensorflow.python.ops.logging_ops import get_summary_op
63from tensorflow.python.ops.lookup_ops import initialize_all_tables
64from tensorflow.python.ops.lookup_ops import tables_initializer
65from tensorflow.python.ops.manip_ops import *
66from tensorflow.python.ops.math_ops import *
67from tensorflow.python.ops.numerics import *
68from tensorflow.python.ops.parsing_ops import *
69from tensorflow.python.ops.partitioned_variables import *
70from tensorflow.python.ops.random_ops import *
71from tensorflow.python.ops.script_ops import py_func
72from tensorflow.python.ops.session_ops import *
73from tensorflow.python.ops.sparse_ops import *
74from tensorflow.python.ops.state_ops import assign
75from tensorflow.python.ops.state_ops import assign_add
76from tensorflow.python.ops.state_ops import assign_sub
77from tensorflow.python.ops.state_ops import count_up_to
78from tensorflow.python.ops.state_ops import scatter_add
79from tensorflow.python.ops.state_ops import scatter_div
80from tensorflow.python.ops.state_ops import scatter_mul
81from tensorflow.python.ops.state_ops import scatter_sub
82from tensorflow.python.ops.state_ops import scatter_update
83from tensorflow.python.ops.state_ops import scatter_nd_add
84from tensorflow.python.ops.state_ops import scatter_nd_sub
85# TODO(simister): Re-enable once binary size increase due to scatter_nd
86# ops is under control.
87# from tensorflow.python.ops.state_ops import scatter_nd_mul
88# from tensorflow.python.ops.state_ops import scatter_nd_div
89from tensorflow.python.ops.state_ops import scatter_nd_update
90from tensorflow.python.ops.string_ops import *
91from tensorflow.python.ops.template import *
92from tensorflow.python.ops.tensor_array_ops import *
93from tensorflow.python.ops.variable_scope import *
94from tensorflow.python.ops.variables import *
95# pylint: enable=wildcard-import
96
97#### For use in remove_undocumented below:
98from tensorflow.python.framework import constant_op as _constant_op
99from tensorflow.python.ops import array_ops as _array_ops
100from tensorflow.python.ops import check_ops as _check_ops
101from tensorflow.python.ops import clip_ops as _clip_ops
102from tensorflow.python.ops import confusion_matrix as _confusion_matrix
103from tensorflow.python.ops import control_flow_ops as _control_flow_ops
104from tensorflow.python.ops import data_flow_ops as _data_flow_ops
105from tensorflow.python.ops import functional_ops as _functional_ops
106from tensorflow.python.ops import gradients as _gradients
107from tensorflow.python.ops import histogram_ops as _histogram_ops
108from tensorflow.python.ops import init_ops as _init_ops
109from tensorflow.python.ops import io_ops as _io_ops
110from tensorflow.python.ops import linalg_ops as _linalg_ops
111from tensorflow.python.ops import logging_ops as _logging_ops
112from tensorflow.python.ops import manip_ops as _manip_ops
113from tensorflow.python.ops import math_ops as _math_ops
114from tensorflow.python.ops import numerics as _numerics
115from tensorflow.python.ops import parsing_ops as _parsing_ops
116from tensorflow.python.ops import partitioned_variables as _partitioned_variables
117from tensorflow.python.ops import random_ops as _random_ops
118from tensorflow.python.ops import script_ops as _script_ops
119from tensorflow.python.ops import session_ops as _session_ops
120from tensorflow.python.ops import sparse_ops as _sparse_ops
121from tensorflow.python.ops import special_math_ops as _special_math_ops
122from tensorflow.python.ops import state_ops as _state_ops
123from tensorflow.python.ops import string_ops as _string_ops
124from tensorflow.python.ops import template as _template
125from tensorflow.python.ops import tensor_array_ops as _tensor_array_ops
126from tensorflow.python.ops import variable_scope as _variable_scope
127from tensorflow.python.ops import variables as _variables
128
129
130_allowed_symbols_math_ops = [
131    # TODO(drpng): decide if we want to reference these in the documentation.
132    "reduced_shape",
133    "sparse_segment_mean_grad",
134    "sparse_segment_sqrt_n_grad",
135
136    # Legacy: will be removed.
137    "arg_max",
138    "arg_min",
139    "lin_space",
140    "sparse_matmul",  # Use tf.matmul.
141    # Deprecated (see versions.h):
142    "batch_fft",
143    "batch_fft2d",
144    "batch_fft3d",
145    "batch_ifft",
146    "batch_ifft2d",
147    "batch_ifft3d",
148    "mul",  # use tf.multiply instead.
149    "neg",  # use tf.negative instead.
150    "sub",  # use tf.subtract instead.
151
152    # These are documented in nn.
153    # We are not importing nn because it would create a circular dependency.
154    "sigmoid",
155    "log_sigmoid",
156    "tanh",
157]
158
159_allowed_symbols_array_ops = [
160    # TODO(drpng): make sure they are documented.
161    # Scalars:
162    "NEW_AXIS",
163    "SHRINK_AXIS",
164    "newaxis",
165
166    # Documented in training.py.
167    # I do not import train, to avoid circular dependencies.
168    # TODO(drpng): this is defined in gen_array_ops, clearly not the right
169    # place.
170    "stop_gradient",
171
172    # See gen_docs_combined for tf.copy documentation.
173    "copy",
174
175    ## TODO(drpng): make them inaccessible directly.
176    ## TODO(drpng): Below, to-doc means that we need to find an appropriate
177    ##  documentation section to reference.
178    ## For re-exporting to tf.*:
179    "constant",
180    "edit_distance",  # to-doc
181    # From gen_array_ops:
182    "copy_host",  # to-doc
183    "immutable_const",  # to-doc
184    "invert_permutation",  # to-doc
185    "quantize_and_dequantize",  # to-doc
186
187    # TODO(drpng): legacy symbols to be removed.
188    "list_diff",  # Use tf.listdiff instead.
189    "batch_matrix_diag",
190    "batch_matrix_band_part",
191    "batch_matrix_diag_part",
192    "batch_matrix_set_diag",
193]
194
195_allowed_symbols_partitioned_variables = [
196    "PartitionedVariable",   # Requires doc link.
197    # Legacy.
198    "create_partitioned_variables",
199    "variable_axis_size_partitioner",
200    "min_max_variable_partitioner",
201    "fixed_size_partitioner",
202]
203
204_allowed_symbols_control_flow_ops = [
205    # TODO(drpng): Find a place in the documentation to reference these or
206    # remove.
207    "control_trigger",
208    "loop_cond",
209    "merge",
210    "switch",
211]
212
213_allowed_symbols_functional_ops = [
214    "nest",  # Used by legacy code.
215]
216
217_allowed_symbols_gradients = [
218    # Documented in training.py:
219    # Not importing training.py to avoid complex graph dependencies.
220    "AggregationMethod",
221    "gradients",  # tf.gradients = gradients.gradients
222    "hessians",
223]
224
225_allowed_symbols_clip_ops = [
226    # Documented in training.py:
227    # Not importing training.py to avoid complex graph dependencies.
228    "clip_by_average_norm",
229    "clip_by_global_norm",
230    "clip_by_norm",
231    "clip_by_value",
232    "global_norm",
233]
234
235_allowed_symbols_image_ops = [
236    # Documented in training.py.
237    # We are not importing training.py to avoid complex dependencies.
238    "audio_summary",
239    "histogram_summary",
240    "image_summary",
241    "merge_all_summaries",
242    "merge_summary",
243    "scalar_summary",
244
245    # TODO(drpng): link in training.py if it should be documented.
246    "get_summary_op",
247]
248
249_allowed_symbols_variable_scope_ops = [
250    "get_local_variable",  # Documented in framework package.
251]
252
253_allowed_symbols_misc = [
254    "deserialize_many_sparse",
255    "parse_single_sequence_example",
256    "serialize_many_sparse",
257    "serialize_sparse",
258    "confusion_matrix",
259]
260
261_allowed_symbols = (_allowed_symbols_array_ops +
262                    _allowed_symbols_clip_ops +
263                    _allowed_symbols_control_flow_ops +
264                    _allowed_symbols_functional_ops +
265                    _allowed_symbols_image_ops +
266                    _allowed_symbols_gradients +
267                    _allowed_symbols_math_ops +
268                    _allowed_symbols_variable_scope_ops +
269                    _allowed_symbols_misc +
270                    _allowed_symbols_partitioned_variables)
271
272remove_undocumented(__name__, _allowed_symbols, [
273    _sys.modules[__name__],
274    _array_ops,
275    _check_ops,
276    _clip_ops,
277    _confusion_matrix,
278    _control_flow_ops,
279    _constant_op,
280    _data_flow_ops,
281    _functional_ops,
282    _gradients,
283    _histogram_ops,
284    _init_ops,
285    _io_ops,
286    _linalg_ops,
287    _logging_ops,
288    _manip_ops,
289    _math_ops,
290    _numerics,
291    _parsing_ops,
292    _partitioned_variables,
293    _random_ops,
294    _script_ops,
295    _session_ops,
296    _sparse_ops,
297    _special_math_ops,
298    _state_ops,
299    _string_ops,
300    _template,
301    _tensor_array_ops,
302    _variable_scope,
303    _variables,
304])
305