• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2017 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_COMPILER_XLA_CLIENT_SHARDING_BUILDER_H_
17 #define TENSORFLOW_COMPILER_XLA_CLIENT_SHARDING_BUILDER_H_
18 
19 #include <vector>
20 
21 #include "tensorflow/compiler/xla/array.h"
22 #include "tensorflow/compiler/xla/shape_tree.h"
23 #include "tensorflow/compiler/xla/shape_util.h"
24 #include "tensorflow/compiler/xla/types.h"
25 #include "tensorflow/compiler/xla/util.h"
26 #include "tensorflow/compiler/xla/xla_data.pb.h"
27 
28 namespace xla {
29 namespace sharding_builder {
30 // A shaped array used to describe the assignment of tiles to devices.
31 using TileAssignment = Array<int64>;
32 
33 // Creates a replicated sharding - replicate a tensor on every device.
34 OpSharding Replicate();
35 
36 // Creates a sharding that assigns a tensor to just one device.
37 OpSharding AssignDevice(int device);
38 
39 // Creates a tiled sharding with the given tile shape and assignment of tiles
40 // to devices.
41 //
42 // If tile_shape is not evenly divisible by the number of devices in
43 // tile_assignment, operations behave as if implicit padding had been inserted.
44 // The value of this padding is undefined.
45 OpSharding Tile(const Shape& tile_shape, const TileAssignment& tile_assignment);
46 
47 // Creates a sharding in one dimension, with the given tile shape which must
48 // be rank 1 and using devices [0..num_tiles).
49 //
50 // This is simply a convenience wrapper for Tile().
51 OpSharding Tile1D(const Shape& tile_shape, int64 num_tiles);
52 
53 // Creates a tuple sharding from the given ShapeTree of element shardings.
54 OpSharding Tuple(const ShapeTree<OpSharding>& shardings);
55 
56 }  // namespace sharding_builder
57 }  // namespace xla
58 
59 #endif  // TENSORFLOW_COMPILER_XLA_CLIENT_SHARDING_BUILDER_H_
60