Python tensorflow.python.pywrap_tensorflow.TF_DeleteBuffer() Examples

The following are 1 code examples of tensorflow.python.pywrap_tensorflow.TF_DeleteBuffer(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module tensorflow.python.pywrap_tensorflow , or try the search function .
Example #1
Source File: c_api_util.py    From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License 6 votes vote down vote up
def tf_buffer():
  """Context manager that creates and deletes TF_Buffer.

  Example usage:
    wtih tf_buffer() as buf:
      # get serialized graph def into buf
      ...
      proto_data = c_api.TF_GetBuffer(buf)
      graph_def.ParseFromString(compat.as_bytes(proto_data))
    # buf has been deleted

  Yields:
    Created TF_Buffer
  """
  buf = c_api.TF_NewBuffer()
  try:
    yield buf
  finally:
    c_api.TF_DeleteBuffer(buf)