From 6e024748f6402ba39393e1ef1f55f6e2c82916f6 Mon Sep 17 00:00:00 2001 From: Advait Jain Date: Wed, 10 Jun 2020 11:21:12 -0700 Subject: [PATCH] Restrict visibility for micro libraries. * testing library visible to all of micro but nothing else. * moved benchmark.h to micro/benchmarks so that it can have private visibility. PiperOrigin-RevId: 315729400 Change-Id: I695b9bb749de8748e9ac929ff612d6a9e7d33b3d --- tensorflow/lite/micro/benchmarks/BUILD | 19 ++++++++--- .../micro/benchmarks/keyword_benchmark.cc | 2 +- .../{testing => benchmarks}/micro_benchmark.h | 6 ++-- .../benchmarks/person_detection_benchmark.cc | 2 +- tensorflow/lite/micro/testing/BUILD | 33 ++++++++++--------- 5 files changed, 36 insertions(+), 26 deletions(-) rename tensorflow/lite/micro/{testing => benchmarks}/micro_benchmark.h (96%) diff --git a/tensorflow/lite/micro/benchmarks/BUILD b/tensorflow/lite/micro/benchmarks/BUILD index 8c5238ef56b..cdd394e8bcb 100644 --- a/tensorflow/lite/micro/benchmarks/BUILD +++ b/tensorflow/lite/micro/benchmarks/BUILD @@ -1,7 +1,16 @@ -# Benchmarks for the ambient music detection model. +licenses(["notice"]) # Apache 2.0 -package( - licenses = ["notice"], # Apache 2.0 +cc_library( + name = "micro_benchmark", + hdrs = [ + "micro_benchmark.h", + ], + deps = [ + "//tensorflow/lite/micro:micro_error_reporter", + "//tensorflow/lite/micro:micro_framework", + "//tensorflow/lite/micro:micro_time", + "//tensorflow/lite/micro:op_resolvers", + ], ) cc_binary( @@ -45,12 +54,12 @@ cc_binary( srcs = ["keyword_benchmark.cc"], deps = [ ":keyword_scrambled_model_data", + ":micro_benchmark", "//tensorflow/lite/c:common", "//tensorflow/lite/micro:micro_error_reporter", "//tensorflow/lite/micro:micro_framework", "//tensorflow/lite/micro:op_resolvers", "//tensorflow/lite/micro/kernels:micro_ops", - "//tensorflow/lite/micro/testing:micro_benchmark", ], ) @@ -58,6 +67,7 @@ cc_binary( name = "person_detection_benchmark", srcs = ["person_detection_benchmark.cc"], deps = [ + ":micro_benchmark", "//tensorflow/lite:schema_fbs_version", "//tensorflow/lite/c:common", "//tensorflow/lite/micro:micro_error_reporter", @@ -68,7 +78,6 @@ cc_binary( "//tensorflow/lite/micro/examples/person_detection:person_detect_model_data", "//tensorflow/lite/micro/examples/person_detection:simple_images_test_data", "//tensorflow/lite/micro/kernels:micro_ops", - "//tensorflow/lite/micro/testing:micro_benchmark", "//tensorflow/lite/schema:schema_fbs", ], ) diff --git a/tensorflow/lite/micro/benchmarks/keyword_benchmark.cc b/tensorflow/lite/micro/benchmarks/keyword_benchmark.cc index 958150aa6ab..65844fb91c1 100644 --- a/tensorflow/lite/micro/benchmarks/keyword_benchmark.cc +++ b/tensorflow/lite/micro/benchmarks/keyword_benchmark.cc @@ -18,11 +18,11 @@ limitations under the License. #include "tensorflow/lite/c/common.h" #include "tensorflow/lite/micro/benchmarks/keyword_scrambled_model_data.h" +#include "tensorflow/lite/micro/benchmarks/micro_benchmark.h" #include "tensorflow/lite/micro/kernels/micro_ops.h" #include "tensorflow/lite/micro/micro_error_reporter.h" #include "tensorflow/lite/micro/micro_interpreter.h" #include "tensorflow/lite/micro/micro_mutable_op_resolver.h" -#include "tensorflow/lite/micro/testing/micro_benchmark.h" /* * Keyword Spotting Benchmark for performance optimizations. The model used in diff --git a/tensorflow/lite/micro/testing/micro_benchmark.h b/tensorflow/lite/micro/benchmarks/micro_benchmark.h similarity index 96% rename from tensorflow/lite/micro/testing/micro_benchmark.h rename to tensorflow/lite/micro/benchmarks/micro_benchmark.h index 4f660308f06..43788dd0e04 100644 --- a/tensorflow/lite/micro/testing/micro_benchmark.h +++ b/tensorflow/lite/micro/benchmarks/micro_benchmark.h @@ -13,8 +13,8 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ -#ifndef TENSORFLOW_LITE_MICRO_TESTING_MICRO_BENCHMARK_H_ -#define TENSORFLOW_LITE_MICRO_TESTING_MICRO_BENCHMARK_H_ +#ifndef TENSORFLOW_LITE_MICRO_BENCHMARKS_MICRO_BENCHMARK_H_ +#define TENSORFLOW_LITE_MICRO_BENCHMARKS_MICRO_BENCHMARK_H_ #include @@ -116,4 +116,4 @@ class MicroBenchmarkRunner { tflite::MicroInterpreter interpreter_; }; -#endif // TENSORFLOW_LITE_MICRO_TESTING_MICRO_BENCHMARK_H_ +#endif // TENSORFLOW_LITE_MICRO_BENCHMARKS_MICRO_BENCHMARK_H_ diff --git a/tensorflow/lite/micro/benchmarks/person_detection_benchmark.cc b/tensorflow/lite/micro/benchmarks/person_detection_benchmark.cc index 49b2b5908c0..31d2a36ed51 100644 --- a/tensorflow/lite/micro/benchmarks/person_detection_benchmark.cc +++ b/tensorflow/lite/micro/benchmarks/person_detection_benchmark.cc @@ -14,6 +14,7 @@ limitations under the License. ==============================================================================*/ #include "tensorflow/lite/c/common.h" +#include "tensorflow/lite/micro/benchmarks/micro_benchmark.h" #include "tensorflow/lite/micro/examples/person_detection/model_settings.h" #include "tensorflow/lite/micro/examples/person_detection/no_person_image_data.h" #include "tensorflow/lite/micro/examples/person_detection/person_detect_model_data.h" @@ -23,7 +24,6 @@ limitations under the License. #include "tensorflow/lite/micro/micro_interpreter.h" #include "tensorflow/lite/micro/micro_mutable_op_resolver.h" #include "tensorflow/lite/micro/micro_utils.h" -#include "tensorflow/lite/micro/testing/micro_benchmark.h" #include "tensorflow/lite/schema/schema_generated.h" #include "tensorflow/lite/version.h" diff --git a/tensorflow/lite/micro/testing/BUILD b/tensorflow/lite/micro/testing/BUILD index 0d617895d19..77a8c07517c 100644 --- a/tensorflow/lite/micro/testing/BUILD +++ b/tensorflow/lite/micro/testing/BUILD @@ -3,9 +3,16 @@ load( "tflite_micro_cc_test", ) -package( - default_visibility = ["//visibility:public"], - licenses = ["notice"], # Apache 2.0 +licenses(["notice"]) # Apache 2.0 + +package_group( + name = "micro", + packages = ["//tensorflow/lite/micro/..."], +) + +package_group( + name = "microfrontend", + packages = ["//tensorflow/lite/experimental/microfrontend/..."], ) exports_files(["test_linux_binary.sh"]) @@ -19,6 +26,10 @@ cc_library( "micro_test.h", "test_utils.h", ], + visibility = [ + ":micro", + ":microfrontend", + ], deps = [ "//tensorflow/lite/c:common", "//tensorflow/lite/core/api", @@ -39,19 +50,6 @@ tflite_micro_cc_test( ], ) -cc_library( - name = "micro_benchmark", - hdrs = [ - "micro_benchmark.h", - ], - deps = [ - "//tensorflow/lite/micro:micro_error_reporter", - "//tensorflow/lite/micro:micro_framework", - "//tensorflow/lite/micro:micro_time", - "//tensorflow/lite/micro:op_resolvers", - ], -) - cc_library( name = "test_conv_model", srcs = [ @@ -60,6 +58,9 @@ cc_library( hdrs = [ "test_conv_model.h", ], + visibility = [ + ":micro", + ], ) py_binary(