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

Method __init__

tensorflow/python/ops/data_flow_ops.py:920–998  ·  view source on GitHub ↗

Creates a barrier that persists across different graph executions. A barrier represents a key-value map, where each key is a string, and each value is a tuple of tensors. At runtime, the barrier contains 'complete' and 'incomplete' elements. A complete element has defined tensors f

(self, types, shapes=None, shared_name=None, name="barrier")

Source from the content-addressed store, hash-verified

918 """Represents a key-value map that persists across graph executions."""
919
920 def __init__(self, types, shapes=None, shared_name=None, name="barrier"):
921 """Creates a barrier that persists across different graph executions.
922
923 A barrier represents a key-value map, where each key is a string, and
924 each value is a tuple of tensors.
925
926 At runtime, the barrier contains 'complete' and 'incomplete'
927 elements. A complete element has defined tensors for all
928 components of its value tuple, and may be accessed using
929 take_many. An incomplete element has some undefined components in
930 its value tuple, and may be updated using insert_many.
931
932 The barrier call `take_many` outputs values in a particular order.
933 First, it only outputs completed values. Second, the order in which
934 completed values are returned matches the order in which their very
935 first component was inserted into the barrier. So, for example, for this
936 sequence of insertions and removals:
937
938 barrier = Barrier((tf.string, tf.int32), shapes=((), ()))
939 barrier.insert_many(0, keys=["k1", "k2"], values=["a", "b"]).run()
940 barrier.insert_many(1, keys=["k1"], values=[1]).run()
941 barrier.insert_many(0, keys=["k3"], values=["c"]).run()
942 barrier.insert_many(1, keys=["k3"], values=[3]).run()
943 barrier.insert_many(1, keys=["k2"], values=[2]).run()
944
945 (indices, keys, values) = barrier.take_many(2)
946 (indices_val, keys_val, values0_val, values1_val) =
947 session.run([indices, keys, values[0], values[1]])
948
949 The output will be (up to permutation of "k1" and "k2"):
950
951 indices_val == (-2**63, -2**63)
952 keys_val == ("k1", "k2")
953 values0_val == ("a", "b")
954 values1_val == (1, 2)
955
956 Note the key "k2" was inserted into the barrier before "k3". Even though
957 "k3" was completed first, both are complete by the time
958 take_many is called. As a result, "k2" is prioritized and "k1" and "k2"
959 are returned first. "k3" remains in the barrier until the next execution
960 of `take_many`. Since "k1" and "k2" had their first insertions into
961 the barrier together, their indices are the same (-2**63). The index
962 of "k3" will be -2**63 + 1, because it was the next new inserted key.
963
964 Args:
965 types: A single dtype or a tuple of dtypes, corresponding to the
966 dtypes of the tensor elements that comprise a value in this barrier.
967 shapes: Optional. Constraints on the shapes of tensors in the values:
968 a single tensor shape tuple; a tuple of tensor shape tuples
969 for each barrier-element tuple component; or None if the shape should
970 not be constrained.
971 shared_name: Optional. If non-empty, this barrier will be shared under
972 the given name across multiple sessions.
973 name: Optional name for the barrier op.
974
975 Raises:
976 ValueError: If one of the `shapes` indicate no elements.
977 """

Callers 8

__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45

Calls 8

_as_type_listFunction · 0.85
_as_shape_listFunction · 0.85
unknown_shapeMethod · 0.80
executing_eagerlyMethod · 0.80
num_elementsMethod · 0.45
barrierMethod · 0.45
contextMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected