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

Function _lift_single_variable

tensorflow/python/eager/wrap_function.py:122–142  ·  view source on GitHub ↗

Lifts `old_variable` out of the `FuncGraph` `graph`.

(old_variable, graph, variable_holder)

Source from the content-addressed store, hash-verified

120
121
122def _lift_single_variable(old_variable, graph, variable_holder):
123 """Lifts `old_variable` out of the `FuncGraph` `graph`."""
124 new_variable = resource_variable_ops.UninitializedVariable(
125 shape=old_variable.shape,
126 dtype=old_variable.dtype,
127 name=old_variable.op.name,
128 trainable=old_variable.trainable,
129 extra_handle_data=old_variable.handle)
130 new_variable._initializer_op = old_variable._initializer_op # pylint: disable=protected-access
131 graph.add_capture(new_variable.handle, old_variable.handle)
132 # Now that we've added the new variable to graph.captures,
133 # graph.capture will use that cached value and do some post-processing
134 # on the capture like recording it on the tape.
135 graph.capture(new_variable.handle)
136 # pylint: disable=protected-access
137 variable_name = new_variable.name.split(":")[0]
138 variable_holder._variables_by_name[variable_name] = new_variable
139 graph._weak_variables.append(weakref.ref(new_variable))
140 # pylint: enable=protected-access
141 graph.watch_variable(new_variable)
142 return new_variable
143
144
145def _lift_unlifted_variables(graph, variable_holder):

Callers 1

_lift_unlifted_variablesFunction · 0.85

Calls 6

add_captureMethod · 0.80
refMethod · 0.80
watch_variableMethod · 0.80
captureMethod · 0.45
splitMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected