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 // Helper functions for dumping Graphs, GraphDefs, and FunctionDefs to files for 17 // debugging. 18 19 #ifndef TENSORFLOW_CORE_UTIL_DUMP_GRAPH_H_ 20 #define TENSORFLOW_CORE_UTIL_DUMP_GRAPH_H_ 21 22 #include "tensorflow/core/framework/function.h" 23 #include "tensorflow/core/framework/graph.pb.h" 24 #include "tensorflow/core/graph/graph.h" 25 26 namespace tensorflow { 27 28 // Dumps 'graph_def' to a file, as a GraphDef text proto. Returns the file name 29 // chosen. 30 // 31 // Automatically picks a file name. Prefixes 'name' with the value of the 32 // TF_DUMP_GRAPH_PREFIX environment variable if 'dirname' is empty, and suffixes 33 // 'name' with ".pbtxt" to form a name. If a graph has already been dumped by 34 // this process with the same name, suffixes with "_n.pbtxt", where 'n' is a 35 // sequence number. 36 string DumpGraphDefToFile(const string& name, GraphDef const& graph_def, 37 const string& dirname = ""); 38 39 // Similar to DumpGraphDefToFile, but builds the GraphDef to dump from a 'graph' 40 // and an optional function library 'flib_def'. Returns the file name chosen. 41 string DumpGraphToFile(const string& name, Graph const& graph, 42 const FunctionLibraryDefinition* flib_def = nullptr, 43 const string& dirname = ""); 44 45 // Similar to DumpGraphDefToFile, but dumps a function as a FunctionDef text 46 // proto. Returns the file name chosen. 47 string DumpFunctionDefToFile(const string& name, FunctionDef const& fdef, 48 const string& dirname = ""); 49 50 } // namespace tensorflow 51 52 #endif // TENSORFLOW_CORE_UTIL_DUMP_GRAPH_H_ 53