MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / placeholder_name

Function placeholder_name

tensorflow/contrib/graph_editor/util.py:413–448  ·  view source on GitHub ↗

Create placeholder name for the graph editor. Args: t: optional tensor on which the placeholder operation's name will be based on scope: absolute scope with which to prefix the placeholder's name. None means that the scope of t is preserved. "" means the root scope. prefix

(t=None, scope=None, prefix=_DEFAULT_PLACEHOLDER_PREFIX)

Source from the content-addressed store, hash-verified

411
412
413def placeholder_name(t=None, scope=None, prefix=_DEFAULT_PLACEHOLDER_PREFIX):
414 """Create placeholder name for the graph editor.
415
416 Args:
417 t: optional tensor on which the placeholder operation's name will be based
418 on
419 scope: absolute scope with which to prefix the placeholder's name. None
420 means that the scope of t is preserved. "" means the root scope.
421 prefix: placeholder name prefix.
422 Returns:
423 A new placeholder name prefixed by "geph". Note that "geph" stands for
424 Graph Editor PlaceHolder. This convention allows to quickly identify the
425 placeholder generated by the Graph Editor.
426 Raises:
427 TypeError: if t is not None or a tf.Tensor.
428 """
429 if scope is not None:
430 scope = scope_finalize(scope)
431 if t is not None:
432 if not isinstance(t, tf_ops.Tensor):
433 raise TypeError("Expected a tf.Tenfor, got: {}".format(type(t)))
434 op_dirname = scope_dirname(t.op.name)
435 op_basename = scope_basename(t.op.name)
436 if scope is None:
437 scope = op_dirname
438
439 if op_basename.startswith("{}__".format(prefix)):
440 ph_name = op_basename
441 else:
442 ph_name = "{}__{}_{}".format(prefix, op_basename, t.value_index)
443
444 return scope + ph_name
445 else:
446 if scope is None:
447 scope = ""
448 return "{}{}".format(scope, prefix)
449
450
451def make_placeholder_from_tensor(t, scope=None,

Calls 5

scope_finalizeFunction · 0.85
typeFunction · 0.85
scope_dirnameFunction · 0.85
scope_basenameFunction · 0.85
formatMethod · 0.45

Tested by

no test coverage detected