diff options
-rw-r--r-- | tensorflow/contrib/lite/testing/generate_examples.py | 5 | ||||
-rw-r--r-- | tensorflow/contrib/lite/testing/generated_examples_zip_test.cc | 34 |
2 files changed, 29 insertions, 10 deletions
diff --git a/tensorflow/contrib/lite/testing/generate_examples.py b/tensorflow/contrib/lite/testing/generate_examples.py index c3cc1e28d7..9b27199c76 100644 --- a/tensorflow/contrib/lite/testing/generate_examples.py +++ b/tensorflow/contrib/lite/testing/generate_examples.py @@ -20,6 +20,9 @@ Usage: generate_examples <output directory> bazel run //tensorflow/contrib/lite/testing:generate_examples + +To more easily debug failures use (or override) the --save_graphdefs flag to +place text proto graphdefs into the generated zip files. """ from __future__ import absolute_import from __future__ import division @@ -427,7 +430,7 @@ def make_zip_of_tests(zip_path, report["toco_log"] = toco_log if FLAGS.save_graphdefs: - archive.writestr(label + ".pb", + archive.writestr(label + ".pbtxt", text_format.MessageToString(graph_def), zipfile.ZIP_DEFLATED) diff --git a/tensorflow/contrib/lite/testing/generated_examples_zip_test.cc b/tensorflow/contrib/lite/testing/generated_examples_zip_test.cc index 860696ecdc..a8714afd83 100644 --- a/tensorflow/contrib/lite/testing/generated_examples_zip_test.cc +++ b/tensorflow/contrib/lite/testing/generated_examples_zip_test.cc @@ -67,9 +67,6 @@ std::map<string, string> kBrokenTests = { // non-const tensors as crops. {R"(^\/batch_to_space_nd.*crops=\[\[1,1\],\[1,1\]\])", "70594634"}, - // Softmax graphs are too complex. - {R"(^\/softmax.*input_shape=\[1,3,4,3\])", "67749831"}, - // SpaceToBatchND only supports 4D tensors. {R"(^\/space_to_batch_nd.*input_shape=\[1,4,4,4,1,1\])", "70848787"}, @@ -207,7 +204,7 @@ std::vector<string> UnarchiveZipAndFindTestNames(const string& zip_file_name) { class OpsTest : public ::testing::TestWithParam<string> {}; -TEST_P(OpsTest, RunStuff) { +TEST_P(OpsTest, RunZipTests) { string test_path = GetParam(); string tflite_test_case = test_path + "_tests.txt"; string tflite_dir = test_path.substr(0, test_path.find_last_of("/")); @@ -230,7 +227,9 @@ TEST_P(OpsTest, RunStuff) { EXPECT_TRUE(result) << test_driver.GetErrorMessage(); } else { if (FLAGS_ignore_known_bugs) { - EXPECT_FALSE(result); + EXPECT_FALSE(result) << "Test was expected to fail but is now passing; " + "you can mark http://b/" + << bug_number << " as fixed! Yay!"; } else { EXPECT_TRUE(result) << test_driver.GetErrorMessage() << ": Possibly due to http://b/" << bug_number; @@ -238,12 +237,29 @@ TEST_P(OpsTest, RunStuff) { } } +struct ZipPathParamName { + template <class ParamType> + string operator()(const ::testing::TestParamInfo<ParamType>& info) const { + string param_name = info.param; + size_t last_slash = param_name.find_last_of("\\/"); + if (last_slash != string::npos) { + param_name = param_name.substr(last_slash); + } + for (size_t index = 0; index < param_name.size(); ++index) { + if (!isalnum(param_name[index]) && param_name[index] != '_') + param_name[index] = '_'; + } + return param_name; + } +}; + // Instantiate a test. This assumes `zip_base`.zip is a declared data file // of this test. -#define INSTANTIATE_TESTS(zip_base) \ - INSTANTIATE_TEST_CASE_P( \ - zip_base, OpsTest, \ - ::testing::ValuesIn(UnarchiveZipAndFindTestNames(#zip_base ".zip"))); +#define INSTANTIATE_TESTS(zip_base) \ + INSTANTIATE_TEST_CASE_P( \ + zip_base, OpsTest, \ + ::testing::ValuesIn(UnarchiveZipAndFindTestNames(#zip_base ".zip")), \ + ZipPathParamName()); INSTANTIATE_TESTS(add) INSTANTIATE_TESTS(arg_max) |