
UXc           @` sY   d  Z  d d l m Z d d l m Z d d l m Z d d l m Z d d d  Z d	 S(
   sA   Graph post-processing logic. Used by both TensorBoard and mldash.i    (   t   absolute_import(   t   division(   t   print_function(   t   compati   t   _too_large_attrsc         C` s   | d k	 rI | d k r' t d   n  | d k rI t d |   qI n  | d k	 r x |  j D] } t | j j    } xi | D]a } | j | j   } | | k s | d k  r | j | =| j | j j j t	 j
 |   q q Wq_ Wn  d S(   s  Prepares (modifies in-place) the graph to be served to the front-end.

  For now, it supports filtering out attributes that are
  too large to be shown in the graph UI.

  Args:
    graph: The GraphDef proto message.
    limit_attr_size: Maximum allowed size in bytes, before the attribute
        is considered large. Default is 1024 (1KB). Must be > 0 or None.
        If None, there will be no filtering.
    large_attrs_key: The attribute key that will be used for storing attributes
        that are too large. Default is '_too_large_attrs'. Must be != None if
        `limit_attr_size` is != None.

  Raises:
    ValueError: If `large_attrs_key is None` while `limit_attr_size != None`.
    ValueError: If `limit_attr_size` is defined, but <= 0.
  s<   large_attrs_key must be != None when limit_attr_size!= None.i    s&   limit_attr_size must be > 0, but is %dN(   t   Nonet
   ValueErrort   nodet   listt   attrt   keyst   ByteSizet   st   appendR   t   as_bytes(   t   grapht   limit_attr_sizet   large_attrs_keyR   R
   t   keyt   size(    (    sn   /tmp/pip-build-h1VYrz/tensorflow/tensorflow-1.0.1.data/purelib/tensorflow/tensorboard/backend/process_graph.pyt   prepare_graph_for_ui   s    
N(   t   __doc__t
   __future__R    R   R   t   tensorflow.python.utilR   R   (    (    (    sn   /tmp/pip-build-h1VYrz/tensorflow/tensorflow-1.0.1.data/purelib/tensorflow/tensorboard/backend/process_graph.pyt   <module>   s   