1 /* Copyright 2019 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_REARRANGE_FUNCTION_ARGUMENT_H_ 17 #define TENSORFLOW_COMPILER_TF2XLA_REARRANGE_FUNCTION_ARGUMENT_H_ 18 19 #include "tensorflow/core/framework/function.h" 20 #include "tensorflow/core/graph/graph.h" 21 22 namespace tensorflow { 23 24 // For the given graph `g`: 25 // 1. Rewrite If/While node functions to rearrange arguments and return values, 26 // so that all resource arguments/return values are placed in the end (as 27 // required by XlaCompiler), 28 // 2. Inline StatefulPartitionedCall nodes so we do not need to rearrange 29 // arguments and return values. 30 // `get_function_body_fn` is used to instantiate FunctionDef. 31 // `fld` is used to store rewritten functions. 32 // `global_fld` is used to potentially supply stack traces for functions when 33 // they are not found in `fld`. 34 Status RearrangeFunctionArguments( 35 std::function<Status(const NameAttrList&, const FunctionBody**)> 36 get_function_body_fn, 37 Graph* g, FunctionLibraryDefinition* fld, 38 const FunctionLibraryDefinition* global_fld = nullptr); 39 40 } // namespace tensorflow 41 42 #endif // TENSORFLOW_COMPILER_TF2XLA_REARRANGE_FUNCTION_ARGUMENT_H_ 43