If this graph contains functions, copy them to `graph_def`.
(self, graph_def, starting_bytesize)
| 3121 | self._control_flow_context = ctx |
| 3122 | |
| 3123 | def _copy_functions_to_graph_def(self, graph_def, starting_bytesize): |
| 3124 | """If this graph contains functions, copy them to `graph_def`.""" |
| 3125 | bytesize = starting_bytesize |
| 3126 | for f in self._functions.values(): |
| 3127 | bytesize += f.definition.ByteSize() |
| 3128 | if bytesize >= (1 << 31) or bytesize < 0: |
| 3129 | raise ValueError("GraphDef cannot be larger than 2GB.") |
| 3130 | graph_def.library.function.extend([f.definition]) |
| 3131 | if f.grad_func_name: |
| 3132 | grad_def = function_pb2.GradientDef() |
| 3133 | grad_def.function_name = f.name |
| 3134 | grad_def.gradient_func = f.grad_func_name |
| 3135 | graph_def.library.gradient.extend([grad_def]) |
| 3136 | |
| 3137 | def _as_graph_def(self, from_version=None, add_shapes=False): |
| 3138 | # pylint: disable=line-too-long |
no test coverage detected