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)
| 411 | |
| 412 | |
| 413 | def 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 | |
| 451 | def make_placeholder_from_tensor(t, scope=None, |
no test coverage detected