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

Function func_graph_from_py_func

tensorflow/python/framework/func_graph.py:736–961  ·  view source on GitHub ↗

Returns a `FuncGraph` generated from `python_func`. Args: name: an identifier for the function. python_func: the Python function to trace. args: the positional args with which the Python function should be called; ignored if a signature is provided. kwargs: the keyword args

(name,
                            python_func,
                            args,
                            kwargs,
                            signature=None,
                            func_graph=None,
                            autograph=False,
                            autograph_options=None,
                            add_control_dependencies=True,
                            arg_names=None,
                            op_return_value=None,
                            collections=None,
                            capture_by_value=None,
                            override_flat_arg_shapes=None)

Source from the content-addressed store, hash-verified

734
735
736def func_graph_from_py_func(name,
737 python_func,
738 args,
739 kwargs,
740 signature=None,
741 func_graph=None,
742 autograph=False,
743 autograph_options=None,
744 add_control_dependencies=True,
745 arg_names=None,
746 op_return_value=None,
747 collections=None,
748 capture_by_value=None,
749 override_flat_arg_shapes=None):
750 """Returns a `FuncGraph` generated from `python_func`.
751
752 Args:
753 name: an identifier for the function.
754 python_func: the Python function to trace.
755 args: the positional args with which the Python function should be called;
756 ignored if a signature is provided.
757 kwargs: the keyword args with which the Python function should be called;
758 ignored if a signature is provided.
759 signature: a possibly nested sequence of `TensorSpecs` specifying the shapes
760 and dtypes of the arguments. When a signature is provided, `args` and
761 `kwargs` are ignored, and `python_func` is traced with Tensors conforming
762 to `signature`. If `None`, the shapes and dtypes are inferred from the
763 inputs.
764 func_graph: Optional. An instance of FuncGraph. If provided, we will use
765 this graph else a new one is built and returned.
766 autograph: whether to use autograph to compile `python_func`.
767 See https://www.tensorflow.org/guide/autograph for more information.
768 autograph_options: additional knobs to control when `autograph=True`.
769 See https://www.tensorflow.org/guide/autograph for more information.
770 add_control_dependencies: If True, automatically adds control dependencies
771 to ensure program order matches execution order and stateful ops always
772 execute.
773 arg_names: Optional list of argument names, used to give input placeholders
774 recognizable names.
775 op_return_value: Optional. A Tensor. If set and `python_func` returns
776 Operations, those return values will be replaced with this value. If not
777 set, returning an Operation triggers an error.
778 collections: a dictionary of collections this FuncGraph should start
779 with. If not specified (None), the FuncGraph will read (but not write to)
780 the outer graph's collections that are not whitelisted, and both
781 read and write to the outer graph's collections that are whitelisted.
782 The current whitelisted collections are the global variables, the
783 local variables, and the trainable variables.
784 Defaults to None.
785 capture_by_value: An optional boolean. If True, the func graph will capture
786 Variables by value instead of reference. By default inherit from outer
787 graphs, and failing that will default to False.
788 override_flat_arg_shapes: An optional list of instances that are either
789 `None` or `TensorShape`. The length must match that of
790 `nest.flatten((args, kwargs), expand_composites=True)`. The entries
791 containing value `None` must match entries in flattened arguments
792 containing non-tensors, while entries containing a `TensorShape` must
793 match entries in the flattened arguments containing tensors.

Callers

nothing calls this directly

Calls 15

as_defaultMethod · 0.95
pop_captureMethod · 0.95
addMethod · 0.95
captureMethod · 0.95
FuncGraphClass · 0.85
check_mutationFunction · 0.85
set_use_resourceMethod · 0.80
unwrapMethod · 0.80

Tested by

no test coverage detected