diff --git a/tensorflow/lite/micro/kernels/logical_test.cc b/tensorflow/lite/micro/kernels/logical_test.cc index eeab32ba..daad05d0 100644 --- a/tensorflow/lite/micro/kernels/logical_test.cc +++ b/tensorflow/lite/micro/kernels/logical_test.cc @@ -17,7 +17,7 @@ limitations under the License. #include "tensorflow/lite/c/common.h" #include "tensorflow/lite/micro/kernels/kernel_runner.h" #include "tensorflow/lite/micro/test_helpers.h" -#include "tensorflow/lite/micro/testing/micro_test.h" +#include "tensorflow/lite/micro/testing/micro_test_v2.h" namespace tflite { namespace testing { @@ -50,12 +50,12 @@ void TestLogicalOp(const TFLMRegistration& registration, int* input1_dims_data, outputs_array, /*builtin_data=*/nullptr); - TF_LITE_MICRO_EXPECT_EQ(kTfLiteOk, runner.InitAndPrepare()); - TF_LITE_MICRO_EXPECT_EQ(kTfLiteOk, runner.Invoke()); + EXPECT_EQ(kTfLiteOk, runner.InitAndPrepare()); + EXPECT_EQ(kTfLiteOk, runner.Invoke()); - TF_LITE_MICRO_EXPECT_EQ(output_dims_count, 4); + EXPECT_EQ(output_dims_count, 4); for (int i = 0; i < output_dims_count; ++i) { - TF_LITE_MICRO_EXPECT_EQ(expected_output_data[i], output_data[i]); + EXPECT_EQ(expected_output_data[i], output_data[i]); } } @@ -63,9 +63,7 @@ void TestLogicalOp(const TFLMRegistration& registration, int* input1_dims_data, } // namespace testing } // namespace tflite -TF_LITE_MICRO_TESTS_BEGIN - -TF_LITE_MICRO_TEST(LogicalOr) { +TEST(LogicalTest, LogicalOr) { int shape[] = {4, 1, 1, 1, 4}; const bool input1[] = {true, false, false, true}; const bool input2[] = {true, false, true, false}; @@ -75,7 +73,7 @@ TF_LITE_MICRO_TEST(LogicalOr) { shape, input2, shape, golden, output_data); } -TF_LITE_MICRO_TEST(BroadcastLogicalOr) { +TEST(LogicalTest, BroadcastLogicalOr) { int input1_shape[] = {4, 1, 1, 1, 4}; const bool input1[] = {true, false, false, true}; int input2_shape[] = {4, 1, 1, 1, 1}; @@ -87,7 +85,7 @@ TF_LITE_MICRO_TEST(BroadcastLogicalOr) { golden, output_data); } -TF_LITE_MICRO_TEST(LogicalAnd) { +TEST(LogicalTest, LogicalAnd) { int shape[] = {4, 1, 1, 1, 4}; const bool input1[] = {true, false, false, true}; const bool input2[] = {true, false, true, false}; @@ -97,7 +95,7 @@ TF_LITE_MICRO_TEST(LogicalAnd) { shape, input2, shape, golden, output_data); } -TF_LITE_MICRO_TEST(BroadcastLogicalAnd) { +TEST(LogicalTest, BroadcastLogicalAnd) { int input1_shape[] = {4, 1, 1, 1, 4}; const bool input1[] = {true, false, false, true}; int input2_shape[] = {4, 1, 1, 1, 1}; @@ -109,4 +107,4 @@ TF_LITE_MICRO_TEST(BroadcastLogicalAnd) { golden, output_data); } -TF_LITE_MICRO_TESTS_END +TF_LITE_MICRO_TESTS_MAIN diff --git a/tensorflow/lite/micro/kernels/logistic_test.cc b/tensorflow/lite/micro/kernels/logistic_test.cc index 224e4e49..8ab7cccc 100644 --- a/tensorflow/lite/micro/kernels/logistic_test.cc +++ b/tensorflow/lite/micro/kernels/logistic_test.cc @@ -17,7 +17,7 @@ limitations under the License. #include "tensorflow/lite/c/common.h" #include "tensorflow/lite/micro/kernels/kernel_runner.h" #include "tensorflow/lite/micro/test_helpers.h" -#include "tensorflow/lite/micro/testing/micro_test.h" +#include "tensorflow/lite/micro/testing/micro_test_v2.h" namespace tflite { namespace testing { @@ -149,11 +149,11 @@ void ValidateLogisticGoldens(TfLiteTensor* tensors, const int tensor_count, micro::KernelRunner runner(registration, tensors, tensor_count, inputs_array, outputs_array, nullptr); - TF_LITE_MICRO_EXPECT_EQ(kTfLiteOk, runner.InitAndPrepare()); - TF_LITE_MICRO_EXPECT_EQ(kTfLiteOk, runner.Invoke()); + EXPECT_EQ(kTfLiteOk, runner.InitAndPrepare()); + EXPECT_EQ(kTfLiteOk, runner.Invoke()); for (int i = 0; i < output_dims_count; ++i) { - TF_LITE_MICRO_EXPECT_NEAR(golden[i], output_data[i], tolerance); + EXPECT_NEAR(golden[i], output_data[i], tolerance); } } @@ -208,16 +208,14 @@ void TestLogisticQuantized(int* input_dims_data, const float* input_data, } // namespace testing } // namespace tflite -TF_LITE_MICRO_TESTS_BEGIN - -TF_LITE_MICRO_TEST(LogisticFloatBasicShouldMatchGolden) { +TEST(LogisticTest, LogisticFloatBasicShouldMatchGolden) { float output_data[tflite::testing::flat_size_basic]; tflite::testing::TestLogisticFloat( tflite::testing::shape_basic, tflite::testing::input_data_basic, tflite::testing::golden_basic, tflite::testing::shape_basic, output_data); } -TF_LITE_MICRO_TEST(LogisticQuantizedInt8BasicShouldMatchGolden) { +TEST(LogisticTest, LogisticQuantizedInt8BasicShouldMatchGolden) { const float input_scale = 0.1; const int input_zero_point = 0; int8_t input_quantized[tflite::testing::flat_size_basic]; @@ -233,7 +231,7 @@ TF_LITE_MICRO_TEST(LogisticQuantizedInt8BasicShouldMatchGolden) { tflite::testing::quantized_output_zero_point_int8, output_data, 1.0f); } -TF_LITE_MICRO_TEST(LogisticFloatWideRangeShouldMatchGolden) { +TEST(LogisticTest, LogisticFloatWideRangeShouldMatchGolden) { float output_data[tflite::testing::flat_size_wide_range]; tflite::testing::TestLogisticFloat( tflite::testing::shape_wide_range, tflite::testing::input_data_wide_range, @@ -241,7 +239,7 @@ TF_LITE_MICRO_TEST(LogisticFloatWideRangeShouldMatchGolden) { output_data); } -TF_LITE_MICRO_TEST(LogisticQuantizedInt8WideRangeShouldMatchGolden) { +TEST(LogisticTest, LogisticQuantizedInt8WideRangeShouldMatchGolden) { const float input_scale = 1.0; const int input_zero_point = 0; int8_t input_quantized[tflite::testing::flat_size_wide_range]; @@ -257,7 +255,7 @@ TF_LITE_MICRO_TEST(LogisticQuantizedInt8WideRangeShouldMatchGolden) { tflite::testing::quantized_output_zero_point_int8, output_data, 1.0f); } -TF_LITE_MICRO_TEST(LogisticQuantizedInt16ShouldMatchGolden) { +TEST(LogisticTest, LogisticQuantizedInt16ShouldMatchGolden) { const float input_scale = 32.f / 65536.f; const int input_zero_point = 0; const float output_scale = 2.f / 65536.f; @@ -274,4 +272,4 @@ TF_LITE_MICRO_TEST(LogisticQuantizedInt16ShouldMatchGolden) { output_data, 16.0f); } -TF_LITE_MICRO_TESTS_END +TF_LITE_MICRO_TESTS_MAIN diff --git a/tensorflow/lite/micro/kernels/lstm_eval_test.cc b/tensorflow/lite/micro/kernels/lstm_eval_test.cc index eaba2c4a..b33a64e9 100644 --- a/tensorflow/lite/micro/kernels/lstm_eval_test.cc +++ b/tensorflow/lite/micro/kernels/lstm_eval_test.cc @@ -25,7 +25,7 @@ limitations under the License. #include "tensorflow/lite/micro/kernels/lstm_shared.h" #include "tensorflow/lite/micro/kernels/testdata/lstm_test_data.h" #include "tensorflow/lite/micro/test_helpers.h" -#include "tensorflow/lite/micro/testing/micro_test.h" +#include "tensorflow/lite/micro/testing/micro_test_v2.h" // TODO(b/230666079) enable below tests for xtensa when the xtensa // kernel is reconciled with reference kernel @@ -36,11 +36,10 @@ constexpr float kTestFloatTolerance = 1e-6f; } // namespace #endif // !defined(XTENSA) -TF_LITE_MICRO_TESTS_BEGIN // TODO(b/230666079) enable below tests for xtensa when the xtensa // kernel is reconciled with reference kernel #if !defined(XTENSA) -TF_LITE_MICRO_TEST(CheckGateOutputFloat) { +TEST(LstmEvalTest, CheckGateOutputFloat) { const tflite::testing::GateOutputCheckData<4, 4> gate_output_data = tflite::testing::Get2X2GateOutputCheckData(); tflite::testing::LstmNodeContent @@ -107,7 +106,7 @@ TF_LITE_MICRO_TEST(CheckGateOutputFloat) { gate_output_data.expected_cell_gate_output, kTestFloatTolerance); } -TF_LITE_MICRO_TEST(CheckGateOutputInt8) { +TEST(LstmEvalTest, CheckGateOutputInt8) { const tflite::testing::GateOutputCheckData<4, 4> gate_output_data = tflite::testing::Get2X2GateOutputCheckData(); tflite::testing::LstmNodeContent @@ -194,7 +193,7 @@ TF_LITE_MICRO_TEST(CheckGateOutputInt8) { gate_output_data.expected_cell_gate_output, tolerance); } -TF_LITE_MICRO_TEST(CheckGateOutputInt16) { +TEST(LstmEvalTest, CheckGateOutputInt16) { const tflite::testing::GateOutputCheckData<4, 4> gate_output_data = tflite::testing::Get2X2GateOutputCheckData(); tflite::testing::LstmNodeContent gate_output_data = tflite::testing::Get2X2GateOutputCheckData(); tflite::testing::LstmNodeContent @@ -297,7 +296,7 @@ TF_LITE_MICRO_TEST(CheckCellStateUpdateFloat) { gate_output_data, float_node_contents, kTestFloatTolerance); } -TF_LITE_MICRO_TEST(CheckCellStateUpdateInt8) { +TEST(LstmEvalTest, CheckCellStateUpdateInt8) { const tflite::testing::GateOutputCheckData<4, 4> gate_output_data = tflite::testing::Get2X2GateOutputCheckData(); tflite::testing::LstmNodeContent @@ -313,7 +312,7 @@ TF_LITE_MICRO_TEST(CheckCellStateUpdateInt8) { int8_node_contents, tolerance); } -TF_LITE_MICRO_TEST(CheckCellStateUpdateInt16) { +TEST(LstmEvalTest, CheckCellStateUpdateInt16) { const tflite::testing::GateOutputCheckData<4, 4> gate_output_data = tflite::testing::Get2X2GateOutputCheckData(); tflite::testing::LstmNodeContent gate_output_data = tflite::testing::Get2X2GateOutputCheckData(); tflite::testing::LstmNodeContent @@ -341,7 +340,7 @@ TF_LITE_MICRO_TEST(CheckHiddenStateUpdateFloat) { gate_output_data, float_node_contents, kTestFloatTolerance); } -TF_LITE_MICRO_TEST(CheckHiddenStateUpdateInt8) { +TEST(LstmEvalTest, CheckHiddenStateUpdateInt8) { const tflite::testing::GateOutputCheckData<4, 4> gate_output_data = tflite::testing::Get2X2GateOutputCheckData(); tflite::testing::LstmNodeContent @@ -355,7 +354,7 @@ TF_LITE_MICRO_TEST(CheckHiddenStateUpdateInt8) { int8_node_contents, tolerance); } -TF_LITE_MICRO_TEST(CheckHiddenStateUpdateInt16) { +TEST(LstmEvalTest, CheckHiddenStateUpdateInt16) { const tflite::testing::GateOutputCheckData<4, 4> gate_output_data = tflite::testing::Get2X2GateOutputCheckData(); tflite::testing::LstmNodeContent gate_output_data = tflite::testing::Get2X2GateOutputCheckData(); tflite::testing::LstmNodeContent @@ -380,7 +379,7 @@ TF_LITE_MICRO_TEST(CheckOneStepLSTMFloat) { kTestFloatTolerance, float_node_contents); } -TF_LITE_MICRO_TEST(CheckOneStepLSTMInt8) { +TEST(LstmEvalTest, CheckOneStepLSTMInt8) { const tflite::testing::GateOutputCheckData<4, 4> gate_output_data = tflite::testing::Get2X2GateOutputCheckData(); tflite::testing::LstmNodeContent @@ -396,7 +395,7 @@ TF_LITE_MICRO_TEST(CheckOneStepLSTMInt8) { int8_node_contents); } -TF_LITE_MICRO_TEST(CheckOneStepLSTMInt16) { +TEST(LstmEvalTest, CheckOneStepLSTMInt16) { const tflite::testing::GateOutputCheckData<4, 4> gate_output_data = tflite::testing::Get2X2GateOutputCheckData(); tflite::testing::LstmNodeContent kernel_eval_data = tflite::testing::Get2X2LstmEvalCheckData(); tflite::testing::LstmNodeContent @@ -424,7 +423,7 @@ TF_LITE_MICRO_TEST(TestLSTMEvalFloat) { kTestFloatTolerance, float_node_contents); } -TF_LITE_MICRO_TEST(TestLSTMEvalInt8) { +TEST(LstmEvalTest, TestLSTMEvalInt8) { const tflite::testing::LstmEvalCheckData<12, 4, 12> kernel_eval_data = tflite::testing::Get2X2LstmEvalCheckData(); tflite::testing::LstmNodeContent @@ -439,7 +438,7 @@ TF_LITE_MICRO_TEST(TestLSTMEvalInt8) { int8_node_contents); } -TF_LITE_MICRO_TEST(TestLSTMEvalInt16) { +TEST(LstmEvalTest, TestLSTMEvalInt16) { const tflite::testing::LstmEvalCheckData<12, 4, 12> kernel_eval_data = tflite::testing::Get2X2LstmEvalCheckData(); tflite::testing::LstmNodeContent void ValidateResultGoldens(const T* golden, const T* output_data, const int output_len, const float tolerance) { for (int i = 0; i < output_len; ++i) { - TF_LITE_MICRO_EXPECT_NEAR(golden[i], output_data[i], tolerance); + EXPECT_NEAR(golden[i], output_data[i], tolerance); } }