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

Class FuncGraph

tensorflow/python/framework/func_graph.py:140–733  ·  view source on GitHub ↗

Graph representing a function body. Attributes: name: The name of the function. inputs: Placeholder tensors representing the inputs to this function. The tensors are in this FuncGraph. This represents "regular" inputs as well as captured inputs (i.e. the values of self.capture

Source from the content-addressed store, hash-verified

138
139
140class FuncGraph(ops.Graph):
141 """Graph representing a function body.
142
143 Attributes:
144 name: The name of the function.
145 inputs: Placeholder tensors representing the inputs to this function. The
146 tensors are in this FuncGraph. This represents "regular" inputs as well as
147 captured inputs (i.e. the values of self.captures), with the regular
148 inputs coming first.
149 outputs: Tensors that will be returned by this function. The tensors are in
150 this FuncGraph.
151 control_outputs: Operations that must be executed before the function
152 represented by this graph can be said to have been executed.
153 structured_input_signature: A tuple of (args, kwargs), which are both
154 possibly-nested python objects that were received by this function. Note
155 that these structures might contain Python `None`s.
156 structured_outputs: A possibly-nested python object which will be returned
157 by this function. The Tensors in this structure are the same as those of
158 self.outputs. Note that this structure might contain Python `None`s.
159 variables: Variables that should be watched during function execution.
160 outer_graph: The graph this function is defined in. May be another FuncGraph
161 or the global default Graph.
162 captures: Maps external tensor -> internal tensor (i.e. input placeholder).
163 The entries are in the order they were captured.
164 control_captures: Set of external ops on which this graph has a control
165 dependency.
166 seed: The graph-level random seed.
167 capture_by_value: If True, the func graph will capture Variables by value
168 instead of reference.
169 """
170
171 def __init__(self, name, collections=None, capture_by_value=None):
172 """Construct a new FuncGraph.
173
174 The graph will inherit its graph key, collections, seed, and distribution
175 strategy stack from the current context or graph.
176
177 Args:
178 name: the name of the function.
179 collections: a dictionary of collections this FuncGraph should start
180 with. If not specified (None), the FuncGraph will read (but not write
181 to) the outer graph's collections that are not whitelisted, and both
182 read and write to the outer graph's collections that are whitelisted.
183 The current whitelisted collections are the global variables, the
184 local variables, and the trainable variables.
185 Defaults to None.
186 capture_by_value: An optional boolean. If True, the func graph will
187 capture Variables by value instead of reference. By default inherit
188 from outer graphs, and failing that will default to False.
189 """
190 super(FuncGraph, self).__init__()
191
192 self.name = name
193 self.inputs = []
194 self.outputs = []
195 self.control_outputs = []
196 self.control_captures = set()
197 self.structured_input_signature = None

Callers 2

function_def_to_graphFunction · 0.90
func_graph_from_py_funcFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected