Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/tensorflow/python/__init__.py: 100%

91 statements  

« prev     ^ index     » next       coverage.py v7.4.0, created at 2024-01-03 07:57 +0000

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"""Import core names of TensorFlow. 

16 

17Programs that want to build TensorFlow Ops and Graphs without having to import 

18the constructors and utilities individually can import this file: 

19 

20 

21import tensorflow as tf 

22""" 

23 

24import ctypes 

25import importlib 

26import sys 

27import traceback 

28 

29# We aim to keep this file minimal and ideally remove completely. 

30# If you are adding a new file with @tf_export decorators, 

31# import it in modules_with_exports.py instead. 

32 

33# go/tf-wildcard-import 

34# pylint: disable=wildcard-import,g-bad-import-order,g-import-not-at-top 

35 

36from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow 

37from tensorflow.python.eager import context 

38 

39# pylint: enable=wildcard-import 

40 

41# Bring in subpackages. 

42from tensorflow.python import data 

43from tensorflow.python import distribute 

44# from tensorflow.python import keras 

45from tensorflow.python.feature_column import feature_column_lib as feature_column 

46# from tensorflow.python.layers import layers 

47from tensorflow.python.module import module 

48from tensorflow.python.ops import bincount_ops 

49from tensorflow.python.ops import bitwise_ops as bitwise 

50from tensorflow.python.ops import cond_v2 

51from tensorflow.python.ops import composite_tensor_ops 

52from tensorflow.python.ops import gradient_checker_v2 

53from tensorflow.python.ops import image_ops as image 

54from tensorflow.python.ops import manip_ops as manip 

55from tensorflow.python.ops import metrics 

56from tensorflow.python.ops import nn 

57from tensorflow.python.ops import numpy_ops 

58from tensorflow.python.ops import ragged 

59from tensorflow.python.ops import sets 

60from tensorflow.python.ops import stateful_random_ops 

61from tensorflow.python.ops import while_v2 

62from tensorflow.python.ops.distributions import distributions 

63from tensorflow.python.ops.linalg import linalg 

64from tensorflow.python.ops.linalg.sparse import sparse 

65from tensorflow.python.ops.losses import losses 

66from tensorflow.python.ops.ragged import ragged_ops as _ragged_ops 

67from tensorflow.python.ops.signal import signal 

68from tensorflow.python.ops.structured import structured_ops as _structured_ops 

69from tensorflow.python.profiler import profiler 

70from tensorflow.python.profiler import profiler_client 

71from tensorflow.python.profiler import profiler_v2 

72from tensorflow.python.profiler import trace 

73from tensorflow.python.saved_model import saved_model 

74from tensorflow.python.summary import summary 

75from tensorflow.python.tpu import api 

76from tensorflow.python.user_ops import user_ops 

77from tensorflow.python.util import compat 

78 

79# Update the RaggedTensor package docs w/ a list of ops that support dispatch. 

80ragged.__doc__ += _ragged_ops.ragged_dispatch.ragged_op_list() 

81 

82# Import to make sure the ops are registered. 

83from tensorflow.python.ops import gen_audio_ops 

84from tensorflow.python.ops import gen_boosted_trees_ops 

85from tensorflow.python.ops import gen_cudnn_rnn_ops 

86from tensorflow.python.ops import gen_rnn_ops 

87from tensorflow.python.ops import gen_sendrecv_ops 

88from tensorflow.python.ops import gen_tpu_ops 

89from tensorflow.python.ops import gen_uniform_quant_ops 

90 

91# Import the names from python/training.py as train.Name. 

92from tensorflow.python.training import training as train 

93from tensorflow.python.training import quantize_training as _quantize_training 

94 

95# Sub-package for performing i/o directly instead of via ops in a graph. 

96from tensorflow.python.lib.io import python_io 

97 

98# Make some application and test modules available. 

99from tensorflow.python.platform import app 

100from tensorflow.python.platform import flags 

101from tensorflow.python.platform import gfile 

102from tensorflow.python.platform import tf_logging as logging 

103from tensorflow.python.platform import resource_loader 

104from tensorflow.python.platform import sysconfig as sysconfig_lib 

105from tensorflow.python.platform import test 

106 

107from tensorflow.python.compat import v2_compat 

108 

109from tensorflow.python.util.all_util import make_all 

110from tensorflow.python.util.tf_export import tf_export 

111 

112# Eager execution 

113from tensorflow.python.eager.context import executing_eagerly 

114from tensorflow.python.eager.remote import connect_to_remote_host 

115from tensorflow.python.eager.def_function import function 

116from tensorflow.python.framework.ops import enable_eager_execution 

117 

118# Check whether TF2_BEHAVIOR is turned on. 

119from tensorflow.python.eager import monitoring as _monitoring 

120from tensorflow.python import tf2 as _tf2 

121_tf2_gauge = _monitoring.BoolGauge( 

122 '/tensorflow/api/tf2_enable', 'Environment variable TF2_BEHAVIOR is set".') 

123_tf2_gauge.get_cell().set(_tf2.enabled()) 

124 

125# Necessary for the symbols in this module to be taken into account by 

126# the namespace management system (API decorators). 

127from tensorflow.python.ops import rnn 

128from tensorflow.python.ops import rnn_cell 

129 

130# TensorFlow Debugger (tfdbg). 

131from tensorflow.python.debug.lib import check_numerics_callback 

132from tensorflow.python.debug.lib import dumping_callback 

133from tensorflow.python.ops import gen_debug_ops 

134 

135# DLPack 

136from tensorflow.python.dlpack.dlpack import from_dlpack 

137from tensorflow.python.dlpack.dlpack import to_dlpack 

138 

139# XLA JIT compiler APIs. 

140from tensorflow.python.compiler.xla import jit 

141from tensorflow.python.compiler.xla import xla 

142 

143# MLIR APIs. 

144from tensorflow.python.compiler.mlir import mlir 

145 

146# Structs (aka extension types) 

147from tensorflow.python.framework import extension_type as _extension_type 

148 

149# Required due to `rnn` and `rnn_cell` not being imported in `nn` directly 

150# (due to a circular dependency issue: rnn depends on layers). 

151nn.dynamic_rnn = rnn.dynamic_rnn 

152nn.static_rnn = rnn.static_rnn 

153nn.raw_rnn = rnn.raw_rnn 

154nn.bidirectional_dynamic_rnn = rnn.bidirectional_dynamic_rnn 

155nn.static_state_saving_rnn = rnn.static_state_saving_rnn 

156nn.rnn_cell = rnn_cell 

157 

158# Update dispatch decorator docstrings to contain lists of registered APIs. 

159# (This should come after any imports that register APIs.) 

160from tensorflow.python.util import dispatch 

161dispatch.update_docstrings_with_api_lists() 

162 

163# Special dunders that we choose to export: 

164_exported_dunders = set([ 

165 '__version__', 

166 '__git_version__', 

167 '__compiler_version__', 

168 '__cxx11_abi_flag__', 

169 '__monolithic_build__', 

170]) 

171 

172# Expose symbols minus dunders, unless they are allowlisted above. 

173# This is necessary to export our dunders. 

174__all__ = [s for s in dir() if s in _exported_dunders or not s.startswith('_')]