xref: /aosp_15_r20/external/tensorflow/tensorflow/python/distribute/distribute_config.py (revision b6fb3261f9314811a0f4371741dbb8839866f948)
1# Copyright 2018 The TensorFlow Authors. All Rights Reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14# ==============================================================================
15"""A configure tuple for high-level APIs for running distribution strategies."""
16
17import collections
18
19
20class DistributeConfig(
21    collections.namedtuple(
22        'DistributeConfig',
23        ['train_distribute', 'eval_distribute', 'remote_cluster'])):
24  """A config tuple for distribution strategies.
25
26  Attributes:
27    train_distribute: a `DistributionStrategy` object for training.
28    eval_distribute: an optional `DistributionStrategy` object for
29      evaluation.
30    remote_cluster: a dict, `ClusterDef` or `ClusterSpec` object specifying
31      the cluster configurations. If this is given, the `train_and_evaluate`
32      method will be running as a standalone client which connects to the
33      cluster for training.
34  """
35
36  def __new__(cls,
37              train_distribute=None,
38              eval_distribute=None,
39              remote_cluster=None):
40    return super(DistributeConfig, cls).__new__(cls, train_distribute,
41                                                eval_distribute, remote_cluster)
42