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

Method wrapped_fn

tensorflow/python/eager/def_function.py:318–335  ·  view source on GitHub ↗

Wraps `self._python_function` in a variable creator scope.

(*args, **kwds)

Source from the content-addressed store, hash-verified

316
317 weak_wrapped_fn = None
318 def wrapped_fn(*args, **kwds):
319 """Wraps `self._python_function` in a variable creator scope."""
320 # We register a variable creator with reduced priority. If an outer
321 # variable creator is just modifying keyword arguments to the variable
322 # constructor, this will work harmoniously. Since the `scope` registered
323 # here actually creates the variable, it taking priority would otherwise
324 # ignore the outer creator.
325 #
326 # If an outer variable creator calls the variable constructor manually,
327 # for example creating a MirroredVariable, then they won't call our
328 # creator. This means we won't be able to trace the initialization graph,
329 # and so variable initializers can't depend on function arguments. This is
330 # better than the alternative, tracing the initialization graph but giving
331 # the user a variable type they didn't want.
332 with ops.get_default_graph()._variable_creator_scope(scope, priority=50): # pylint: disable=protected-access
333 # __wrapped__ allows AutoGraph to swap in a converted function. We give
334 # the function a weak reference to itself to avoid a reference cycle.
335 return weak_wrapped_fn().__wrapped__(*args, **kwds)
336 weak_wrapped_fn = weakref.ref(wrapped_fn)
337
338 return self._defun(tf_decorator.make_decorator(

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected