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

Function _ones

tensorflow/python/eager/backprop.py:657–672  ·  view source on GitHub ↗
(shape, dtype)

Source from the content-addressed store, hash-verified

655
656
657def _ones(shape, dtype):
658 as_dtype = dtypes.as_dtype(dtype)
659 if as_dtype == dtypes.string:
660 return None
661
662 if not context.context().executing_eagerly():
663 return array_ops.ones(shape, dtype)
664
665 if as_dtype.is_bool:
666 value = True
667 else:
668 value = 1
669
670 if shape == (): # pylint: disable=g-explicit-bool-comparison
671 return constant_op.constant(value, dtype=dtype)
672 return _fast_fill(value, shape, dtype)
673
674
675_default_vspace = imperative_grad.VSpace(

Callers

nothing calls this directly

Calls 5

_fast_fillFunction · 0.85
executing_eagerlyMethod · 0.80
onesMethod · 0.80
contextMethod · 0.45
constantMethod · 0.45

Tested by

no test coverage detected