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

Function replicate

tensorflow/python/data/experimental/ops/distribute.py:126–149  ·  view source on GitHub ↗

A transformation that replicates `dataset` onto a list of devices. Args: dataset: A `tf.data.Dataset` object. devices: A list of devices to replicate the dataset on. Returns: A dictionary mapping device name to a dataset on that device.

(dataset, devices)

Source from the content-addressed store, hash-verified

124
125
126def replicate(dataset, devices):
127 """A transformation that replicates `dataset` onto a list of devices.
128
129 Args:
130 dataset: A `tf.data.Dataset` object.
131 devices: A list of devices to replicate the dataset on.
132
133 Returns:
134 A dictionary mapping device name to a dataset on that device.
135 """
136 if not isinstance(dataset, dataset_ops.DatasetV2):
137 raise TypeError("`dataset` must be a `tf.data.Dataset` object.")
138
139 # pylint: disable=protected-access
140 with ops.colocate_with(dataset._variant_tensor):
141 dataset = dataset._apply_options()
142 stateful_whitelist = dataset.options().experimental_stateful_whitelist
143 graph_def = dataset._as_serialized_graph(
144 stateful_whitelist=stateful_whitelist)
145 datasets = {}
146 for device in devices:
147 ds = _RemoteDataset(graph_def, device, dataset.element_spec)
148 datasets[device] = ds
149 return datasets
150
151
152_AutoShardDatasetV1.__doc__ = _AutoShardDataset.__doc__

Callers

nothing calls this directly

Calls 5

_RemoteDatasetClass · 0.85
colocate_withMethod · 0.80
_apply_optionsMethod · 0.80
_as_serialized_graphMethod · 0.80
optionsMethod · 0.45

Tested by

no test coverage detected