MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / __init__

Method __init__

tensorflow/python/framework/ops.py:2811–2927  ·  view source on GitHub ↗

Creates a new, empty Graph.

(self)

Source from the content-addressed store, hash-verified

2809 """
2810
2811 def __init__(self):
2812 """Creates a new, empty Graph."""
2813 # Protects core state that can be returned via public accessors.
2814 # Thread-safety is provided on a best-effort basis to support buggy
2815 # programs, and is not guaranteed by the public `tf.Graph` API.
2816 #
2817 # NOTE(mrry): This does not protect the various stacks. A warning will
2818 # be reported if these are used from multiple threads
2819 self._lock = threading.RLock()
2820 # The group lock synchronizes Session.run calls with methods that create
2821 # and mutate ops (e.g. Graph.create_op()). This synchronization is
2822 # necessary because it's illegal to modify an operation after it's been run.
2823 # The group lock allows any number of threads to mutate ops at the same time
2824 # but if any modification is going on, all Session.run calls have to wait.
2825 # Similarly, if one or more Session.run calls are going on, all mutate ops
2826 # have to wait until all Session.run calls have finished.
2827 self._group_lock = lock_util.GroupLock(num_groups=2)
2828 self._nodes_by_id = {} # GUARDED_BY(self._lock)
2829 self._next_id_counter = 0 # GUARDED_BY(self._lock)
2830 self._nodes_by_name = {} # GUARDED_BY(self._lock)
2831 self._version = 0 # GUARDED_BY(self._lock)
2832 # Maps a name used in the graph to the next id to use for that name.
2833 self._names_in_use = {}
2834 self._stack_state_is_thread_local = False
2835 self._thread_local = threading.local()
2836 # Functions that will be applied to choose a device if none is specified.
2837 # In TF2.x or after switch_to_thread_local(),
2838 # self._thread_local._device_function_stack is used instead.
2839 self._graph_device_function_stack = traceable_stack.TraceableStack()
2840 # GPU Stream that will be applied to choose a device
2841 # In TF2.x or after switch_to_thread_local(),
2842 # self._thread_local._gpu_stream_stack is used instead.
2843 self._graph_gpu_stream_stack = traceable_stack.TraceableStack()
2844 # Default original_op applied to new ops.
2845 self._default_original_op = None
2846 # Current control flow context. It could be either CondContext or
2847 # WhileContext defined in ops/control_flow_ops.py
2848 self._control_flow_context = None
2849 # A new node will depend of the union of all of the nodes in the stack.
2850 # In TF2.x or after switch_to_thread_local(),
2851 # self._thread_local._control_dependencies_stack is used instead.
2852 self._graph_control_dependencies_stack = []
2853 # Arbitrary collections of objects.
2854 self._collections = {}
2855 # The graph-level random seed
2856 self._seed = None
2857 # A dictionary of attributes that should be applied to all ops.
2858 self._attr_scope_map = {}
2859 # A map from op type to the kernel label that should be used.
2860 self._op_to_kernel_label_map = {}
2861 # A map from op type to an alternative op type that should be used when
2862 # computing gradients.
2863 self._gradient_override_map = {}
2864 # True if the graph is considered "finalized". In that case no
2865 # new operations can be added.
2866 self._finalized = False
2867 # Functions defined in the graph
2868 self._functions = collections.OrderedDict()

Callers 2

__init__Method · 0.45
__init__Method · 0.45

Calls 2

uidFunction · 0.85

Tested by

no test coverage detected