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

Method _create_graph_function

tensorflow/python/eager/function.py:2012–2045  ·  view source on GitHub ↗

Create a `ConcreteFunction` from `args` and `kwargs`.

(self, args, kwargs, override_flat_arg_shapes=None)

Source from the content-addressed store, hash-verified

2010 colocation_stack, in_cross_replica_context)
2011
2012 def _create_graph_function(self, args, kwargs, override_flat_arg_shapes=None):
2013 """Create a `ConcreteFunction` from `args` and `kwargs`."""
2014 if self.input_signature is None:
2015 arglen = len(args)
2016 else:
2017 arglen = len(self.input_signature)
2018 base_arg_names = self._function_spec.arg_names[:arglen]
2019 num_missing_args = arglen - len(self._function_spec.arg_names)
2020 missing_arg_names = [self._function_spec.vararg_name] * num_missing_args
2021 # Produce a list of missing args of the form ["arg_0", "arg_1", ...],
2022 # where arg is based on the self._function_spec.vararg_name.
2023 missing_arg_names = [
2024 "%s_%d" % (arg, i) for i, arg in enumerate(missing_arg_names)
2025 ]
2026 arg_names = base_arg_names + missing_arg_names
2027 graph_function = ConcreteFunction(
2028 func_graph_module.func_graph_from_py_func(
2029 self._name,
2030 self._python_function,
2031 args,
2032 kwargs,
2033 self.input_signature,
2034 autograph=self._autograph,
2035 autograph_options=self._autograph_options,
2036 arg_names=arg_names,
2037 override_flat_arg_shapes=override_flat_arg_shapes,
2038 capture_by_value=self._capture_by_value),
2039 self._function_attributes,
2040 # Tell the ConcreteFunction to clean up its graph once it goes out of
2041 # scope. This is not the default behavior since it gets used in some
2042 # places (like Keras) where the FuncGraph lives longer than the
2043 # ConcreteFunction.
2044 shared_func_graph=False)
2045 return graph_function
2046
2047 def _define_function_with_shape_relaxation(self, args, kwargs):
2048 """Define a function, relaxing arg shapes to avoid unecessary retracing."""

Calls 1

ConcreteFunctionClass · 0.85

Tested by

no test coverage detected