From a0ce008cf6b64561e3dbe24b9cdea608b7c7c7a4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/On-Device=20Lab=28SR=29/Staff?= =?utf8?q?=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Mon, 1 Jul 2019 13:08:55 +0900 Subject: [PATCH] [tf2tflite] Pass test configurations via .config file (#4017) * [tf2tflite] Pass test configurationss via .config file Now, "testall" script takes test configurations via .config file, which makes it easy to re-invoke tests from command-line. Signed-off-by: Jonghyun Park * Update comment to reflect the actual implementation --- contrib/tf2tflite/CMakeLists.txt | 56 +++++++++++++++++++++++++++++++++------- contrib/tf2tflite/testall | 24 +++++------------ 2 files changed, 53 insertions(+), 27 deletions(-) diff --git a/contrib/tf2tflite/CMakeLists.txt b/contrib/tf2tflite/CMakeLists.txt index 9c86284..215cde4 100644 --- a/contrib/tf2tflite/CMakeLists.txt +++ b/contrib/tf2tflite/CMakeLists.txt @@ -88,21 +88,59 @@ foreach(PREFIX IN ITEMS ${TESTCASES}) list(APPEND TEST_NAMES ${PREFIX}) endforeach(PREFIX) +## +## Copy testall +## +set(TEST_RUNNER "${CMAKE_CURRENT_BINARY_DIR}/testall") +set(TEST_RUNNER_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/testall") + +add_custom_command( + OUTPUT ${TEST_RUNNER} + COMMAND ${CMAKE_COMMAND} -E copy "${TEST_RUNNER_SOURCE}" "${TEST_RUNNER}" + DEPENDS ${TEST_RUNNER_SOURCE} + COMMENT "Generate test runner" +) + +list(APPEND TEST_DEPS "${TEST_RUNNER}") + +### +### Generate test.config +### +set(TEST_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/test.config") + +add_custom_command( + OUTPUT ${TEST_CONFIG} + COMMAND ${CMAKE_COMMAND} -E remove -f ${TEST_CONFIG} + COMMAND ${CMAKE_COMMAND} -E echo 'NNKIT_RUN_PATH=\"$\"' >> ${TEST_CONFIG} + COMMAND ${CMAKE_COMMAND} -E echo 'TF_BACKEND_PATH=\"$\"' >> ${TEST_CONFIG} + COMMAND ${CMAKE_COMMAND} -E echo 'TFLITE_BACKEND_PATH=\"$\"' >> ${TEST_CONFIG} + COMMAND ${CMAKE_COMMAND} -E echo 'TF2TFLITE_PATH=\"$\"' >> ${TEST_CONFIG} + COMMAND ${CMAKE_COMMAND} -E echo 'RANDOMIZE_ACTION_PATH=\"$\"' >> ${TEST_CONFIG} + COMMAND ${CMAKE_COMMAND} -E echo 'HDF5_EXPORT_ACTION_PATH=\"$\"' >> ${TEST_CONFIG} + COMMAND ${CMAKE_COMMAND} -E echo 'HDF5_IMPORT_ACTION_PATH=\"$\"' >> ${TEST_CONFIG} + COMMAND ${CMAKE_COMMAND} -E echo 'I5DIFF_PATH=\"$\"' >> ${TEST_CONFIG} + DEPENDS + nnkit-run + nnkit_tf_backend + nnkit_tflite_backend + tf2tflite + nnkit_randomize_action + nnkit_HDF5_export_action + nnkit_HDF5_import_action + i5diff + COMMENT "Generate test configuration" +) + +list(APPEND TEST_DEPS "${TEST_CONFIG}") + # This "tf2tflite_deps" target enforces CMake to generate all the dependencies during "build" phase add_custom_target(tf2tflite_deps ALL DEPENDS ${TEST_DEPS}) # Run tests add_test( NAME tf2tflite_test - COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/testall" - $ - $ - $ - $ - $ - $ - $ - $ + COMMAND "${TEST_RUNNER}" + "${TEST_CONFIG}" "${CMAKE_CURRENT_BINARY_DIR}" ${TEST_NAMES} ) diff --git a/contrib/tf2tflite/testall b/contrib/tf2tflite/testall index 860f980..94ef9eb 100755 --- a/contrib/tf2tflite/testall +++ b/contrib/tf2tflite/testall @@ -1,18 +1,11 @@ #!/bin/bash -# Need at least 9 arguments -if [[ $# -lt 9 ]]; then +# Need at least 2 arguments +if [[ $# -lt 2 ]]; then echo "USAGE: $0 ..." echo echo "ARGUMENTS:" - echo " [nnkit-run path]" - echo " [TF backend path]" - echo " [TFLITE backend path]" - echo " [TF2TFLITE path]" - echo " [randomize action path]" - echo " [HDF5 export action path]" - echo " [HDF5 import action path]" - echo " [i5diff path]" + echo " [test.config path]" echo " [WORKDIR]" echo " [Prefix1]" echo " [Prefix2]" @@ -20,16 +13,11 @@ if [[ $# -lt 9 ]]; then exit 255 fi -NNKIT_RUN_PATH="$1"; shift -TF_BACKEND_PATH="$1"; shift -TFLITE_BACKEND_PATH="$1"; shift -TF2TFLITE_PATH="$1"; shift -RANDOMIZE_ACTION_PATH="$1"; shift -HDF5_EXPORT_ACTION_PATH="$1"; shift -HDF5_IMPORT_ACTION_PATH="$1"; shift -I5DIFF_PATH="$1"; shift +CONFIG_PATH="$1"; shift WORKDIR="$1"; shift +source "${CONFIG_PATH}" + echo "-- Found nnkit-run: ${NNKIT_RUN_PATH}" echo "-- Found TF backend: ${TF_BACKEND_PATH}" echo "-- Found TFLITE backend: ${TFLITE_BACKEND_PATH}" -- 2.7.4