• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #ifndef TENSORFLOW_CORE_GRAPPLER_UTILS_COLOCATION_H_
17 #define TENSORFLOW_CORE_GRAPPLER_UTILS_COLOCATION_H_
18 
19 #include <unordered_map>
20 #include "tensorflow/core/framework/graph.pb.h"
21 
22 namespace tensorflow {
23 namespace grappler {
24 
25 // Evaluates the colocation relation in the graph and rewrites the new
26 // colocation relation in the graph. We scan the graph nodes sequentially, and
27 // builds a disjoint-sets of nodes (within each disjoint-set the nodes are
28 // colocated with each other). We then select the root node of each set as a
29 // representative node, and then colocate each node within the set (should also
30 // exist in graph) with the representative node.
31 // Note that there is current one situation this function can't handle:
32 // Node A colocates with X, node B colocates with Y, X colocates with Y but
33 // X, Y are removed from graph. In this case we can't know A colocates with B.
34 void ReassignColocation(GraphDef* graph);
35 
36 }  // namespace grappler
37 }  // namespace tensorflow
38 
39 #endif  // TENSORFLOW_CORE_GRAPPLER_UTILS_COLOCATION_H_
40