From 907e1baf6e889e4b7b54cd6292b81ae1e29408bf Mon Sep 17 00:00:00 2001 From: Anna R Date: Thu, 6 Jun 2019 16:12:09 -0700 Subject: [PATCH] Split out TF_Status into a separate header file so that other C API libraries can depend on it without depending on c_api_internal. PiperOrigin-RevId: 251948141 --- tensorflow/c/BUILD | 25 +++++++++++++++++++++---- tensorflow/c/c_api.cc | 1 + tensorflow/c/c_api_internal.h | 5 +---- tensorflow/c/tf_status.cc | 2 +- tensorflow/c/tf_status_helper.cc | 3 ++- tensorflow/c/tf_status_helper.h | 2 +- tensorflow/c/tf_status_internal.h | 28 ++++++++++++++++++++++++++++ 7 files changed, 55 insertions(+), 11 deletions(-) create mode 100644 tensorflow/c/tf_status_internal.h diff --git a/tensorflow/c/BUILD b/tensorflow/c/BUILD index c9ce334f528..243bc35a696 100644 --- a/tensorflow/c/BUILD +++ b/tensorflow/c/BUILD @@ -58,7 +58,6 @@ tf_cuda_library( "c_api.h", "c_api_internal.h", "tf_datatype.h", - "tf_status.h", "tf_tensor.h", ], visibility = [ @@ -78,7 +77,7 @@ tf_cuda_library( "//tensorflow/core:op_gen_lib", "//tensorflow/core/distributed_runtime:server_lib", ], - }), + }) + [":tf_status_internal"], ) cc_library( @@ -102,6 +101,7 @@ tf_cuda_library( ":c_api_no_xla", ":c_api_internal", ":tf_attrtype", + ":tf_status_internal", ] + select({ "//tensorflow:with_xla_support": [ "//tensorflow/compiler/tf2xla:xla_compiler", @@ -126,6 +126,7 @@ tf_cuda_library( ":c_api_internal", ":tf_attrtype", ":tf_datatype", + ":tf_status_internal", ] + select({ "//tensorflow:android": [ "//tensorflow/core:android_tensorflow_lib_lite", @@ -153,6 +154,22 @@ tf_cuda_library( }), ) +tf_cuda_library( + name = "tf_status_internal", + hdrs = [ + "tf_status.h", + "tf_status_internal.h", + ], + deps = select({ + "//tensorflow:android": [ + "//tensorflow/core:android_tensorflow_lib_lite", + ], + "//conditions:default": [ + "//tensorflow/core:lib", + ], + }), +) + cc_library( name = "tf_status", srcs = ["tf_status.cc"], @@ -163,7 +180,7 @@ cc_library( "//tensorflow/core:android_tensorflow_lib_lite", ], "//conditions:default": [ - "//tensorflow/c:c_api_internal", + ":tf_status_internal", "//tensorflow/core:lib", ], }), @@ -246,8 +263,8 @@ tf_cuda_library( hdrs = ["tf_status_helper.h"], visibility = ["//visibility:public"], deps = [ - ":c_api_internal", ":c_api_no_xla", + ":tf_status_internal", "//tensorflow/core:lib", ], ) diff --git a/tensorflow/c/c_api.cc b/tensorflow/c/c_api.cc index 38ac7d0281b..da202f840d3 100644 --- a/tensorflow/c/c_api.cc +++ b/tensorflow/c/c_api.cc @@ -35,6 +35,7 @@ limitations under the License. #include "tensorflow/core/framework/op_gen_lib.h" #endif // !defined(IS_MOBILE_PLATFORM) && !defined(IS_SLIM_BUILD) #include "tensorflow/c/c_api_internal.h" +#include "tensorflow/c/tf_status_internal.h" #include "tensorflow/c/tf_tensor.h" #include "tensorflow/core/common_runtime/device_mgr.h" #include "tensorflow/core/common_runtime/eval_const_tensor.h" diff --git a/tensorflow/c/c_api_internal.h b/tensorflow/c/c_api_internal.h index f02160044c5..7254127cd2e 100644 --- a/tensorflow/c/c_api_internal.h +++ b/tensorflow/c/c_api_internal.h @@ -29,6 +29,7 @@ limitations under the License. #include "tensorflow/core/platform/platform.h" // clang-format on +#include "tensorflow/c/tf_status_internal.h" #if !defined(IS_MOBILE_PLATFORM) && !defined(IS_SLIM_BUILD) #include "tensorflow/core/framework/op_gen_lib.h" #endif // !defined(IS_MOBILE_PLATFORM) && !defined(IS_SLIM_BUILD) @@ -52,10 +53,6 @@ class ServerInterface; // Internal structures used by the C API. These are likely to change and should // not be depended on. -struct TF_Status { - tensorflow::Status status; -}; - struct TF_Tensor { ~TF_Tensor(); diff --git a/tensorflow/c/tf_status.cc b/tensorflow/c/tf_status.cc index a77b18c2ca0..43c0d9e1fe4 100644 --- a/tensorflow/c/tf_status.cc +++ b/tensorflow/c/tf_status.cc @@ -15,7 +15,7 @@ limitations under the License. #include "tensorflow/c/tf_status.h" -#include "tensorflow/c/c_api_internal.h" +#include "tensorflow/c/tf_status_internal.h" #include "tensorflow/core/lib/core/status.h" using ::tensorflow::Status; diff --git a/tensorflow/c/tf_status_helper.cc b/tensorflow/c/tf_status_helper.cc index eaaed89500b..e0097e88019 100644 --- a/tensorflow/c/tf_status_helper.cc +++ b/tensorflow/c/tf_status_helper.cc @@ -14,7 +14,8 @@ limitations under the License. ==============================================================================*/ #include "tensorflow/c/tf_status_helper.h" -#include "tensorflow/c/c_api_internal.h" + +#include "tensorflow/c/tf_status_internal.h" namespace tensorflow { diff --git a/tensorflow/c/tf_status_helper.h b/tensorflow/c/tf_status_helper.h index 7661a01de4a..14b19393665 100644 --- a/tensorflow/c/tf_status_helper.h +++ b/tensorflow/c/tf_status_helper.h @@ -16,7 +16,7 @@ limitations under the License. #ifndef TENSORFLOW_C_TF_STATUS_HELPER_H_ #define TENSORFLOW_C_TF_STATUS_HELPER_H_ -#include "tensorflow/c/c_api.h" +#include "tensorflow/c/tf_status.h" #include "tensorflow/core/lib/core/status.h" namespace tensorflow { diff --git a/tensorflow/c/tf_status_internal.h b/tensorflow/c/tf_status_internal.h new file mode 100644 index 00000000000..66ca9938f0c --- /dev/null +++ b/tensorflow/c/tf_status_internal.h @@ -0,0 +1,28 @@ +/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_C_TF_STATUS_INTERNAL_H_ +#define TENSORFLOW_C_TF_STATUS_INTERNAL_H_ + +#include "tensorflow/core/lib/core/status.h" + +// Internal structures used by the status C API. These are likely to change +// and should not be depended on. + +struct TF_Status { + tensorflow::Status status; +}; + +#endif // TENSORFLOW_C_TF_STATUS_INTERNAL_H_