1/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. 2 3Licensed under the Apache License, Version 2.0 (the "License"); 4you may not use this file except in compliance with the License. 5You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9Unless required by applicable law or agreed to in writing, software 10distributed under the License is distributed on an "AS IS" BASIS, 11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12See the License for the specific language governing permissions and 13limitations under the License. 14==============================================================================*/ 15 16#ifndef TENSORFLOW_GRAPH_CONTROL_FLOW_H_ 17#define TENSORFLOW_GRAPH_CONTROL_FLOW_H_ 18 19#include <vector> 20 21#include "tensorflow/core/graph/graph.h" 22#include "tensorflow/core/lib/core/status.h" 23 24namespace tensorflow { 25 26// Control flow info for a graph node. 27struct ControlFlowInfo { 28 const Node* frame = nullptr; // frame of a node 29 const Node* parent_frame = nullptr; // parent frame of a node 30 string frame_name; // frame name of a node 31}; 32 33// Assign to each node the name of the frame and the level it belongs to. 34// We check the well-formedness of the graph: All inputs to a node must 35// come from the same frame and have the same "static" iteration level. 36// `info` is cleared and populated by this function. 37// NOTE(yuanbyu): For now, we require all sends/recvs have iteration level 38// 0. This essentially means there can't be multiple serial Nexts in 39// an iteration, which all sane front-ends should satisfy. 40Status BuildControlFlowInfo(Graph* g, std::vector<ControlFlowInfo>* info); 41 42} // namespace tensorflow 43 44#endif // TENSORFLOW_GRAPH_CONTROL_FLOW_H_ 45