From e299f48cecd972e39fb30ca7511494619f55e82c Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9D=B4=EC=83=81=EA=B7=9C/On-Device=20Lab=28SR=29/Princip?= =?utf8?q?al=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Thu, 29 Aug 2019 16:05:30 +0900 Subject: [PATCH] [nnpkg_tool] Revise nnpkg_test and model2nnpkg for readable log (#7028) `nnpkg_test` - distinguish the run and compare result. - shows the errors after a blank line. - does not use `set -e` to continue after error for pretty printing. `model2nnpkg` - It becmome less noisy. Signed-off-by: Sanggyu Lee --- tools/nnpackage_tool/model2nnpkg/model2nnpkg.sh | 3 +-- tools/nnpackage_tool/nnpkg_test/nnpkg_test.sh | 28 ++++++++++++++++++------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/tools/nnpackage_tool/model2nnpkg/model2nnpkg.sh b/tools/nnpackage_tool/model2nnpkg/model2nnpkg.sh index b66e534..87cd787 100755 --- a/tools/nnpackage_tool/model2nnpkg/model2nnpkg.sh +++ b/tools/nnpackage_tool/model2nnpkg/model2nnpkg.sh @@ -56,7 +56,7 @@ fi name=${modelfile%.*} extension=${modelfile##*.} -echo -n "Generating nnpackage ... " +echo "Generating nnpackage "$name" in "$outdir"" mkdir -p "$outdir"/"$name"/metadata cat > "$outdir"/"$name"/metadata/MANIFEST <<-EOF { @@ -68,4 +68,3 @@ cat > "$outdir"/"$name"/metadata/MANIFEST <<-EOF } EOF cp "$1" "$outdir"/"$name" -echo "done; created in $outdir/$name." diff --git a/tools/nnpackage_tool/nnpkg_test/nnpkg_test.sh b/tools/nnpackage_tool/nnpkg_test/nnpkg_test.sh index caa5aa4..e4b81a0 100755 --- a/tools/nnpackage_tool/nnpkg_test/nnpkg_test.sh +++ b/tools/nnpackage_tool/nnpkg_test/nnpkg_test.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -eu +set -u command_exists() { command -v "$@" > /dev/null 2>&1 @@ -82,10 +82,22 @@ fi dumped="$outdir/$tcname".out.h5 -LD_LIBRARY_PATH=Product/out/lib $nnpkg_run \ +echo -n "[ Run ] $nnpkg " + +if LD_LIBRARY_PATH=Product/out/lib $nnpkg_run \ --nnpackage "$nnpkg" \ --load "$nnpkg/metadata/tc/input.h5" \ ---dump "$dumped" >& /dev/null +--dump "$dumped" >& /dev/null > "$dumped.log" 2>&1 ; then + echo -e "\tPass" + rm "$dumped.log" +else + echo -e "\tFail" + echo "" + cat "$dumped.log" + echo "" + rm "$dumped.log" + exit 2 +fi # diff @@ -96,13 +108,15 @@ fi expected="$nnpkg/metadata/tc/expected.h5" -if $difftool -d 0.001 -v "$dumped" "$expected" /value >& $dumped.log; then - echo "Pass: $tcname" +echo -n "[Compare] $nnpkg " + +if $difftool -d 0.001 -v "$dumped" "$expected" /value >& "$dumped.log"; then + echo -e "\tPass" rm "$dumped" "$dumped.log" else - echo "Fail: $tcname" + echo -e "\tFail" [ $delete_dumped_on_failure ] && rm "$dumped" cat "$dumped.log" rm "$dumped.log" - exit 2 + exit 3 fi -- 2.7.4