diff --git a/tensorflow/lite/experimental/microfrontend/lib/BUILD b/tensorflow/lite/experimental/microfrontend/lib/BUILD index 57f8055e9df..1a75b40356e 100644 --- a/tensorflow/lite/experimental/microfrontend/lib/BUILD +++ b/tensorflow/lite/experimental/microfrontend/lib/BUILD @@ -1,10 +1,4 @@ # Library for generating feature vectors from audio data - -load( - "//tensorflow/lite/micro/testing:micro_test.bzl", - "tflite_micro_cc_test", -) - package( default_visibility = ["//visibility:public"], licenses = ["notice"], # Apache 2.0 @@ -123,7 +117,7 @@ cc_library( ], ) -tflite_micro_cc_test( +cc_test( name = "fft_test", srcs = ["fft_test.cc"], deps = [ @@ -132,7 +126,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "filterbank_test", srcs = ["filterbank_test.cc"], # Setting copts for experimental code to [], but this code should be fixed @@ -144,7 +138,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "frontend_test", srcs = ["frontend_test.cc"], # Setting copts for experimental code to [], but this code should be fixed @@ -156,7 +150,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "log_scale_test", srcs = ["log_scale_test.cc"], # Setting copts for experimental code to [], but this code should be fixed @@ -168,7 +162,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "noise_reduction_test", srcs = ["noise_reduction_test.cc"], # Setting copts for experimental code to [], but this code should be fixed @@ -180,7 +174,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "pcan_gain_control_test", srcs = ["pcan_gain_control_test.cc"], # Setting copts for experimental code to [], but this code should be fixed @@ -192,7 +186,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "window_test", srcs = ["window_test.cc"], # Setting copts for experimental code to [], but this code should be fixed diff --git a/tensorflow/lite/micro/BUILD b/tensorflow/lite/micro/BUILD index 48d08487d24..be05366d015 100644 --- a/tensorflow/lite/micro/BUILD +++ b/tensorflow/lite/micro/BUILD @@ -1,8 +1,4 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") -load( - "//tensorflow/lite/micro/testing:micro_test.bzl", - "tflite_micro_cc_test", -) load( "//tensorflow/lite/micro:build_def.bzl", "micro_copts", @@ -220,7 +216,7 @@ cc_library( ], ) -tflite_micro_cc_test( +cc_test( name = "micro_error_reporter_test", srcs = [ "micro_error_reporter_test.cc", @@ -230,7 +226,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "micro_mutable_op_resolver_test", srcs = [ "micro_mutable_op_resolver_test.cc", @@ -242,7 +238,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "micro_interpreter_test", srcs = [ "micro_interpreter_test.cc", @@ -259,7 +255,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "simple_memory_allocator_test", srcs = [ "simple_memory_allocator_test.cc", @@ -271,7 +267,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "recording_simple_memory_allocator_test", srcs = [ "recording_simple_memory_allocator_test.cc", @@ -284,7 +280,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "micro_allocator_test", srcs = [ "micro_allocator_test.cc", @@ -298,7 +294,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "recording_micro_allocator_test", srcs = [ "recording_micro_allocator_test.cc", @@ -313,7 +309,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "memory_helpers_test", srcs = [ "memory_helpers_test.cc", @@ -325,7 +321,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "testing_helpers_test", srcs = [ "testing_helpers_test.cc", @@ -337,7 +333,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "micro_utils_test", srcs = [ "micro_utils_test.cc", @@ -348,7 +344,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "micro_string_test", srcs = [ "micro_string_test.cc", @@ -359,7 +355,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "micro_time_test", srcs = [ "micro_time_test.cc", @@ -370,7 +366,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "memory_arena_threshold_test", srcs = [ "memory_arena_threshold_test.cc", diff --git a/tensorflow/lite/micro/benchmarks/README.md b/tensorflow/lite/micro/benchmarks/README.md index 30275e595f5..74de7599c97 100644 --- a/tensorflow/lite/micro/benchmarks/README.md +++ b/tensorflow/lite/micro/benchmarks/README.md @@ -29,13 +29,13 @@ visual wakewords model. To run the keyword benchmark on x86, run ``` -make -f tensorflow/lite/micro/tools/make/Makefile test_keyword_benchmark +make -f tensorflow/lite/micro/tools/make/Makefile run_keyword_benchmark ``` To run the person detection benchmark on x86, run ``` -make -f tensorflow/lite/micro/tools/make/Makefile test_person_detection_benchmark +make -f tensorflow/lite/micro/tools/make/Makefile run_person_detection_benchmark ``` ## Run on Xtensa XPG Simulator @@ -44,7 +44,7 @@ To run the keyword benchmark on the Xtensa XPG simulator, you will need a valid Xtensa toolchain and license. With these set up, run: ``` -make -f tensorflow/lite/micro/tools/make/Makefile TARGET=xtensa OPTIMIZED_KERNEL_DIR=xtensa TARGET_ARCH= XTENSA_CORE= test_keyword_benchmark -j18 +make -f tensorflow/lite/micro/tools/make/Makefile TARGET=xtensa OPTIMIZED_KERNEL_DIR=xtensa TARGET_ARCH= XTENSA_CORE= run_keyword_benchmark -j18 ``` ## Run on Sparkfun Edge diff --git a/tensorflow/lite/micro/examples/hello_world/BUILD b/tensorflow/lite/micro/examples/hello_world/BUILD index 34106b4a896..238187e9cd4 100644 --- a/tensorflow/lite/micro/examples/hello_world/BUILD +++ b/tensorflow/lite/micro/examples/hello_world/BUILD @@ -1,10 +1,5 @@ # Description: # TensorFlow Lite for Microcontrollers "hello world" example. - -load( - "//tensorflow/lite/micro/testing:micro_test.bzl", - "tflite_micro_cc_test", -) load( "//tensorflow/lite/micro:build_def.bzl", "micro_copts", @@ -27,7 +22,7 @@ cc_library( copts = micro_copts(), ) -tflite_micro_cc_test( +cc_test( name = "hello_world_test", srcs = [ "hello_world_test.cc", diff --git a/tensorflow/lite/micro/examples/image_recognition_experimental/BUILD b/tensorflow/lite/micro/examples/image_recognition_experimental/BUILD index 2f707d9e8ef..69c37ee065b 100644 --- a/tensorflow/lite/micro/examples/image_recognition_experimental/BUILD +++ b/tensorflow/lite/micro/examples/image_recognition_experimental/BUILD @@ -1,11 +1,5 @@ # Description: # TensorFlow Lite for Microcontrollers image recognition example. - -load( - "//tensorflow/lite/micro/testing:micro_test.bzl", - "tflite_micro_cc_test", -) - package( features = ["-layering_check"], licenses = ["notice"], # Apache 2.0 @@ -27,7 +21,7 @@ cc_library( ], ) -tflite_micro_cc_test( +cc_test( name = "image_recognition_test", srcs = ["image_recognition_test.cc"], tags = [ diff --git a/tensorflow/lite/micro/examples/image_recognition_experimental/Makefile.inc b/tensorflow/lite/micro/examples/image_recognition_experimental/Makefile.inc index 76b21cb2580..feb6ed417b1 100644 --- a/tensorflow/lite/micro/examples/image_recognition_experimental/Makefile.inc +++ b/tensorflow/lite/micro/examples/image_recognition_experimental/Makefile.inc @@ -33,7 +33,7 @@ ifneq ($(filter disco_f746ng,$(ALL_TAGS)),) endif $(eval $(call microlite_test,image_recognition,\ -$(IMAGE_RECOGNITION_SRCS),$(IMAGE_RECOGNITION_HDRS))) +$(IMAGE_RECOGNITION_SRCS),$(IMAGE_RECOGNITION_HDRS), exclude)) $(eval $(call microlite_test,image_recognition_test,\ $(IMAGE_RECOGNITION_TEST_SRCS),$(IMAGE_RECOGNITION_TEST_HDRS))) diff --git a/tensorflow/lite/micro/examples/magic_wand/BUILD b/tensorflow/lite/micro/examples/magic_wand/BUILD index 0f9c517e988..a83306bcd5c 100644 --- a/tensorflow/lite/micro/examples/magic_wand/BUILD +++ b/tensorflow/lite/micro/examples/magic_wand/BUILD @@ -1,11 +1,5 @@ # Description: # TensorFlow Lite for Microcontrollers "gesture recognition" example. - -load( - "//tensorflow/lite/micro/testing:micro_test.bzl", - "tflite_micro_cc_test", -) - package( default_visibility = ["//visibility:public"], features = ["-layering_check"], @@ -34,7 +28,7 @@ cc_library( ], ) -tflite_micro_cc_test( +cc_test( name = "magic_wand_test", srcs = [ "magic_wand_test.cc", @@ -71,7 +65,7 @@ cc_library( ], ) -tflite_micro_cc_test( +cc_test( name = "accelerometer_handler_test", srcs = [ "accelerometer_handler_test.cc", @@ -99,7 +93,7 @@ cc_library( ], ) -tflite_micro_cc_test( +cc_test( name = "gesture_predictor_test", srcs = [ "gesture_predictor_test.cc", @@ -126,7 +120,7 @@ cc_library( ], ) -tflite_micro_cc_test( +cc_test( name = "output_handler_test", srcs = [ "output_handler_test.cc", diff --git a/tensorflow/lite/micro/examples/micro_speech/BUILD b/tensorflow/lite/micro/examples/micro_speech/BUILD index e7acd6552e4..d20b8a14992 100644 --- a/tensorflow/lite/micro/examples/micro_speech/BUILD +++ b/tensorflow/lite/micro/examples/micro_speech/BUILD @@ -1,11 +1,5 @@ # Description: # TensorFlow Lite microcontroller example. - -load( - "//tensorflow/lite/micro/testing:micro_test.bzl", - "tflite_micro_cc_test", -) - package( default_visibility = ["//visibility:public"], features = ["-layering_check"], @@ -44,7 +38,7 @@ cc_library( ], ) -tflite_micro_cc_test( +cc_test( name = "micro_speech_test", srcs = [ "micro_speech_test.cc", @@ -111,7 +105,7 @@ cc_library( ], ) -tflite_micro_cc_test( +cc_test( name = "simple_features_generator_reference_test", srcs = [ "simple_features/simple_features_generator_test.cc", @@ -143,7 +137,7 @@ cc_library( ], ) -tflite_micro_cc_test( +cc_test( name = "simple_features_generator_fixed_test", srcs = [ "simple_features/simple_features_generator_test.cc", @@ -191,7 +185,7 @@ cc_library( ], ) -tflite_micro_cc_test( +cc_test( name = "audio_provider_test", srcs = [ "audio_provider_test.cc", @@ -206,7 +200,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "audio_provider_mock_test", srcs = [ "audio_provider_mock_test.cc", @@ -239,7 +233,7 @@ cc_library( ], ) -tflite_micro_cc_test( +cc_test( name = "feature_provider_test", srcs = [ "feature_provider_test.cc", @@ -272,11 +266,15 @@ cc_library( ], ) -tflite_micro_cc_test( +cc_test( name = "feature_provider_mock_test", + size = "small", srcs = [ "feature_provider_mock_test.cc", ], + tags = [ + "noasan", # TODO(b/179930607): Fix with asan. + ], deps = [ ":feature_provider_mock", "//tensorflow/lite/c:common", @@ -303,7 +301,7 @@ cc_library( ], ) -tflite_micro_cc_test( +cc_test( name = "recognize_commands_test", srcs = [ "recognize_commands_test.cc", @@ -335,7 +333,7 @@ cc_library( ], ) -tflite_micro_cc_test( +cc_test( name = "command_responder_test", srcs = [ "command_responder_test.cc", diff --git a/tensorflow/lite/micro/examples/micro_speech/micro_features/BUILD b/tensorflow/lite/micro/examples/micro_speech/micro_features/BUILD index 3dff48682c7..39dd4ca60f4 100644 --- a/tensorflow/lite/micro/examples/micro_speech/micro_features/BUILD +++ b/tensorflow/lite/micro/examples/micro_speech/micro_features/BUILD @@ -1,10 +1,4 @@ # Library for generating feature vectors from audio data - -load( - "//tensorflow/lite/micro/testing:micro_test.bzl", - "tflite_micro_cc_test", -) - package( default_visibility = ["//visibility:public"], features = ["-layering_check"], @@ -76,11 +70,15 @@ cc_library( ], ) -tflite_micro_cc_test( +cc_test( name = "micro_features_generator_test", + size = "small", srcs = [ "micro_features_generator_test.cc", ], + tags = [ + "noasan", # TODO(b/179930607): Fix with asan. + ], deps = [ ":micro_features_generator", ":micro_features_generator_test_data", diff --git a/tensorflow/lite/micro/examples/person_detection/BUILD b/tensorflow/lite/micro/examples/person_detection/BUILD index cf69ef9509b..73ed802a25e 100644 --- a/tensorflow/lite/micro/examples/person_detection/BUILD +++ b/tensorflow/lite/micro/examples/person_detection/BUILD @@ -1,11 +1,5 @@ # Description: # TensorFlow Lite for Microcontrollers Vision Example. - -load( - "//tensorflow/lite/micro/testing:micro_test.bzl", - "tflite_micro_cc_test", -) - package( default_visibility = ["//visibility:public"], features = ["-layering_check"], @@ -53,7 +47,7 @@ cc_library( ], ) -tflite_micro_cc_test( +cc_test( name = "person_detection_test", srcs = ["person_detection_test.cc"], tags = [ @@ -87,7 +81,7 @@ cc_library( ], ) -tflite_micro_cc_test( +cc_test( name = "image_provider_test", srcs = [ "image_provider_test.cc", @@ -115,7 +109,7 @@ cc_library( ], ) -tflite_micro_cc_test( +cc_test( name = "detection_responder_test", srcs = [ "detection_responder_test.cc", diff --git a/tensorflow/lite/micro/kernels/BUILD b/tensorflow/lite/micro/kernels/BUILD index f62ea111062..8ec2b84f8f1 100644 --- a/tensorflow/lite/micro/kernels/BUILD +++ b/tensorflow/lite/micro/kernels/BUILD @@ -1,7 +1,3 @@ -load( - "//tensorflow/lite/micro/testing:micro_test.bzl", - "tflite_micro_cc_test", -) load( "//tensorflow/lite/micro:build_def.bzl", "micro_copts", @@ -27,6 +23,10 @@ package_group( packages = ["//tensorflow/lite/micro"], ) +#################################### +# C++ libraries +#################################### + cc_library( name = "activation_utils", hdrs = ["activation_utils.h"], @@ -287,23 +287,11 @@ cc_library( }), ) +#################################### +# C++ tests +#################################### + cc_test( - name = "shape_test", - srcs = ["shape_test.cc"], - deps = [ - ":kernel_runner", - "//tensorflow/lite/c:common", - "//tensorflow/lite/micro:op_resolvers", - "//tensorflow/lite/micro:test_helpers", - "//tensorflow/lite/micro/testing:micro_test", - ], -) - -test_suite( - name = "all_tests", -) - -tflite_micro_cc_test( name = "activations_test", srcs = [ "activations_test.cc", @@ -317,7 +305,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "add_test", srcs = [ "add_test.cc", @@ -331,7 +319,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "arg_min_max_test", srcs = [ "arg_min_max_test.cc", @@ -345,7 +333,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "batch_to_space_nd_test", srcs = [ "batch_to_space_nd_test.cc", @@ -359,7 +347,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "cast_test", srcs = ["cast_test.cc"], deps = [ @@ -372,7 +360,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "ceil_test", srcs = [ "ceil_test.cc", @@ -386,7 +374,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "circular_buffer_test", srcs = [ "circular_buffer_test.cc", @@ -401,7 +389,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "comparisons_test", srcs = [ "comparisons_test.cc", @@ -414,7 +402,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "concatenation_test", srcs = [ "concatenation_test.cc", @@ -427,7 +415,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "conv_test", srcs = [ "conv_test.cc", @@ -442,7 +430,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "depthwise_conv_test", srcs = [ "depthwise_conv_test.cc", @@ -456,7 +444,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "dequantize_test", srcs = [ "dequantize_test.cc", @@ -469,7 +457,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "detection_postprocess_test", srcs = [ "detection_postprocess_test.cc", @@ -485,7 +473,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "elementwise_test", srcs = ["elementwise_test.cc"], deps = [ @@ -498,7 +486,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "exp_test", srcs = ["exp_test.cc"], deps = [ @@ -511,7 +499,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "floor_test", srcs = [ "floor_test.cc", @@ -525,7 +513,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "fully_connected_test", srcs = [ "fully_connected_test.cc", @@ -540,7 +528,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "hard_swish_test", srcs = ["hard_swish_test.cc"], deps = [ @@ -552,7 +540,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "l2norm_test", srcs = [ "l2norm_test.cc", @@ -566,7 +554,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "logical_test", srcs = [ "logical_test.cc", @@ -580,7 +568,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "logistic_test", srcs = [ "logistic_test.cc", @@ -594,7 +582,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "maximum_minimum_test", srcs = [ "maximum_minimum_test.cc", @@ -608,7 +596,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "mul_test", srcs = [ "mul_test.cc", @@ -621,7 +609,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "neg_test", srcs = [ "neg_test.cc", @@ -635,7 +623,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "pack_test", srcs = [ "pack_test.cc", @@ -649,7 +637,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "pad_test", srcs = [ "pad_test.cc", @@ -667,7 +655,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "pooling_test", srcs = [ "pooling_test.cc", @@ -680,7 +668,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "prelu_test", srcs = [ "prelu_test.cc", @@ -693,7 +681,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "quantization_util_test", srcs = [ "quantization_util_test.cc", @@ -705,7 +693,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "quantize_test", srcs = [ "quantize_test.cc", @@ -718,7 +706,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "reduce_test", srcs = [ "reduce_test.cc", @@ -732,7 +720,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "reshape_test", srcs = [ "reshape_test.cc", @@ -747,7 +735,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "resize_nearest_neighbor_test", srcs = [ "resize_nearest_neighbor_test.cc", @@ -761,7 +749,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "round_test", srcs = [ "round_test.cc", @@ -775,7 +763,19 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( + name = "shape_test", + srcs = ["shape_test.cc"], + deps = [ + ":kernel_runner", + "//tensorflow/lite/c:common", + "//tensorflow/lite/micro:op_resolvers", + "//tensorflow/lite/micro:test_helpers", + "//tensorflow/lite/micro/testing:micro_test", + ], +) + +cc_test( name = "softmax_test", srcs = [ "softmax_test.cc", @@ -789,7 +789,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "space_to_batch_nd_test", srcs = [ "space_to_batch_nd_test.cc", @@ -804,7 +804,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "split_test", srcs = [ "split_test.cc", @@ -819,7 +819,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "split_v_test", srcs = [ "split_v_test.cc", @@ -834,7 +834,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "strided_slice_test", srcs = [ "strided_slice_test.cc", @@ -848,7 +848,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "sub_test", srcs = [ "sub_test.cc", @@ -861,7 +861,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "svdf_test", srcs = [ "svdf_test.cc", @@ -874,7 +874,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "tanh_test", srcs = ["tanh_test.cc"], deps = [ @@ -885,7 +885,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "transpose_conv_test", srcs = [ "transpose_conv_test.cc", @@ -900,7 +900,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "unpack_test", srcs = [ "unpack_test.cc", @@ -914,7 +914,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "zeros_like_test", srcs = ["zeros_like_test.cc"], deps = [ diff --git a/tensorflow/lite/micro/memory_planner/BUILD b/tensorflow/lite/micro/memory_planner/BUILD index e524e85f0ed..a1908908b42 100644 --- a/tensorflow/lite/micro/memory_planner/BUILD +++ b/tensorflow/lite/micro/memory_planner/BUILD @@ -1,7 +1,3 @@ -load( - "//tensorflow/lite/micro/testing:micro_test.bzl", - "tflite_micro_cc_test", -) load( "//tensorflow/lite/micro:build_def.bzl", "micro_copts", @@ -58,7 +54,7 @@ cc_library( ], ) -tflite_micro_cc_test( +cc_test( name = "linear_memory_planner_test", srcs = [ "linear_memory_planner_test.cc", @@ -69,7 +65,7 @@ tflite_micro_cc_test( ], ) -tflite_micro_cc_test( +cc_test( name = "greedy_memory_planner_test", srcs = [ "greedy_memory_planner_test.cc", diff --git a/tensorflow/lite/micro/testing/BUILD b/tensorflow/lite/micro/testing/BUILD index d07e965cba4..23be405d0f2 100644 --- a/tensorflow/lite/micro/testing/BUILD +++ b/tensorflow/lite/micro/testing/BUILD @@ -1,9 +1,3 @@ -load("@bazel_skylib//:bzl_library.bzl", "bzl_library") -load( - "//tensorflow/lite/micro/testing:micro_test.bzl", - "tflite_micro_cc_test", -) - package( features = ["-layering_check"], licenses = ["notice"], # Apache 2.0 @@ -40,7 +34,7 @@ cc_library( ], ) -tflite_micro_cc_test( +cc_test( name = "util_test", srcs = [ "util_test.cc", @@ -79,10 +73,3 @@ py_binary( "@absl_py//absl:app", ], ) - -bzl_library( - name = "micro_test_bzl", - srcs = ["micro_test.bzl"], - visibility = ["//visibility:private"], - deps = ["//tensorflow/lite/micro:build_def_bzl"], -) diff --git a/tensorflow/lite/micro/testing/micro_test.bzl b/tensorflow/lite/micro/testing/micro_test.bzl deleted file mode 100644 index 5e1a56fdc48..00000000000 --- a/tensorflow/lite/micro/testing/micro_test.bzl +++ /dev/null @@ -1,73 +0,0 @@ -"""Rules for simple testing without dependencies by parsing output logs.""" - -load( - "//tensorflow/lite/micro:build_def.bzl", - "micro_copts", -) - -def tflite_micro_cc_test( - name, - size = "medium", - expected_in_logs = "~~~ALL TESTS PASSED~~~", - srcs = [], - includes = [], - defines = [], - copts = micro_copts(), - nocopts = "", - linkopts = [], - deps = [], - tags = [], - visibility = None): - """Tests a C/C++ binary without testing framework dependencies`. - - Runs a C++ binary, and tests that the output logs contain the - expected value. This is a deliberately spartan way of testing, to match - what's available when testing microcontroller binaries. - - Args: - name: a unique name for this rule. - expected_in_logs: A regular expression that is required to be - present in the binary's logs for the test to pass. - srcs: sources to compile (C, C++, ld scripts). - includes: include paths to add to this rule and its dependents. - defines: list of `VAR` or `VAR=VAL` to pass to CPP for this rule and - its dependents. - copts: gcc compilation flags for this rule only. - nocopts: list of gcc compilation flags to remove for this rule - only. No regexp like for `cc_library`. - linkopts: `gcc` flags to add to the linking phase. For "pure" ld flags, - prefix them with the `-Wl,` prefix here. - deps: dependencies. only `tflite_bare_metal_cc_library()` dependencies - allowed. - visibility: visibility. - """ - native.cc_binary( - name = name + "_binary", - srcs = srcs, - includes = includes, - defines = defines, - copts = copts, - nocopts = nocopts, - linkopts = linkopts, - deps = deps, - tags = tags, - visibility = visibility, - ) - native.sh_test( - name = name, - size = size, - srcs = [ - "//tensorflow/lite/micro/testing:test_linux_binary.sh", - ], - args = [ - native.package_name() + "/" + name + "_binary", - "'" + expected_in_logs + "'", - ], - data = [ - name + "_binary", - # Internal test dependency placeholder - ], - deps = [ - ], - tags = tags, - ) diff --git a/tensorflow/lite/micro/testing/test_hexagon_binary.sh b/tensorflow/lite/micro/testing/test_hexagon_binary.sh index a3ea244147c..98b3c50431a 100755 --- a/tensorflow/lite/micro/testing/test_hexagon_binary.sh +++ b/tensorflow/lite/micro/testing/test_hexagon_binary.sh @@ -20,7 +20,6 @@ # Second argument is a regular expression that's required to be in the output # logs for the test to pass. -declare -r ROOT_DIR=`pwd` declare -r TEST_TMPDIR=/tmp/test_hexagon_binary/ declare -r MICRO_LOG_PATH=${TEST_TMPDIR}/$1 declare -r MICRO_LOG_FILENAME=${MICRO_LOG_PATH}/logs.txt @@ -29,11 +28,14 @@ mkdir -p ${MICRO_LOG_PATH} hexagon-elfcopy $1 $1.elf hexagon-sim $1.elf 2>&1 | tee ${MICRO_LOG_FILENAME} -if grep -q "$2" ${MICRO_LOG_FILENAME} +if [[ ${2} != "non_test_binary" ]] then - echo "$1: PASS" - exit 0 -else - echo "$1: FAIL - '$2' not found in logs." - exit 1 + if grep -q "$2" ${MICRO_LOG_FILENAME} + then + echo "$1: PASS" + exit 0 + else + echo "$1: FAIL - '$2' not found in logs." + exit 1 + fi fi diff --git a/tensorflow/lite/micro/testing/test_linux_binary.sh b/tensorflow/lite/micro/testing/test_linux_binary.sh deleted file mode 100755 index 30cf0413c4f..00000000000 --- a/tensorflow/lite/micro/testing/test_linux_binary.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -# 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. -# ============================================================================== -# -# Tests a Linux binary by parsing the log output. -# -# First argument is the binary location. -# Second argument is a regular expression that's required to be in the output logs -# for the test to pass. - -declare -r ROOT_DIR=`pwd` -declare -r TEST_TMPDIR=/tmp/test_linux_binary/ -declare -r MICRO_LOG_PATH=${TEST_TMPDIR}/$1 -declare -r MICRO_LOG_FILENAME=${MICRO_LOG_PATH}/logs.txt -mkdir -p ${MICRO_LOG_PATH} - -ERROR_MSG="$1: FAIL - '$2' not found in logs." -print_error_and_exit() { - echo ${ERROR_MSG} - cat ${MICRO_LOG_FILENAME} - exit 1 -} - -# This traps the signal from the test binary ($1) and checks if there was a -# segfault and adds that to the error log (which would otherwise be missing). -trap 'if [[ $? -eq 139 ]]; then echo "Segmentation fault" >> ${MICRO_LOG_FILENAME}; print_error_and_exit; fi' CHLD - -# This trap statement prevents the bash script from segfaulting with a cryptic -# message like: -# tensorflow/lite/micro/testing/test_linux_binary.sh: line 44: 210514 Segmentation fault $1 > ${MICRO_LOG_FILENAME} 2>&1 -# What we get instead is purely another Segmentation fault text in the output. -trap '' SEGV - -$1 > ${MICRO_LOG_FILENAME} 2>&1 - -if grep -q "$2" ${MICRO_LOG_FILENAME} -then - echo "$1: PASS" - exit 0 -else - print_error_and_exit -fi - diff --git a/tensorflow/lite/micro/testing/test_xtensa_binary.sh b/tensorflow/lite/micro/testing/test_xtensa_binary.sh index fb9ca9cd48d..9141d2f6d8f 100755 --- a/tensorflow/lite/micro/testing/test_xtensa_binary.sh +++ b/tensorflow/lite/micro/testing/test_xtensa_binary.sh @@ -21,7 +21,6 @@ # Second argument is a regular expression that's required to be in the output # logs for the test to pass. -declare -r ROOT_DIR=`pwd` declare -r TEST_TMPDIR=/tmp/test_xtensa_binary/ declare -r MICRO_LOG_PATH=${TEST_TMPDIR}/$1 declare -r MICRO_LOG_FILENAME=${MICRO_LOG_PATH}/logs.txt @@ -29,11 +28,13 @@ mkdir -p ${MICRO_LOG_PATH} xt-run $1 2>&1 | tee ${MICRO_LOG_FILENAME} -if grep -q "$2" ${MICRO_LOG_FILENAME} +if [[ ${2} != "non_test_binary" ]] then - echo "$1: PASS" - exit 0 -else - echo "$1: FAIL - '$2' not found in logs." - exit 1 + if grep -q "$2" ${MICRO_LOG_FILENAME} + then + exit 0 + else + exit 1 + fi fi + diff --git a/tensorflow/lite/micro/tools/ci_build/test_bazel.sh b/tensorflow/lite/micro/tools/ci_build/test_bazel.sh index 77bd91904db..92732b72d23 100755 --- a/tensorflow/lite/micro/tools/ci_build/test_bazel.sh +++ b/tensorflow/lite/micro/tools/ci_build/test_bazel.sh @@ -48,9 +48,25 @@ readable_run cp tensorflow/lite/micro/tools/ci_build/tflm_bazel/WORKSPACE ./ # Now that we are set up to download fewer external deps as part of a bazel # build, we can go ahead and invoke bazel. -CC=clang readable_run bazel test tensorflow/lite/micro/... --test_tag_filters=-no_oss --build_tag_filters=-no_oss -CC=clang readable_run bazel test tensorflow/lite/micro/... --config=msan --test_tag_filters=-no_oss,-nomsan --build_tag_filters=-no_oss,-nomsan -CC=clang readable_run bazel test tensorflow/lite/micro/... --config=asan --test_tag_filters=-no_oss,-noasan --build_tag_filters=-no_oss,-noasan +CC=clang readable_run bazel test tensorflow/lite/micro/... \ + --test_tag_filters=-no_oss --build_tag_filters=-no_oss \ + --test_output=errors + +CC=clang readable_run bazel test tensorflow/lite/micro/... \ + --config=msan \ + --test_tag_filters=-no_oss,-nomsan --build_tag_filters=-no_oss,-nomsan \ + --test_output=errors + +CC=clang readable_run bazel test tensorflow/lite/micro/... \ + --config=asan \ + --test_tag_filters=-no_oss,-noasan --build_tag_filters=-no_oss,-noasan \ + --test_output=errors + # TODO(b/178621680): enable ubsan once bazel + clang + ubsan errors are fixed. #CC=clang readable_run bazel test tensorflow/lite/micro/... --config=ubsan --test_tag_filters=-no_oss,-noubsan --build_tag_filters=-no_oss,-noubsan -CC=clang readable_run bazel test tensorflow/lite/micro/... --test_tag_filters=-no_oss --build_tag_filters=-no_oss --copt=-DTF_LITE_STATIC_MEMORY + +CC=clang readable_run bazel test tensorflow/lite/micro/... \ + --test_tag_filters=-no_oss --build_tag_filters=-no_oss \ + --copt=-DTF_LITE_STATIC_MEMORY \ + --test_output=errors + diff --git a/tensorflow/lite/micro/tools/make/Makefile b/tensorflow/lite/micro/tools/make/Makefile index 4820f9d83b0..73d7fedd48a 100644 --- a/tensorflow/lite/micro/tools/make/Makefile +++ b/tensorflow/lite/micro/tools/make/Makefile @@ -93,7 +93,7 @@ third_party/gemmlowp \ third_party/flatbuffers/include \ third_party/ruy -TEST_SCRIPT := tensorflow/lite/micro/testing/test_linux_binary.sh +TEST_SCRIPT := MICROLITE_LIBS := -lm diff --git a/tensorflow/lite/micro/tools/make/helper_functions.inc b/tensorflow/lite/micro/tools/make/helper_functions.inc index f9c0c297d23..efbda33b4ac 100644 --- a/tensorflow/lite/micro/tools/make/helper_functions.inc +++ b/tensorflow/lite/micro/tools/make/helper_functions.inc @@ -437,10 +437,20 @@ endef # Handles the details of generating a binary target, including specializing # for the current platform, and generating project file targets. +# +# Note that while the function is called microlite_test, it is used for both +# test and non-test binaries. + +# Files that end with _test are added as test targets (i.e. can be executed with +# make test_. ALl others can be executed with make run_ +# # Arguments are: -# 1 - Name of test. -# 2 - C/C++ source files implementing the test. -# 3 - C/C++ header files needed for the test. +# 1 - Name of target. +# 2 - C/C++ source files +# 3 - C/C++ header files +# 4 - if "exclude", then the non-test target will be excluded from +# MICROLITE_BUILD_TARGETS. This exception is needed because not all the +# microlite_test targets (e.g. the examples) are buildable on all platforms. # Calling eval on the output will create the targets that you need. define microlite_test ifeq (,$(findstring _test, $(1))) @@ -461,24 +471,21 @@ $$($(1)_BINARY): $$($(1)_LOCAL_OBJS) $$(MICROLITE_LIB_PATH) $$(MICROLITE_LIB_PATH) $$(LDFLAGS) $$(MICROLITE_LIBS) $(1): $$($(1)_BINARY) $(1)_bin: $$($(1)_BINARY).bin -test_$(1): $$($(1)_BINARY) - @test -f $$(TEST_SCRIPT) || (echo 'Unable to find the test script. Is the software emulation available in $$(TARGET)?'; exit 1) - $$(TEST_SCRIPT) $$($(1)_BINARY) $$(TEST_PASS_STRING) $$(TARGET) ifneq (,$(findstring _test,$(1))) MICROLITE_TEST_TARGETS += test_$(1) MICROLITE_BUILD_TARGETS += $$($(1)_BINARY) -endif -# The ifneq can make is seem that the body of the if block is executed when -# _benchmark is not found in $(1). Actually, the check is saying that if -# findstring does not return empty, i.e. if _benchmark is found in $(1), we -# should add something to the MICROLITE_BUILD_TARGETS. -# -# This ensures that a `make build` command will builds all the tests and -# benchmarks, though `make test` will only run the tests. -ifneq (,$(findstring _benchmark,$(1))) - MICROLITE_BUILD_TARGETS += $$($(1)_BINARY) +test_$(1): $$($(1)_BINARY) + $$(TEST_SCRIPT) $$($(1)_BINARY) $$(TEST_PASS_STRING) $$(TARGET) + +else + ifeq ($(findstring exclude,$(4)),) + MICROLITE_BUILD_TARGETS += $$($(1)_BINARY) + endif + +run_$(1): $$($(1)_BINARY) + $$(TEST_SCRIPT) $$($(1)_BINARY) non_test_binary $$(TARGET) endif $(eval $(call generate_microlite_projects,$(1),$(call specialize,$(2)),$(3)))