• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2019 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 
16 #ifndef TENSORFLOW_CORE_GRAPPLER_OPTIMIZERS_DATA_AUTO_SHARD_H_
17 #define TENSORFLOW_CORE_GRAPPLER_OPTIMIZERS_DATA_AUTO_SHARD_H_
18 
19 #include "tensorflow/core/framework/dataset_options.pb.h"
20 #include "tensorflow/core/grappler/optimizers/data/optimizer_base.h"
21 
22 namespace tensorflow {
23 namespace grappler {
24 
25 class AutoShard : public TFDataOptimizerBase {
26  public:
27   AutoShard() = default;
28   ~AutoShard() override = default;
29 
name()30   string name() const override { return "tf_auto_shard"; }
31 
UsesFunctionLibrary()32   bool UsesFunctionLibrary() const override { return true; }
33 
34   Status Init(
35       const tensorflow::RewriterConfig_CustomGraphOptimizer* config) override;
36 
37   Status OptimizeAndCollectStats(Cluster* cluster, const GrapplerItem& item,
38                                  GraphDef* output,
39                                  OptimizationStats* stats) override;
40 
41  private:
42   int64 num_workers_;
43   int64 num_replicas_;
44   int64 index_;
45   tensorflow::data::AutoShardPolicy auto_shard_policy_;
46 };
47 
48 }  // namespace grappler
49 }  // namespace tensorflow
50 
51 #endif  // TENSORFLOW_CORE_GRAPPLER_OPTIMIZERS_DATA_AUTO_SHARD_H_
52