tf.contrib.tpu.device_assignment
Stay organized with collections
Save and categorize content based on your preferences.
Computes a device_assignment of a computation across a TPU topology.
tf.contrib.tpu.device_assignment(
topology, computation_shape=None, computation_stride=None, num_replicas=1
)
Attempts to choose a compact grid of cores for locality.
Returns a DeviceAssignment
that describes the cores in the topology assigned
to each core of each replica.
computation_shape
and computation_stride
values should be powers of 2 for
optimal packing.
Args |
topology
|
A Topology object that describes the TPU cluster topology.
To obtain a TPU topology, evaluate the Tensor returned by
initialize_system using Session.run . Either a serialized
TopologyProto or a Topology object may be passed. Note: you must
evaluate the Tensor first; you cannot pass an unevaluated Tensor here.
|
computation_shape
|
A rank 1 int32 numpy array with size equal to the
topology rank, describing the shape of the computation's block of cores.
If None, the computation_shape is [1] * topology_rank .
|
computation_stride
|
A rank 1 int32 numpy array of size topology_rank ,
describing the inter-core spacing of the computation_shape cores in the
TPU topology. If None, the computation_stride is [1] * topology_rank .
|
num_replicas
|
The number of computation replicas to run. The replicas will
be packed into the free spaces of the topology.
|
Returns |
A DeviceAssignment object, which describes the mapping between the logical
cores in each computation replica and the physical cores in the TPU
topology.
|
Raises |
ValueError
|
If topology is not a valid Topology object.
|
ValueError
|
If computation_shape or computation_stride are not 1D int32
numpy arrays with shape [3] where all values are positive.
|
ValueError
|
If computation's replicas cannot fit into the TPU topology.
|
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.
Last updated 2020-10-01 UTC.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.contrib.tpu.device_assignment\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/tpu/device_assignment.py#L215-L386) |\n\nComputes a device_assignment of a computation across a TPU topology. \n\n tf.contrib.tpu.device_assignment(\n topology, computation_shape=None, computation_stride=None, num_replicas=1\n )\n\nAttempts to choose a compact grid of cores for locality.\n\nReturns a `DeviceAssignment` that describes the cores in the topology assigned\nto each core of each replica.\n\n`computation_shape` and `computation_stride` values should be powers of 2 for\noptimal packing.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `topology` | A `Topology` object that describes the TPU cluster topology. To obtain a TPU topology, evaluate the `Tensor` returned by `initialize_system` using `Session.run`. Either a serialized `TopologyProto` or a `Topology` object may be passed. Note: you must evaluate the `Tensor` first; you cannot pass an unevaluated `Tensor` here. |\n| `computation_shape` | A rank 1 int32 numpy array with size equal to the topology rank, describing the shape of the computation's block of cores. If None, the `computation_shape` is `[1] * topology_rank`. |\n| `computation_stride` | A rank 1 int32 numpy array of size `topology_rank`, describing the inter-core spacing of the `computation_shape` cores in the TPU topology. If None, the `computation_stride` is `[1] * topology_rank`. |\n| `num_replicas` | The number of computation replicas to run. The replicas will be packed into the free spaces of the topology. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A DeviceAssignment object, which describes the mapping between the logical cores in each computation replica and the physical cores in the TPU topology. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|------------------------------------------------------------------------------------------------------------------------------|\n| `ValueError` | If `topology` is not a valid `Topology` object. |\n| `ValueError` | If `computation_shape` or `computation_stride` are not 1D int32 numpy arrays with shape \\[3\\] where all values are positive. |\n| `ValueError` | If computation's replicas cannot fit into the TPU topology. |\n\n\u003cbr /\u003e"]]