aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Austin Anderson <angerson@google.com>2017-11-17 16:39:49 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-11-17 16:44:20 -0800
commit3f65709fc058d280ddf25043de0fc171cad1eaa2 (patch)
tree0547853e7659bd4dd5e89da1f55c39777721af0b
parent172d475ffbe9a88379a44a8fb32b8029e01ac11a (diff)
Change some Quantized op tests to use TEST() macros and main()
PiperOrigin-RevId: 176178241
-rw-r--r--tensorflow/core/kernels/BUILD10
-rw-r--r--tensorflow/core/kernels/quantization_utils_test.cc59
-rw-r--r--tensorflow/core/kernels/quantized_add_op_test.cc28
-rw-r--r--tensorflow/core/kernels/quantized_instance_norm_test.cc21
-rw-r--r--tensorflow/core/kernels/quantized_mul_op_test.cc28
-rw-r--r--tensorflow/core/kernels/quantized_resize_bilinear_op_test.cc24
6 files changed, 65 insertions, 105 deletions
diff --git a/tensorflow/core/kernels/BUILD b/tensorflow/core/kernels/BUILD
index 00cf3f90e9..39e8e499cd 100644
--- a/tensorflow/core/kernels/BUILD
+++ b/tensorflow/core/kernels/BUILD
@@ -4992,7 +4992,6 @@ tf_cc_test(
"//tensorflow/core:nn_ops_op_lib",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core:test",
- "//tensorflow/core:test_main",
"//tensorflow/core:testlib",
"//third_party/eigen3",
],
@@ -5035,7 +5034,6 @@ tf_cc_binary(
"//tensorflow/cc:client_session",
"//tensorflow/core:framework",
"//tensorflow/core:tensor_testutil",
- "//tensorflow/core:test_main",
],
}),
)
@@ -5095,7 +5093,6 @@ cc_binary(
"//tensorflow/core:tensor_testutil",
"//tensorflow/core:tensorflow",
"//tensorflow/core:test",
- "//tensorflow/core:test_main",
],
}),
)
@@ -5119,7 +5116,6 @@ tf_cc_test(
"//tensorflow/core:nn_ops_op_lib",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core:test",
- "//tensorflow/core:test_main",
"//tensorflow/core:testlib",
],
)
@@ -5140,7 +5136,6 @@ tf_cc_test(
"//tensorflow/core:image_ops_op_lib",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core:test",
- "//tensorflow/core:test_main",
"//tensorflow/core:testlib",
],
)
@@ -5184,7 +5179,6 @@ cc_binary(
"//tensorflow/core:image_ops_op_lib",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core:test",
- "//tensorflow/core:test_main",
"//tensorflow/core:testlib",
],
}),
@@ -5298,7 +5292,6 @@ cc_binary(
":quantized_ops",
"//tensorflow/core:framework",
"//tensorflow/core:tensor_testutil",
- "//tensorflow/core:test_main",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core:test",
],
@@ -5324,7 +5317,6 @@ tf_cc_test(
"//tensorflow/core:nn_ops_op_lib",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core:test",
- "//tensorflow/core:test_main",
"//tensorflow/core:testlib",
],
)
@@ -5436,7 +5428,6 @@ cc_binary(
"//conditions:default": [
"//tensorflow/core:framework",
"//tensorflow/core:tensor_testutil",
- "//tensorflow/core:test_main",
],
}),
)
@@ -5457,7 +5448,6 @@ tf_cc_test(
"//tensorflow/core:lib",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core:test",
- "//tensorflow/core:test_main",
"//tensorflow/core:testlib",
],
)
diff --git a/tensorflow/core/kernels/quantization_utils_test.cc b/tensorflow/core/kernels/quantization_utils_test.cc
index eae303b85e..a73581fbbc 100644
--- a/tensorflow/core/kernels/quantization_utils_test.cc
+++ b/tensorflow/core/kernels/quantization_utils_test.cc
@@ -910,42 +910,41 @@ void TestComputeLerp4xAll() {
} // namespace tensorflow
-#if defined(__ANDROID__)
-int main(int argc, char** argv) {
-#define RUN_TEST(t) \
- LOG(INFO) << "Test: " << #t; \
- tensorflow::t();
-#else
#define RUN_TEST(t) \
TEST(QuantizationUtilsTest, t) { tensorflow::t(); }
-#endif
- RUN_TEST(TestFloatToQuantized);
- RUN_TEST(TestQuantizedToFloat);
- RUN_TEST(TestAvoidBias);
- RUN_TEST(TestRequantizeInNewRange);
- RUN_TEST(TestRequantizeInNewRangeRealData);
- RUN_TEST(TestRequantizeInNewRange32To8Bit);
- RUN_TEST(TestRequantizeManyInNewRange32To8Bit);
- RUN_TEST(TestRequantizeManyInNewRange32To8BitUsingEigen);
- RUN_TEST(TestRequantizeManyInNewRange32To8BitEigenVsNonEigen);
- RUN_TEST(TestRequantizeManyInNewRange32To8BitSignedEigenVsNonEigen);
- RUN_TEST(TestFloatTensorToQuantized);
- RUN_TEST(TestRequantizeManyInNewRange8To32Bit);
- RUN_TEST(TestFloatToQuantizedInPlaceUsingEigen);
- RUN_TEST(TestOverflowWithEigen);
- RUN_TEST(TestQuantizedTensorToFloat);
- RUN_TEST(TestQuantizedToFloatInPlaceUsingEigen);
+RUN_TEST(TestFloatToQuantized);
+RUN_TEST(TestQuantizedToFloat);
+RUN_TEST(TestAvoidBias);
+RUN_TEST(TestRequantizeInNewRange);
+RUN_TEST(TestRequantizeInNewRangeRealData);
+RUN_TEST(TestRequantizeInNewRange32To8Bit);
+RUN_TEST(TestRequantizeManyInNewRange32To8Bit);
+RUN_TEST(TestRequantizeManyInNewRange32To8BitUsingEigen);
+RUN_TEST(TestRequantizeManyInNewRange32To8BitEigenVsNonEigen);
+RUN_TEST(TestRequantizeManyInNewRange32To8BitSignedEigenVsNonEigen);
+RUN_TEST(TestFloatTensorToQuantized);
+RUN_TEST(TestRequantizeManyInNewRange8To32Bit);
+RUN_TEST(TestFloatToQuantizedInPlaceUsingEigen);
+RUN_TEST(TestOverflowWithEigen);
+RUN_TEST(TestQuantizedTensorToFloat);
+RUN_TEST(TestQuantizedToFloatInPlaceUsingEigen);
#if defined(__ANDROID__)
+
+RUN_TEST(BenchmarkRequantizeManyInNewRange);
+
#ifdef QUANTIZATION_UTILS_USE_NEON
- RUN_TEST(TestDivide64x2PowAll);
- RUN_TEST(TestComputeLerp4xAll);
-#endif
- tensorflow::BenchmarkRequantizeManyInNewRange();
+RUN_TEST(TestDivide64x2PowAll);
+RUN_TEST(TestComputeLerp4xAll);
+
+#endif // QUANTIZATION_UTILS_USE_NEON
+
+#endif // __ANDROID__
- LOG(INFO) << "All tests complete.";
- return 0;
+int main(int argc, char** argv) {
+ // On Linux, add: FLAGS_logtostderr = true;
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
}
-#endif
diff --git a/tensorflow/core/kernels/quantized_add_op_test.cc b/tensorflow/core/kernels/quantized_add_op_test.cc
index 74d16b282d..90bd145ad0 100644
--- a/tensorflow/core/kernels/quantized_add_op_test.cc
+++ b/tensorflow/core/kernels/quantized_add_op_test.cc
@@ -276,10 +276,10 @@ void BenchmarkVectorPlusTensor() {
TimeAdd({100000, 100}, {100}, 1);
}
-#if !defined(__ANDROID__)
+} // end namespace tensorflow
#define RUN_TEST(t) \
- TEST(QuantizedAddOpTest, t) { t(); }
+ TEST(QuantizedAddOpTest, t) { tensorflow::t(); }
RUN_TEST(TestManualScalar);
RUN_TEST(TestManualVector);
@@ -288,24 +288,16 @@ RUN_TEST(TestScalar);
RUN_TEST(TestVector);
RUN_TEST(TestVectorPlusTensor);
-#undef RUN_TEST
+#if defined(__ANDROID__)
-#endif // __ANDROID__
+RUN_TEST(BenchmarkTensorScalar);
+RUN_TEST(BenchmarkVector);
+RUN_TEST(BenchmarkVectorPlusTensor);
-} // end namespace tensorflow
+#endif // __ANDROID__
-#if defined(__ANDROID__)
int main(int argc, char** argv) {
- LOG(INFO) << "TestManualScalar:";
- tensorflow::TestManualScalar();
- LOG(INFO) << "TestManualVector:";
- tensorflow::TestManualVector();
- LOG(INFO) << "TestManualVectorPlusTensor:";
- tensorflow::TestManualVectorPlusTensor();
- tensorflow::BenchmarkTensorScalar();
- tensorflow::BenchmarkVector();
- tensorflow::BenchmarkVectorPlusTensor();
- LOG(INFO) << "All tests complete";
- return 0;
+ // On Linux, add: FLAGS_logtostderr = true;
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
}
-#endif // __ANDROID__
diff --git a/tensorflow/core/kernels/quantized_instance_norm_test.cc b/tensorflow/core/kernels/quantized_instance_norm_test.cc
index 29d8dbc0df..d2b15ee20b 100644
--- a/tensorflow/core/kernels/quantized_instance_norm_test.cc
+++ b/tensorflow/core/kernels/quantized_instance_norm_test.cc
@@ -173,10 +173,10 @@ void TestClamp() {
Expect(input_tensor, -10.0f, 10.0f, true, 0.0f, 1.0f);
}
-#if !defined(__ANDROID__)
+} // end namespace tensorflow
#define RUN_TEST(t) \
- TEST(QuantizedInstanceNormTest, t) { t(); }
+ TEST(QuantizedAddOpTest, t) { tensorflow::t(); }
RUN_TEST(TestBasic);
RUN_TEST(TestZeroInput);
@@ -184,19 +184,8 @@ RUN_TEST(TestMaxInput);
RUN_TEST(TestOutputRangeGiven);
RUN_TEST(TestClamp);
-#undef RUN_TEST
-
-#endif // __ANDROID__
-
-} // end namespace tensorflow
-
-#if defined(__ANDROID__)
int main(int argc, char** argv) {
- tensorflow::TestBasic();
- tensorflow::TestZeroInput();
- tensorflow::TestMaxInput();
- tensorflow::TestOutputRangeGiven();
- tensorflow::TestClamp();
- return 0;
+ // On Linux, add: FLAGS_logtostderr = true;
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
}
-#endif // __ANDROID__
diff --git a/tensorflow/core/kernels/quantized_mul_op_test.cc b/tensorflow/core/kernels/quantized_mul_op_test.cc
index 45d6c51444..5f858eb8ce 100644
--- a/tensorflow/core/kernels/quantized_mul_op_test.cc
+++ b/tensorflow/core/kernels/quantized_mul_op_test.cc
@@ -276,10 +276,10 @@ void BenchmarkVectorTimesTensor() {
TimeMul({100000, 100}, {100}, 100);
}
-#if !defined(__ANDROID__)
+} // end namespace tensorflow
#define RUN_TEST(t) \
- TEST(QuantizedMulOpTest, t) { t(); }
+ TEST(QuantizedAddOpTest, t) { tensorflow::t(); }
RUN_TEST(TestManualScalar);
RUN_TEST(TestManualVector);
@@ -288,24 +288,16 @@ RUN_TEST(TestScalar);
RUN_TEST(TestVector);
RUN_TEST(TestVectorTimesTensor);
-#undef RUN_TEST
+#if defined(__ANDROID__)
-#endif // __ANDROID__
+RUN_TEST(BenchmarkTensorScalar);
+RUN_TEST(BenchmarkVector);
+RUN_TEST(BenchmarkVectorTimesTensor);
-} // end namespace tensorflow
+#endif // __ANDROID__
-#if defined(__ANDROID__)
int main(int argc, char** argv) {
- LOG(INFO) << "TestManualScalar:";
- tensorflow::TestManualScalar();
- LOG(INFO) << "TestManualVector:";
- tensorflow::TestManualVector();
- LOG(INFO) << "TestManualVectorTimesTensor:";
- tensorflow::TestManualVectorTimesTensor();
- tensorflow::BenchmarkTensorScalar();
- tensorflow::BenchmarkVector();
- tensorflow::BenchmarkVectorTimesTensor();
- LOG(INFO) << "All tests complete";
- return 0;
+ // On Linux, add: FLAGS_logtostderr = true;
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
}
-#endif // __ANDROID__
diff --git a/tensorflow/core/kernels/quantized_resize_bilinear_op_test.cc b/tensorflow/core/kernels/quantized_resize_bilinear_op_test.cc
index 8d3d7105a4..e6133415d0 100644
--- a/tensorflow/core/kernels/quantized_resize_bilinear_op_test.cc
+++ b/tensorflow/core/kernels/quantized_resize_bilinear_op_test.cc
@@ -373,22 +373,20 @@ void RunBenchmarkResizeBilinearTwoDims() {
} // namespace tensorflow
-#if defined(__ANDROID__)
-int main(int argc, char** argv) {
-#define RUN_TEST(t) \
- LOG(INFO) << "Test: " << #t; \
- tensorflow::t();
-#else
#define RUN_TEST(t) \
TEST(QuantizationResizeBilenarTest, t) { tensorflow::t(); }
-#endif
- RUN_TEST(TestResizeBilinearOneDim);
- RUN_TEST(TestResizeBilinearTwoDims);
+RUN_TEST(TestResizeBilinearOneDim);
+RUN_TEST(TestResizeBilinearTwoDims);
#if defined(__ANDROID__)
- RUN_TEST(RunBenchmarkResizeBilinearTwoDims);
- LOG(INFO) << "All tests complete.";
- return 0;
+
+RUN_TEST(RunBenchmarkResizeBilinearTwoDims);
+
+#endif // __ANDROID__
+
+int main(int argc, char** argv) {
+ // On Linux, add: FLAGS_logtostderr = true;
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
}
-#endif