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

19 statements  

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

1# Copyright 2016 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"""Conversion of eager-style Python into TensorFlow graph code. 

16 

17NOTE: In TensorFlow 2.0, AutoGraph is automatically applied when using 

18`tf.function`. This module contains lower-level APIs for advanced use. 

19 

20AutoGraph transforms a subset of Python which operates on TensorFlow objects 

21into equivalent TensorFlow graph code. When executing the graph, it has the same 

22effect as if you ran the original code in eager mode. 

23Python code which doesn't operate on TensorFlow objects remains functionally 

24unchanged, but keep in mind that `tf.function` only executes such code at trace 

25time, and generally will not be consistent with eager execution. 

26 

27For more information, see the 

28[AutoGraph reference documentation](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/autograph/g3doc/reference/index.md), 

29and the [tf.function guide](https://www.tensorflow.org/guide/function#autograph_transformations). 

30""" 

31 

32# TODO(mdan): Bring only the relevant symbols to the top level. 

33from tensorflow.python.autograph import operators 

34from tensorflow.python.autograph import utils 

35from tensorflow.python.autograph.core.converter import ConversionOptions 

36from tensorflow.python.autograph.core.converter import Feature 

37from tensorflow.python.autograph.impl.api import AutoGraphError 

38from tensorflow.python.autograph.impl.api import convert 

39from tensorflow.python.autograph.impl.api import converted_call 

40from tensorflow.python.autograph.impl.api import do_not_convert 

41from tensorflow.python.autograph.impl.api import StackTraceMapper 

42from tensorflow.python.autograph.impl.api import to_code 

43from tensorflow.python.autograph.impl.api import to_graph 

44from tensorflow.python.autograph.lang.directives import set_element_type 

45from tensorflow.python.autograph.lang.directives import set_loop_options 

46from tensorflow.python.autograph.lang.special_functions import stack 

47from tensorflow.python.autograph.utils import ag_logging 

48from tensorflow.python.util.all_util import remove_undocumented 

49 

50# TODO(mdan): Revisit this list once we finalize the generated code mechanism. 

51_allowed_symbols = [ 

52 # Main API 

53 'AutoGraphError', 

54 'ConversionOptions', 

55 'Feature', 

56 'StackTraceMapper', 

57 'convert', 

58 'converted_call', 

59 'do_not_convert', 

60 'to_code', 

61 'to_graph', 

62 # Overloaded operators 

63 'operators', 

64 # Python language "extensions" 

65 'set_element_type', 

66 'set_loop_options', 

67 'stack', 

68 'tensor_list', 

69 # Utilities: to be removed 

70 'utils', 

71] 

72 

73remove_undocumented(__name__, _allowed_symbols)