aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/lite
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-06-13 10:48:16 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-06-13 10:50:46 -0700
commitea76cd8938e794e8cc190032c27deaf561ac88a6 (patch)
treeca939eb80260e51b1cb83037884dbda78019dfdb /tensorflow/contrib/lite
parent696ac9923003150484ab0bce29d5b66d5a317eb6 (diff)
- Teaches zip tests about unzip location on Android
- Passes use_nnapi from TestDriver to interpeter - Adds command line flag to generated tests for NNAPI - Fixes logic for allocating im2col tensor so that tests pass without NNAPI PiperOrigin-RevId: 200416472
Diffstat (limited to 'tensorflow/contrib/lite')
-rw-r--r--tensorflow/contrib/lite/testing/BUILD14
-rw-r--r--tensorflow/contrib/lite/testing/generated_examples_zip_test.cc14
-rw-r--r--tensorflow/contrib/lite/testing/tflite_driver.cc1
3 files changed, 22 insertions, 7 deletions
diff --git a/tensorflow/contrib/lite/testing/BUILD b/tensorflow/contrib/lite/testing/BUILD
index 80e4c5a4dd..b823c97f38 100644
--- a/tensorflow/contrib/lite/testing/BUILD
+++ b/tensorflow/contrib/lite/testing/BUILD
@@ -20,11 +20,15 @@ load(
size = "large",
srcs = ["generated_examples_zip_test.cc"],
args = [
- "--zip_file_path=$(location :zip_%s)" % test_name,
- # TODO(angerson) We may be able to add an external unzip binary instead
- # of relying on an existing one for OSS builds.
- "--unzip_binary_path=/usr/bin/unzip",
- ],
+ ] + select({
+ "//tensorflow:android": [],
+ "//conditions:default": [
+ "--zip_file_path=$(location :zip_%s)" % test_name,
+ # TODO(angerson) We may be able to add an external unzip binary instead
+ # of relying on an existing one for OSS builds.
+ "--unzip_binary_path=/usr/bin/unzip",
+ ],
+ }),
data = [
":zip_%s" % test_name,
],
diff --git a/tensorflow/contrib/lite/testing/generated_examples_zip_test.cc b/tensorflow/contrib/lite/testing/generated_examples_zip_test.cc
index e85020448a..8a59d756f8 100644
--- a/tensorflow/contrib/lite/testing/generated_examples_zip_test.cc
+++ b/tensorflow/contrib/lite/testing/generated_examples_zip_test.cc
@@ -36,7 +36,12 @@ bool FLAGS_ignore_known_bugs = true;
// TODO(b/71769302) zip_files_dir should have a more accurate default, if
// possible
string* FLAGS_zip_file_path = new string("./");
+#ifndef __ANDROID__
string* FLAGS_unzip_binary_path = new string("/usr/bin/unzip");
+#else
+string* FLAGS_unzip_binary_path = new string("/system/bin/unzip");
+#endif
+bool FLAGS_use_nnapi = false;
} // namespace
// TensorFlow system environment for file system called.
@@ -212,7 +217,7 @@ TEST_P(OpsTest, RunZipTests) {
std::ifstream tflite_stream(tflite_test_case);
ASSERT_TRUE(tflite_stream.is_open()) << tflite_test_case;
- tflite::testing::TfLiteDriver test_driver(/*use_nnapi=*/true);
+ tflite::testing::TfLiteDriver test_driver(FLAGS_use_nnapi);
test_driver.SetModelBaseDir(tflite_dir);
string bug_number;
@@ -273,7 +278,10 @@ int main(int argc, char** argv) {
"Required: Location of the test zip file."),
tensorflow::Flag("unzip_binary_path",
tflite::testing::FLAGS_unzip_binary_path,
- "Required: Location of a suitable unzip binary.")};
+ "Required: Location of a suitable unzip binary."),
+ tensorflow::Flag("use_nnapi", &tflite::testing::FLAGS_use_nnapi,
+ "Whether to enable the NNAPI delegate")};
+
bool success = tensorflow::Flags::Parse(&argc, argv, flags);
if (!success || (argc == 2 && !strcmp(argv[1], "--helpfull"))) {
fprintf(stderr, "%s", tensorflow::Flags::Usage(argv[0], flags).c_str());
@@ -281,6 +289,8 @@ int main(int argc, char** argv) {
}
::tflite::LogToStderr();
+ // TODO(mikie): googletest arguments do not work - maybe the tensorflow flags
+ // parser removes them?
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
diff --git a/tensorflow/contrib/lite/testing/tflite_driver.cc b/tensorflow/contrib/lite/testing/tflite_driver.cc
index fc28faf524..f518bf864c 100644
--- a/tensorflow/contrib/lite/testing/tflite_driver.cc
+++ b/tensorflow/contrib/lite/testing/tflite_driver.cc
@@ -163,6 +163,7 @@ void TfLiteDriver::LoadModel(const string& bin_file_path) {
Invalidate("Failed build interpreter");
return;
}
+ interpreter_->UseNNAPI(use_nnapi_);
must_allocate_tensors_ = true;
}