diff --git a/tensorflow/lite/tools/BUILD b/tensorflow/lite/tools/BUILD index 3b8f501e5d8..106b79bbafc 100644 --- a/tensorflow/lite/tools/BUILD +++ b/tensorflow/lite/tools/BUILD @@ -9,6 +9,8 @@ package( licenses = ["notice"], # Apache 2.0 ) +exports_files(["logging.h"]) + common_copts = ["-Wall"] py_binary( diff --git a/tensorflow/lite/tools/benchmark/BUILD b/tensorflow/lite/tools/benchmark/BUILD index 40fcc7f9ba9..203fdee3787 100644 --- a/tensorflow/lite/tools/benchmark/BUILD +++ b/tensorflow/lite/tools/benchmark/BUILD @@ -9,19 +9,8 @@ package( licenses = ["notice"], # Apache 2.0 ) -exports_files(["logging.h"]) - common_copts = ["-Wall"] + tflite_copts() -cc_library( - name = "logging", - hdrs = ["logging.h"], - copts = common_copts, - deps = [ - "//tensorflow/lite/tools:logging", - ], -) - cc_binary( name = "benchmark_model", srcs = [ @@ -39,7 +28,7 @@ cc_binary( tags = ["builder_default_android_arm64"], deps = [ ":benchmark_tflite_model_lib", - ":logging", + "//tensorflow/lite/tools:logging", ], ) @@ -60,7 +49,7 @@ cc_binary( deps = [ ":benchmark_performance_options", ":benchmark_tflite_model_lib", - ":logging", + "//tensorflow/lite/tools:logging", ], ) @@ -83,9 +72,9 @@ tf_cc_binary( }), deps = [ ":benchmark_tflite_model_lib", - ":logging", "//tensorflow/lite/delegates/flex:delegate", "//tensorflow/lite/testing:init_tensorflow", + "//tensorflow/lite/tools:logging", ], ) @@ -110,11 +99,11 @@ cc_test( ":benchmark_performance_options", ":benchmark_tflite_model_lib", ":delegate_provider_hdr", - ":logging", "//tensorflow/lite:framework", "//tensorflow/lite:string_util", "//tensorflow/lite/testing:util", "//tensorflow/lite/tools:command_line_flags", + "//tensorflow/lite/tools:logging", "@com_google_absl//absl/algorithm", "@com_google_absl//absl/memory", "@com_google_absl//absl/strings:str_format", @@ -151,7 +140,6 @@ cc_library( ":benchmark_utils", ":coreml_delegate_provider", ":delegate_provider_hdr", - ":logging", ":profiling_listener", ":tflite_execution_providers", "//tensorflow/lite:framework", @@ -160,6 +148,7 @@ cc_library( "//tensorflow/lite/profiling:platform_profiler", "//tensorflow/lite/profiling:profile_summary_formatter", "//tensorflow/lite/profiling:profiler", + "//tensorflow/lite/tools:logging", "//tensorflow/lite/tools/evaluation:utils", "@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/strings", @@ -178,7 +167,7 @@ cc_library( ":benchmark_model_lib", ":benchmark_params", ":benchmark_utils", - ":logging", + "//tensorflow/lite/tools:logging", "@com_google_absl//absl/memory", "//tensorflow/core/util:stats_calculator_portable", "//tensorflow/lite/c:common", @@ -210,13 +199,13 @@ cc_library( deps = [ ":benchmark_params", ":benchmark_utils", - ":logging", "//tensorflow/core/util:stats_calculator_portable", "//tensorflow/lite:framework", "//tensorflow/lite/c:common", "//tensorflow/lite/profiling:memory_info", "//tensorflow/lite/profiling:time", "//tensorflow/lite/tools:command_line_flags", + "//tensorflow/lite/tools:logging", ], ) @@ -230,7 +219,7 @@ cc_library( ":benchmark_params", "//tensorflow/lite/c:common", "//tensorflow/lite/tools:command_line_flags", - "//tensorflow/lite/tools/benchmark:logging", + "//tensorflow/lite/tools:logging", ], ) @@ -322,10 +311,7 @@ cc_library( "//conditions:default": [], }), deps = [ - ":benchmark_model_lib", - ":benchmark_params", ":delegate_provider_hdr", - ":logging", "//tensorflow/lite/tools/evaluation:utils", ] + select({ "//tensorflow:ios": [ diff --git a/tensorflow/lite/tools/benchmark/android/BUILD b/tensorflow/lite/tools/benchmark/android/BUILD index f2baf78cc82..b9b9331fcb8 100644 --- a/tensorflow/lite/tools/benchmark/android/BUILD +++ b/tensorflow/lite/tools/benchmark/android/BUILD @@ -35,7 +35,6 @@ tflite_jni_binary( deps = [ "//tensorflow/lite/java/jni", "//tensorflow/lite/tools/benchmark:benchmark_tflite_model_lib", - "//tensorflow/lite/tools/benchmark:logging", ], ) diff --git a/tensorflow/lite/tools/benchmark/android/jni/benchmark_model_jni.cc b/tensorflow/lite/tools/benchmark/android/jni/benchmark_model_jni.cc index ca20afb0ca0..d74b27757d6 100644 --- a/tensorflow/lite/tools/benchmark/android/jni/benchmark_model_jni.cc +++ b/tensorflow/lite/tools/benchmark/android/jni/benchmark_model_jni.cc @@ -19,7 +19,6 @@ limitations under the License. #include <string> #include "tensorflow/lite/tools/benchmark/benchmark_tflite_model.h" -#include "tensorflow/lite/tools/benchmark/logging.h" #ifdef __ANDROID__ #include <android/log.h> diff --git a/tensorflow/lite/tools/benchmark/benchmark_main.cc b/tensorflow/lite/tools/benchmark/benchmark_main.cc index 4eebc31cab8..76ae68fe98e 100644 --- a/tensorflow/lite/tools/benchmark/benchmark_main.cc +++ b/tensorflow/lite/tools/benchmark/benchmark_main.cc @@ -16,7 +16,7 @@ limitations under the License. #include <iostream> #include "tensorflow/lite/tools/benchmark/benchmark_tflite_model.h" -#include "tensorflow/lite/tools/benchmark/logging.h" +#include "tensorflow/lite/tools/logging.h" namespace tflite { namespace benchmark { diff --git a/tensorflow/lite/tools/benchmark/benchmark_model.cc b/tensorflow/lite/tools/benchmark/benchmark_model.cc index aec55e96a67..4c6fb0eb86e 100644 --- a/tensorflow/lite/tools/benchmark/benchmark_model.cc +++ b/tensorflow/lite/tools/benchmark/benchmark_model.cc @@ -21,7 +21,7 @@ limitations under the License. #include "tensorflow/lite/profiling/memory_info.h" #include "tensorflow/lite/profiling/time.h" #include "tensorflow/lite/tools/benchmark/benchmark_utils.h" -#include "tensorflow/lite/tools/benchmark/logging.h" +#include "tensorflow/lite/tools/logging.h" namespace tflite { namespace benchmark { diff --git a/tensorflow/lite/tools/benchmark/benchmark_performance_options.cc b/tensorflow/lite/tools/benchmark/benchmark_performance_options.cc index 08d07100b44..26fed5e279f 100644 --- a/tensorflow/lite/tools/benchmark/benchmark_performance_options.cc +++ b/tensorflow/lite/tools/benchmark/benchmark_performance_options.cc @@ -30,8 +30,8 @@ limitations under the License. #include "tensorflow/lite/profiling/time.h" #include "tensorflow/lite/tools/benchmark/benchmark_params.h" #include "tensorflow/lite/tools/benchmark/benchmark_utils.h" -#include "tensorflow/lite/tools/benchmark/logging.h" #include "tensorflow/lite/tools/command_line_flags.h" +#include "tensorflow/lite/tools/logging.h" #if (defined(ANDROID) || defined(__ANDROID__)) && \ (defined(__arm__) || defined(__aarch64__)) diff --git a/tensorflow/lite/tools/benchmark/benchmark_plus_flex_main.cc b/tensorflow/lite/tools/benchmark/benchmark_plus_flex_main.cc index 8dd2db11dd8..71cac47152f 100644 --- a/tensorflow/lite/tools/benchmark/benchmark_plus_flex_main.cc +++ b/tensorflow/lite/tools/benchmark/benchmark_plus_flex_main.cc @@ -15,7 +15,7 @@ limitations under the License. #include "tensorflow/lite/testing/init_tensorflow.h" #include "tensorflow/lite/tools/benchmark/benchmark_tflite_model.h" -#include "tensorflow/lite/tools/benchmark/logging.h" +#include "tensorflow/lite/tools/logging.h" namespace tflite { namespace benchmark { diff --git a/tensorflow/lite/tools/benchmark/benchmark_test.cc b/tensorflow/lite/tools/benchmark/benchmark_test.cc index 3560f866eff..c86b812fd69 100644 --- a/tensorflow/lite/tools/benchmark/benchmark_test.cc +++ b/tensorflow/lite/tools/benchmark/benchmark_test.cc @@ -28,8 +28,8 @@ limitations under the License. #include "tensorflow/lite/tools/benchmark/benchmark_performance_options.h" #include "tensorflow/lite/tools/benchmark/benchmark_tflite_model.h" #include "tensorflow/lite/tools/benchmark/delegate_provider.h" -#include "tensorflow/lite/tools/benchmark/logging.h" #include "tensorflow/lite/tools/command_line_flags.h" +#include "tensorflow/lite/tools/logging.h" namespace { const std::string* g_fp32_model_path = nullptr; diff --git a/tensorflow/lite/tools/benchmark/benchmark_tflite_model.cc b/tensorflow/lite/tools/benchmark/benchmark_tflite_model.cc index 261825923fd..dc158c1ff0a 100644 --- a/tensorflow/lite/tools/benchmark/benchmark_tflite_model.cc +++ b/tensorflow/lite/tools/benchmark/benchmark_tflite_model.cc @@ -37,8 +37,8 @@ limitations under the License. #include "tensorflow/lite/string_util.h" #include "tensorflow/lite/tools/benchmark/benchmark_utils.h" #include "tensorflow/lite/tools/benchmark/delegate_provider.h" -#include "tensorflow/lite/tools/benchmark/logging.h" #include "tensorflow/lite/tools/benchmark/profiling_listener.h" +#include "tensorflow/lite/tools/logging.h" void RegisterSelectedOps(::tflite::MutableOpResolver* resolver); @@ -64,7 +64,7 @@ constexpr int kOpProfilingEnabledDefault = false; class PlatformProfilingListener : public BenchmarkListener { public: explicit PlatformProfilingListener(Interpreter* interpreter) { - TFLITE_BENCHMARK_CHECK(interpreter); + TFLITE_TOOLS_CHECK(interpreter); platform_profiler_ = profiling::CreatePlatformProfiler(); interpreter->SetProfiler(platform_profiler_.get()); } @@ -214,7 +214,7 @@ TfLiteStatus PopulateInputLayerInfo( input.name = names[i]; - TFLITE_BENCHMARK_CHECK(util::SplitAndParse(shapes[i], ',', &input.shape)) + TFLITE_TOOLS_CHECK(util::SplitAndParse(shapes[i], ',', &input.shape)) << "Incorrect size string specified: " << shapes[i]; for (int dim : input.shape) { if (dim == -1) { @@ -392,7 +392,7 @@ TfLiteStatus BenchmarkTfLiteModel::ValidateParams() { } uint64_t BenchmarkTfLiteModel::ComputeInputBytes() { - TFLITE_BENCHMARK_CHECK(interpreter_); + TFLITE_TOOLS_CHECK(interpreter_); uint64_t total_input_bytes = 0; for (int input : interpreter_->inputs()) { auto* t = interpreter_->tensor(input); @@ -652,7 +652,7 @@ TfLiteStatus BenchmarkTfLiteModel::Init() { auto interpreter_inputs = interpreter_->inputs(); if (!inputs_.empty()) { - TFLITE_BENCHMARK_CHECK_EQ(inputs_.size(), interpreter_inputs.size()) + TFLITE_TOOLS_CHECK_EQ(inputs_.size(), interpreter_inputs.size()) << "Inputs mismatch: Model inputs #:" << inputs_.size() << " expected: " << interpreter_inputs.size(); } diff --git a/tensorflow/lite/tools/benchmark/benchmark_tflite_performance_options_main.cc b/tensorflow/lite/tools/benchmark/benchmark_tflite_performance_options_main.cc index 6bf4cf4e193..7c8c6b39f78 100644 --- a/tensorflow/lite/tools/benchmark/benchmark_tflite_performance_options_main.cc +++ b/tensorflow/lite/tools/benchmark/benchmark_tflite_performance_options_main.cc @@ -15,7 +15,7 @@ limitations under the License. #include "tensorflow/lite/tools/benchmark/benchmark_performance_options.h" #include "tensorflow/lite/tools/benchmark/benchmark_tflite_model.h" -#include "tensorflow/lite/tools/benchmark/logging.h" +#include "tensorflow/lite/tools/logging.h" namespace tflite { namespace benchmark { diff --git a/tensorflow/lite/tools/benchmark/delegate_provider.h b/tensorflow/lite/tools/benchmark/delegate_provider.h index a1531de4cad..6090b7f6ee8 100644 --- a/tensorflow/lite/tools/benchmark/delegate_provider.h +++ b/tensorflow/lite/tools/benchmark/delegate_provider.h @@ -21,8 +21,8 @@ limitations under the License. #include "tensorflow/lite/c/common.h" #include "tensorflow/lite/tools/benchmark/benchmark_params.h" -#include "tensorflow/lite/tools/benchmark/logging.h" #include "tensorflow/lite/tools/command_line_flags.h" +#include "tensorflow/lite/tools/logging.h" namespace tflite { namespace benchmark { diff --git a/tensorflow/lite/tools/benchmark/experimental/ios/BUILD.apple b/tensorflow/lite/tools/benchmark/experimental/ios/BUILD.apple index 20c0dea33c2..34651c9d7a2 100644 --- a/tensorflow/lite/tools/benchmark/experimental/ios/BUILD.apple +++ b/tensorflow/lite/tools/benchmark/experimental/ios/BUILD.apple @@ -11,7 +11,7 @@ package( ios_static_framework( name = "TensorFlowLiteBenchmarkC_framework", hdrs = [ - "//tensorflow/lite/tools/benchmark:logging.h", + "//tensorflow/lite/tools:logging.h", "//tensorflow/lite/tools/benchmark/experimental/c:benchmark_c_api.h", "//tensorflow/lite/tools/benchmark/experimental/c:c_api_types.h", ], diff --git a/tensorflow/lite/tools/benchmark/ios/TFLiteBenchmark/TFLiteBenchmark/BenchmarkViewController.mm b/tensorflow/lite/tools/benchmark/ios/TFLiteBenchmark/TFLiteBenchmark/BenchmarkViewController.mm index 7811fcb9c84..fac3c7899be 100644 --- a/tensorflow/lite/tools/benchmark/ios/TFLiteBenchmark/TFLiteBenchmark/BenchmarkViewController.mm +++ b/tensorflow/lite/tools/benchmark/ios/TFLiteBenchmark/TFLiteBenchmark/BenchmarkViewController.mm @@ -21,7 +21,7 @@ #if defined(USE_TFLITE_BENCHMARK_HEADERS) #include "tensorflow/lite/tools/benchmark/experimental/c/benchmark_c_api.h" -#include "tensorflow/lite/tools/benchmark/logging.h" +#include "tensorflow/lite/tools/logging.h" #else #import <TensorFlowLiteBenchmarkC/TensorFlowLiteBenchmarkC.h> #endif diff --git a/tensorflow/lite/tools/benchmark/logging.h b/tensorflow/lite/tools/benchmark/logging.h deleted file mode 100644 index ff3287026b2..00000000000 --- a/tensorflow/lite/tools/benchmark/logging.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2018 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_LITE_TOOLS_BENCHMARK_LOGGING_H_ -#define TENSORFLOW_LITE_TOOLS_BENCHMARK_LOGGING_H_ - -// TODO(b/149482807): completely remove this file from the code base. -#include "tensorflow/lite/tools/logging.h" - -#define TFLITE_BENCHMARK_CHECK(condition) TFLITE_TOOLS_CHECK(condition) -#define TFLITE_BENCHMARK_CHECK_EQ(a, b) TFLITE_TOOLS_CHECK(a == b) - -#endif // TENSORFLOW_LITE_TOOLS_BENCHMARK_LOGGING_H_