Skip to contentSkip to conversation

Add tensorflow-lite

PATCH In review Hongmei Gou 2 participants 6 messages Aug 22, 2019 – Sep 20, 2019

lore
Share & tools
lore
#0 lore raw

v2 cover Add tensorflow-lite

This patch set starts from the baseline recipe at
https://github.com/nnsuite/meta-neural-network/tree/master/recipes-tensorflow/tensorflow-lite,

The major changes are listed below:

1. Made some cleanup for the baseline recipes, such as updating NEON2SSE and replacing AUTOREV

2. Installed minimal and benchmark_model binaries which have been built with the original Makefile

3. Patched Makefile to add label_image and installed the example binary and files (model/image/labels.txt) needed to run the example

v2 change:
Keep the dependencies in the original single recipe, instead of creating separate recipes for all the dependencies

Hongmei Gou (3):
tensorflow-lite: add version 1.12
tensorflow-lite: install minimal and benchmark_model examples, and all
.a files
tensorflow-lite: add label_image example and install the files to run
the example

 ...001-Makefile-add-label_image-example.patch |  89 ++++++++++++
 ...odification-for-tflite-1.12-to-eigen.patch |  13 ++
 .../files/tensorflow-lite.pc.in               |   6 +
 .../tensorflow-lite/tensorflow-lite_1.12.bb   | 136 ++++++++++++++++++
 4 files changed, 244 insertions(+)
 create mode 100644 meta-arago-extras/recipes-support/tensorflow-lite/files/0001-Makefile-add-label_image-example.patch
 create mode 100644 meta-arago-extras/recipes-support/tensorflow-lite/files/apply-modification-for-tflite-1.12-to-eigen.patch
 create mode 100644 meta-arago-extras/recipes-support/tensorflow-lite/files/tensorflow-lite.pc.in
 create mode 100644 meta-arago-extras/recipes-support/tensorflow-lite/tensorflow-lite_1.12.bb
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/3 tensorflow-lite: add version 1.12

* Source of the recipe:
https://github.com/nnsuite/meta-neural-network/tree/master/recipes-tensorflow/tensorflow-lite
* Further changes from the baseline include:
1. Replaced moving master with commit ID for NEON2SSE, and updated the checksum;
2. Replaced AUTOREV with the commit ID for tensorflow version 1.12;
3. Removed do_configure{} which is not needed;
4. Removed installation for flatbuffers.

---
 ...odification-for-tflite-1.12-to-eigen.patch |  13 ++
 .../files/tensorflow-lite.pc.in               |   6 +
 .../tensorflow-lite/tensorflow-lite_1.12.bb   | 119 ++++++++++++++++++
 3 files changed, 138 insertions(+)
 create mode 100644 meta-arago-extras/recipes-support/tensorflow-lite/files/apply-modification-for-tflite-1.12-to-eigen.patch
 create mode 100644 meta-arago-extras/recipes-support/tensorflow-lite/files/tensorflow-lite.pc.in
 create mode 100644 meta-arago-extras/recipes-support/tensorflow-lite/tensorflow-lite_1.12.bb
meta-arago-extras/recipes-support/tensorflow-lite/files/apply-modification-for-tflite-1.12-to-eigen.patch new file +13 -0
new file mode 100644
index 00000000..1a8de78b
@@ -0,0 +1,13 @@
+diff --git a/tensorflow/contrib/lite/tools/make/downloads/eigen/Eigen/src/Core/arch/NEON/Complex.h b/tensorflow/contrib/lite/tools/make/downloads/eigen/Eigen/src/Core/arch/NEON/Complex.h
+index 306a309beb..4527a64c91 100644
+--- a/tensorflow/contrib/lite/tools/make/downloads/eigen/Eigen/src/Core/arch/NEON/Complex.h
++++ b/tensorflow/contrib/lite/tools/make/downloads/eigen/Eigen/src/Core/arch/NEON/Complex.h
+@@ -295,7 +295,7 @@ ptranspose(PacketBlock<Packet2cf,2>& kernel) {
+   static uint64x2_t p2ul_CONJ_XOR = {0x0, 0x8000000000000000};
+ #else
+   const uint64_t  p2ul_conj_XOR_DATA[] = { 0x0, 0x8000000000000000 };
+-  static uint64x2_t p2ul_CONJ_XOR = vld1q_u64( p2ul_conj_XOR_DATA );
++  static uint64x2_t p2ul_CONJ_XOR;// = vld1q_u64( p2ul_conj_XOR_DATA ); - Removed by script
+ #endif
+ 
+ struct Packet1cd
meta-arago-extras/recipes-support/tensorflow-lite/files/tensorflow-lite.pc.in new file +6 -0
new file mode 100644
index 00000000..44afd0ee
@@ -0,0 +1,6 @@
+ Name: tensorflow lite
+ Description: tensorflow lite static library
+ Version: @version@
+ Requires:
+ Libs: -L@libdir@ -ltensorflow-lite
+ Cflags: -I@includedir@
meta-arago-extras/recipes-support/tensorflow-lite/tensorflow-lite_1.12.bb new file +119 -0

119 lines not on this page · raw message

Signature · 1 line
2.17.1
#3 lore raw

PATCH v2 3/3 tensorflow-lite: add label_image example and install the files to run the example

In reply to Hongmei Gou

* Patch Makefile to add the label_image example
* Install sample model/image/labels.txt to run the example

---
 ...001-Makefile-add-label_image-example.patch | 89 +++++++++++++++++++
 .../tensorflow-lite/tensorflow-lite_1.12.bb   | 15 +++-
 2 files changed, 100 insertions(+), 4 deletions(-)
 create mode 100644 meta-arago-extras/recipes-support/tensorflow-lite/files/0001-Makefile-add-label_image-example.patch
meta-arago-extras/recipes-support/tensorflow-lite/files/0001-Makefile-add-label_image-example.patch new file +89 -0
new file mode 100644
index 00000000..61f821e3
@@ -0,0 +1,89 @@
+From 87cf7e879640436f19f26e338dce6c343c19bfd8 Mon Sep 17 00:00:00 2001
+From: Hongmei Gou <[email protected]>
+Date: Wed, 21 Aug 2019 18:03:17 -0400
+Subject: [PATCH] Makefile: add label_image example
+
+Upstream-Status: Pending
+
+Signed-off-by: Hongmei Gou <[email protected]>
+---
+ tensorflow/contrib/lite/tools/make/Makefile | 21 +++++++++++++++++++--
+ 1 file changed, 19 insertions(+), 2 deletions(-)
+
+diff --git a/tensorflow/contrib/lite/tools/make/Makefile b/tensorflow/contrib/lite/tools/make/Makefile
+index 16012a3fb1..a5e5cb3fc7 100644
+--- a/tensorflow/contrib/lite/tools/make/Makefile
++++ b/tensorflow/contrib/lite/tools/make/Makefile
+@@ -72,6 +72,11 @@ BENCHMARK_BINARY_NAME := benchmark_model
+ MINIMAL_SRCS := \
+ tensorflow/contrib/lite/examples/minimal/minimal.cc
+ 
++# label image example
++LABELIMAGE_SRCS := \
++tensorflow/contrib/lite/examples/label_image/bitmap_helpers.cc \
++tensorflow/contrib/lite/examples/label_image/label_image.cc
++
+ # What sources we want to compile, must be kept in sync with the main Bazel
+ # build files.
+ 
+@@ -108,7 +113,8 @@ $(wildcard tensorflow/contrib/lite/*/*test.cc) \
+ $(wildcard tensorflow/contrib/lite/*/*/*test.cc) \
+ $(wildcard tensorflow/contrib/lite/*/*/*/*test.cc) \
+ $(wildcard tensorflow/contrib/lite/kernels/test_util.cc) \
+-$(MINIMAL_SRCS)
++$(MINIMAL_SRCS) \
++$(LABELIMAGE_SRCS)
+ ifeq ($(BUILD_TYPE),micro)
+ CORE_CC_EXCLUDE_SRCS += \
+ tensorflow/contrib/lite/mmap_allocation.cc \
+@@ -135,6 +141,7 @@ include $(wildcard $(MAKEFILE_DIR)/targets/*_makefile.inc)
+ 
+ ALL_SRCS := \
+ 	$(MINIMAL_SRCS) \
++	$(LABELIMAGE_SRCS) \
+ 	$(PROFILER_SRCS) \
+ 	$(PROFILER_SUMMARY_SRCS) \
+ 	$(TF_LITE_CC_SRCS) \
+@@ -150,6 +157,7 @@ LIB_PATH := $(LIBDIR)$(LIB_NAME)
+ BENCHMARK_LIB := $(LIBDIR)$(BENCHMARK_LIB_NAME)
+ BENCHMARK_BINARY := $(BINDIR)$(BENCHMARK_BINARY_NAME)
+ MINIMAL_BINARY := $(BINDIR)minimal
++LABELIMAGE_BINARY := $(BINDIR)label_image
+ 
+ CXX := $(CC_PREFIX)${TARGET_TOOLCHAIN_PREFIX}g++
+ CC := $(CC_PREFIX)${TARGET_TOOLCHAIN_PREFIX}gcc
+@@ -158,6 +166,9 @@ AR := $(CC_PREFIX)${TARGET_TOOLCHAIN_PREFIX}ar
+ MINIMAL_OBJS := $(addprefix $(OBJDIR), \
+ $(patsubst %.cc,%.o,$(patsubst %.c,%.o,$(MINIMAL_SRCS))))
+ 
++LABELIMAGE_OBJS := $(addprefix $(OBJDIR), \
++$(patsubst %.cc,%.o,$(patsubst %.c,%.o,$(LABELIMAGE_SRCS))))
++
+ LIB_OBJS := $(addprefix $(OBJDIR), \
+ $(patsubst %.cc,%.o,$(patsubst %.c,%.o,$(TF_LITE_CC_SRCS))))
+ 
+@@ -174,7 +185,7 @@ $(OBJDIR)%.o: %.c
+ 	$(CC) $(CCFLAGS) $(INCLUDES) -c $< -o $@
+ 
+ # The target that's compiled if there's no command-line arguments.
+-all: $(LIB_PATH)  $(MINIMAL_BINARY) $(BENCHMARK_BINARY)
++all: $(LIB_PATH)  $(MINIMAL_BINARY) $(LABELIMAGE_BINARY) $(BENCHMARK_BINARY)
+ 
+ # The target that's compiled for micro-controllers
+ micro: $(LIB_PATH)
+@@ -198,6 +209,12 @@ $(BENCHMARK_LIB) : $(LIB_PATH) $(BENCHMARK_OBJS)
+ 	@mkdir -p $(dir $@)
+ 	$(AR) $(ARFLAGS) $(BENCHMARK_LIB) $(LIB_OBJS) $(BENCHMARK_OBJS)
+ 
++$(LABELIMAGE_BINARY): $(LABELIMAGE_OBJS) $(LIB_PATH)
++	@mkdir -p $(dir $@)
++	$(CXX) $(CXXFLAGS) $(INCLUDES) \
++	-o $(LABELIMAGE_BINARY) $(LABELIMAGE_OBJS) \
++	$(LIBFLAGS) $(LIB_PATH) $(LDFLAGS) $(LIBS)
++
+ benchmark_lib: $(BENCHMARK_LIB)
+ 
+ $(BENCHMARK_BINARY) : $(BENCHMARK_LIB)
+-- 
+2.17.1
+
meta-arago-extras/recipes-support/tensorflow-lite/tensorflow-lite_1.12.bb +11 -4
index 38df078f..b393f7eb 100644
@@ -30,12 +30,17 @@ SRC_URI = "git://github.com/tensorflow/tensorflow.git;branch=r1.12;protocol=http
     https://mirror.bazel.build/github.com/google/farmhash/archive/816a4ae622e964763ca0862d9dbd19324a1eaf45.tar.gz;md5sum=${MD5SUM_FARMHASH};sha256sum=${SHA256SUM_FARMHASH} \
     https://github.com/google/flatbuffers/archive/1f5eae5d6a135ff6811724f6c57f911d1f46bb15.tar.gz;md5sum=${MD5SUM_FLATBUFFER};sha256sum=${SHA256SUM_FLATBUFFER} \
     https://mirror.bazel.build/www.kurims.kyoto-u.ac.jp/~ooura/fft.tgz;md5sum=${MD5SUM_FFT};sha256sum=${SHA256SUM_FFT} \
+    http://download.tensorflow.org/models/mobilenet_v1_2018_08_02/mobilenet_v1_1.0_224_quant.tgz;name=mobilenet_v1_quant;subdir=${WORKDIR}/model;destsuffix=model \
     file://apply-modification-for-tflite-1.12-to-eigen.patch \
+    file://0001-Makefile-add-label_image-example.patch \
     file://tensorflow-lite.pc.in"
 
+SRC_URI[mobilenet_v1_quant.md5sum] = "36af340c00e60291931cb30ce32d4e86"
+SRC_URI[mobilenet_v1_quant.sha256sum] = "d32432d28673a936b2d6281ab0600c71cf7226dfe4cdcef3012555f691744166"
+
 SRCREV = "5b900cfe4b3b848f577315a0dde09a729f770e95"
 
-PR = "r2"
+PR = "r3"
 
 S = "${WORKDIR}/git"
 
@@ -118,12 +123,14 @@ do_install() {
     install -d ${D}${datadir}/${PN}-${PV}/examples
     install -m 0755 ${S}/tensorflow/contrib/lite/tools/make/gen/${TARGET_OS}_${TUNE_ARCH}/bin/minimal ${D}${datadir}/${PN}-${PV}/examples
     install -m 0755 ${S}/tensorflow/contrib/lite/tools/make/gen/${TARGET_OS}_${TUNE_ARCH}/bin/benchmark_model ${D}${datadir}/${PN}-${PV}/examples
+    install -m 0755 ${S}/tensorflow/contrib/lite/tools/make/gen/${TARGET_OS}_${TUNE_ARCH}/bin/label_image ${D}${datadir}/${PN}-${PV}/examples
+    install -m 0644 ${S}/tensorflow/contrib/lite/examples/label_image/testdata/grace_hopper.bmp ${D}${datadir}/${PN}-${PV}/examples
+    install -m 0644 ${S}/tensorflow/contrib/lite/java/ovic/src/testdata/labels.txt ${D}${datadir}/${PN}-${PV}/examples
+    install -m 0644 ${WORKDIR}/model/mobilenet_v1_1.0_224_quant.tflite ${D}${datadir}/${PN}-${PV}/examples
 }
 
 PACKAGES += "${PN}-examples"
 
-FILES_${PN}-examples = " \
-    ${datadir}/${PN}-${PV}/examples/minimal \
-    ${datadir}/${PN}-${PV}/examples/benchmark_model \ "
+FILES_${PN}-examples = "${datadir}/${PN}-${PV}/examples"
 
 ALLOW_EMPTY_${PN} = "1"
Signature · 1 line
2.17.1
#2 lore raw

PATCH v2 2/3 tensorflow-lite: install minimal and benchmark_model examples, and all .a files

In reply to Hongmei Gou
---
 .../tensorflow-lite/tensorflow-lite_1.12.bb        | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
meta-arago-extras/recipes-support/tensorflow-lite/tensorflow-lite_1.12.bb +12 -2
index ebd175e1..38df078f 100644
@@ -35,7 +35,7 @@ SRC_URI = "git://github.com/tensorflow/tensorflow.git;branch=r1.12;protocol=http
 
 SRCREV = "5b900cfe4b3b848f577315a0dde09a729f770e95"
 
-PR = "r1"
+PR = "r2"
 
 S = "${WORKDIR}/git"
 
@@ -94,7 +94,7 @@ do_compile() {
 
 do_install() {
     install -d ${D}${libdir}
-    install -m 0644 ${S}/tensorflow/contrib/lite/tools/make/gen/${TARGET_OS}_${TUNE_ARCH}/lib/libtensorflow-lite.a ${D}${libdir}/
+    install -m 0644 ${S}/tensorflow/contrib/lite/tools/make/gen/${TARGET_OS}_${TUNE_ARCH}/lib/*.a ${D}${libdir}/
     install -d ${D}${includedir}/tensorflow/contrib/lite
     install -m 0644 ${S}/tensorflow/contrib/lite/*.h ${D}${includedir}/tensorflow/contrib/lite/
     install -d ${D}${includedir}/tensorflow/contrib/lite/c
@@ -114,6 +114,16 @@ do_install() {
     sed -i 's:@version@:${PV}:g
         s:@libdir@:${libdir}:g
         s:@includedir@:${includedir}:g' ${D}${libdir}/pkgconfig/tensorflow-lite.pc
+    # install examples
+    install -d ${D}${datadir}/${PN}-${PV}/examples
+    install -m 0755 ${S}/tensorflow/contrib/lite/tools/make/gen/${TARGET_OS}_${TUNE_ARCH}/bin/minimal ${D}${datadir}/${PN}-${PV}/examples
+    install -m 0755 ${S}/tensorflow/contrib/lite/tools/make/gen/${TARGET_OS}_${TUNE_ARCH}/bin/benchmark_model ${D}${datadir}/${PN}-${PV}/examples
 }
 
+PACKAGES += "${PN}-examples"
+
+FILES_${PN}-examples = " \
+    ${datadir}/${PN}-${PV}/examples/minimal \
+    ${datadir}/${PN}-${PV}/examples/benchmark_model \ "
+
 ALLOW_EMPTY_${PN} = "1"
Signature · 1 line
2.17.1
Acked-by on the v2 series
#4 lore raw
In reply to Hongmei Gou

ACK

Quoted 33 lines · Hongmei Gou

This patch set starts from the baseline recipe at
https://github.com/nnsuite/meta-neural-network/tree/master/recipes-tensorflow/tensorflow-lite,

The major changes are listed below:

1. Made some cleanup for the baseline recipes, such as updating NEON2SSE and replacing AUTOREV

2. Installed minimal and benchmark_model binaries which have been built with the original Makefile

3. Patched Makefile to add label_image and installed the example binary and files (model/image/labels.txt) needed to run the example

v2 change:
Keep the dependencies in the original single recipe, instead of creating separate recipes for all the dependencies

Hongmei Gou (3):
tensorflow-lite: add version 1.12
tensorflow-lite: install minimal and benchmark_model examples, and all
.a files
tensorflow-lite: add label_image example and install the files to run
the example

  ...001-Makefile-add-label_image-example.patch |  89 ++++++++++++
  ...odification-for-tflite-1.12-to-eigen.patch |  13 ++
  .../files/tensorflow-lite.pc.in               |   6 +
  .../tensorflow-lite/tensorflow-lite_1.12.bb   | 136 ++++++++++++++++++
  4 files changed, 244 insertions(+)

create mode 100644 meta-arago-extras/recipes-support/tensorflow-lite/files/0001-Makefile-add-label_image-example.patch create mode 100644 meta-arago-extras/recipes-support/tensorflow-lite/files/apply-modification-for-tflite-1.12-to-eigen.patch create mode 100644 meta-arago-extras/recipes-support/tensorflow-lite/files/tensorflow-lite.pc.in
create mode 100644 meta-arago-extras/recipes-support/tensorflow-lite/tensorflow-lite_1.12.bb

#5 lore raw
In reply to Hongmei Gou

Denys,

Please backport these to ti2019.03.

Thank you,

Jake

Quoted 33 lines · Hongmei Gou

This patch set starts from the baseline recipe at
https://github.com/nnsuite/meta-neural-network/tree/master/recipes-tensorflow/tensorflow-lite,

The major changes are listed below:

1. Made some cleanup for the baseline recipes, such as updating NEON2SSE and replacing AUTOREV

2. Installed minimal and benchmark_model binaries which have been built with the original Makefile

3. Patched Makefile to add label_image and installed the example binary and files (model/image/labels.txt) needed to run the example

v2 change:
Keep the dependencies in the original single recipe, instead of creating separate recipes for all the dependencies

Hongmei Gou (3):
tensorflow-lite: add version 1.12
tensorflow-lite: install minimal and benchmark_model examples, and all
.a files
tensorflow-lite: add label_image example and install the files to run
the example

  ...001-Makefile-add-label_image-example.patch |  89 ++++++++++++
  ...odification-for-tflite-1.12-to-eigen.patch |  13 ++
  .../files/tensorflow-lite.pc.in               |   6 +
  .../tensorflow-lite/tensorflow-lite_1.12.bb   | 136 ++++++++++++++++++
  4 files changed, 244 insertions(+)

create mode 100644 meta-arago-extras/recipes-support/tensorflow-lite/files/0001-Makefile-add-label_image-example.patch create mode 100644 meta-arago-extras/recipes-support/tensorflow-lite/files/apply-modification-for-tflite-1.12-to-eigen.patch create mode 100644 meta-arago-extras/recipes-support/tensorflow-lite/files/tensorflow-lite.pc.in
create mode 100644 meta-arago-extras/recipes-support/tensorflow-lite/tensorflow-lite_1.12.bb