All of lore.kernel.org
 help / color / mirror / Atom feed
From: Djordje Senicic <x0157990@ti.com>
To: <meta-arago@arago-project.org>
Cc: Djordje Senicic <x0157990@ti.com>
Subject: [thud/master][PATCH v2 2/3] demo-glow: Add mnist inference demo based on GLOW compiler
Date: Thu, 20 Jun 2019 02:38:14 -0400	[thread overview]
Message-ID: <20190620063815.18898-2-x0157990@ti.com> (raw)
In-Reply-To: <20190620063815.18898-1-x0157990@ti.com>

Signed-off-by: Djordje Senicic <x0157990@ti.com>
---
 .../recipes-apps/demo-glow/demo-glow.bb       | 46 +++++++++++++++++++
 .../files/0001-fix-missing-string.patch       | 10 ++++
 .../demo-glow/files/Makefile.build            | 18 ++++++++
 .../recipes-apps/demo-glow/files/makefile     | 13 ++++++
 4 files changed, 87 insertions(+)
 create mode 100644 meta-arago-extras/recipes-apps/demo-glow/demo-glow.bb
 create mode 100644 meta-arago-extras/recipes-apps/demo-glow/files/0001-fix-missing-string.patch
 create mode 100644 meta-arago-extras/recipes-apps/demo-glow/files/Makefile.build
 create mode 100644 meta-arago-extras/recipes-apps/demo-glow/files/makefile

diff --git a/meta-arago-extras/recipes-apps/demo-glow/demo-glow.bb b/meta-arago-extras/recipes-apps/demo-glow/demo-glow.bb
new file mode 100644
index 00000000..c7422948
--- /dev/null
+++ b/meta-arago-extras/recipes-apps/demo-glow/demo-glow.bb
@@ -0,0 +1,46 @@
+DESCRIPTION = "Demo application based on pytorch neural network compiler glow, using mnist model" 
+HOMEPAGE = "https://github.com/pytorch/glow/tree/master/examples/bundles/lenet_mnist"
+SECTION = "examples" 
+LICENSE = "Apache-2.0" 
+LIC_FILES_CHKSUM = "file://LICENSE;md5=86d3f3a95c324c9479bd8986968f4327"
+
+PV = "1.0"
+PR = "r1" 
+
+DEPENDS    = "glow-native libpng"
+
+SRC_URI = "https://raw.githubusercontent.com/pytorch/glow/1af031c9c040dd4ff843d9b50f83e71f6e605631/examples/bundles/lenet_mnist/main.cpp;name=lenet_mnist_main;subdir=src \
+           file://0001-fix-missing-string.patch \
+           file://makefile;subdir=src \
+           file://Makefile.build;subdir=src \
+           http://fb-glow-assets.s3.amazonaws.com/models/lenet_mnist.tar.gz;name=lenet_mnist;subdir=src \
+           https://raw.githubusercontent.com/pytorch/glow/1af031c9c040dd4ff843d9b50f83e71f6e605631/LICENSE;name=lenet_mnist_license;subdir=src \
+          "
+
+SRC_URI[lenet_mnist.md5sum] = "7aded5f273b3198795683c238492d1a9"
+SRC_URI[lenet_mnist_main.md5sum] = "e80ec7a97dec86828ff1a51026c237bc"
+SRC_URI[lenet_mnist_license.md5sum] = "86d3f3a95c324c9479bd8986968f4327"
+
+S = "${WORKDIR}/src"
+
+do_compile() {
+   install -d ${WORKDIR}/build
+   ${STAGING_DIR_NATIVE}/usr/share/glow/bin/image-classifier ${STAGING_DIR_NATIVE}/usr/share/glow/tests/images/mnist/1_1008.png -m=mnist.onnx -image-mode=0to1 -model-input-name=data_0 -emit-bundle ${WORKDIR}/build/ -cpu -target armv7l-unknown-linux-gnueabihf   -network-name="lenet_mnist"
+   ${CXX} ${S}/main.cpp ${WORKDIR}/build/lenet_mnist.o -lm -lpng -fpack-struct=8 -fpermissive -o ${WORKDIR}/build/infer_mnist
+}
+
+do_install () {
+   install -d ${D}${datadir}/glow/infer
+   install -d ${D}${datadir}/glow/tests
+   cp -Prf --preserve=mode,timestamps ${WORKDIR}/build/*.weights ${D}${datadir}/glow/infer
+   cp -Prf --preserve=mode,timestamps ${WORKDIR}/build/infer_mnist ${D}${datadir}/glow/infer
+   cp -Prf --preserve=mode,timestamps ${WORKDIR}/build/lenet_mnist.o ${D}${datadir}/glow/infer
+   cp -Prf --preserve=mode,timestamps ${WORKDIR}/src/makefile ${D}${datadir}/glow/infer
+   cp -Prf --preserve=mode,timestamps ${WORKDIR}/src/main.cpp ${D}${datadir}/glow/infer
+   cp -Prf --preserve=mode,timestamps ${STAGING_DIR_NATIVE}/usr/share/glow/tests/images/mnist/*.png ${D}${datadir}/glow/tests/.
+}
+
+FILES_${PN} += "${datadir}/glow"
+
+CREATE_SRCIPK = "1"
+SRCIPK_INSTALL_DIR = "example-applications/${PN}-${PV}"
diff --git a/meta-arago-extras/recipes-apps/demo-glow/files/0001-fix-missing-string.patch b/meta-arago-extras/recipes-apps/demo-glow/files/0001-fix-missing-string.patch
new file mode 100644
index 00000000..ba0533ab
--- /dev/null
+++ b/meta-arago-extras/recipes-apps/demo-glow/files/0001-fix-missing-string.patch
@@ -0,0 +1,10 @@
+--- ./main.cpp	2019-06-06 13:31:07.485528729 -0400
++++ ./main_mod.cpp	2019-06-06 13:30:50.333529003 -0400
+@@ -18,6 +18,7 @@
+ #include <png.h>
+ #include <stdio.h>
+ #include <stdlib.h>
++#include <string.h>
+ 
+ #include <string>
+ #include <vector>
diff --git a/meta-arago-extras/recipes-apps/demo-glow/files/Makefile.build b/meta-arago-extras/recipes-apps/demo-glow/files/Makefile.build
new file mode 100644
index 00000000..399cc3c0
--- /dev/null
+++ b/meta-arago-extras/recipes-apps/demo-glow/files/Makefile.build
@@ -0,0 +1,18 @@
+-include ../../Rules.make
+
+ENV_SETUP ?= ../../linux-devkit/environment-setup
+DESTDIR ?=
+
+all: release
+
+lenet_mnist:
+	${SDK_PATH_NATIVE}/usr/share/glow/bin/image-classifier ${SDK_PATH_NATIVE}/usr/share/glow/tests/images/mnist/1_1008.png -m=mnist.onnx -image-mode=0to1 -model-input-name=data_0 -emit-bundle ./ -cpu -target armv7l-unknown-linux-gnueabihf   -network-name="lenet_mnist"
+
+release: lenet_mnist
+	@. ${ENV_SETUP}; \
+	make
+
+clean:
+	@. ${ENV_SETUP}; \
+        make clean
+	rm lenet_mnist.*
diff --git a/meta-arago-extras/recipes-apps/demo-glow/files/makefile b/meta-arago-extras/recipes-apps/demo-glow/files/makefile
new file mode 100644
index 00000000..01b19c8c
--- /dev/null
+++ b/meta-arago-extras/recipes-apps/demo-glow/files/makefile
@@ -0,0 +1,13 @@
+PHONY: all
+
+all: infer_mnist
+LIBS = -lm -lpng
+
+infer_mnist: main.cpp lenet_mnist.o
+	$(CXX) main.cpp lenet_mnist.o -o infer_mnist $(LIBS) $(CXXFLAGS) -fpack-struct=8 -fpermissive
+
+clean:
+	rm -rf infer_mnist
+
+test:
+	./infer_mnist ../tests/0_1009.png
-- 
2.17.1



  reply	other threads:[~2019-06-20 11:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-20  6:38 [thud/master][PATCH v2 1/3] glow: Add pytorch neural network compiler and dependencies Djordje Senicic
2019-06-20  6:38 ` Djordje Senicic [this message]
2019-06-20  6:38 ` [thud/master][PATCH v2 3/3] glow: Add glow and demo-glow to packagegroups Djordje Senicic
2019-06-21 15:26   ` [EXTERNAL] " Jacob Stiffler
2019-06-21 15:44     ` Senicic, Djordje
2019-06-21 22:27 ` [thud/master][PATCH v2 1/3] glow: Add pytorch neural network compiler and dependencies Denys Dmytriyenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190620063815.18898-2-x0157990@ti.com \
    --to=x0157990@ti.com \
    --cc=meta-arago@arago-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.