tf.tpu.experimental.Topology
Stay organized with collections
Save and categorize content based on your preferences.
Describes a set of TPU devices.
tf.tpu.experimental.Topology(
serialized=None, mesh_shape=None, device_coordinates=None
)
Represents both the shape of the physical mesh, and the mapping between
TensorFlow TPU devices to physical mesh coordinates.
Args |
serialized
|
A serialized TopologyProto , or None . If not None , the
serialized proto is parsed to discover the topology.
|
mesh_shape
|
A sequence of 4 positive integers, or None . If not None ,
the shape of the TPU topology, in number of cores. Ignored if
serialized is not None .
|
device_coordinates
|
A rank 3 numpy array that describes the mapping from
TensorFlow TPU devices to TPU fabric coordinates, or None . If
specified, array is a rank 3 int32 array with shape
[tasks, devices, axis] . tasks is the number of tasks in the TPU
cluster, devices is the number of TPU devices per task, and axis is
the number of axes in the TPU cluster topology. Each entry gives the
axis -th coordinate in the topology of a task/device pair. TPU
topologies are 4-dimensional, with dimensions (x, y, z, core number) .
This arg is ignored if serialized is not None`.
|
Raises |
ValueError
|
If serialized does not describe a well-formed topology.
|
ValueError
|
If serialized is None and mesh_shape is not a sequence
of 4 positive integers.
|
ValueError
|
If serialized is None and device_coordinates is not a
rank 3 numpy int32 array that describes a valid coordinate mapping.
|
Attributes |
device_coordinates
|
Describes the mapping from TPU devices to topology coordinates.
|
mesh_rank
|
Returns the number of dimensions in the mesh.
|
mesh_shape
|
A rank 1 int32 array describing the shape of the TPU topology.
|
missing_devices
|
Array of indices of missing devices.
|
num_tasks
|
Returns the number of TensorFlow tasks in the TPU slice.
|
num_tpus_per_task
|
Returns the number of TPU devices per task in the TPU slice.
|
Methods
cpu_device_name_at_coordinates
View source
cpu_device_name_at_coordinates(
device_coordinates, job=None
)
Returns the CPU device attached to a logical core.
serialized
View source
serialized()
Returns the serialized form of the topology.
task_ordinal_at_coordinates
View source
task_ordinal_at_coordinates(
device_coordinates
)
Returns the TensorFlow task number attached to device_coordinates
.
Args |
device_coordinates
|
An integer sequence describing a device's physical
coordinates in the TPU fabric.
|
Returns |
Returns the TensorFlow task number that contains the TPU device with those
physical coordinates.
|
tpu_device_name_at_coordinates
View source
tpu_device_name_at_coordinates(
device_coordinates, job=None
)
Returns the name of the TPU device assigned to a logical core.
tpu_device_ordinal_at_coordinates
View source
tpu_device_ordinal_at_coordinates(
device_coordinates
)
Returns the TensorFlow device number at device_coordinates
.
Args |
device_coordinates
|
An integer sequence describing a device's physical
coordinates in the TPU fabric.
|
Returns |
Returns the TensorFlow device number within the task corresponding to
attached to the device with those physical coordinates.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2023-10-06 UTC.
[null,null,["Last updated 2023-10-06 UTC."],[],[],null,["# tf.tpu.experimental.Topology\n\n\u003cbr /\u003e\n\n|---------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/tpu/topology.py#L39-L239) |\n\nDescribes a set of TPU devices.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.tpu.experimental.Topology`](https://www.tensorflow.org/api_docs/python/tf/tpu/experimental/Topology)\n\n\u003cbr /\u003e\n\n tf.tpu.experimental.Topology(\n serialized=None, mesh_shape=None, device_coordinates=None\n )\n\nRepresents both the shape of the physical mesh, and the mapping between\nTensorFlow TPU devices to physical mesh coordinates.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `serialized` | A serialized `TopologyProto`, or `None`. If not `None`, the serialized proto is parsed to discover the topology. |\n| `mesh_shape` | A sequence of 4 positive integers, or `None`. If not `None`, the shape of the TPU topology, in number of cores. Ignored if `serialized` is not `None`. |\n| `device_coordinates` | A rank 3 numpy array that describes the mapping from TensorFlow TPU devices to TPU fabric coordinates, or `None`. If specified, array is a rank 3 int32 array with shape `[tasks, devices, axis]`. `tasks` is the number of tasks in the TPU cluster, `devices` is the number of TPU devices per task, and `axis` is the number of axes in the TPU cluster topology. Each entry gives the `axis`-th coordinate in the topology of a task/device pair. TPU topologies are 4-dimensional, with dimensions `(x, y, z, core number)`. This arg is ignored if `serialized is not`None\\`. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|---------------------------------------------------------------------------------------------------------------------------------|\n| `ValueError` | If `serialized` does not describe a well-formed topology. |\n| `ValueError` | If `serialized` is `None` and `mesh_shape` is not a sequence of 4 positive integers. |\n| `ValueError` | If `serialized` is `None` and `device_coordinates` is not a rank 3 numpy int32 array that describes a valid coordinate mapping. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ---------- ||\n|----------------------|-----------------------------------------------------------------|\n| `device_coordinates` | Describes the mapping from TPU devices to topology coordinates. |\n| `mesh_rank` | Returns the number of dimensions in the mesh. |\n| `mesh_shape` | A rank 1 int32 array describing the shape of the TPU topology. |\n| `missing_devices` | Array of indices of missing devices. |\n| `num_tasks` | Returns the number of TensorFlow tasks in the TPU slice. |\n| `num_tpus_per_task` | Returns the number of TPU devices per task in the TPU slice. |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `cpu_device_name_at_coordinates`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/tpu/topology.py#L208-L211) \n\n cpu_device_name_at_coordinates(\n device_coordinates, job=None\n )\n\nReturns the CPU device attached to a logical core.\n\n### `serialized`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/tpu/topology.py#L229-L239) \n\n serialized()\n\nReturns the serialized form of the topology.\n\n### `task_ordinal_at_coordinates`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/tpu/topology.py#L182-L193) \n\n task_ordinal_at_coordinates(\n device_coordinates\n )\n\nReturns the TensorFlow task number attached to `device_coordinates`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|----------------------|-----------------------------------------------------------------------------------|\n| `device_coordinates` | An integer sequence describing a device's physical coordinates in the TPU fabric. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| Returns the TensorFlow task number that contains the TPU device with those physical coordinates. ||\n\n\u003cbr /\u003e\n\n### `tpu_device_name_at_coordinates`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/tpu/topology.py#L213-L217) \n\n tpu_device_name_at_coordinates(\n device_coordinates, job=None\n )\n\nReturns the name of the TPU device assigned to a logical core.\n\n### `tpu_device_ordinal_at_coordinates`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/tpu/topology.py#L195-L206) \n\n tpu_device_ordinal_at_coordinates(\n device_coordinates\n )\n\nReturns the TensorFlow device number at `device_coordinates`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|----------------------|-----------------------------------------------------------------------------------|\n| `device_coordinates` | An integer sequence describing a device's physical coordinates in the TPU fabric. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| Returns the TensorFlow device number within the task corresponding to attached to the device with those physical coordinates. ||\n\n\u003cbr /\u003e"]]