From 90423d0b082869f441f3e0ee54a314c6b7b6abc9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9C=A4=ED=98=84=EC=8B=9D/On-Device=20Lab=28SR=29/Princip?= =?utf8?q?al=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Fri, 8 Nov 2019 14:32:33 +0900 Subject: [PATCH] [tf2tflite-dredd-pbtxt-test] Using rule-lib.sh in dredd-rule-lib (#8860) tf2tflite-dredd-pbtxt-test now uses rule-lib.sh in dredd-rule-lib. Signed-off-by: Hyun Sik Yoon --- compiler/tf2tflite-dredd-pbtxt-test/CMakeLists.txt | 7 +- compiler/tf2tflite-dredd-pbtxt-test/requires.cmake | 1 + compiler/tf2tflite-dredd-pbtxt-test/rule-lib.sh | 120 --------------------- 3 files changed, 7 insertions(+), 121 deletions(-) delete mode 100755 compiler/tf2tflite-dredd-pbtxt-test/rule-lib.sh diff --git a/compiler/tf2tflite-dredd-pbtxt-test/CMakeLists.txt b/compiler/tf2tflite-dredd-pbtxt-test/CMakeLists.txt index e30afb0..d4fbc14 100644 --- a/compiler/tf2tflite-dredd-pbtxt-test/CMakeLists.txt +++ b/compiler/tf2tflite-dredd-pbtxt-test/CMakeLists.txt @@ -4,6 +4,7 @@ unset(REQUIRED_TARGETS) list(APPEND REQUIRED_TARGETS tfl-inspect) list(APPEND REQUIRED_TARGETS tf2tflite) list(APPEND REQUIRED_TARGETS tfkit) +list(APPEND REQUIRED_TARGETS dredd_rule_lib) TargetRequire_Return(${REQUIRED_TARGETS}) nncc_find_resource(TensorFlowTests) @@ -152,7 +153,11 @@ list(APPEND DEPS "${TARGET_RUNNER}") # # copy rule-lib.sh (a library of shell script functions) # -set(SOURCE_RULE_LIB "${CMAKE_CURRENT_SOURCE_DIR}/rule-lib.sh") + +# getting path for rule-lib.sh in dredd-rule-lib +get_target_property(DREDD_RULE_LIB_DIR dredd_rule_lib BINARY_DIR) + +set(SOURCE_RULE_LIB "${DREDD_RULE_LIB_DIR}/rule-lib.sh") set(TARGET_RULE_LIB "${CMAKE_CURRENT_BINARY_DIR}/rule-lib.sh") add_custom_command( diff --git a/compiler/tf2tflite-dredd-pbtxt-test/requires.cmake b/compiler/tf2tflite-dredd-pbtxt-test/requires.cmake index c077b66..f5a746e 100644 --- a/compiler/tf2tflite-dredd-pbtxt-test/requires.cmake +++ b/compiler/tf2tflite-dredd-pbtxt-test/requires.cmake @@ -1,3 +1,4 @@ require("tfkit") require("tf2tflite") require("tfl-inspect") +require("dredd-rule-lib") diff --git a/compiler/tf2tflite-dredd-pbtxt-test/rule-lib.sh b/compiler/tf2tflite-dredd-pbtxt-test/rule-lib.sh deleted file mode 100755 index 967e2fd..0000000 --- a/compiler/tf2tflite-dredd-pbtxt-test/rule-lib.sh +++ /dev/null @@ -1,120 +0,0 @@ -#!/bin/bash - -ERROR_FLAG="Error" - -# -# Define rule -# -# - Params: rule name (metric), actual value, condition, expected value -# - condition is '=', '!=', '<', '>', '<=', '>='. Refer to "man expr" -# - Return -# - 0 : success -# - 1 : fail (condition check fail) -# - 10 : error while getting actual value -# - 11 : error while running expected value -# - 20 : wrong param count -# - -RULE() -{ - if [ "$#" -ne 4 ];then - echo "** [Error] count of RULE parameter should be 4" - return 20 - fi - - RULE_NAME=$1 - ACTUAL=$2 - COND=$3 - EXPECTED=$4 - - # not to exit when expr result with 0 - set +e - - # check if ACTUAL or EXPECTED has "ERROR" string - expr match "${ACTUAL}" ${ERROR_FLAG} - if [ $? = 0 ]; then - echo "** Error in ACTUAL" - return 10 - fi - - expr match "${EXPECTED}" ${ERROR_FLAG} - if [ $? = 0 ]; then - echo "** Error in EXPECTED" - return 11 - fi - - expr ${ACTUAL} ${COND} ${EXPECTED} - RESULT=$? - - # roll-back - set -e - - # Note: return value of 'expr' - # - 0 : result is true - # - 1 : result is false - # - 2 : error - - if [ ${RESULT} -eq 0 ];then - echo -e "\n** [${RULE_NAME}] \t success \t ([actual: ${ACTUAL}] ${COND} [expected: ${EXPECTED}])\n" - elif [ ${RESULT} -eq 1 ];then - echo -e "\n** [${RULE_NAME}] \t ** fail \t ([actual: ${ACTUAL}] ${COND} [expected: ${EXPECTED}])\n" - else - echo -e "\t** Error in [expr ${ACTUAL} ${COND} ${EXPECTED}]" - fi - - return ${RESULT} -} - -# -# Define each function to get quality value -# - -# Note: These function is called by a sub-shell. -# So return value should be passed through "echo return_value" -# tip: for debugging, surround the code with "set -x" and "set +x" - -file_size() -{ - if [ ! -f ${TFLITE_PATH} ]; then - echo "${ERROR_FLAG} - ${TFLITE_PATH} does not exist" - else - echo `cat ${TFLITE_PATH} | wc -c` - fi -} - -all_op_count() -{ - if [ ! -f ${TFLITE_PATH} ]; then - echo "${ERROR_FLAG} - ${TFLITE_PATH} does not exist" - elif [ ! -f ${TFL_INSPECT_PATH} ]; then - echo "${ERROR_FLAG} - ${TFL_INSPECT_PATH} does not exist" - else - echo `${TFL_INSPECT_PATH} --operators ${TFLITE_PATH} | wc -l` - fi -} - -op_count() -{ - if [ "$#" -ne 1 ];then - echo "${ERROR_FLAG} - Wrong argument number" - elif [ ! -f ${TFLITE_PATH} ]; then - echo "${ERROR_FLAG} - ${TFLITE_PATH} does not exist" - elif [ ! -f ${TFL_INSPECT_PATH} ]; then - echo "${ERROR_FLAG} - ${TFL_INSPECT_PATH} does not exist" - else - echo `${TFL_INSPECT_PATH} --operators ${TFLITE_PATH} | grep -w "$1" | wc -l` - fi -} - -conv2d_weight_not_constant() -{ - if [ ! -f ${TFLITE_PATH} ]; then - echo "${ERROR_FLAG} - ${TFLITE_PATH} does not exist" - elif [ ! -f ${TFL_INSPECT_PATH} ]; then - echo "${ERROR_FLAG} - ${TFL_INSPECT_PATH} does not exist" - else - echo `${TFL_INSPECT_PATH} --conv2d_weight ${TFLITE_PATH} | awk -F, '{ if ($2 != "CONST") print $0}' | wc -l` - fi -} - -# TODO define more qullity test function -- 2.7.4