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_TF2XLA_CONST_ANALYSIS_H_ 17 #define TENSORFLOW_COMPILER_TF2XLA_CONST_ANALYSIS_H_ 18 19 #include <vector> 20 21 #include "tensorflow/core/graph/graph.h" 22 #include "tensorflow/core/lib/core/status.h" 23 24 namespace tensorflow { 25 26 // Backwards dataflow analysis that finds nodes in a graph that must be 27 // compile-time constants for us to be able to lower the graph to XLA. 28 // 29 // The indices of the arguments to `graph` that must be constant are returned in 30 // `compile_time_const_arg_indices`, if `compile_time_const_arg_indices` is not 31 // null. 32 // 33 // The ids of the nodes in `graph` that must be constant are returned in 34 // `compile_time_const_nodes`, if `compile_time_const_nodes` is not null. 35 // 36 // Only propagate const-ness along edges for which `edge_filter` returns true. 37 Status BackwardsConstAnalysis( 38 const Graph& g, std::vector<bool>* compile_time_const_arg_indices, 39 std::vector<bool>* compile_time_const_nodes, 40 FunctionLibraryRuntime* flib_runtime, 41 std::function<bool(const Edge&)> edge_filter = [](const Edge& e) { 42 return true; 43 }); 44 45 } // namespace tensorflow 46 47 #endif // TENSORFLOW_COMPILER_TF2XLA_CONST_ANALYSIS_H_ 48