1 /* Copyright 2021 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 #include "tensorflow/c/experimental/ops/gen/cpp/renderers/include_renderer.h" 16 17 #include "tensorflow/core/lib/io/path.h" 18 19 namespace tensorflow { 20 namespace generator { 21 namespace cpp { 22 IncludeRenderer(RendererContext context)23IncludeRenderer::IncludeRenderer(RendererContext context) : Renderer(context) {} 24 SelfHeader()25void IncludeRenderer::SelfHeader() { 26 Include(SelfHeaderPath()); 27 BlankLine(); 28 } 29 SelfHeaderPath() const30string IncludeRenderer::SelfHeaderPath() const { 31 return io::JoinPath(context_.path_config.tf_root_dir, 32 context_.path_config.tf_output_dir, 33 context_.cpp_config.unit + "_ops.h"); 34 } 35 Include(const string & tf_file_path)36void IncludeRenderer::Include(const string &tf_file_path) { 37 CodeLine("#include \"$0\"", 38 io::JoinPath(context_.path_config.tf_prefix_dir, tf_file_path)); 39 } 40 Headers()41void IncludeRenderer::Headers() { 42 Include("tensorflow/c/eager/abstract_context.h"); 43 Include("tensorflow/c/eager/abstract_tensor_handle.h"); 44 if (context_.mode == RendererContext::kSource) { 45 Include("tensorflow/c/eager/tracing_utils.h"); 46 Include("tensorflow/core/framework/types.h"); 47 Include("tensorflow/core/platform/errors.h"); 48 BlankLine(); 49 Statement("using tensorflow::tracing::MaybeSetOpName"); 50 } 51 BlankLine(); 52 } 53 54 } // namespace cpp 55 } // namespace generator 56 } // namespace tensorflow 57