parameters: (filename)
return_statement: return graph_def
docstring: Reads a file containing `GraphDef` and returns the protocol buffer.
  
    Args:
      filename: `graph_def` filename including the path.
  
    Returns:
      A `GraphDef` protocol buffer.
  
    Raises:
      IOError: If the file doesn't exist, or cannot be successfully parsed.
docstring_summary: Reads a file containing `GraphDef` and returns the protocol buffer.
docstring_tokens: Reads a file containing GraphDef and returns the protocol buffer .
function: def _read_file(filename):
    """Reads a file containing `GraphDef` and returns the protocol buffer.
  
    Args:
      filename: `graph_def` filename including the path.
  
    Returns:
      A `GraphDef` protocol buffer.
  
    Raises:
      IOError: If the file doesn't exist, or cannot be successfully parsed.
    """
    graph_def = graph_pb2.GraphDef()
    if not file_io.file_exists(filename):
      raise IOError("File %s does not exist." % filename)
    # First try to read it as a binary file.
    file_content = file_io.FileIO(filename, "rb").read()
    try:
      graph_def.ParseFromString(file_content)
      return graph_def
    except Exception:  # pylint: disable=broad-except
      pass
  
    # Next try to read it as a text file.
    try:
      text_format.Merge(file_content, graph_def)
    except text_format.ParseError as e:
      raise IOError("Cannot parse file %s: %s." % (filename, str(e)))
  
    return graph_def
function_tokens: def _read_file ( filename ) : graph_def = graph_pb2 . GraphDef ( ) if not file_io . file_exists ( filename ) : raise IOError ( "File %s does not exist." % filename ) # First try to read it as a binary file. file_content = file_io . FileIO ( filename , "rb" ) . read ( ) try : graph_def . ParseFromString ( file_content ) return graph_def except Exception : # pylint: disable=broad-except pass # Next try to read it as a text file. try : text_format . Merge ( file_content , graph_def ) except text_format . ParseError as e : raise IOError ( "Cannot parse file %s: %s." % ( filename , str ( e ) ) ) return graph_def