Return-Path: Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) by arago-project.org (Postfix) with ESMTPS id 638AD52A20 for ; Wed, 13 Nov 2019 00:25:55 +0000 (UTC) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id xAD0OUU7017822 for ; Tue, 12 Nov 2019 18:24:30 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1573604670; bh=qXu62TdHiOxGDpm3vV/lwtSCiKWJW1Bx0g450I7w88k=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=xjFArmsj+ythcCvwIn5MMMDiuJKgfAZ9lichFsJakCfN0pulzeNqDf/oAEsk01FMY zvzpkKcUfnDZUh8mfgzOfSXYRVU6eViJvhlJw0UBXOy32OOUFlLXPLrX6kH544Ihkl ENSLibPqu8KVeT73SGQBUdAGqm44n3caJfPHInRw= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id xAD0OUmW108313 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 12 Nov 2019 18:24:30 -0600 Received: from DFLE101.ent.ti.com (10.64.6.22) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Tue, 12 Nov 2019 18:24:13 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE101.ent.ti.com (10.64.6.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Tue, 12 Nov 2019 18:24:12 -0600 Received: from UDA0271529.gt.design.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id xAD0ONE9056588; Tue, 12 Nov 2019 18:24:30 -0600 From: Hongmei Gou To: Date: Tue, 12 Nov 2019 19:13:48 -0500 Message-ID: <20191113001349.30916-2-a0271529@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191113001349.30916-1-a0271529@ti.com> References: <20191113001349.30916-1-a0271529@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: Hongmei Gou Subject: [thud/master] [PATCH 2/3] tensorflow-lite: add scripts for benchmarking X-BeenThere: meta-arago@arago-project.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Arago metadata layer for TI SDKs - OE-Core/Yocto compatible List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Nov 2019 00:25:55 -0000 Content-Type: text/plain Signed-off-by: Hongmei Gou --- .../tensorflow-lite/files/tflite-benchmark.sh | 58 +++++++++++++++++++ .../tensorflow-lite/tensorflow-lite_1.15.bb | 6 +- 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 meta-arago-extras/recipes-support/tensorflow-lite/files/tflite-benchmark.sh diff --git a/meta-arago-extras/recipes-support/tensorflow-lite/files/tflite-benchmark.sh b/meta-arago-extras/recipes-support/tensorflow-lite/files/tflite-benchmark.sh new file mode 100644 index 00000000..c37ca53f --- /dev/null +++ b/meta-arago-extras/recipes-support/tensorflow-lite/files/tflite-benchmark.sh @@ -0,0 +1,58 @@ +#!/bin/sh + +#list of model packages +declare -a model_list=( +"http://storage.googleapis.com/download.tensorflow.org/models/mobilenet_v1_2018_08_02/mobilenet_v1_1.0_224_quant.tgz" +"http://storage.googleapis.com/download.tensorflow.org/models/tflite_11_05_08/mobilenet_v2_1.0_224_quant.tgz" +"http://storage.googleapis.com/download.tensorflow.org/models/inception_v1_224_quant_20181026.tgz" +"http://storage.googleapis.com/download.tensorflow.org/models/inception_v2_224_quant_20181026.tgz" +"http://storage.googleapis.com/download.tensorflow.org/models/tflite_11_05_08/inception_v3_quant.tgz" +"http://storage.googleapis.com/download.tensorflow.org/models/inception_v4_299_quant_20181026.tgz" +"http://storage.googleapis.com/download.tensorflow.org/models/tflite/coco_ssd_mobilenet_v1_1.0_quant_2018_06_29.zip" +) + +# create a new directory to host and unpack the models +rm -rf ~/tflite-benchmark +mkdir ~/tflite-benchmark + +# set up http proxy - MODIFY THIS AS NEEDED!! +ti_http_proxy="http://webproxy.ext.ti.com:80" + +# Set maximal number of threads to the number of arm cores +max_num_threads=`nproc` + +# TFLite install dir on filesystem +tflite_install_dir=$(find /usr/share -maxdepth 1 -type d -name "tensorflow-lite*") + +for model_link in "${model_list[@]}" +do + # download the model package to modeldir + modelpkg="${model_link##*/}" + modeldir="${modelpkg%.*}" + + mkdir ~/tflite-benchmark/$modeldir + cd ~/tflite-benchmark/$modeldir + + echo "Downloading $modelpkg..." + http_proxy="$ti_http_proxy" wget "$model_link" + + # unpack the model package + if [[ $modelpkg =~ \.tgz$ ]]; then + tar -xzvf $modelpkg + fi + if [[ $modelpkg =~ \.zip$ ]]; then + unzip $modelpkg + fi + + # run benchmark for the model + for model in *.tflite; do + for num_threads in $( seq 1 $max_num_threads ) + do + echo "Running benchmark_model for $model with $num_threads thread(s)..." + $tflite_install_dir/examples/benchmark_model --graph=${model} --num_threads=$num_threads --enable_op_profiling=true > ${modeldir}_thread_${num_threads}.log + cat ${modeldir}_thread_${num_threads}.log | grep Timings + done + done +done + +echo "Benchmarking completed!" diff --git a/meta-arago-extras/recipes-support/tensorflow-lite/tensorflow-lite_1.15.bb b/meta-arago-extras/recipes-support/tensorflow-lite/tensorflow-lite_1.15.bb index c676177b..aade3a1d 100644 --- a/meta-arago-extras/recipes-support/tensorflow-lite/tensorflow-lite_1.15.bb +++ b/meta-arago-extras/recipes-support/tensorflow-lite/tensorflow-lite_1.15.bb @@ -33,6 +33,7 @@ SRC_URI = "git://github.com/tensorflow/tensorflow.git;branch=r${PV};protocol=htt 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-${PV}-to-eigen.patch \ file://0001-Makefile-add-label_image-example-${PV}.patch \ + file://tflite-benchmark.sh \ file://tensorflow-lite.pc.in" SRC_URI[mobilenet_v1_quant.md5sum] = "36af340c00e60291931cb30ce32d4e86" @@ -40,7 +41,7 @@ SRC_URI[mobilenet_v1_quant.sha256sum] = "d32432d28673a936b2d6281ab0600c71cf7226d SRCREV = "590d6eef7e91a6a7392c8ffffb7b58f2e0c8bc6b" -PR = "r1" +PR = "r2" S = "${WORKDIR}/git" @@ -128,6 +129,9 @@ do_install() { install -m 0644 ${S}/tensorflow/lite/examples/label_image/testdata/grace_hopper.bmp ${D}${datadir}/${PN}-${PV}/examples install -m 0644 ${S}/tensorflow/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 + # install scripts for benchmarking + install -d ${D}${bindir} + install -m 0755 ${WORKDIR}/tflite-benchmark.sh ${D}/${bindir} } PACKAGES += "${PN}-examples" -- 2.17.1