From 2944db012c1f88bc3a453003022b985269235ca2 Mon Sep 17 00:00:00 2001 From: Mihai Maruseac Date: Wed, 2 Oct 2019 13:56:01 -0700 Subject: [PATCH] Separate TF_FileStatistics into own file. Also do some required cleanup and removal of duplicates as a drive by fix. PiperOrigin-RevId: 272512533 --- tensorflow/c/BUILD | 23 ++++++++++++++------- tensorflow/c/env.h | 16 ++++----------- tensorflow/c/tf_file_statistics.h | 34 +++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 19 deletions(-) create mode 100644 tensorflow/c/tf_file_statistics.h diff --git a/tensorflow/c/BUILD b/tensorflow/c/BUILD index 463899d7712..d5509120082 100644 --- a/tensorflow/c/BUILD +++ b/tensorflow/c/BUILD @@ -25,6 +25,7 @@ filegroup( "c_api_experimental.h", "tf_attrtype.h", "tf_datatype.h", + "tf_file_statistics.h", "tf_status.h", "tf_tensor.h", ], @@ -95,6 +96,7 @@ tf_cuda_library( "c_api.h", "tf_attrtype.h", "tf_datatype.h", + "tf_file_statistics.h", "tf_status.h", "tf_tensor.h", ], @@ -105,6 +107,7 @@ tf_cuda_library( ":c_api_internal", ":tf_attrtype", ":tf_status_internal", + ":tf_file_statistics", ] + select({ "//tensorflow:with_xla_support": [ "//tensorflow/compiler/tf2xla:xla_compiler", @@ -189,6 +192,12 @@ cc_library( }), ) +cc_library( + name = "tf_file_statistics", + hdrs = ["tf_file_statistics.h"], + visibility = ["//visibility:public"], +) + cc_library( name = "tf_datatype", srcs = ["tf_datatype.cc"], @@ -329,18 +338,18 @@ tf_cuda_library( visibility = ["//visibility:public"], deps = select({ "//tensorflow:android": [ - ":c_api", - ":tf_status_helper", "//tensorflow/core:android_tensorflow_lib_lite", - "//tensorflow/core:lib", ], "//conditions:default": [ - ":c_api", - ":tf_status_helper", "//tensorflow/core:framework", - "//tensorflow/core:lib", ], - }) + [":c_api_internal"], + }) + [ + ":c_api", + ":tf_status_helper", + ":c_api_internal", + ":tf_file_statistics", + "//tensorflow/core:lib", + ], ) tf_cuda_library( diff --git a/tensorflow/c/env.h b/tensorflow/c/env.h index 73078fcbbc5..2a763730bc3 100644 --- a/tensorflow/c/env.h +++ b/tensorflow/c/env.h @@ -13,14 +13,15 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ +#ifndef TENSORFLOW_C_ENV_H_ +#define TENSORFLOW_C_ENV_H_ + #include #include #include -#ifndef TENSORFLOW_C_ENV_H_ -#define TENSORFLOW_C_ENV_H_ - #include "tensorflow/c/c_api.h" +#include "tensorflow/c/tf_file_statistics.h" // -------------------------------------------------------------------------- // C API for tensorflow::Env. @@ -33,15 +34,6 @@ typedef struct TF_WritableFileHandle TF_WritableFileHandle; typedef struct TF_StringStream TF_StringStream; typedef struct TF_Thread TF_Thread; -typedef struct TF_FileStatistics { - // The length of the file in bytes. - int64_t length; - // The last modified time in nanoseconds. - int64_t mtime_nsec; - // Whether the name refers to a directory. - bool is_directory; -} TF_FileStatistics; - typedef struct TF_ThreadOptions { // Thread stack size to use (in bytes), zero implies that the system default // will be used. diff --git a/tensorflow/c/tf_file_statistics.h b/tensorflow/c/tf_file_statistics.h new file mode 100644 index 00000000000..bbf23831f4e --- /dev/null +++ b/tensorflow/c/tf_file_statistics.h @@ -0,0 +1,34 @@ +/* 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_FILE_STATISTICS_H_ +#define TENSORFLOW_C_TF_FILE_STATISTICS_H_ + +#include + +typedef struct TF_FileStatistics { + // The length of the file in bytes. + int64_t length; + // The last modified time in nanoseconds. + int64_t mtime_nsec; + // Whether the name refers to a directory. + bool is_directory; +} TF_FileStatistics; + +// TODO(mihaimaruseac): `tensorflow::FileStatistics` from +// `core/platform/file_statistics.h` is a duplicate of this so maybe try to +// remove duplication later? + +#endif // TENSORFLOW_C_TF_FILE_STATISTICS_H_