diff options
32 files changed, 71 insertions, 43 deletions
diff --git a/tensorflow/contrib/lite/BUILD b/tensorflow/contrib/lite/BUILD index 52460123cc..3f1b0be1a7 100644 --- a/tensorflow/contrib/lite/BUILD +++ b/tensorflow/contrib/lite/BUILD @@ -111,6 +111,7 @@ cc_test( deps = [ ":framework", ":string_util", + "//tensorflow/contrib/lite/testing:util", "@com_google_googletest//:gtest", ], ) @@ -134,6 +135,7 @@ cc_test( srcs = ["simple_memory_arena_test.cc"], deps = [ ":framework", + "//tensorflow/contrib/lite/testing:util", "@com_google_googletest//:gtest", ], ) @@ -152,6 +154,7 @@ cc_test( ], deps = [ ":framework", + "//tensorflow/contrib/lite/testing:util", "@com_google_googletest//:gtest", ], ) @@ -163,6 +166,7 @@ cc_test( srcs = ["context_test.cc"], deps = [ ":framework", + "//tensorflow/contrib/lite/testing:util", "@com_google_googletest//:gtest", ], ) diff --git a/tensorflow/contrib/lite/context_test.cc b/tensorflow/contrib/lite/context_test.cc index d0a104f43d..20d6f69a25 100644 --- a/tensorflow/contrib/lite/context_test.cc +++ b/tensorflow/contrib/lite/context_test.cc @@ -15,6 +15,7 @@ limitations under the License. #include "tensorflow/contrib/lite/context.h" #include <gtest/gtest.h> +#include "tensorflow/contrib/lite/testing/util.h" namespace tflite { @@ -68,7 +69,7 @@ TEST(IntArray, TestIntArrayEqual) { } // namespace tflite int main(int argc, char** argv) { - // On Linux, add: tflite::LogToStderr(); + ::tflite::LogToStderr(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/tensorflow/contrib/lite/kernels/BUILD b/tensorflow/contrib/lite/kernels/BUILD index bbbfa3e741..ad76e90606 100644 --- a/tensorflow/contrib/lite/kernels/BUILD +++ b/tensorflow/contrib/lite/kernels/BUILD @@ -32,6 +32,7 @@ cc_library( "//tensorflow/contrib/lite:framework", "//tensorflow/contrib/lite:schema_fbs_version", "//tensorflow/contrib/lite:string_util", + "//tensorflow/contrib/lite/testing:util", "//tensorflow/core:lib", "@com_google_googletest//:gtest", ], diff --git a/tensorflow/contrib/lite/kernels/activations_test.cc b/tensorflow/contrib/lite/kernels/activations_test.cc index f10aee7017..33ca56e745 100644 --- a/tensorflow/contrib/lite/kernels/activations_test.cc +++ b/tensorflow/contrib/lite/kernels/activations_test.cc @@ -317,7 +317,7 @@ TEST(QuantizedActivationsOpTest, Softmax2D) { } // namespace tflite int main(int argc, char** argv) { - // On Linux, add: tflite::LogToStderr(); + ::tflite::LogToStderr(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/tensorflow/contrib/lite/kernels/add_test.cc b/tensorflow/contrib/lite/kernels/add_test.cc index 8e12a837c4..ddf45bb576 100644 --- a/tensorflow/contrib/lite/kernels/add_test.cc +++ b/tensorflow/contrib/lite/kernels/add_test.cc @@ -164,8 +164,7 @@ TEST(QuantizedAddOpModel, QuantizedVariousInputShapes) { } // namespace } // namespace tflite int main(int argc, char** argv) { - // On Linux, add: tflite::LogToStderr(); - tflite::LogToStderr(); + ::tflite::LogToStderr(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/tensorflow/contrib/lite/kernels/basic_rnn_test.cc b/tensorflow/contrib/lite/kernels/basic_rnn_test.cc index dfa75655bc..5ecccb985e 100644 --- a/tensorflow/contrib/lite/kernels/basic_rnn_test.cc +++ b/tensorflow/contrib/lite/kernels/basic_rnn_test.cc @@ -261,7 +261,7 @@ TEST(FullyConnectedOpTest, BlackBoxTest) { } // namespace tflite int main(int argc, char** argv) { - // On Linux, add: tflite::LogToStderr(); + ::tflite::LogToStderr(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/tensorflow/contrib/lite/kernels/concatenation_test.cc b/tensorflow/contrib/lite/kernels/concatenation_test.cc index 94e5b2acdc..499856a93c 100644 --- a/tensorflow/contrib/lite/kernels/concatenation_test.cc +++ b/tensorflow/contrib/lite/kernels/concatenation_test.cc @@ -156,7 +156,7 @@ TEST(ConcatenationOpTest, FourInputsQuantized) { } // namespace tflite int main(int argc, char** argv) { - // On Linux, add: tflite::LogToStderr(); + ::tflite::LogToStderr(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/tensorflow/contrib/lite/kernels/conv_test.cc b/tensorflow/contrib/lite/kernels/conv_test.cc index 18d7a31d59..1d0a81c313 100644 --- a/tensorflow/contrib/lite/kernels/conv_test.cc +++ b/tensorflow/contrib/lite/kernels/conv_test.cc @@ -434,7 +434,7 @@ TEST(ConvolutionOpTest, SimpleTestQuantizedWithAnisotropicStrides) { } // namespace tflite int main(int argc, char** argv) { - // On Linux, add: tflite::LogToStderr(); + ::tflite::LogToStderr(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/tensorflow/contrib/lite/kernels/depthwise_conv_test.cc b/tensorflow/contrib/lite/kernels/depthwise_conv_test.cc index 39227b2811..1439c8bce1 100644 --- a/tensorflow/contrib/lite/kernels/depthwise_conv_test.cc +++ b/tensorflow/contrib/lite/kernels/depthwise_conv_test.cc @@ -180,7 +180,7 @@ TEST(QuantizedDepthwiseConvolutionOpTest, SimpleTestQuantized) { } // namespace tflite int main(int argc, char** argv) { - // On Linux, add: tflite::LogToStderr(); + ::tflite::LogToStderr(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/tensorflow/contrib/lite/kernels/embedding_lookup_sparse_test.cc b/tensorflow/contrib/lite/kernels/embedding_lookup_sparse_test.cc index 69d9c5cc7d..dcdc5fffad 100644 --- a/tensorflow/contrib/lite/kernels/embedding_lookup_sparse_test.cc +++ b/tensorflow/contrib/lite/kernels/embedding_lookup_sparse_test.cc @@ -158,9 +158,7 @@ TEST(EmbeddingLookupOpTest, Indices3DTest) { } // namespace tflite int main(int argc, char** argv) { -#ifdef OS_LINUX - tflite::LogToStderr(); -#endif + ::tflite::LogToStderr(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/tensorflow/contrib/lite/kernels/embedding_lookup_test.cc b/tensorflow/contrib/lite/kernels/embedding_lookup_test.cc index 8c030b0677..9b501878f1 100644 --- a/tensorflow/contrib/lite/kernels/embedding_lookup_test.cc +++ b/tensorflow/contrib/lite/kernels/embedding_lookup_test.cc @@ -88,7 +88,7 @@ TEST(EmbeddingLookupOpTest, SimpleTest) { } // namespace tflite int main(int argc, char** argv) { - // On Linux, add: tflite::LogToStderr(); + ::tflite::LogToStderr(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/tensorflow/contrib/lite/kernels/fully_connected_test.cc b/tensorflow/contrib/lite/kernels/fully_connected_test.cc index 112e3f1ba0..a0f766c4f4 100644 --- a/tensorflow/contrib/lite/kernels/fully_connected_test.cc +++ b/tensorflow/contrib/lite/kernels/fully_connected_test.cc @@ -370,8 +370,7 @@ TEST(FullyConnectedOpTest, BlackBoxTest) { } // namespace tflite int main(int argc, char** argv) { - // On Linux, add: tflite::LogToStderr(); - tflite::LogToStderr(); + ::tflite::LogToStderr(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/tensorflow/contrib/lite/kernels/hashtable_lookup_test.cc b/tensorflow/contrib/lite/kernels/hashtable_lookup_test.cc index 916a23225e..cb6038f900 100644 --- a/tensorflow/contrib/lite/kernels/hashtable_lookup_test.cc +++ b/tensorflow/contrib/lite/kernels/hashtable_lookup_test.cc @@ -170,7 +170,7 @@ TEST(HashtableLookupOpTest, TestString) { } // namespace tflite int main(int argc, char** argv) { - // On Linux, add: tflite::LogToStderr(); + ::tflite::LogToStderr(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/tensorflow/contrib/lite/kernels/l2norm_test.cc b/tensorflow/contrib/lite/kernels/l2norm_test.cc index b1db89b8bd..30e103f330 100644 --- a/tensorflow/contrib/lite/kernels/l2norm_test.cc +++ b/tensorflow/contrib/lite/kernels/l2norm_test.cc @@ -57,7 +57,7 @@ TEST(L2NormOpTest, SimpleTest) { } // namespace tflite int main(int argc, char** argv) { - // On Linux, add: tflite::LogToStderr(); + ::tflite::LogToStderr(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/tensorflow/contrib/lite/kernels/local_response_norm_test.cc b/tensorflow/contrib/lite/kernels/local_response_norm_test.cc index 63a8b0a3d0..d75ce258a0 100644 --- a/tensorflow/contrib/lite/kernels/local_response_norm_test.cc +++ b/tensorflow/contrib/lite/kernels/local_response_norm_test.cc @@ -95,7 +95,7 @@ TEST(LocalResponseNormOpTest, SmallRadius) { } // namespace tflite int main(int argc, char** argv) { - // On Linux, add: tflite::LogToStderr(); + ::tflite::LogToStderr(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/tensorflow/contrib/lite/kernels/lsh_projection_test.cc b/tensorflow/contrib/lite/kernels/lsh_projection_test.cc index 1011927848..414d728dfc 100644 --- a/tensorflow/contrib/lite/kernels/lsh_projection_test.cc +++ b/tensorflow/contrib/lite/kernels/lsh_projection_test.cc @@ -117,7 +117,7 @@ TEST(LSHProjectionOpTest2, Sparse3DInputs) { } // namespace tflite int main(int argc, char** argv) { - // On Linux, add: tflite::LogToStderr(); + ::tflite::LogToStderr(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/tensorflow/contrib/lite/kernels/lstm_test.cc b/tensorflow/contrib/lite/kernels/lstm_test.cc index be4c7ddbf8..c068286b0d 100644 --- a/tensorflow/contrib/lite/kernels/lstm_test.cc +++ b/tensorflow/contrib/lite/kernels/lstm_test.cc @@ -1081,8 +1081,7 @@ TEST(LSTMOpTest, BlackBoxTestWithPeepholeWithProjectionNoClipping) { } // namespace tflite int main(int argc, char** argv) { - // On Linux, add: tflite::LogToStderr(); - tflite::LogToStderr(); + ::tflite::LogToStderr(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/tensorflow/contrib/lite/kernels/mul_test.cc b/tensorflow/contrib/lite/kernels/mul_test.cc index 4b858e1f39..4255cfe18a 100644 --- a/tensorflow/contrib/lite/kernels/mul_test.cc +++ b/tensorflow/contrib/lite/kernels/mul_test.cc @@ -120,8 +120,7 @@ TEST(QuantizedMulOpTest, NoActivation) { } // namespace tflite int main(int argc, char** argv) { - // On Linux, add: tflite::LogToStderr(); - tflite::LogToStderr(); + ::tflite::LogToStderr(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/tensorflow/contrib/lite/kernels/optional_tensor_test.cc b/tensorflow/contrib/lite/kernels/optional_tensor_test.cc index 8e9cc07656..17166715ca 100644 --- a/tensorflow/contrib/lite/kernels/optional_tensor_test.cc +++ b/tensorflow/contrib/lite/kernels/optional_tensor_test.cc @@ -334,8 +334,7 @@ TEST(LSTMOpTest, BlackBoxTestWithCifgWithPeepholeNoProjectionNoClipping) { } // namespace tflite int main(int argc, char** argv) { - // On Linux, add: tflite::LogToStderr(); - tflite::LogToStderr(); + ::tflite::LogToStderr(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/tensorflow/contrib/lite/kernels/pooling_test.cc b/tensorflow/contrib/lite/kernels/pooling_test.cc index e1b51ec7d5..01c91b2ba9 100644 --- a/tensorflow/contrib/lite/kernels/pooling_test.cc +++ b/tensorflow/contrib/lite/kernels/pooling_test.cc @@ -155,7 +155,7 @@ TEST(FloatPoolingOpTest, L2Pool) { } // namespace tflite int main(int argc, char** argv) { - // On Linux, add: tflite::LogToStderr(); + ::tflite::LogToStderr(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/tensorflow/contrib/lite/kernels/reshape_test.cc b/tensorflow/contrib/lite/kernels/reshape_test.cc index 59ce7d5648..0fbcf6e6aa 100644 --- a/tensorflow/contrib/lite/kernels/reshape_test.cc +++ b/tensorflow/contrib/lite/kernels/reshape_test.cc @@ -83,8 +83,7 @@ TEST(ReshapeOpTest, WithStretchDimension) { } // namespace tflite int main(int argc, char** argv) { - // On Linux, add: tflite::LogToStderr(); - tflite::LogToStderr(); + ::tflite::LogToStderr(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/tensorflow/contrib/lite/kernels/resize_bilinear_test.cc b/tensorflow/contrib/lite/kernels/resize_bilinear_test.cc index 0257c0b557..314a71e210 100644 --- a/tensorflow/contrib/lite/kernels/resize_bilinear_test.cc +++ b/tensorflow/contrib/lite/kernels/resize_bilinear_test.cc @@ -111,7 +111,7 @@ TEST(ResizeBilinearOpTest, ThreeDimensionalResize) { } // namespace tflite int main(int argc, char** argv) { - // On Linux, add: tflite::LogToStderr(); + ::tflite::LogToStderr(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/tensorflow/contrib/lite/kernels/skip_gram_test.cc b/tensorflow/contrib/lite/kernels/skip_gram_test.cc index e7f6bc904b..185b64cb44 100644 --- a/tensorflow/contrib/lite/kernels/skip_gram_test.cc +++ b/tensorflow/contrib/lite/kernels/skip_gram_test.cc @@ -251,7 +251,7 @@ TEST(SkipGramTest, TestInputWithExtraSpace) { } // namespace tflite int main(int argc, char** argv) { - // On Linux, add: tflite::LogToStderr(); + ::tflite::LogToStderr(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/tensorflow/contrib/lite/kernels/softmax_test.cc b/tensorflow/contrib/lite/kernels/softmax_test.cc index ec8ec03b0d..6c5338ff0f 100644 --- a/tensorflow/contrib/lite/kernels/softmax_test.cc +++ b/tensorflow/contrib/lite/kernels/softmax_test.cc @@ -136,8 +136,7 @@ TEST(SoftmaxOpTest, CompareWithTFminiBetaNotEq1) { } // namespace tflite int main(int argc, char** argv) { - // On Linux, add: tflite::LogToStderr(); - tflite::LogToStderr(); + ::tflite::LogToStderr(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/tensorflow/contrib/lite/kernels/space_to_depth_test.cc b/tensorflow/contrib/lite/kernels/space_to_depth_test.cc index 911f08a92c..997f354861 100644 --- a/tensorflow/contrib/lite/kernels/space_to_depth_test.cc +++ b/tensorflow/contrib/lite/kernels/space_to_depth_test.cc @@ -95,8 +95,7 @@ TEST(SpaceToDepthOpModel, Int64) { } // namespace tflite int main(int argc, char** argv) { - // On Linux, add: tflite::LogToStderr(); - tflite::LogToStderr(); + ::tflite::LogToStderr(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/tensorflow/contrib/lite/kernels/svdf_test.cc b/tensorflow/contrib/lite/kernels/svdf_test.cc index d956025e9d..4de2ceaf05 100644 --- a/tensorflow/contrib/lite/kernels/svdf_test.cc +++ b/tensorflow/contrib/lite/kernels/svdf_test.cc @@ -306,7 +306,7 @@ TEST(SVDFOpTest, BlackBoxTestRank2) { } // namespace tflite int main(int argc, char** argv) { - // On Linux, add: tflite::LogToStderr(); + ::tflite::LogToStderr(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/tensorflow/contrib/lite/kernels/test_util.h b/tensorflow/contrib/lite/kernels/test_util.h index e68e494661..adcdeddbfc 100644 --- a/tensorflow/contrib/lite/kernels/test_util.h +++ b/tensorflow/contrib/lite/kernels/test_util.h @@ -24,16 +24,11 @@ limitations under the License. #include "tensorflow/contrib/lite/kernels/register.h" #include "tensorflow/contrib/lite/model.h" #include "tensorflow/contrib/lite/string_util.h" +#include "tensorflow/contrib/lite/testing/util.h" #include "tensorflow/core/platform/logging.h" namespace tflite { -inline void LogToStderr() { -#ifdef PLATFORM_GOOGLE - FLAGS_logtostderr = true; -#endif -} - // A gmock matcher that check that elements of a float vector match to a given // tolerance. std::vector<::testing::Matcher<float>> ArrayFloatNear( diff --git a/tensorflow/contrib/lite/model_test.cc b/tensorflow/contrib/lite/model_test.cc index 6104386642..83a5150a46 100644 --- a/tensorflow/contrib/lite/model_test.cc +++ b/tensorflow/contrib/lite/model_test.cc @@ -26,6 +26,7 @@ limitations under the License. #include <gtest/gtest.h> #include "tensorflow/contrib/lite/error_reporter.h" +#include "tensorflow/contrib/lite/testing/util.h" // Comparison for TfLiteRegistration. Since TfLiteRegistration is a C object, // we must declare this in global namespace, so argument-dependent operator @@ -261,7 +262,7 @@ TEST(BasicFlatBufferModel, TestBuildModelFromCorruptedData) { } // namespace tflite int main(int argc, char** argv) { - // On Linux, add: tflite::LogToStderr(); + ::tflite::LogToStderr(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/tensorflow/contrib/lite/simple_memory_arena_test.cc b/tensorflow/contrib/lite/simple_memory_arena_test.cc index ac676092c6..4444f642eb 100644 --- a/tensorflow/contrib/lite/simple_memory_arena_test.cc +++ b/tensorflow/contrib/lite/simple_memory_arena_test.cc @@ -16,6 +16,7 @@ limitations under the License. #include <gmock/gmock.h> #include <gtest/gtest.h> +#include "tensorflow/contrib/lite/testing/util.h" namespace tflite { namespace { @@ -85,7 +86,7 @@ TEST(SimpleMemoryArenaTest, TestAfterClear) { } // namespace tflite int main(int argc, char** argv) { - // On Linux, add: tflite::LogToStderr(); + ::tflite::LogToStderr(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/tensorflow/contrib/lite/string_util_test.cc b/tensorflow/contrib/lite/string_util_test.cc index 5c351638dc..d53fec7512 100644 --- a/tensorflow/contrib/lite/string_util_test.cc +++ b/tensorflow/contrib/lite/string_util_test.cc @@ -17,6 +17,7 @@ limitations under the License. #include <gtest/gtest.h> #include "tensorflow/contrib/lite/context.h" #include "tensorflow/contrib/lite/interpreter.h" +#include "tensorflow/contrib/lite/testing/util.h" namespace tflite { @@ -111,7 +112,7 @@ TEST(StringUtil, TestEmptyList) { } // namespace tflite int main(int argc, char** argv) { - // On Linux, add: tflite::LogToStderr(); + ::tflite::LogToStderr(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/tensorflow/contrib/lite/testing/BUILD b/tensorflow/contrib/lite/testing/BUILD index ecddb4b807..3ff65dd381 100644 --- a/tensorflow/contrib/lite/testing/BUILD +++ b/tensorflow/contrib/lite/testing/BUILD @@ -160,6 +160,12 @@ cc_library( ], ) +cc_library( + name = "util", + testonly = 1, + hdrs = ["util.h"], +) + cc_test( name = "test_runner_test", srcs = ["test_runner_test.cc"], diff --git a/tensorflow/contrib/lite/testing/util.h b/tensorflow/contrib/lite/testing/util.h new file mode 100644 index 0000000000..4d4304f022 --- /dev/null +++ b/tensorflow/contrib/lite/testing/util.h @@ -0,0 +1,28 @@ +/* Copyright 2017 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 THIRD_PARTY_TENSORFLOW_CONTRIB_LITE_TESTING_UTIL_H_ +#define THIRD_PARTY_TENSORFLOW_CONTRIB_LITE_TESTING_UTIL_H_ + +namespace tflite { + +inline void LogToStderr() { +#ifdef PLATFORM_GOOGLE + FLAGS_logtostderr = true; +#endif +} + +} // namespace tflite + +#endif // THIRD_PARTY_TENSORFLOW_CONTRIB_LITE_TESTING_UTIL_H_ |