Ejemplo n.º 1
0
def assign_renamed_collections_handler(info, elem, elem_):
  """Add the transformed elem to the (renamed) collections of elem.

  A collection is renamed only if is not a known key, as described in
  `tf.GraphKeys`.

  Args:
    info: Transform._TmpInfo instance.
    elem: the original element (`tf.Tensor` or `tf.Operation`)
    elem_: the transformed element
  """
  known_collection_names = util.get_predefined_collection_names()
  for name, collection in iteritems(info.collections):
    if elem not in collection:
      continue

    if name in known_collection_names:
      transformed_name = name
    else:
      transformed_name = info.new_name(name)
    info.graph_.add_to_collection(transformed_name, elem_)
Ejemplo n.º 2
0
def assign_renamed_collections_handler(info, elem, elem_):
    """Add the transformed elem to the (renamed) collections of elem.

  A collection is renamed only if is not a known key, as described in
  `tf.GraphKeys`.

  Args:
    info: Transform._TmpInfo instance.
    elem: the original element (`tf.Tensor` or `tf.Operation`)
    elem_: the transformed element
  """
    known_collection_names = util.get_predefined_collection_names()
    for name, collection in iteritems(info.collections):
        if elem not in collection:
            continue

        if name in known_collection_names:
            transformed_name = name
        else:
            transformed_name = info.new_name(name)
        info.graph_.add_to_collection(transformed_name, elem_)