TensorFlow Lite 单元测试编译和执行
1. TensorFlow
(base) yongqiang@yongqiang:~/tensorflow_work$ git clone https://github.com/tensorflow/tensorflow.git
...
(base) yongqiang@yongqiang:~/tensorflow_work$
2. TensorFlow Lite 单元测试编译和执行
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/README.md
/home/yongqiang/tensorflow_work/tensorflow/tensorflow/lite/kernels/quantize.cc
/home/yongqiang/tensorflow_work/tensorflow/tensorflow/lite/kernels/quantize_test.cc
/home/yongqiang/tensorflow_work/tensorflow/tensorflow/lite/kernels/mirror_pad.cc
/home/yongqiang/tensorflow_work/tensorflow/tensorflow/lite/kernels/mirror_pad_test.cc
bazel test //tensorflow/lite/kernels/mirror_pad_test --distdir=/home/yongqiang/tensorflow_work/dist_dir/
(base) yongqiang@yongqiang:~/tensorflow_work/tensorflow$ bazel test //tensorflow/lite/kernels/mirror_pad_test --distdir=/home/yongqiang/tensorflow_work/dist_dir/
2.1 .bazelversion
(base) yongqiang@yongqiang:~/tensorflow_work/tensorflow$ bazel clean
ERROR: The project you're trying to build requires Bazel 3.7.2 (specified in /home/yongqiang/tensorflow_work/tensorflow/.bazelversion), but it wasn't found in /home/yongqiang/.bazel/bin.
Bazel binaries for all official releases can be downloaded from here:
https://github.com/bazelbuild/bazel/releases
You can download the required version directly using this command:
(cd "/home/yongqiang/.bazel/bin" && curl -fLO https://releases.bazel.build/3.7.2/release/bazel-3.7.2-linux-x86_64 && chmod +x bazel-3.7.2-linux-x86_64)
(base) yongqiang@yongqiang:~/tensorflow_work/tensorflow$
修改前:
(base) yongqiang@yongqiang:~/tensorflow_work/tensorflow$ cat .bazelversion
3.7.2
(base) yongqiang@yongqiang:~/tensorflow_work/tensorflow$
修改后:
(base) yongqiang@yongqiang:~/tensorflow_work/tensorflow$ cat .bazelversion
4.2.1
(base) yongqiang@yongqiang:~/tensorflow_work/tensorflow$
2.2 --distdir=/home/yongqiang/tensorflow_work/dist_dir/
WARNING: Download from https://storage.googleapis.com/mirror.tensorflow.org/github.com/tensorflow/runtime/archive/eeaa95e05ce236b56c960a3ec8e816c8d78c7106.tar.gz failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException Unknown host: storage.googleapis.com
WARNING: Download from https://github.com/tensorflow/runtime/archive/eeaa95e05ce236b56c960a3ec8e816c8d78c7106.tar.gz failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException Unknown host: github.com
遇到编译时无法下载的库,使用浏览器或者 wget 放置到 /home/yongqiang/tensorflow_work/dist_dir/ 目录。
(base) yongqiang@yongqiang:~/tensorflow_work$ mkdir dist_dir
(base) yongqiang@yongqiang:~/tensorflow_work$ cd dist_dir/
(base) yongqiang@yongqiang:~/tensorflow_work/dist_dir$ ls
(base) yongqiang@yongqiang:~/tensorflow_work/dist_dir$ pwd
/home/yongqiang/tensorflow_work/dist_dir
(base) yongqiang@yongqiang:~/tensorflow_work/dist_dir$
(base) yongqiang@yongqiang:~/tensorflow_work/dist_dir$ wget https://github.com/tensorflow/runtime/archive/eeaa95e05ce236b56c960a3ec8e816c8d78c7106.tar.gz
--2021-11-18 23:34:30-- https://github.com/tensorflow/runtime/archive/eeaa95e05ce236b56c960a3ec8e816c8d78c7106.tar.gz
Resolving github.com (github.com)... 20.205.243.166
Connecting to github.com (github.com)|20.205.243.166|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/tensorflow/runtime/tar.gz/eeaa95e05ce236b56c960a3ec8e816c8d78c7106 [following]
--2021-11-18 23:34:31-- https://codeload.github.com/tensorflow/runtime/tar.gz/eeaa95e05ce236b56c960a3ec8e816c8d78c7106
Resolving codeload.github.com (codeload.github.com)... 20.205.243.165
Connecting to codeload.github.com (codeload.github.com)|20.205.243.165|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 15257152 (15M) [application/x-gzip]
Saving to: ‘eeaa95e05ce236b56c960a3ec8e816c8d78c7106.tar.gz’
eeaa95e05ce236b56c960a3ec8e816c8d78c7106.tar 100%[=============================================================================================>] 14.55M 66.6KB/s in 3m 39s
2021-11-18 23:38:12 (68.0 KB/s) - ‘eeaa95e05ce236b56c960a3ec8e816c8d78c7106.tar.gz’ saved [15257152/15257152]
(base) yongqiang@yongqiang:~/tensorflow_work/dist_dir$
References
https://www.tensorflow.org/lite/ https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/g3doc
|