tensorflow/python/data/experimental/ops/distribute.py
def replicate(dataset, devices):
  """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.
  """
  if not isinstance(dataset, dataset_ops.DatasetV2):
    raise TypeError("`dataset` must be a `tf.data.Dataset` object.")

  # pylint: disable=protected-access
  dataset_device = dataset._variant_tensor.device

  datasets = {}
  if len(devices) == 1 and devices[0] == dataset_device:
    datasets[devices[0]] = dataset
    return datasets

  with ops.colocate_with(dataset._variant_tensor):
    dataset = dataset._apply_options()
    policy = dataset.options().experimental_external_state_policy
    if policy is None:
      policy = ExternalStatePolicy.WARN
    graph_def = dataset._as_serialized_graph(
        strip_device_assignment=True,
        external_state_policy=policy)
  for device in devices:
    ds = _RemoteDataset(graph_def, device, dataset.element_spec)
    datasets[device] = ds
  return datasets
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.
  
A transformation that replicates `dataset` onto a list of devices.
A transformation that replicates ` dataset ` onto a list of devices .
def replicate(dataset, devices):
  if not isinstance(dataset, dataset_ops.DatasetV2):
    raise TypeError("`dataset` must be a `tf.data.Dataset` object.")
  dataset_device = dataset._variant_tensor.device
  datasets = {}
  if len(devices) == 1 and devices[0] == dataset_device:
    datasets[devices[0]] = dataset
    return datasets
  with ops.colocate_with(dataset._variant_tensor):
    dataset = dataset._apply_options()
    policy = dataset.options().experimental_external_state_policy
    if policy is None:
      policy = ExternalStatePolicy.WARN
    graph_def = dataset._as_serialized_graph(
        strip_device_assignment=True,
        external_state_policy=policy)
  for device in devices:
    ds = _RemoteDataset(graph_def, device, dataset.element_spec)
    datasets[device] = ds
  return datasets
def replicate ( dataset , devices ) : if not isinstance ( dataset , dataset_ops . DatasetV2 ) : raise TypeError ( "`dataset` must be a `tf.data.Dataset` object." ) dataset_device = dataset . _variant_tensor . device datasets = { } if len ( devices ) == 1 and devices [ 0 ] == dataset_device : datasets [ devices [ 0 ] ] = dataset return datasets with ops . colocate_with ( dataset . _variant_tensor ) : dataset = dataset . _apply_options ( ) policy = dataset . options ( ) . experimental_external_state_policy if policy is None : policy = ExternalStatePolicy . WARN graph_def = dataset . _as_serialized_graph ( strip_device_assignment = True , external_state_policy = policy ) for device in devices : ds = _RemoteDataset ( graph_def , device , dataset . element_spec ) datasets [ device ] = ds return datasets
A transformation that replicates `dataset` onto a list of devices.
A transformation that replicates ` dataset ` onto a list of devices .
"""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.
  """ # pylint: disable=protected-access
A dictionary mapping device name to a dataset on that device.
A dictionary mapping device name to a dataset on that device .
dataset
A `tf.data.Dataset` object.
A ` tf . data . Dataset ` object .
devices
A list of devices to replicate the dataset on.
A list of devices to replicate the dataset on .