Returns the `OpDef` proto for `type`. `type` is a string.
(self, type)
| 3821 | return self._next_id_counter |
| 3822 | |
| 3823 | def _get_op_def(self, type): # pylint: disable=redefined-builtin |
| 3824 | """Returns the `OpDef` proto for `type`. `type` is a string.""" |
| 3825 | # NOTE: No locking is required because the lookup and insertion operations |
| 3826 | # on Python dictionaries are atomic. |
| 3827 | try: |
| 3828 | return self._op_def_cache[type] |
| 3829 | except KeyError: |
| 3830 | with c_api_util.tf_buffer() as buf: |
| 3831 | # pylint: disable=protected-access |
| 3832 | c_api.TF_GraphGetOpDef(self._c_graph, compat.as_bytes(type), buf) |
| 3833 | # pylint: enable=protected-access |
| 3834 | data = c_api.TF_GetBuffer(buf) |
| 3835 | op_def = op_def_pb2.OpDef() |
| 3836 | op_def.ParseFromString(compat.as_bytes(data)) |
| 3837 | self._op_def_cache[type] = op_def |
| 3838 | return op_def |
| 3839 | |
| 3840 | def as_default(self): |
| 3841 | """Returns a context manager that makes this `Graph` the default graph. |
no test coverage detected