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

Function split_compile_and_replicate

tensorflow/python/tpu/tpu.py:742–1066  ·  view source on GitHub ↗

Builds graph operators that runs compilation and replicated computation. This is a lower level interface than replicate that returns a separate compile and execute output tensor. In the generated graph the compile op feeds into the execute op and no additional compilation is incurred when run

(computation,
                                inputs=None,
                                infeed_queue=None,
                                device_assignment=None,
                                name=None,
                                use_tpu=True,
                                maximum_shapes=None)

Source from the content-addressed store, hash-verified

740
741
742def split_compile_and_replicate(computation,
743 inputs=None,
744 infeed_queue=None,
745 device_assignment=None,
746 name=None,
747 use_tpu=True,
748 maximum_shapes=None):
749 """Builds graph operators that runs compilation and replicated computation.
750
751 This is a lower level interface than replicate that returns a separate compile
752 and execute output tensor. In the generated graph the compile op feeds into
753 the execute op and no additional compilation is incurred when running the
754 compile op before the execute op. The compile op returns additional
755 information about the compilation but does not return the compiled program.
756
757 Args:
758 computation: A Python function that builds the computation to replicate.
759 inputs: A list of lists of input tensors or `None` (equivalent to
760 `[[]]`), indexed by `[replica_num][input_num]`. All replicas must
761 have the same number of inputs. Each input can be a nested structure
762 containing values that are convertible to tensors. Note that passing an
763 N-dimension list of compatible values will result in a N-dimension list of
764 scalar tensors rather than a single Rank-N tensors. If you need different
765 behavior, convert part of inputs to tensors with `tf.convert_to_tensor`.
766 infeed_queue: If not `None`, the `InfeedQueue` from which to append a tuple
767 of arguments as inputs to computation.
768 device_assignment: If not `None`, a `DeviceAssignment` describing the
769 mapping between logical cores in the computation with physical cores in
770 the TPU topology. Uses a default device assignment if `None`. The
771 `DeviceAssignment` may be omitted if each replica of the computation uses
772 only one core, and there is either only one replica, or the number of
773 replicas is equal to the number of cores in the TPU system.
774 name: (Deprecated) Does nothing.
775 use_tpu: When false, the input `computation` is executed on the XLA CPU/GPU
776 backends. Currently, only supports a default placement (computation is
777 placed on GPU if one is available, and on CPU if not).
778 maximum_shapes: A nested structure of tf.TensorShape representing the shape
779 to which the respective component of each input element in each replica
780 should be padded. Any unknown dimensions (e.g.
781 tf.compat.v1.Dimension(None) in a tf.TensorShape or -1 in a tensor-like
782 object) will be padded to the maximum size of that dimension over all
783 replicas. The structure of `maximum_shapes` needs to be the same as
784 `inputs[0]`.
785
786 Returns:
787 A list of lists with the first list corresponding to the compile op and the
788 second a list of output tensors, indexed by `[replica_num][output_num]`.
789 Raises:
790 ValueError: If all replicas do not have equal numbers of input tensors.
791 ValueError: If the number of inputs per replica does not match
792 the number of formal parameters to `computation`.
793 ValueError: If the static `inputs` dimensions don't match with the values
794 given in `maximum_shapes`.
795 ValueError: If the structure of inputs per replica does not match
796 the structure of `maximum_shapes`.
797 """
798 del name
799 inputs = [[]] if inputs is None else inputs

Callers 2

replicateFunction · 0.85
split_compile_and_shardFunction · 0.85

Calls 15

EnterMethod · 0.95
trace_tpuMethod · 0.95
HostComputeCoreMethod · 0.95
anyFunction · 0.85
_pad_all_inputFunction · 0.85
TPUReplicateContextClass · 0.85
computationFunction · 0.85
serializedMethod · 0.80
unique_nameMethod · 0.80
_set_attrMethod · 0.80
set_use_resourceMethod · 0.80

Tested by

no test coverage detected