tf.tpu.rewrite
Stay organized with collections
Save and categorize content based on your preferences.
Rewrites computation
for execution on a TPU system.
tf.tpu.rewrite(
computation, inputs=None, infeed_queue=None, device_assignment=None, name=None
)
Args |
computation
|
A Python function that builds a computation to apply to the
input. If the function takes n inputs, 'inputs' should be a list of n
tensors.
computation may return a list of operations and tensors. Tensors must
come before operations in the returned list. The return value of
rewrite is a list of tensors corresponding to the tensors from the
output of computation .
All Operation s constructed during computation will be executed when
evaluating any of the returned output tensors, not just the ones returned.
|
inputs
|
A list of input tensors or None (equivalent to an empty list).
Each input can be a nested structure containing values that are
convertible to tensors. Note that passing an N-dimension list of
compatible values will result in a N-dimention list of scalar tensors
rather than a single Rank-N tensors. If you need different behavior,
convert part of inputs to tensors with tf.convert_to_tensor .
|
infeed_queue
|
If not None , the InfeedQueue from which to append a tuple
of arguments as inputs to computation .
|
device_assignment
|
if not None , a DeviceAssignment describing the
mapping between logical cores in the computation with physical cores in
the TPU topology. May be omitted for a single-core computation, in which
case the core attached to task 0, TPU device 0 is used.
|
name
|
(Deprecated) Does nothing.
|
Returns |
Same data structure as if computation(*inputs) is called directly with some
exceptions for correctness. Exceptions include:
1) None output: a NoOp would be returned which control-depends on
computation.
2) Single value output: A tuple containing the value would be returned.
3) Operation-only outputs: a NoOp would be returned which
control-depends on computation.
|
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.tpu.rewrite\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/tpu/tpu.py#L1464-L1514) |\n\nRewrites `computation` for execution on a TPU system.\n\n#### View aliases\n\n\n**Main aliases**\n\n\\`tf.contrib.tpu.rewrite\\`\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.rewrite`](/api_docs/python/tf/compat/v1/tpu/rewrite)\n\n\u003cbr /\u003e\n\n tf.tpu.rewrite(\n computation, inputs=None, infeed_queue=None, device_assignment=None, name=None\n )\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `computation` | A Python function that builds a computation to apply to the input. If the function takes n inputs, 'inputs' should be a list of n tensors. \u003cbr /\u003e `computation` may return a list of operations and tensors. Tensors must come before operations in the returned list. The return value of `rewrite` is a list of tensors corresponding to the tensors from the output of `computation`. All `Operation`s constructed during `computation` will be executed when evaluating any of the returned output tensors, not just the ones returned. |\n| `inputs` | A list of input tensors or `None` (equivalent to an empty list). Each input can be a nested structure containing values that are convertible to tensors. Note that passing an N-dimension list of compatible values will result in a N-dimention list of scalar tensors rather than a single Rank-N tensors. If you need different behavior, convert part of inputs to tensors with [`tf.convert_to_tensor`](../../tf/convert_to_tensor). |\n| `infeed_queue` | If not `None`, the `InfeedQueue` from which to append a tuple of arguments as inputs to `computation`. |\n| `device_assignment` | if not `None`, a `DeviceAssignment` describing the mapping between logical cores in the computation with physical cores in the TPU topology. May be omitted for a single-core computation, in which case the core attached to task 0, TPU device 0 is used. |\n| `name` | (Deprecated) Does nothing. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| Same data structure as if computation(\\*inputs) is called directly with some exceptions for correctness. Exceptions include: \u003cbr /\u003e 1) None output: a NoOp would be returned which control-depends on computation. 2) Single value output: A tuple containing the value would be returned. 3) Operation-only outputs: a NoOp would be returned which control-depends on computation. ||\n\n\u003cbr /\u003e"]]