diff options
Diffstat (limited to 'compiler/one-cmds/tests')
374 files changed, 14714 insertions, 0 deletions
diff --git a/compiler/one-cmds/tests/CMakeLists.txt b/compiler/one-cmds/tests/CMakeLists.txt new file mode 100644 index 000000000..8c006c10b --- /dev/null +++ b/compiler/one-cmds/tests/CMakeLists.txt @@ -0,0 +1,152 @@ +# Install one-cmds test scripts + +# Gather test scripts +file(GLOB TESTITEMS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "./*.test") +file(GLOB CONFIGITEMS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "./*.cfg") +file(GLOB QCONFIGITEMS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "./*.qconf.json") +file(GLOB PYSCRIPTS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "./*.py") +file(GLOB WORKFLOWITEMS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "./*.workflow.json") + +# Create a script to run the tests at installation folder +set(DRIVER_SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/runtestall.sh") + +file(WRITE "${DRIVER_SCRIPT}" "#!/bin/bash\n\n") +file(APPEND "${DRIVER_SCRIPT}" "SCRIPT_PATH=$(cd $(dirname $\{BASH_SOURCE\[0\]\}) && pwd)\n") +file(APPEND "${DRIVER_SCRIPT}" "pushd $SCRIPT_PATH > /dev/null\n") +file(APPEND "${DRIVER_SCRIPT}" "rm -rf runtestall.log\n") +file(APPEND "${DRIVER_SCRIPT}" "export PATH=$SCRIPT_PATH/../bin:$PATH\n") +file(APPEND "${DRIVER_SCRIPT}" "if [[ $# -ge 1 ]]; then\n") +file(APPEND "${DRIVER_SCRIPT}" " USER_PATH=$1\n") +file(APPEND "${DRIVER_SCRIPT}" " export PATH=$USER_PATH:$PATH\n") +file(APPEND "${DRIVER_SCRIPT}" "fi\n") +file(APPEND "${DRIVER_SCRIPT}" "\n") +file(APPEND "${DRIVER_SCRIPT}" "# refer https://github.com/Samsung/ONE/issues/6286\n") +file(APPEND "${DRIVER_SCRIPT}" "set -o pipefail\n\n") +file(APPEND "${DRIVER_SCRIPT}" "fail_count=0\n") +file(APPEND "${DRIVER_SCRIPT}" "trap \"(( fail_count++ ))\" ERR\n\n") + +foreach(TESTITEM IN ITEMS ${TESTITEMS}) + get_filename_component(ITEM_PREFIX ${TESTITEM} NAME_WE) + + set(TESTITEM_SCRIPT_FILE "${ITEM_PREFIX}.test") + set(TESTITEM_SCRIPT_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/${TESTITEM_SCRIPT_FILE}") + + file(APPEND "${DRIVER_SCRIPT}" "/bin/bash ${TESTITEM_SCRIPT_FILE} | tee -a runtestall.log\n") + + install(FILES ${TESTITEM} DESTINATION test) + +endforeach(TESTITEM) + +foreach(CONFIGITEM IN ITEMS ${CONFIGITEMS}) + get_filename_component(ITEM_PREFIX ${CONFIGITEM} NAME_WE) + install(FILES ${CONFIGITEM} DESTINATION test) +endforeach(CONFIGITEM) + +foreach(QCONFIGITEM IN ITEMS ${QCONFIGITEMS}) + get_filename_component(ITEM_PREFIX ${QCONFIGITEM} NAME_WE) + install(FILES ${QCONFIGITEM} DESTINATION test) +endforeach(QCONFIGITEM) + +foreach(PYSCRIPT IN ITEMS ${PYSCRIPTS}) + get_filename_component(ITEM_PREFIX ${PYSCRIPT} NAME_WE) + install(FILES ${PYSCRIPT} DESTINATION test) +endforeach(PYSCRIPT) + +foreach(WORKFLOWITEM IN ITEMS ${WORKFLOWITEMS}) + get_filename_component(ITEM_PREFIX ${WORKFLOWITEM} NAME_WE) + install(FILES ${WORKFLOWITEM} DESTINATION test) +endforeach(WORKFLOWITEM) + +file(APPEND "${DRIVER_SCRIPT}" "popd > /dev/null\n\n") + +file(APPEND "${DRIVER_SCRIPT}" +"if [[ $fail_count != 0 ]]; then + echo \"$fail_count TESTS FAILED\" + exit 255 +else + echo \"ALL TESTS PASSED!\" +fi\n +") + +set(PREPARE_TEST_MATERIALS_SH "${CMAKE_CURRENT_SOURCE_DIR}/prepare_test_materials.sh") +set(PREPROCESS_IMAGES_PY "${CMAKE_CURRENT_SOURCE_DIR}/preprocess_images.py") +set(ONNX_LEGALIZE_RUN_COMPARE "${CMAKE_CURRENT_SOURCE_DIR}/onnx_legalize_run_compare.py") +set(PRINT_ONNX_MODEL "${CMAKE_CURRENT_SOURCE_DIR}/print_onnx_model.py") + +install(FILES ${DRIVER_SCRIPT} + PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE + DESTINATION test) + +install(FILES ${PREPARE_TEST_MATERIALS_SH} + PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE + DESTINATION test) + +install(FILES ${PREPROCESS_IMAGES_PY} + PERMISSIONS OWNER_WRITE OWNER_READ + GROUP_READ + WORLD_READ + DESTINATION test) + +install(FILES ${ONNX_LEGALIZE_RUN_COMPARE} + PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE + DESTINATION test) + +install(FILES ${PRINT_ONNX_MODEL} + PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE + DESTINATION test) + +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/README.txt + DESTINATION test) + +add_subdirectory(onnx-operations) + +if(ENABLE_ONE_IMPORT_PYTORCH) + add_subdirectory(pytorch-operations) +endif(ENABLE_ONE_IMPORT_PYTORCH) + +# Generate group option list for tests +get_filename_component(ONE_CMDS_DIR ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY) +set(ONE_PYTHON_DIR "onelib") +set(CONSTANT_EXPORTING_SCRIPT "${ONE_CMDS_DIR}/${ONE_PYTHON_DIR}/export_constant.py") +set(O1_OPTION "O1") +set(O1_TXT_FILE "${O1_OPTION}.list") +set(O1_TXT_FILE_BIN "${CMAKE_CURRENT_BINARY_DIR}/${O1_TXT_FILE}") +set(NON_O1_TXT_FILE "non-${O1_OPTION}.list") +set(NON_O1_TXT_FILE_BIN "${CMAKE_CURRENT_BINARY_DIR}/${NON_O1_TXT_FILE}") + +add_custom_command(OUTPUT ${O1_TXT_FILE_BIN} + COMMAND ${PYTHON_EXECUTABLE} ${CONSTANT_EXPORTING_SCRIPT} --constant ${O1_OPTION} + --format txt --output_path ${O1_TXT_FILE_BIN} + DEPENDS ${CONSTANT_EXPORTING_SCRIPT} + COMMENT "Generate ${O1_TXT_FILE}" +) + +add_custom_command(OUTPUT ${NON_O1_TXT_FILE_BIN} + COMMAND ${PYTHON_EXECUTABLE} ${CONSTANT_EXPORTING_SCRIPT} --constant ${O1_OPTION} + --format txt --output_path ${NON_O1_TXT_FILE_BIN} + --exclusive + DEPENDS ${CONSTANT_EXPORTING_SCRIPT} + COMMENT "Generate ${NON_O1_TXT_FILE}" +) + +add_custom_target("O1_txt_target" ALL DEPENDS ${O1_TXT_FILE_BIN} ${NON_O1_TXT_FILE_BIN}) + +install(FILES ${O1_TXT_FILE_BIN} + PERMISSIONS OWNER_WRITE OWNER_READ + GROUP_READ + WORLD_READ + DESTINATION test) + +install(FILES ${NON_O1_TXT_FILE_BIN} + PERMISSIONS OWNER_WRITE OWNER_READ + GROUP_READ + WORLD_READ + DESTINATION test) diff --git a/compiler/one-cmds/tests/OONE-BUILD_014.cfg b/compiler/one-cmds/tests/OONE-BUILD_014.cfg new file mode 100644 index 000000000..a39aae071 --- /dev/null +++ b/compiler/one-cmds/tests/OONE-BUILD_014.cfg @@ -0,0 +1,2 @@ +[one-optimize] +make_batchnorm_gamma_positive=True diff --git a/compiler/one-cmds/tests/OONECC_024.cfg b/compiler/one-cmds/tests/OONECC_024.cfg new file mode 100644 index 000000000..a39aae071 --- /dev/null +++ b/compiler/one-cmds/tests/OONECC_024.cfg @@ -0,0 +1,2 @@ +[one-optimize] +make_batchnorm_gamma_positive=True diff --git a/compiler/one-cmds/tests/README.txt b/compiler/one-cmds/tests/README.txt new file mode 100644 index 000000000..0d4d0ecbe --- /dev/null +++ b/compiler/one-cmds/tests/README.txt @@ -0,0 +1,27 @@ +one-cmds testing +================ + +Run 'runtestall.sh' program to test ONE command line programs, all at once. + +Steps: +1) run 'one-prepare-venv' in bin folder to prepare python virtual-env with TensorFlow + - you need to run this only once + - read 'doc/how-to-prepare-virtualenv.txt' for more information +---------------------------------------------- +bin/one-prepare-venv +---------------------------------------------- + +2) run 'test/prepare_test_materials.sh' to download test material models + - you need to run this only once + - you need internet connection to download files + - you may need to install 'wget' and 'unzip' packages +---------------------------------------------- +test/prepare_test_materials.sh +---------------------------------------------- + +3) run 'test/runtestall.sh' to run the test +---------------------------------------------- +test/runtestall.sh +---------------------------------------------- + +End. diff --git a/compiler/one-cmds/tests/one-build_001.cfg b/compiler/one-cmds/tests/one-build_001.cfg new file mode 100644 index 000000000..b022ba74b --- /dev/null +++ b/compiler/one-cmds/tests/one-build_001.cfg @@ -0,0 +1,20 @@ +[one-build] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=True +one-quantize=False +one-pack=False +one-codegen=False + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v2 + +[one-optimize] +input_path=inception_v3.circle +output_path=inception_v3.opt.circle diff --git a/compiler/one-cmds/tests/one-build_001.test b/compiler/one-cmds/tests/one-build_001.test new file mode 100644 index 000000000..e6c6ee77b --- /dev/null +++ b/compiler/one-cmds/tests/one-build_001.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import-tf -> one-optimize + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="one-build_001.cfg" +outputfile="inception_v3.opt.circle" + +rm -f ${filename}.log +rm -f ${outputfile} + +# run test +one-build -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-build_002.cfg b/compiler/one-cmds/tests/one-build_002.cfg new file mode 100644 index 000000000..bbf09159b --- /dev/null +++ b/compiler/one-cmds/tests/one-build_002.cfg @@ -0,0 +1,24 @@ +[one-build] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=True +one-quantize=False +one-pack=True +one-codegen=False + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v2 + +[one-optimize] +input_path=inception_v3.circle +output_path=inception_v3.opt.circle + +[one-pack] +input_path=inception_v3.opt.circle +output_path=inception_v3_pkg diff --git a/compiler/one-cmds/tests/one-build_002.test b/compiler/one-cmds/tests/one-build_002.test new file mode 100644 index 000000000..c29d422d6 --- /dev/null +++ b/compiler/one-cmds/tests/one-build_002.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import-tf -> one-optimize -> one-pack + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="one-build_002.cfg" +outputfile="inception_v3_pkg" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test +one-build -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-build_003.cfg b/compiler/one-cmds/tests/one-build_003.cfg new file mode 100644 index 000000000..6aec3cab6 --- /dev/null +++ b/compiler/one-cmds/tests/one-build_003.cfg @@ -0,0 +1,21 @@ +[one-build] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=False +one-quantize=True +one-pack=False +one-codegen=False + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v1 + +[one-quantize] +input_path=inception_v3.circle +output_path=inception_v3.quantized.circle +input_data=inception_v3_test_data.h5 diff --git a/compiler/one-cmds/tests/one-build_003.test b/compiler/one-cmds/tests/one-build_003.test new file mode 100644 index 000000000..6337b5095 --- /dev/null +++ b/compiler/one-cmds/tests/one-build_003.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import-tf -> one-quantize + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="one-build_003.cfg" +outputfile="inception_v3.quantized.circle" + +rm -f ${filename}.log +rm -f ${outputfile} + +# run test +one-build -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-build_004.cfg b/compiler/one-cmds/tests/one-build_004.cfg new file mode 100644 index 000000000..c23405bea --- /dev/null +++ b/compiler/one-cmds/tests/one-build_004.cfg @@ -0,0 +1,20 @@ +[one-build] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=False +one-quantize=False +one-pack=False +one-codegen=True + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v1 + +[one-codegen] +backend=dummy +command=-o sample.tvn inception_v3.circle diff --git a/compiler/one-cmds/tests/one-build_004.test b/compiler/one-cmds/tests/one-build_004.test new file mode 100644 index 000000000..5406355e2 --- /dev/null +++ b/compiler/one-cmds/tests/one-build_004.test @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import-tf -> one-codegen + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-compile + exit 255 +} + +trap trap_err_onexit ERR + +configfile="one-build_004.cfg" +outputfile="sample.tvn" + +rm -f ${filename}.log +rm -f ${outputfile} + +# copy dummy-compile to bin folder +cp dummy-compile ../bin/dummy-compile + +# run test +one-build -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +rm -rf ../bin/dummy-compile + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-build_005.cfg b/compiler/one-cmds/tests/one-build_005.cfg new file mode 100644 index 000000000..841b37234 --- /dev/null +++ b/compiler/one-cmds/tests/one-build_005.cfg @@ -0,0 +1,20 @@ +[one-build] +one-import-tf=False +one-import-tflite=True +one-import-bcq=False +one-optimize=True +one-quantize=False +one-pack=False +one-codegen=True + +[one-import-tflite] +input_path=inception_v3.tflite +output_path=inception_v3.circle + +[one-optimize] +input_path=inception_v3.circle +output_path=inception_v3.opt.circle + +[one-codegen] +backend=dummy +command=-o sample.tvn inception_v3.opt.circle diff --git a/compiler/one-cmds/tests/one-build_005.test b/compiler/one-cmds/tests/one-build_005.test new file mode 100644 index 000000000..f003be536 --- /dev/null +++ b/compiler/one-cmds/tests/one-build_005.test @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import-tflite -> one-optimize -> one-codgen + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-compile + exit 255 +} + +trap trap_err_onexit ERR + +configfile="one-build_005.cfg" +outputfile="sample.tvn" + +rm -f ${filename}.log +rm -f ${outputfile} + +# copy dummy-compile to bin folder +cp dummy-compile ../bin/dummy-compile + +# run test +one-build -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +rm -rf ../bin/dummy-compile + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-build_006.cfg b/compiler/one-cmds/tests/one-build_006.cfg new file mode 100644 index 000000000..e754bdeca --- /dev/null +++ b/compiler/one-cmds/tests/one-build_006.cfg @@ -0,0 +1,29 @@ +[one-build] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=True +one-quantize=True +one-pack=False +one-codegen=True + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v1 + +[one-optimize] +input_path=inception_v3.circle +output_path=inception_v3.opt.circle + +[one-quantize] +input_path=inception_v3.opt.circle +output_path=inception_v3.quantized.circle +input_data=inception_v3_test_data.h5 + +[one-codegen] +backend=dummy +command=-o sample.tvn inception_v3.quantized.circle diff --git a/compiler/one-cmds/tests/one-build_006.test b/compiler/one-cmds/tests/one-build_006.test new file mode 100644 index 000000000..07770151a --- /dev/null +++ b/compiler/one-cmds/tests/one-build_006.test @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import-tf -> one-optimize -> one-quantize -> one-codegen + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-compile + exit 255 +} + +trap trap_err_onexit ERR + +configfile="one-build_006.cfg" +outputfile="sample.tvn" + +rm -f ${filename}.log +rm -f ${outputfile} + +# copy dummy-compile to bin folder +cp dummy-compile ../bin/dummy-compile + +# run test +one-build -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +rm -rf ../bin/dummy-compile + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-build_007.cfg b/compiler/one-cmds/tests/one-build_007.cfg new file mode 100644 index 000000000..52610750d --- /dev/null +++ b/compiler/one-cmds/tests/one-build_007.cfg @@ -0,0 +1,29 @@ +[one-build] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=False +one-quantize=True +one-pack=True +one-codegen=False + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v1 + +[one-optimize] +input_path=inception_v3.circle +output_path=inception_v3.opt.circle + +[one-quantize] +input_path=inception_v3.opt.circle +output_path=inception_v3.quantized.circle +input_data=inception_v3_test_data.h5 + +[one-pack] +input_path=inception_v3.quantized.circle +output_path=inception_v3_pkg diff --git a/compiler/one-cmds/tests/one-build_007.test b/compiler/one-cmds/tests/one-build_007.test new file mode 100644 index 000000000..4fd6a2a67 --- /dev/null +++ b/compiler/one-cmds/tests/one-build_007.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import-tf -> one-optimize -> one-quantize -> one-pack + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="one-build_007.cfg" +outputfile="inception_v3_pkg" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test +one-build -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-build_008.cfg b/compiler/one-cmds/tests/one-build_008.cfg new file mode 100644 index 000000000..8c777f64f --- /dev/null +++ b/compiler/one-cmds/tests/one-build_008.cfg @@ -0,0 +1,22 @@ +[one-build] +one-import-tf=False +one-import-tflite=False +one-import-bcq=False +one-import-onnx=True +one-optimize=True +one-quantize=False +one-pack=False +one-codegen=True + +[one-import-onnx] +input_path=test_onnx_model.onnx +output_path=test_onnx_model.circle + +[one-optimize] +input_path=test_onnx_model.circle +output_path=test_onnx_model.opt.circle +remove_redundant_transpose=True + +[one-codegen] +backend=dummy +command=-o test_onnx_model.bin test_onnx_model.opt.circle diff --git a/compiler/one-cmds/tests/one-build_008.test b/compiler/one-cmds/tests/one-build_008.test new file mode 100644 index 000000000..d19b95fc7 --- /dev/null +++ b/compiler/one-cmds/tests/one-build_008.test @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import-tf -> one-optimize -> one-quantize -> one-codegen + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-compile + exit 255 +} + +trap trap_err_onexit ERR + +configfile="one-build_008.cfg" +outputfile="test_onnx_model.bin" + +rm -f ${filename}.log +rm -f ${outputfile} + +# copy dummy-compile to bin folder +cp dummy-compile ../bin/dummy-compile + +# run test +one-build -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +rm -rf ../bin/dummy-compile + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-build_009.cfg b/compiler/one-cmds/tests/one-build_009.cfg new file mode 100644 index 000000000..b5a35dd97 --- /dev/null +++ b/compiler/one-cmds/tests/one-build_009.cfg @@ -0,0 +1,23 @@ +[one-build] +one-import-tf=False +one-import-tflite=False +one-import-bcq=False +one-import-onnx=True +one-optimize=True +one-quantize=False +one-pack=False +one-codegen=True + +[one-import-onnx] +input_path=onnx_conv2d_conv2d.onnx +output_path=onnx_conv2d_conv2d.circle + +[one-optimize] +input_path=onnx_conv2d_conv2d.circle +output_path=onnx_conv2d_conv2d.opt.circle +remove_redundant_transpose=True +convert_nchw_to_nhwc=True + +[one-codegen] +backend=dummy +command=-o onnx_conv2d_conv2d.bin onnx_conv2d_conv2d.opt.circle diff --git a/compiler/one-cmds/tests/one-build_009.test b/compiler/one-cmds/tests/one-build_009.test new file mode 100644 index 000000000..ae5351957 --- /dev/null +++ b/compiler/one-cmds/tests/one-build_009.test @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import-onnx -> one-optimize -> one-codegen + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-compile + exit 255 +} + +trap trap_err_onexit ERR + +configfile="one-build_009.cfg" +outputfile="onnx_conv2d_conv2d.bin" + +rm -f ${filename}.log +rm -f ${outputfile} + +# copy dummy-compile to bin folder +cp dummy-compile ../bin/dummy-compile + +# run test +one-build -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +rm -rf ../bin/dummy-compile + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-build_010.cfg b/compiler/one-cmds/tests/one-build_010.cfg new file mode 100644 index 000000000..3be9ed3f9 --- /dev/null +++ b/compiler/one-cmds/tests/one-build_010.cfg @@ -0,0 +1,17 @@ +[one-build] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=False +one-quantize=False +one-pack=False +one-codegen=False + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.alt.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v1 +save_intermediate=True diff --git a/compiler/one-cmds/tests/one-build_010.test b/compiler/one-cmds/tests/one-build_010.test new file mode 100644 index 000000000..b76e81cf9 --- /dev/null +++ b/compiler/one-cmds/tests/one-build_010.test @@ -0,0 +1,48 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import-tf: intermediate file should exist + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="one-build_010.cfg" +outputfile="inception_v3.alt.circle" +intermfile="inception_v3.alt.tflite" + +rm -f ${filename}.log +rm -f ${outputfile} +rm -f ${intermfile} + +# run test +one-build -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi +if [[ ! -s "${intermfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-build_011.cfg b/compiler/one-cmds/tests/one-build_011.cfg new file mode 100644 index 000000000..15d2c103c --- /dev/null +++ b/compiler/one-cmds/tests/one-build_011.cfg @@ -0,0 +1,14 @@ +[one-build] +one-import-tf=False +one-import-tflite=False +one-import-bcq=False +one-import-onnx=True +one-optimize=False +one-quantize=False +one-pack=False +one-codegen=False + +[one-import-onnx] +input_path=test_onnx_model.onnx +output_path=test_onnx_model.circle +save_intermediate=True diff --git a/compiler/one-cmds/tests/one-build_011.test b/compiler/one-cmds/tests/one-build_011.test new file mode 100644 index 000000000..efd714325 --- /dev/null +++ b/compiler/one-cmds/tests/one-build_011.test @@ -0,0 +1,48 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import-onnx + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="one-build_011.cfg" +outputfile="test_onnx_model.circle" +intermfile="test_onnx_model.tflite" + +rm -f ${filename}.log +rm -f ${outputfile} +rm -f ${intermfile} + +# run test +one-build -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi +if [[ ! -s "${intermfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-build_012.cfg b/compiler/one-cmds/tests/one-build_012.cfg new file mode 100644 index 000000000..74b0a0ca0 --- /dev/null +++ b/compiler/one-cmds/tests/one-build_012.cfg @@ -0,0 +1,22 @@ +[one-build] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=False +one-quantize=True +one-pack=False +one-codegen=False + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v1 + +[one-quantize] +input_path=inception_v3.circle +output_path=inception_v3.list.quantized.circle +input_data=datalist.txt +input_data_format=list diff --git a/compiler/one-cmds/tests/one-build_012.test b/compiler/one-cmds/tests/one-build_012.test new file mode 100644 index 000000000..5f123cd57 --- /dev/null +++ b/compiler/one-cmds/tests/one-build_012.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import-tf -> one-quantize + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="one-build_012.cfg" +outputfile="inception_v3.list.quantized.circle" + +rm -f ${filename}.log +rm -f ${outputfile} + +# run test +one-build -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-build_013.cfg b/compiler/one-cmds/tests/one-build_013.cfg new file mode 100644 index 000000000..8e9e40e66 --- /dev/null +++ b/compiler/one-cmds/tests/one-build_013.cfg @@ -0,0 +1,22 @@ +[one-build] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=False +one-quantize=True +one-pack=False +one-codegen=False + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v1 + +[one-quantize] +input_path=inception_v3.circle +output_path=inception_v3.dir.quantized.circle +input_data=raw_files +input_data_format=directory diff --git a/compiler/one-cmds/tests/one-build_013.test b/compiler/one-cmds/tests/one-build_013.test new file mode 100644 index 000000000..9a71f02e5 --- /dev/null +++ b/compiler/one-cmds/tests/one-build_013.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import-tf -> one-quantize + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="one-build_013.cfg" +outputfile="inception_v3.dir.quantized.circle" + +rm -f ${filename}.log +rm -f ${outputfile} + +# run test +one-build -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-build_014.cfg b/compiler/one-cmds/tests/one-build_014.cfg new file mode 100644 index 000000000..f09145ec3 --- /dev/null +++ b/compiler/one-cmds/tests/one-build_014.cfg @@ -0,0 +1,22 @@ +[one-build] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-import-onnx=False +one-optimize=True +one-quantize=False +one-pack=False +one-codegen=False + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v1 + +[one-optimize] +input_path=inception_v3.circle +output_path=inception_v3.opt.circle +make_batchnorm_gamma_positive=False diff --git a/compiler/one-cmds/tests/one-build_014.test b/compiler/one-cmds/tests/one-build_014.test new file mode 100644 index 000000000..10e6cc65b --- /dev/null +++ b/compiler/one-cmds/tests/one-build_014.test @@ -0,0 +1,78 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Use `OONE-BUILD_014` optimization option + +: ' +This test assumes below directories. + +[one hierarchy] + one + ├── backends + ├── bin + ├── doc + ├── include + ├── lib + ├── optimization + └── test # pwd +' + +OPT_ALREADY_EXIST=true + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +clean_envir() +{ + rm -rf ../optimization/OONE-BUILD_014.cfg + if [ "$OPT_ALREADY_EXIST" = false ]; then + rm -rf ../optimization + fi +} + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + clean_envir + exit 255 +} + +trap trap_err_onexit ERR + +configfile="one-build_014.cfg" +outputfile="inception_v3.opt.circle" + +rm -f ${filename}.log +rm -f ${outputfile} + +if [ ! -d "../optimization" ]; then + mkdir -p ../optimization + OPT_ALREADY_EXIST=false +fi + +cp OONE-BUILD_014.cfg ../optimization + +# run test +LUCI_LOG=5 one-build -C ${configfile} -OONE-BUILD_014 > ${filename}.log 2>&1 + +clean_envir + +if ! grep -q "MakeBatchNormGammaPositivePass" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 +fi + +trap_err_onexit diff --git a/compiler/one-cmds/tests/one-build_neg_001.test b/compiler/one-cmds/tests/one-build_neg_001.test new file mode 100644 index 000000000..2ea26d23f --- /dev/null +++ b/compiler/one-cmds/tests/one-build_neg_001.test @@ -0,0 +1,41 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with missing configuration file + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Not found given configuration file" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="one-build_neg_001.cfg" + +# run test +one-build -C ${configfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-build_neg_002.cfg b/compiler/one-cmds/tests/one-build_neg_002.cfg new file mode 100644 index 000000000..99db96651 --- /dev/null +++ b/compiler/one-cmds/tests/one-build_neg_002.cfg @@ -0,0 +1,20 @@ +[one-build] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=True +one-quantize=False +one-pack=True +one-codegen=False + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v2 + +[one-optimize] +input_path=inception_v3.circle +output_path=inception_v3.opt.circle diff --git a/compiler/one-cmds/tests/one-build_neg_002.test b/compiler/one-cmds/tests/one-build_neg_002.test new file mode 100644 index 000000000..dece9c0bc --- /dev/null +++ b/compiler/one-cmds/tests/one-build_neg_002.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with missing one-pack section in configuration file + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "configuration file must have 'one-pack' section" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="one-build_neg_002.cfg" + +rm -f ${filename}.log + +# run test +one-build -C ${configfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-build_neg_003.cfg b/compiler/one-cmds/tests/one-build_neg_003.cfg new file mode 100644 index 000000000..fa027cb95 --- /dev/null +++ b/compiler/one-cmds/tests/one-build_neg_003.cfg @@ -0,0 +1,15 @@ +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v2 + +[one-optimize] +input_path=inception_v3.circle +output_path=inception_v3.opt.circle + +[one-pack] +input_path=inception_v3.opt.circle +output_path=inception_v3_pkg diff --git a/compiler/one-cmds/tests/one-build_neg_003.test b/compiler/one-cmds/tests/one-build_neg_003.test new file mode 100644 index 000000000..c793d13e0 --- /dev/null +++ b/compiler/one-cmds/tests/one-build_neg_003.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with missing one-build section in configuration file + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "\[one-build\] section is required in configuraion file" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="one-build_neg_003.cfg" + +rm -f ${filename}.log + +# run test +one-build -C ${configfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-build_neg_004.cfg b/compiler/one-cmds/tests/one-build_neg_004.cfg new file mode 100644 index 000000000..571077b42 --- /dev/null +++ b/compiler/one-cmds/tests/one-build_neg_004.cfg @@ -0,0 +1,24 @@ +[one-build] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=True +one-quantize=False +one-pack=False +one-codegen=False + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v2 + +[one-optimize] +input_path=inception_v3.circle +output_path=inception_v3.opt.circle + +[one-optimize] +input_path=inception_v4.circle +output_path=inception_v4.opt.circle diff --git a/compiler/one-cmds/tests/one-build_neg_004.test b/compiler/one-cmds/tests/one-build_neg_004.test new file mode 100644 index 000000000..b0d4e616d --- /dev/null +++ b/compiler/one-cmds/tests/one-build_neg_004.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with duplicate section + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "section 'one-optimize' already exists" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="one-build_neg_004.cfg" + +rm -f ${filename}.log + +# run test +one-build -C ${configfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-build_neg_005.cfg b/compiler/one-cmds/tests/one-build_neg_005.cfg new file mode 100644 index 000000000..ad9efbca1 --- /dev/null +++ b/compiler/one-cmds/tests/one-build_neg_005.cfg @@ -0,0 +1,16 @@ +[one-build] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=False +one-quantize=False +one-pack=False +one-codegen=False + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.alt.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v2 diff --git a/compiler/one-cmds/tests/one-build_neg_005.test b/compiler/one-cmds/tests/one-build_neg_005.test new file mode 100644 index 000000000..9b2511103 --- /dev/null +++ b/compiler/one-cmds/tests/one-build_neg_005.test @@ -0,0 +1,50 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative one-import-tf intermediate file should not exist + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="one-build_neg_005.cfg" +outputfile="inception_v3.alt.circle" +intermfile="inception_v3.alt.tflite" + +rm -rf ${outputfile} +rm -rf ${intermfile} +rm -f ${filename}.log + +# run test +one-build -C ${configfile} > ${filename}.log 2>&1 + +# output should exist +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi +# intermediate file should not exist +if [[ -f "${intermfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-build_neg_006.cfg b/compiler/one-cmds/tests/one-build_neg_006.cfg new file mode 100644 index 000000000..abe4c7d77 --- /dev/null +++ b/compiler/one-cmds/tests/one-build_neg_006.cfg @@ -0,0 +1,13 @@ +[one-build] +one-import-tf=False +one-import-tflite=False +one-import-bcq=False +one-import-onnx=True +one-optimize=False +one-quantize=False +one-pack=False +one-codegen=False + +[one-import-onnx] +input_path=test_onnx_model.onnx +output_path=test_onnx_model.circle diff --git a/compiler/one-cmds/tests/one-build_neg_006.test b/compiler/one-cmds/tests/one-build_neg_006.test new file mode 100644 index 000000000..d228f8f1f --- /dev/null +++ b/compiler/one-cmds/tests/one-build_neg_006.test @@ -0,0 +1,50 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative one-import-tf intermediate file should not exist + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="one-build_neg_006.cfg" +outputfile="test_onnx_model.circle" +intermfile="test_onnx_model.tflite" + +rm -rf ${outputfile} +rm -rf ${intermfile} +rm -f ${filename}.log + +# run test +one-build -C ${configfile} > ${filename}.log 2>&1 + +# output should exist +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi +# intermediate file should not exist +if [[ -f "${intermfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-build_neg_007.test b/compiler/one-cmds/tests/one-build_neg_007.test new file mode 100644 index 000000000..59a5d25c1 --- /dev/null +++ b/compiler/one-cmds/tests/one-build_neg_007.test @@ -0,0 +1,71 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Valid optimization option but invalid configuration file path + +: ' +This test assumes below directories. + +[one hierarchy] + one + ├── backends + ├── bin + ├── doc + ├── include + ├── lib + ├── optimization + └── test # pwd +' + +OPT_ALREADY_EXIST=true + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + rm -rf ../optimization/OONE_BUILD_NEG_007.cfg + if [ "$OPT_ALREADY_EXIST" = false ]; then + rm -rf ../optimization + fi + if grep -q "Not found given configuration file" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +if [ ! -d "../optimization" ]; then + mkdir -p ../optimization + OPT_ALREADY_EXIST=false +fi + + +touch ../optimization/OONE_BUILD_NEG_007.cfg + +configfile=".." + +rm -f ${filename}.log + +# run test +one-build -C ${configfile} -OONE_BUILD_NEG_007 > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-build_neg_008.test b/compiler/one-cmds/tests/one-build_neg_008.test new file mode 100644 index 000000000..2b41222e9 --- /dev/null +++ b/compiler/one-cmds/tests/one-build_neg_008.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Invalid optimization option + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Invalid optimization option" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile=".." + +rm -f ${filename}.log + +# run test +one-build -C ${configfile} -OONE_BUILD_NEG_008 > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-build_neg_009.test b/compiler/one-cmds/tests/one-build_neg_009.test new file mode 100644 index 000000000..5e3698d23 --- /dev/null +++ b/compiler/one-cmds/tests/one-build_neg_009.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Have space in the optimization name + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Not allowed to have space in the optimization name" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile=".." + +rm -f ${filename}.log + +# run test +one-build -C ${configfile} "-O SPACE OPTION" > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-codegen_001.test b/compiler/one-cmds/tests/one-codegen_001.test new file mode 100644 index 000000000..dbc4ad7f7 --- /dev/null +++ b/compiler/one-cmds/tests/one-codegen_001.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +rm -f ${filename}.log + +# copy help-compile to bin folder +cp help-compile ../bin/help-compile + +# run test +one-codegen -b help -- -h > ${filename}.log 2>&1 + +rm -rf ../bin/help-compile + +if grep -q "HELP MESSAGE!!" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 +fi + +trap_err_onexit diff --git a/compiler/one-cmds/tests/one-codegen_002.test b/compiler/one-cmds/tests/one-codegen_002.test new file mode 100644 index 000000000..95e7b7b68 --- /dev/null +++ b/compiler/one-cmds/tests/one-codegen_002.test @@ -0,0 +1,48 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# run one-codegen with dummy-compile driver + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-compile + exit 255 +} + +trap trap_err_onexit ERR + +outputfile="sample.tvn" + +rm -rf ${outputfile} +rm -f ${filename}.log + +# copy dummy-compile to bin folder +cp dummy-compile ../bin/dummy-compile + +# run test +one-codegen -b dummy -o ${outputfile} "dummy.circle" > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +rm -rf ../bin/dummy-compile + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-codegen_003.test b/compiler/one-cmds/tests/one-codegen_003.test new file mode 100644 index 000000000..f283ec38b --- /dev/null +++ b/compiler/one-cmds/tests/one-codegen_003.test @@ -0,0 +1,48 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# run one-codegen with dummy-compile driver + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-compile + exit 255 +} + +trap trap_err_onexit ERR + +outputfile="sample.tvn" + +rm -rf ${outputfile} +rm -f ${filename}.log + +# copy dummy-compile to bin folder +cp dummy-compile ../bin/dummy-compile + +# run test +one-codegen -b dummy -- -o ${outputfile} "dummy.circle" > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +rm -rf ../bin/dummy-compile + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-codegen_004.test b/compiler/one-cmds/tests/one-codegen_004.test new file mode 100644 index 000000000..485f591a5 --- /dev/null +++ b/compiler/one-cmds/tests/one-codegen_004.test @@ -0,0 +1,40 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# print one-codegen's help message + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +rm -f ${filename}.log + +# run test +one-codegen -h > ${filename}.log 2>&1 + +if grep -q "command line tool for code generation" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 +fi + +trap_err_onexit diff --git a/compiler/one-cmds/tests/one-codegen_neg_001.test b/compiler/one-cmds/tests/one-codegen_neg_001.test new file mode 100644 index 000000000..137a3f90d --- /dev/null +++ b/compiler/one-cmds/tests/one-codegen_neg_001.test @@ -0,0 +1,41 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with no input + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "error: the following arguments are required: -b/--backend" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +rm -f ${filename}.log + +# run test +one-codegen > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-codegen_neg_002.test b/compiler/one-cmds/tests/one-codegen_neg_002.test new file mode 100644 index 000000000..28dfa920c --- /dev/null +++ b/compiler/one-cmds/tests/one-codegen_neg_002.test @@ -0,0 +1,41 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-codegen ${command} without backend option + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "error: the following arguments are required: -b/--backend" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +rm -f ${filename}.log + +# run test +one-codegen -o test.tvn test.circle > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-codegen_neg_003.test b/compiler/one-cmds/tests/one-codegen_neg_003.test new file mode 100644 index 000000000..0622b6a07 --- /dev/null +++ b/compiler/one-cmds/tests/one-codegen_neg_003.test @@ -0,0 +1,41 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-codegen -- ${command} without backend option + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "error: the following arguments are required: -b/--backend" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +rm -f ${filename}.log + +# run test +one-codegen -- -o test.tvn test.circle > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-codegen_neg_004.cfg b/compiler/one-cmds/tests/one-codegen_neg_004.cfg new file mode 100644 index 000000000..b104fbb27 --- /dev/null +++ b/compiler/one-cmds/tests/one-codegen_neg_004.cfg @@ -0,0 +1,6 @@ +[onecc] +one-codegen=True + +[one-codegen] +backend=dummy +# command=.. diff --git a/compiler/one-cmds/tests/one-codegen_neg_004.test b/compiler/one-cmds/tests/one-codegen_neg_004.test new file mode 100644 index 000000000..c35549bdc --- /dev/null +++ b/compiler/one-cmds/tests/one-codegen_neg_004.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# command key is missing + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "error: 'command' key is missing in the configuration file" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="one-codegen_neg_004.cfg" + +rm -f ${filename}.log + +# run test +one-codegen -b dummy -C ${configfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-codegen_neg_005.test b/compiler/one-cmds/tests/one-codegen_neg_005.test new file mode 100644 index 000000000..4c52dcd89 --- /dev/null +++ b/compiler/one-cmds/tests/one-codegen_neg_005.test @@ -0,0 +1,41 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# commands for the backend is missing + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "error: commands for the backend is missing" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +rm -f ${filename}.log + +# run test +one-codegen -b dummy > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-import-bcq_001.test b/compiler/one-cmds/tests/one-import-bcq_001.test new file mode 100644 index 000000000..a414eed66 --- /dev/null +++ b/compiler/one-cmds/tests/one-import-bcq_001.test @@ -0,0 +1,45 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./bcq.pb" +outputfile="./bcq.circle" + +rm -f ${filename}.log +rm -rf $outputfile + +# run test +one-import-bcq \ +--input_path ${inputfile} \ +--output_path ${outputfile} \ +--input_arrays Placeholder \ +--output_arrays MatMul > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-import-bcq_neg_001.test b/compiler/one-cmds/tests/one-import-bcq_neg_001.test new file mode 100644 index 000000000..cb8fe9ed3 --- /dev/null +++ b/compiler/one-cmds/tests/one-import-bcq_neg_001.test @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid input array + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "ValueError: Invalid tensors" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./bcq.pb" +outputfile="./bcq.circle" + +rm -rf ${outputfile} +rm -f ${filename}.log + +# run test +one-import-bcq \ +--input_path ${inputfile} \ +--output_path ${outputfile} \ +--input_arrays Placeholder_null \ +--output_arrays MatMul > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-import-bcq_neg_002.test b/compiler/one-cmds/tests/one-import-bcq_neg_002.test new file mode 100644 index 000000000..25c772ff9 --- /dev/null +++ b/compiler/one-cmds/tests/one-import-bcq_neg_002.test @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid output array + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "ValueError: Invalid tensors" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./bcq.pb" +outputfile="./bcq.circle" + +rm -rf ${outputfile} +rm -f ${filename}.log + +# run test +one-import-bcq \ +--input_path ${inputfile} \ +--output_path ${outputfile} \ +--input_arrays Placeholder \ +--output_arrays MatMul_null > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-import-bcq_neg_003.test b/compiler/one-cmds/tests/one-import-bcq_neg_003.test new file mode 100644 index 000000000..20ef67a6d --- /dev/null +++ b/compiler/one-cmds/tests/one-import-bcq_neg_003.test @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid input path + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "No such file or directory" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./bcq_null.pb" +outputfile="./bcq.circle" + +rm -rf ${outputfile} +rm -f ${filename}.log + +# run test +one-import-bcq \ +--input_path ${inputfile} \ +--output_path ${outputfile} \ +--input_arrays Placeholder \ +--output_arrays MatMul > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-import-bcq_neg_004.test b/compiler/one-cmds/tests/one-import-bcq_neg_004.test new file mode 100644 index 000000000..44a8ae19b --- /dev/null +++ b/compiler/one-cmds/tests/one-import-bcq_neg_004.test @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid input path + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Error parsing message" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./while_3.pbtxt" +outputfile="./bcq.circle" + +rm -rf ${outputfile} +rm -f ${filename}.log + +# run test +one-import-bcq \ +--input_path ${inputfile} \ +--output_path ${outputfile} \ +--input_arrays Placeholder \ +--output_arrays MatMul > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-import-bcq_neg_005.test b/compiler/one-cmds/tests/one-import-bcq_neg_005.test new file mode 100644 index 000000000..550804fea --- /dev/null +++ b/compiler/one-cmds/tests/one-import-bcq_neg_005.test @@ -0,0 +1,48 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid output path + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Failed to write circle" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./bcq.pb" +outputfile="." + +rm -f ${filename}.log + +# run test +one-import-bcq \ +--input_path ${inputfile} \ +--output_path ${outputfile} \ +--input_arrays Placeholder \ +--output_arrays MatMul > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-import-bcq_neg_006.test b/compiler/one-cmds/tests/one-import-bcq_neg_006.test new file mode 100644 index 000000000..7b872eb42 --- /dev/null +++ b/compiler/one-cmds/tests/one-import-bcq_neg_006.test @@ -0,0 +1,48 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid input shapes + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "ValueError: The shape of tensor" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./bcq.pb" +outputfile="./bcq.circle" + +rm -f ${filename}.log + +# run test +one-import-bcq \ +--input_path ${inputfile} \ +--output_path ${outputfile} \ +--input_arrays Placeholder --input_shapes "1,32,32" \ +--output_arrays MatMul > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-import-bcq_neg_007.test b/compiler/one-cmds/tests/one-import-bcq_neg_007.test new file mode 100644 index 000000000..50d47c0a0 --- /dev/null +++ b/compiler/one-cmds/tests/one-import-bcq_neg_007.test @@ -0,0 +1,48 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid input shapes + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "ValueError: The shape of tensor" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./bcq.pb" +outputfile="./bcq.circle" + +rm -f ${filename}.log + +# run test +one-import-bcq \ +--input_path ${inputfile} \ +--output_path ${outputfile} \ +--input_arrays Placeholder --input_shapes "30,30" \ +--output_arrays MatMul > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-import-bcq_neg_008.test b/compiler/one-cmds/tests/one-import-bcq_neg_008.test new file mode 100644 index 000000000..2edd33d38 --- /dev/null +++ b/compiler/one-cmds/tests/one-import-bcq_neg_008.test @@ -0,0 +1,48 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid input shapes + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "ValueError: invalid literal for" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./bcq.pb" +outputfile="./bcq.circle" + +rm -f ${filename}.log + +# run test +one-import-bcq \ +--input_path ${inputfile} \ +--output_path ${outputfile} \ +--input_arrays Placeholder --input_shapes "32,O" \ +--output_arrays MatMul > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-import-bcq_neg_009.test b/compiler/one-cmds/tests/one-import-bcq_neg_009.test new file mode 100644 index 000000000..72c1a877e --- /dev/null +++ b/compiler/one-cmds/tests/one-import-bcq_neg_009.test @@ -0,0 +1,48 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid input shapes + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "must have the same number of items" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./bcq.pb" +outputfile="./bcq.circle" + +rm -f ${filename}.log + +# run test +one-import-bcq \ +--input_path ${inputfile} \ +--output_path ${outputfile} \ +--input_arrays Placeholder --input_shapes "32,32:1" \ +--output_arrays MatMul > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-import-onnx_001.test b/compiler/one-cmds/tests/one-import-onnx_001.test new file mode 100644 index 000000000..39a96074d --- /dev/null +++ b/compiler/one-cmds/tests/one-import-onnx_001.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./test_onnx_model.onnx" +outputfile="./test_onnx_model.circle" + +rm -rf ${outputfile} +rm -f ${filename}.log + +# run test +one-import-onnx \ +--input_path ${inputfile} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-import-onnx_002.test b/compiler/one-cmds/tests/one-import-onnx_002.test new file mode 100644 index 000000000..0430a8e32 --- /dev/null +++ b/compiler/one-cmds/tests/one-import-onnx_002.test @@ -0,0 +1,71 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# test for experimental_disable_batchmatmul_unfold option + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./reshape_matmul.onnx" +outputfile="./reshape_matmul.one-import-onnx_002.circle" + +rm -rf ${outputfile} +rm -rf ${outputfile}.log + +# run test without option that should drop FULLY_CONNECTED +one-import-onnx \ +--input_path ${inputfile} \ +--output_path ${outputfile} > /dev/null 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +circle-operator --code ${outputfile} > ${outputfile}.log 2>&1 + +if ! grep -q "FULLY_CONNECTED" "${outputfile}.log"; then + trap_err_onexit +fi + +rm -rf ${outputfile} +rm -rf ${outputfile}.log + +# run test with option that should drop BATCH_MATMUL +one-import-onnx \ +--experimental_disable_batchmatmul_unfold \ +--input_path ${inputfile} \ +--output_path ${outputfile} > /dev/null 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +circle-operator --code ${outputfile} > ${outputfile}.log 2>&1 + +if ! grep -q "BATCH_MATMUL" "${outputfile}.log"; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" +exit 0 diff --git a/compiler/one-cmds/tests/one-import-onnx_ext_001.test b/compiler/one-cmds/tests/one-import-onnx_ext_001.test new file mode 100644 index 000000000..be8dadcf1 --- /dev/null +++ b/compiler/one-cmds/tests/one-import-onnx_ext_001.test @@ -0,0 +1,53 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# test for one-import-onnx to invoke extension + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -f ../bin/one-import-onnx-ext + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./onnx_conv2d_conv2d.onnx" +outputfile="./onnx_conv2d_conv2d.onnx_ext_001.circle" +logfile=${filename}.log + +rm -f ${outputfile} +rm -f ${logfile} + +# copy dummy-compile to bin folder +cp dummy-onnx-ext ../bin/one-import-onnx-ext + +# run test +one-import-onnx \ +--input_path ${inputfile} \ +--output_path ${outputfile} > ${logfile} 2>&1 + +if ! grep -q "one-import-onnx-ext dummy output!!!" "${logfile}"; then + trap_err_onexit +fi + +rm -f ../bin/one-import-onnx-ext + +echo "${filename_ext} SUCCESS" +exit 0 diff --git a/compiler/one-cmds/tests/one-import_001.test b/compiler/one-cmds/tests/one-import_001.test new file mode 100644 index 000000000..2647337d2 --- /dev/null +++ b/compiler/one-cmds/tests/one-import_001.test @@ -0,0 +1,45 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.pb" +outputfile="./inception_v3.circle" + +# Note: Do not remove output circle file as it's used for quantize tests +rm -f ${filename}.log + +# run test +one-import tf \ +--input_path ${inputfile} \ +--output_path ${outputfile} \ +--input_arrays input --input_shapes "1,299,299,3" \ +--output_arrays InceptionV3/Predictions/Reshape_1 > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-import_002.cfg b/compiler/one-cmds/tests/one-import_002.cfg new file mode 100644 index 000000000..e7ede7bc2 --- /dev/null +++ b/compiler/one-cmds/tests/one-import_002.cfg @@ -0,0 +1,16 @@ +[one-build] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=False +one-quantize=False +one-pack=False +one-codegen=False + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3_cfg.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v2 diff --git a/compiler/one-cmds/tests/one-import_002.test b/compiler/one-cmds/tests/one-import_002.test new file mode 100644 index 000000000..24f673c43 --- /dev/null +++ b/compiler/one-cmds/tests/one-import_002.test @@ -0,0 +1,46 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# positive usage with overriding option + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="one-import_002.cfg" +outputfile_cmd="inception_v3_cmd.circle" +outputfile_cfg="inception_v3_cfg.circle" + +rm -f ${filename}.log +rm -f ${outputfile_cmd} +rm -f ${outputfile_cfg} + +# run test +one-import tf -C ${configfile} \ +--output_path=${outputfile_cmd} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile_cmd}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-import_003.cfg b/compiler/one-cmds/tests/one-import_003.cfg new file mode 100644 index 000000000..b679ebdb3 --- /dev/null +++ b/compiler/one-cmds/tests/one-import_003.cfg @@ -0,0 +1,13 @@ +[one-build] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=False +one-quantize=False +one-pack=False +one-codegen=False + +[one-import-tf] +model_format=saved_model +input_path=test_saved_model +output_path=test_saved_model.circle diff --git a/compiler/one-cmds/tests/one-import_003.test b/compiler/one-cmds/tests/one-import_003.test new file mode 100644 index 000000000..92e4b151b --- /dev/null +++ b/compiler/one-cmds/tests/one-import_003.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# import of TF 2.x saved model + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="one-import_003.cfg" +outputfile="test_saved_model.circle" + +rm -f ${filename}.log +rm -f ${outputfile} + +# run test +one-import tf -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-import_004.cfg b/compiler/one-cmds/tests/one-import_004.cfg new file mode 100644 index 000000000..d28c8dff6 --- /dev/null +++ b/compiler/one-cmds/tests/one-import_004.cfg @@ -0,0 +1,13 @@ +[one-build] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=False +one-quantize=False +one-pack=False +one-codegen=False + +[one-import-tf] +model_format=keras_model +input_path=test_keras_model.h5 +output_path=test_keras_model.circle diff --git a/compiler/one-cmds/tests/one-import_004.test b/compiler/one-cmds/tests/one-import_004.test new file mode 100644 index 000000000..42c1692a3 --- /dev/null +++ b/compiler/one-cmds/tests/one-import_004.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# import of TF 2.x keras model + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="one-import_004.cfg" +outputfile="test_keras_model.circle" + +rm -f ${filename}.log +rm -f ${outputfile} + +# run test +one-import tf -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-import_005.cfg b/compiler/one-cmds/tests/one-import_005.cfg new file mode 100644 index 000000000..abe4c7d77 --- /dev/null +++ b/compiler/one-cmds/tests/one-import_005.cfg @@ -0,0 +1,13 @@ +[one-build] +one-import-tf=False +one-import-tflite=False +one-import-bcq=False +one-import-onnx=True +one-optimize=False +one-quantize=False +one-pack=False +one-codegen=False + +[one-import-onnx] +input_path=test_onnx_model.onnx +output_path=test_onnx_model.circle diff --git a/compiler/one-cmds/tests/one-import_005.test b/compiler/one-cmds/tests/one-import_005.test new file mode 100644 index 000000000..75122d6f2 --- /dev/null +++ b/compiler/one-cmds/tests/one-import_005.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# import onnx model with cfg file + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="one-import_005.cfg" +outputfile="test_onnx_model.circle" + +rm -f ${outputfile} +rm -f ${filename}.log + +# run test +one-import onnx -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-import_006.test b/compiler/one-cmds/tests/one-import_006.test new file mode 100644 index 000000000..a9be173e5 --- /dev/null +++ b/compiler/one-cmds/tests/one-import_006.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# import onnx model + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="test_onnx_model.onnx" +outputfile="test_onnx_model.circle" + +rm -f ${outputfile} +rm -f ${filename}.log + +# run test +one-import onnx -i ${inputfile} -o ${outputfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-import_neg_001.test b/compiler/one-cmds/tests/one-import_neg_001.test new file mode 100644 index 000000000..20a69641a --- /dev/null +++ b/compiler/one-cmds/tests/one-import_neg_001.test @@ -0,0 +1,55 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage improper input model + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "ValueError: Invalid tensors 'input' were found" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + # TF 2.12.x: error report has changed + if grep -q "invalid start byte" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.tflite" +outputfile="./inception_v3.circle" + +# do not remove output file +# rm -rf ${outputfile} +rm -rf ${filename}.log + +# run test +one-import tf \ +--input_path ${inputfile} \ +--output_path ${outputfile} \ +--input_arrays input --input_shapes "1,299,299,3" \ +--output_arrays InceptionV3/Predictions/Reshape_1 > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-import_neg_002.test b/compiler/one-cmds/tests/one-import_neg_002.test new file mode 100644 index 000000000..9cf0b1401 --- /dev/null +++ b/compiler/one-cmds/tests/one-import_neg_002.test @@ -0,0 +1,55 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with unsupported dynamic tensor + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + # TF2.3.0 + if grep -q "is incompatible with result type" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + # TF2.6.0 + if grep -q "is incompatible with body result type" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./while_3.pbtxt" +outputfile="./while_3.circle" + +rm -rf ${outputfile} +rm -rf ${filename}.log + +# run test +one-import tf \ +--input_path ${inputfile} \ +--output_path ${outputfile} \ +--input_arrays Hole,Hole_2 --input_shapes "1,1:1,1" \ +--output_arrays Output > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-import_neg_003.test b/compiler/one-cmds/tests/one-import_neg_003.test new file mode 100644 index 000000000..9561ceafd --- /dev/null +++ b/compiler/one-cmds/tests/one-import_neg_003.test @@ -0,0 +1,58 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid output array + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + # TODO Error message depends on TF version. Find better way. + # TF 2.3.0 + if grep -q "ValueError: Invalid tensors" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + # TF 2.5.0 + if grep -q "ConverterError: <unknown>:0: error:" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.pb" +outputfile="./inception_v3.circle" + +# do not remove output file +# rm -rf ${outputfile} +rm -rf ${filename}.log + +# run test +one-import tf \ +--input_path ${inputfile} \ +--output_path ${outputfile} \ +--input_arrays input --input_shapes "1,299,299,3" \ +--output_arrays InceptionV3/Predictions/Reshape_2 > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-import_neg_004.test b/compiler/one-cmds/tests/one-import_neg_004.test new file mode 100644 index 000000000..8626eb9ab --- /dev/null +++ b/compiler/one-cmds/tests/one-import_neg_004.test @@ -0,0 +1,50 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid input shape + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "ValueError: The shape of tensor" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.pb" +outputfile="./inception_v3.circle" + +# do not remove output file +# rm -rf ${outputfile} +rm -rf ${filename}.log + +# run test +one-import tf \ +--input_path ${inputfile} \ +--output_path ${outputfile} \ +--input_arrays input --input_shapes "1,299,299,1" \ +--output_arrays InceptionV3/Predictions/Reshape_1 > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-import_neg_005.test b/compiler/one-cmds/tests/one-import_neg_005.test new file mode 100644 index 000000000..f73826f00 --- /dev/null +++ b/compiler/one-cmds/tests/one-import_neg_005.test @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid input shape + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "ValueError: The shape of tensor" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.pb" +outputfile="./inception_v3.imp_neg_005.circle" + +rm -rf ${outputfile} +rm -rf ${filename}.log + +# run test +one-import tf \ +--input_path ${inputfile} \ +--output_path ${outputfile} \ +--input_arrays input --input_shapes "1,299,299" \ +--output_arrays InceptionV3/Predictions/Reshape_1 > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-import_neg_006.test b/compiler/one-cmds/tests/one-import_neg_006.test new file mode 100644 index 000000000..985bd1c1e --- /dev/null +++ b/compiler/one-cmds/tests/one-import_neg_006.test @@ -0,0 +1,52 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid input shape + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "ConverterError: <unknown>:0: error:" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.pb" +outputfile="./inception_v3.imp_neg_006.circle" + +rm -rf ${outputfile} +rm -rf ${filename}.log + +# run test +one-import tf \ +--input_path ${inputfile} \ +--output_path ${outputfile} \ +--input_arrays input --input_shapes "0,299,299,3" \ +--output_arrays InceptionV3/Predictions/Reshape_1 > ${filename}.log 2>&1 + +# NOTE TF2.3.0 fails(which is expected) but doesn't for TF2.5(4?) and above +# https://github.com/tensorflow/tensorflow/issues/51756 for details +# TODO exit 255 +echo "${filename_ext} SKIPPED" +exit 0 diff --git a/compiler/one-cmds/tests/one-import_neg_007.test b/compiler/one-cmds/tests/one-import_neg_007.test new file mode 100644 index 000000000..2552157da --- /dev/null +++ b/compiler/one-cmds/tests/one-import_neg_007.test @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid input shape + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "ValueError: invalid literal" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.pb" +outputfile="./inception_v3.imp_neg_007.circle" + +rm -rf ${outputfile} +rm -rf ${filename}.log + +# run test +one-import tf \ +--input_path ${inputfile} \ +--output_path ${outputfile} \ +--input_arrays input --input_shapes "None,299,299,3" \ +--output_arrays InceptionV3/Predictions/Reshape_1 > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-import_neg_008.test b/compiler/one-cmds/tests/one-import_neg_008.test new file mode 100644 index 000000000..d62899d2e --- /dev/null +++ b/compiler/one-cmds/tests/one-import_neg_008.test @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid input shape + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "must have the same number of items" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.pb" +outputfile="./inception_v3.imp_neg_008.circle" + +rm -rf ${outputfile} +rm -rf ${filename}.log + +# run test +one-import tf \ +--input_path ${inputfile} \ +--output_path ${outputfile} \ +--input_arrays input,InceptionV3/Predictions/Shape --input_shapes "1,299,299,3" \ +--output_arrays InceptionV3/Predictions/Reshape_1 > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-import_neg_009.test b/compiler/one-cmds/tests/one-import_neg_009.test new file mode 100644 index 000000000..0b5deb32f --- /dev/null +++ b/compiler/one-cmds/tests/one-import_neg_009.test @@ -0,0 +1,48 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid output path + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Failed to write circle" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.pb" +outputfile="." + +rm -rf ${filename}.log + +# run test +one-import tf \ +--input_path ${inputfile} \ +--output_path ${outputfile} \ +--input_arrays input --input_shapes "1,299,299,3" \ +--output_arrays InceptionV3/Predictions/Reshape_1 > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-import_neg_010.test b/compiler/one-cmds/tests/one-import_neg_010.test new file mode 100644 index 000000000..11512fd18 --- /dev/null +++ b/compiler/one-cmds/tests/one-import_neg_010.test @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid input_arrays + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "ValueError: Invalid tensors" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.pb" +outputfile="./inception_v3.imp_neg_010.circle" + +rm -rf ${outputfile} +rm -rf ${filename}.log + +# run test +one-import tf \ +--input_path ${inputfile} \ +--output_path ${outputfile} \ +--input_arrays input2 --input_shapes "1,299,299,3" \ +--output_arrays InceptionV3/Predictions/Reshape_1 > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-infer-test-post-process.py b/compiler/one-cmds/tests/one-infer-test-post-process.py new file mode 100644 index 000000000..0f0e0d701 --- /dev/null +++ b/compiler/one-cmds/tests/one-infer-test-post-process.py @@ -0,0 +1,16 @@ +# This script gets one argument and print it + +import sys +from pathlib import Path + + +def main(): + if len(sys.argv) < 2: + filepath = Path(sys.argv[0]) + sys.exit("Usage: " + filepath.name + " [Word to print]") + word = sys.argv[1] + print(word) + + +if __name__ == '__main__': + main() diff --git a/compiler/one-cmds/tests/one-infer_001.test b/compiler/one-cmds/tests/one-infer_001.test new file mode 100644 index 000000000..e8f1bc7be --- /dev/null +++ b/compiler/one-cmds/tests/one-infer_001.test @@ -0,0 +1,44 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/help-infer + exit 255 +} + +trap trap_err_onexit ERR + +# copy help-infer to bin folder +cp help-infer ../bin/help-infer + +rm -f ${filename}.log + +# run test +one-infer -d help-infer -- -h > ${filename}.log + +rm -rf ../bin/help-infer + +if grep -q "HELP MESSAGE!!" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 +fi + +trap_err_onexit diff --git a/compiler/one-cmds/tests/one-infer_002.test b/compiler/one-cmds/tests/one-infer_002.test new file mode 100644 index 000000000..6d22fb303 --- /dev/null +++ b/compiler/one-cmds/tests/one-infer_002.test @@ -0,0 +1,50 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-infer + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="sample.tvn" + +if [[ ! -s "${inputfile}" ]]; then + touch ${inputfile} +fi + +# copy dummy-infer to bin folder +cp dummy-infer ../bin/dummy-infer + +rm -f ${filename}.log + +# run test +one-infer -d dummy-infer -- ${inputfile} > ${filename}.log + +rm -rf ../bin/dummy-infer + +if grep -q "dummy-infer dummy output!!!" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 +fi + +trap_err_onexit diff --git a/compiler/one-cmds/tests/one-infer_003.test b/compiler/one-cmds/tests/one-infer_003.test new file mode 100644 index 000000000..b8fbe93ae --- /dev/null +++ b/compiler/one-cmds/tests/one-infer_003.test @@ -0,0 +1,40 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# print one-infer's help message + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +rm -f ${filename}.log + +# run test +one-infer -h > ${filename}.log + +if grep -q "command line tool to infer model" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 +fi + +trap_err_onexit diff --git a/compiler/one-cmds/tests/one-infer_004.cfg b/compiler/one-cmds/tests/one-infer_004.cfg new file mode 100644 index 000000000..fd5353b0c --- /dev/null +++ b/compiler/one-cmds/tests/one-infer_004.cfg @@ -0,0 +1,3 @@ +[one-infer] +driver=dummy-infer +command=sample.tvn diff --git a/compiler/one-cmds/tests/one-infer_004.test b/compiler/one-cmds/tests/one-infer_004.test new file mode 100644 index 000000000..249728c1e --- /dev/null +++ b/compiler/one-cmds/tests/one-infer_004.test @@ -0,0 +1,53 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-infer with configuration input + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-infer + exit 255 +} + +trap trap_err_onexit ERR + +configfile="one-infer_004.cfg" +inputfile="sample.tvn" + +if [[ ! -s "${inputfile}" ]]; then + touch ${inputfile} +fi + +# copy dummy-infer to bin folder +cp dummy-infer ../bin/dummy-infer + +rm -f ${filename}.log + +# run test +one-infer -C ${configfile} > ${filename}.log + +rm -rf ../bin/dummy-infer + +if grep -q "dummy-infer dummy output!!!" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 +fi + +trap_err_onexit diff --git a/compiler/one-cmds/tests/one-infer_005.test b/compiler/one-cmds/tests/one-infer_005.test new file mode 100644 index 000000000..7a921fb60 --- /dev/null +++ b/compiler/one-cmds/tests/one-infer_005.test @@ -0,0 +1,55 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-infer with post process script + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-infer + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="sample.tvn" + +if [[ ! -s "${inputfile}" ]]; then + touch ${inputfile} +fi + +# copy dummy-infer to bin folder +cp dummy-infer ../bin/dummy-infer + +rm -f ${filename}.log + +# run test +one-infer -d dummy-infer --post-process "./one-infer-test-post-process.py TOKEN" -- ${inputfile} > ${filename}.log 2>&1 +return_code=$? + +rm -rf ../bin/dummy-infer + +if grep -q "dummy-infer dummy output!!!" "${filename}.log"; then + if [ "$return_code" -eq "0" ]; then + echo "${filename_ext} SUCCESS" + exit 0 + fi +fi + +trap_err_onexit diff --git a/compiler/one-cmds/tests/one-infer_neg_001.test b/compiler/one-cmds/tests/one-infer_neg_001.test new file mode 100644 index 000000000..15df58ad9 --- /dev/null +++ b/compiler/one-cmds/tests/one-infer_neg_001.test @@ -0,0 +1,41 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with no input + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "error: the following arguments are required: -d/--driver" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +rm -f ${filename}.log + +# run test +one-infer > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-infer_neg_002.test b/compiler/one-cmds/tests/one-infer_neg_002.test new file mode 100644 index 000000000..1fd16f2f8 --- /dev/null +++ b/compiler/one-cmds/tests/one-infer_neg_002.test @@ -0,0 +1,42 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# passed driver is not found + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" +driver_name="neg-infer" + +trap_err_onexit() +{ + if grep -q "FileNotFoundError: ${driver_name} not found" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +rm -f ${filename}.log + +# run test +one-infer -d ${driver_name} -- -h > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-infer_neg_003.test b/compiler/one-cmds/tests/one-infer_neg_003.test new file mode 100644 index 000000000..1de4d68d5 --- /dev/null +++ b/compiler/one-cmds/tests/one-infer_neg_003.test @@ -0,0 +1,56 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-infer with invalid post process script + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + return_code=$? + if grep -q "dummy-infer dummy output!!!" "${filename}.log"; then + # Case of succeed of inference driver but error after it + if [ "$return_code" -ne "0" ]; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + fi + + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-infer + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="sample.tvn" + +if [[ ! -s "${inputfile}" ]]; then + touch ${inputfile} +fi + +# copy dummy-infer to bin folder +cp dummy-infer ../bin/dummy-infer + +rm -f ${filename}.log + +# run test +one-infer -d dummy-infer --post-process "./one-infer-test-post-process.py" -- ${inputfile} > ${filename}.log 2>&1 + +rm -rf ../bin/dummy-infer +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-optimize_001.test b/compiler/one-cmds/tests/one-optimize_001.test new file mode 100644 index 000000000..94c906297 --- /dev/null +++ b/compiler/one-cmds/tests/one-optimize_001.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +outputfile="./inception_v3-opt.circle" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test +one-optimize --resolve_customop_add \ +--input_path ${inputfile} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-optimize_002.test b/compiler/one-cmds/tests/one-optimize_002.test new file mode 100644 index 000000000..f0a83361d --- /dev/null +++ b/compiler/one-cmds/tests/one-optimize_002.test @@ -0,0 +1,44 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +outputfile="./inception_v3-opt.circle" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test +one-optimize --resolve_customop_add \ +--change_outputs InceptionV3/Logits/SpatialSqueeze1 \ +--input_path ${inputfile} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-optimize_003.test b/compiler/one-cmds/tests/one-optimize_003.test new file mode 100644 index 000000000..11a9fb4f9 --- /dev/null +++ b/compiler/one-cmds/tests/one-optimize_003.test @@ -0,0 +1,62 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./UnidirSeqLSTM.tflite" +intermfile="./UnidirSeqLSTM.circle" +outputfile="./UnidirSeqLSTM-opt.circle" + +rm -f ${intermfile} +rm -f ${outputfile} +rm -f ${intermfile}.log +rm -f ${outputfile}.log + +# run test +one-import-tflite \ +--input_path ${inputfile} \ +--output_path ${intermfile} > /dev/null 2>&1 + +one-optimize --unroll_unidirseqlstm \ +--input_path ${intermfile} \ +--output_path ${outputfile} > /dev/null 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +# check UNIDIRECTIONAL_SEQUENCE_LSTM exist +circle-operator --code ${intermfile} > ${intermfile}.log 2>&1 +if ! grep -q "UNIDIRECTIONAL_SEQUENCE_LSTM" "${intermfile}.log"; then + trap_err_onexit +fi + +# check UNIDIRECTIONAL_SEQUENCE_LSTM absent +circle-operator --code ${outputfile} > ${outputfile}.log 2>&1 +if grep -q "UNIDIRECTIONAL_SEQUENCE_LSTM" "${outputfile}.log"; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-optimize_neg_001.test b/compiler/one-cmds/tests/one-optimize_neg_001.test new file mode 100644 index 000000000..f88b4f861 --- /dev/null +++ b/compiler/one-cmds/tests/one-optimize_neg_001.test @@ -0,0 +1,47 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# this test should fail + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Invalid input file" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.pb" +outputfile="./inception_v3-opt.circle" + +rm -rf ${outputfile} +rm -f ${filename}.log + +# run test +one-optimize --resolve_customop_add \ +--input_path ${inputfile} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-optimize_neg_002.test b/compiler/one-cmds/tests/one-optimize_neg_002.test new file mode 100644 index 000000000..3f37e6240 --- /dev/null +++ b/compiler/one-cmds/tests/one-optimize_neg_002.test @@ -0,0 +1,47 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid input path + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Failed to open file" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circletxt" +outputfile="./inception_v3-opt.circle" + +rm -rf ${outputfile} +rm -f ${filename}.log + +# run test +one-optimize --resolve_customop_add \ +--input_path ${inputfile} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-optimize_neg_003.test b/compiler/one-cmds/tests/one-optimize_neg_003.test new file mode 100644 index 000000000..9d6483c2b --- /dev/null +++ b/compiler/one-cmds/tests/one-optimize_neg_003.test @@ -0,0 +1,44 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage without output folder path + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "the following arguments are required: -o/--output_path" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" + +rm -f ${filename}.log + +# run test +one-optimize --resolve_customop_add \ +--input_path "${inputfile}" > "${filename}.log" 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-optimize_neg_004.test b/compiler/one-cmds/tests/one-optimize_neg_004.test new file mode 100644 index 000000000..5abd4c553 --- /dev/null +++ b/compiler/one-cmds/tests/one-optimize_neg_004.test @@ -0,0 +1,48 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# this test should fail + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Change outputs failed" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +outputfile="./inception_v3-opt.circle" + +rm -rf ${outputfile} +rm -rf ${filename}.log + +# run test +one-optimize --resolve_customop_add \ +--change_outputs non_existing_node_name \ +--input_path ${inputfile} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-pack_001.test b/compiler/one-cmds/tests/one-pack_001.test new file mode 100644 index 000000000..b05d0fe11 --- /dev/null +++ b/compiler/one-cmds/tests/one-pack_001.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +outputfolder="nnpack" + +rm -f ${filename}.log +rm -rf ${outputfolder} + +# run test +one-pack \ +-i ${inputfile} \ +-o ${outputfolder} > ${filename}.log 2>&1 + +if [[ ! -d "${outputfolder}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-pack_neg_001.test b/compiler/one-cmds/tests/one-pack_neg_001.test new file mode 100644 index 000000000..9cf388004 --- /dev/null +++ b/compiler/one-cmds/tests/one-pack_neg_001.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid input path + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "inception_v2.circle does not exist" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +rm -rf ${filename}.log + +# run test +one-pack \ +-i ./inception_v2.circle \ +-o nnpack > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-pack_neg_002.test b/compiler/one-cmds/tests/one-pack_neg_002.test new file mode 100644 index 000000000..9faa8d9d7 --- /dev/null +++ b/compiler/one-cmds/tests/one-pack_neg_002.test @@ -0,0 +1,47 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with filename without extension + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "modelfile does not have extension" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +rm -rf ${filename}.log +rm -rf nnpack + +# prepare dummy file +touch ./sample + +# run test +one-pack \ +-i ./sample \ +-o nnpack > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-pack_neg_003.test b/compiler/one-cmds/tests/one-pack_neg_003.test new file mode 100644 index 000000000..5db4a3805 --- /dev/null +++ b/compiler/one-cmds/tests/one-pack_neg_003.test @@ -0,0 +1,45 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage without output folder path + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "the following arguments are required: -o/--output_path" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +rm -rf ${filename}.log + +# prepare dummy file +touch ./sample.circle + +# run test +one-pack \ +-i ./sample.circle > "${filename}.log" 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-partition_001.test b/compiler/one-cmds/tests/one-partition_001.test new file mode 100644 index 000000000..ddd2ae098 --- /dev/null +++ b/compiler/one-cmds/tests/one-partition_001.test @@ -0,0 +1,47 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" +testmodel="Net_InstanceNorm_003" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="${testmodel}.circle" +partfile="${testmodel}.part" +outputfile="${testmodel}.conn.json" + +rm -f ${filename}.log +rm -rf ${testmodel}.000* +rm -rf ${testmodel}.conn.* +rm -rf ${testmodel}.*.log + +# run test +one-partition \ +--input_file ${inputfile} \ +--part_file ${partfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-partition_neg_001.test b/compiler/one-cmds/tests/one-partition_neg_001.test new file mode 100644 index 000000000..b594eba0d --- /dev/null +++ b/compiler/one-cmds/tests/one-partition_neg_001.test @@ -0,0 +1,56 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid .part file (wrong comply value) + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" +testmodel="Net_InstanceNorm_003" + +trap_err_onexit() +{ + if grep -q "ERROR" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + # for debug build test + if grep -1 "std::runtime_error" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="${testmodel}.circle" +partfile="${testmodel}.neg.part" +outputfile="${testmodel}.conn.json" + +rm -rf ${testmodel}.000* +rm -rf ${testmodel}.conn.* +rm -rf ${testmodel}.*.log +rm -rf ${filename}.log + +# run test +one-partition \ +--input_file ${inputfile} \ +--part_file ${partfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-partition_neg_002.test b/compiler/one-cmds/tests/one-partition_neg_002.test new file mode 100644 index 000000000..23fe84c05 --- /dev/null +++ b/compiler/one-cmds/tests/one-partition_neg_002.test @@ -0,0 +1,47 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid .cfg file (no one-partition section) + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" +testmodel="Net_InstanceNorm_003" + +trap_err_onexit() +{ + if grep -q "'one-partition' section" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +cfgfile="${testmodel}.neg.cfg" + +rm -rf ${testmodel}.000* +rm -rf ${testmodel}.conn.* +rm -rf ${testmodel}.*.log +rm -rf ${filename}.log + +# run test +one-partition -C ${cfgfile}> ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-profile_001.test b/compiler/one-cmds/tests/one-profile_001.test new file mode 100644 index 000000000..b4bdc72b0 --- /dev/null +++ b/compiler/one-cmds/tests/one-profile_001.test @@ -0,0 +1,44 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/help-profile + exit 255 +} + +trap trap_err_onexit ERR + +# copy help-profile to bin folder +cp help-profile ../bin/help-profile + +rm -f ${filename}.log + +# run test +one-profile -b help -- -h > ${filename}.log + +rm -rf ../bin/help-profile + +if grep -q "HELP MESSAGE!!" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 +fi + +trap_err_onexit diff --git a/compiler/one-cmds/tests/one-profile_002.test b/compiler/one-cmds/tests/one-profile_002.test new file mode 100644 index 000000000..3b85dee54 --- /dev/null +++ b/compiler/one-cmds/tests/one-profile_002.test @@ -0,0 +1,52 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# run one-codegen with dummy-profile driver + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-profile + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="sample.tvn" + +if [[ ! -s "${inputfile}" ]]; then + touch ${inputfile} +fi + +# copy dummy-profile to bin folder +cp dummy-profile ../bin/dummy-profile + +rm -f ${filename}.log + +# run test +one-profile -b dummy ${inputfile} > ${filename}.log + +rm -rf ../bin/dummy-profile + +if grep -q "dummy-profile dummy output!!!" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 +fi + +trap_err_onexit diff --git a/compiler/one-cmds/tests/one-profile_003.test b/compiler/one-cmds/tests/one-profile_003.test new file mode 100644 index 000000000..ad98bb455 --- /dev/null +++ b/compiler/one-cmds/tests/one-profile_003.test @@ -0,0 +1,40 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# print one-profile's help message + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +rm -f ${filename}.log + +# run test +one-profile -h > ${filename}.log + +if grep -q "command line tool for profiling backend model" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 +fi + +trap_err_onexit diff --git a/compiler/one-cmds/tests/one-profile_004.cfg b/compiler/one-cmds/tests/one-profile_004.cfg new file mode 100644 index 000000000..6d4387b0a --- /dev/null +++ b/compiler/one-cmds/tests/one-profile_004.cfg @@ -0,0 +1,3 @@ +[one-profile] +backend=dummy +command=sample.tvn diff --git a/compiler/one-cmds/tests/one-profile_004.test b/compiler/one-cmds/tests/one-profile_004.test new file mode 100644 index 000000000..7b77caa4d --- /dev/null +++ b/compiler/one-cmds/tests/one-profile_004.test @@ -0,0 +1,53 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-profile with configuration input + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-profile + exit 255 +} + +trap trap_err_onexit ERR + +configfile="one-profile_004.cfg" +inputfile="sample.tvn" + +if [[ ! -s "${inputfile}" ]]; then + touch ${inputfile} +fi + +# copy dummy-profile to bin folder +cp dummy-profile ../bin/dummy-profile + +rm -f ${filename}.log + +# run test +one-profile -C ${configfile} > ${filename}.log + +rm -rf ../bin/dummy-profile + +if grep -q "dummy-profile dummy output!!!" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 +fi + +trap_err_onexit diff --git a/compiler/one-cmds/tests/one-profile_neg_001.test b/compiler/one-cmds/tests/one-profile_neg_001.test new file mode 100644 index 000000000..f5b2dce02 --- /dev/null +++ b/compiler/one-cmds/tests/one-profile_neg_001.test @@ -0,0 +1,41 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with no input + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "error: the following arguments are required: -b/--backend" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +rm -f ${filename}.log + +# run test +one-profile > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-profile_neg_002.test b/compiler/one-cmds/tests/one-profile_neg_002.test new file mode 100644 index 000000000..6964312a3 --- /dev/null +++ b/compiler/one-cmds/tests/one-profile_neg_002.test @@ -0,0 +1,41 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-profile ${command} without backend option + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "error: the following arguments are required: -b/--backend" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +rm -f ${filename}.log + +# run test +one-profile test.tvn > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-profile_neg_003.test b/compiler/one-cmds/tests/one-profile_neg_003.test new file mode 100644 index 000000000..a00215452 --- /dev/null +++ b/compiler/one-cmds/tests/one-profile_neg_003.test @@ -0,0 +1,41 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-profile -- ${command} without backend option + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "error: the following arguments are required: -b/--backend" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +rm -f ${filename}.log + +# run test +one-profile -- test.tvn > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-profile_neg_004.cfg b/compiler/one-cmds/tests/one-profile_neg_004.cfg new file mode 100644 index 000000000..93afcb4df --- /dev/null +++ b/compiler/one-cmds/tests/one-profile_neg_004.cfg @@ -0,0 +1,6 @@ +[onecc] +one-profile=True + +[one-profile] +backend=dummy +# command=.. diff --git a/compiler/one-cmds/tests/one-profile_neg_004.test b/compiler/one-cmds/tests/one-profile_neg_004.test new file mode 100644 index 000000000..404ac1071 --- /dev/null +++ b/compiler/one-cmds/tests/one-profile_neg_004.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# command key is missing + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "error: 'command' key is missing in the configuration file" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="one-profile_neg_004.cfg" + +rm -f ${filename}.log + +# run test +one-profile -b dummy -C ${configfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-profile_neg_005.test b/compiler/one-cmds/tests/one-profile_neg_005.test new file mode 100644 index 000000000..9a915497b --- /dev/null +++ b/compiler/one-cmds/tests/one-profile_neg_005.test @@ -0,0 +1,41 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# commands for the backend is missing + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "error: commands for the backend is missing" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +rm -f ${filename}.log + +# run test +one-profile -b dummy > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-quantize_001.test b/compiler/one-cmds/tests/one-quantize_001.test new file mode 100644 index 000000000..96804bf9d --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_001.test @@ -0,0 +1,46 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +outputfile="./inception_v3.quantized.circle" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ./inception_v3.circle \ +--input_data ./inception_v3_test_data.h5 \ +--output_path ./inception_v3.quantized.circle > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-quantize_002.test b/compiler/one-cmds/tests/one-quantize_002.test new file mode 100644 index 000000000..0ddaad170 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_002.test @@ -0,0 +1,45 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +outputfile="./inception_v3.random.quantized.circle" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test without input data +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-quantize_003.test b/compiler/one-cmds/tests/one-quantize_003.test new file mode 100644 index 000000000..b96263ea6 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_003.test @@ -0,0 +1,47 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +outputfile="./inception_v3.list.quantized.circle" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test with list-format input data (datalist.txt) +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ./datalist.txt \ +--input_data_format list \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-quantize_004.test b/compiler/one-cmds/tests/one-quantize_004.test new file mode 100644 index 000000000..afb40805f --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_004.test @@ -0,0 +1,47 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +outputfile="./inception_v3.directory.quantized.circle" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test with directory-format input data (raw_files) +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ./raw_files \ +--input_data_format directory \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-quantize_005.test b/compiler/one-cmds/tests/one-quantize_005.test new file mode 100644 index 000000000..e5403e270 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_005.test @@ -0,0 +1,47 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.mat.q8.circle" +outputfile="./inception_v3.one-quantize_005.q8.circle" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test with force_quantparam option +one-quantize \ +--force_quantparam \ +--tensor_name input \ +--scale 2.3 \ +--zero_point 33 \ +--input_path ${inputfile} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-quantize_006.test b/compiler/one-cmds/tests/one-quantize_006.test new file mode 100644 index 000000000..2521a96a8 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_006.test @@ -0,0 +1,50 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.mat.q8.circle" +outputfile="./inception_v3.one-quantize_006.q8.circle" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test with force_quantparam option (multi tensors) +one-quantize \ +--force_quantparam \ +--tensor_name input \ +--scale 2.3 \ +--zero_point 33 \ +--tensor_name InceptionV3/Predictions/Reshape_1 \ +--scale 2.3 \ +--zero_point 33 \ +--input_path ${inputfile} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-quantize_007.test b/compiler/one-cmds/tests/one-quantize_007.test new file mode 100644 index 000000000..771b85757 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_007.test @@ -0,0 +1,47 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +outputfile="./inception_v3.random.quantized.q16.iq8.circle" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test without input data +one-quantize \ +--input_dtype float32 \ +--quantized_dtype int16 \ +--granularity channel \ +--input_type uint8 \ +--input_path ${inputfile} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-quantize_008.test b/compiler/one-cmds/tests/one-quantize_008.test new file mode 100644 index 000000000..fcc4141d4 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_008.test @@ -0,0 +1,47 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +outputfile="./inception_v3.random.quantized.q16.oq8.circle" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test without input data +one-quantize \ +--input_dtype float32 \ +--quantized_dtype int16 \ +--granularity channel \ +--output_type uint8 \ +--input_path ${inputfile} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-quantize_009.qconf.json b/compiler/one-cmds/tests/one-quantize_009.qconf.json new file mode 100644 index 000000000..ac274e83a --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_009.qconf.json @@ -0,0 +1,36 @@ +{ + "default_quantization_dtype" : "uint8", + "default_granularity" : "channel", + "layers" : [ + { + "name" : "InceptionV3/InceptionV3/Conv2d_2b_3x3/Relu;InceptionV3/InceptionV3/Conv2d_2b_3x3/BatchNorm/FusedBatchNorm;InceptionV3/InceptionV3/Mixed_6a/Branch_1/Conv2d_0a_1x1/Conv2D;InceptionV3/InceptionV3/Conv2d_2b_3x3/Conv2D", + "dtype" : "int16", + "granularity" : "channel" + }, + { + "name" : "InceptionV3/InceptionV3/MaxPool_5a_3x3/MaxPool", + "dtype" : "int16", + "granularity" : "channel" + }, + { + "name" : "InceptionV3/InceptionV3/Mixed_5b/concat", + "dtype" : "int16", + "granularity" : "channel" + }, + { + "name" : "InceptionV3/InceptionV3/Mixed_5b/Branch_3/AvgPool_0a_3x3/AvgPool", + "dtype" : "int16", + "granularity" : "channel" + }, + { + "name" : "InceptionV3/InceptionV3/Mixed_7c/concat", + "dtype" : "int16", + "granularity" : "channel" + }, + { + "name" : "InceptionV3/Predictions/Reshape_1", + "dtype" : "int16", + "granularity" : "channel" + } + ] +} diff --git a/compiler/one-cmds/tests/one-quantize_009.test b/compiler/one-cmds/tests/one-quantize_009.test new file mode 100644 index 000000000..0c13292e9 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_009.test @@ -0,0 +1,47 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +outputfile="./inception_v3.random.quantized.mixed.circle" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test without input data +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--granularity channel \ +--quant_config one-quantize_009.qconf.json \ +--input_path ${inputfile} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-quantize_010.test b/compiler/one-cmds/tests/one-quantize_010.test new file mode 100644 index 000000000..83d5f3745 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_010.test @@ -0,0 +1,57 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +check_message() +{ + if grep -q "MPEIR for InceptionV3/Predictions/Reshape_1 is" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + trap_err_onexit +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +outputfile="./inception_v3.one-quantize_010.q.circle" +datafile="./inception_v3_test_data.h5" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--granularity channel \ +--input_path ${inputfile} \ +--input_data ${datafile} \ +--output_path ${outputfile} \ +--evaluate_result \ +--test_data ${datafile} \ +--print_mpeir > ${filename}.log 2>&1 + +check_message diff --git a/compiler/one-cmds/tests/one-quantize_011.test b/compiler/one-cmds/tests/one-quantize_011.test new file mode 100644 index 000000000..88abe4e5a --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_011.test @@ -0,0 +1,57 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +check_message() +{ + if grep -q "Mean Top-5 match ratio for InceptionV3/Predictions/Reshape_1 is" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + trap_err_onexit +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +outputfile="./inception_v3.one-quantize_011.q.circle" +datafile="./inception_v3_test_data.h5" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--granularity channel \ +--input_path ${inputfile} \ +--input_data ${datafile} \ +--output_path ${outputfile} \ +--evaluate_result \ +--test_data ${datafile} \ +--print_top5_match > ${filename}.log 2>&1 + +check_message diff --git a/compiler/one-cmds/tests/one-quantize_012.qconf.json b/compiler/one-cmds/tests/one-quantize_012.qconf.json new file mode 100644 index 000000000..4a15b04f5 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_012.qconf.json @@ -0,0 +1,16 @@ +{ + "default_quantization_dtype" : "uint8", + "default_granularity" : "channel", + "layers" : [ + { + "names" : ["InceptionV3/InceptionV3/Conv2d_2b_3x3/Relu;InceptionV3/InceptionV3/Conv2d_2b_3x3/BatchNorm/FusedBatchNorm;InceptionV3/InceptionV3/Mixed_6a/Branch_1/Conv2d_0a_1x1/Conv2D;InceptionV3/InceptionV3/Conv2d_2b_3x3/Conv2D", + "InceptionV3/InceptionV3/MaxPool_5a_3x3/MaxPool", + "InceptionV3/InceptionV3/Mixed_5b/concat", + "InceptionV3/InceptionV3/Mixed_5b/Branch_3/AvgPool_0a_3x3/AvgPool", + "InceptionV3/InceptionV3/Mixed_7c/concat", + "InceptionV3/Predictions/Reshape_1"], + "dtype" : "int16", + "granularity" : "channel" + } + ] +} diff --git a/compiler/one-cmds/tests/one-quantize_012.test b/compiler/one-cmds/tests/one-quantize_012.test new file mode 100644 index 000000000..db3bb1745 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_012.test @@ -0,0 +1,47 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +outputfile="./inception_v3.one-quantize_012.q.circle" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test without input data +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--granularity channel \ +--quant_config one-quantize_012.qconf.json \ +--input_path ${inputfile} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-quantize_013.qconf.json b/compiler/one-cmds/tests/one-quantize_013.qconf.json new file mode 100644 index 000000000..4a15b04f5 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_013.qconf.json @@ -0,0 +1,16 @@ +{ + "default_quantization_dtype" : "uint8", + "default_granularity" : "channel", + "layers" : [ + { + "names" : ["InceptionV3/InceptionV3/Conv2d_2b_3x3/Relu;InceptionV3/InceptionV3/Conv2d_2b_3x3/BatchNorm/FusedBatchNorm;InceptionV3/InceptionV3/Mixed_6a/Branch_1/Conv2d_0a_1x1/Conv2D;InceptionV3/InceptionV3/Conv2d_2b_3x3/Conv2D", + "InceptionV3/InceptionV3/MaxPool_5a_3x3/MaxPool", + "InceptionV3/InceptionV3/Mixed_5b/concat", + "InceptionV3/InceptionV3/Mixed_5b/Branch_3/AvgPool_0a_3x3/AvgPool", + "InceptionV3/InceptionV3/Mixed_7c/concat", + "InceptionV3/Predictions/Reshape_1"], + "dtype" : "int16", + "granularity" : "channel" + } + ] +} diff --git a/compiler/one-cmds/tests/one-quantize_013.test b/compiler/one-cmds/tests/one-quantize_013.test new file mode 100644 index 000000000..0d985ff19 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_013.test @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# quantized_dtype and granularity are given by qconfig file +# (not by command line interface) + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +outputfile="./inception_v3.one-quantize_013.q.circle" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test without input data +# quantized_dtype and granularity are not given here +one-quantize \ +--input_dtype float32 \ +--quant_config one-quantize_013.qconf.json \ +--input_path ${inputfile} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-quantize_014.test b/compiler/one-cmds/tests/one-quantize_014.test new file mode 100644 index 000000000..40b79fafc --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_014.test @@ -0,0 +1,60 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Test if `circle-eval-diff` supports directory input. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +check_message() +{ + if grep -q "Mean Top-5 match ratio for InceptionV3/Predictions/Reshape_1 is" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + trap_err_onexit +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +outputfile="./inception_v3.one-quantize_014.q.circle" +datadir="./raw_files/" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--granularity channel \ +--input_path ${inputfile} \ +--input_data ${datadir} \ +--input_data_format dir \ +--output_path ${outputfile} \ +--evaluate_result \ +--test_data ${datadir} \ +--print_top5_match > ${filename}.log 2>&1 + +check_message diff --git a/compiler/one-cmds/tests/one-quantize_015.test b/compiler/one-cmds/tests/one-quantize_015.test new file mode 100644 index 000000000..a069601a3 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_015.test @@ -0,0 +1,46 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Test if --fake_quantize option works well + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.mat.q8.circle" +outputfile="./inception_v3.one-quantize_015.fq.circle" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test +one-quantize \ +--fake_quantize \ +--input_path ${inputfile} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-quantize_016.test b/compiler/one-cmds/tests/one-quantize_016.test new file mode 100644 index 000000000..cfebc2f1e --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_016.test @@ -0,0 +1,70 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +# TODO Resolve circledump not found +# https://github.com/Samsung/ONE/issues/10550 +if ! command -v circledump &> /dev/null +then + echo "${filename_ext} SKIPPED" + exit 0 +fi + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./reshape_matmul.circle" +outputfile="./reshape_matmul.one-quantize_016.circle" + +rm -f ${filename}.log +rm -f ${filename}.first.cdump +rm -f ${filename}.second.cdump +rm -f ${outputfile} + +# run test with different input_type +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--granularity channel \ +--input_type uint8,int16 \ +--input_path ${inputfile} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +circledump ${outputfile} | grep "T(0:0)" > ${filename}.first.cdump +circledump ${outputfile} | grep "T(0:1)" > ${filename}.second.cdump + +# check dtype of the first input (uint8) +if ! grep -q "UINT8" "${filename}.first.cdump"; then + trap_err_onexit +fi + +# check dtype of the second input (int16) +if ! grep -q "INT16" "${filename}.second.cdump"; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-quantize_017.test b/compiler/one-cmds/tests/one-quantize_017.test new file mode 100644 index 000000000..f4d3ee834 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_017.test @@ -0,0 +1,46 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./mobilenet_edgetpu_224_1.0_int8.circle" +outputfile="./mobilenet_edgetpu_224_1.0_int8.one-quantize_017.circle" + +rm -f ${filename}.log +rm -f ${outputfile} + +# run test +one-quantize \ +--requantize \ +--input_model_dtype int8 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-quantize_018.test b/compiler/one-cmds/tests/one-quantize_018.test new file mode 100644 index 000000000..dd609dda5 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_018.test @@ -0,0 +1,51 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# ampq test for bisection_type = 'i16_front' (front nodes will be quantized to int16) +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +outputfile="./inception_v3.q_opt.one-quantize_018.circle" +datafile="./inception_v3_test_data.h5" +bisection_type="i16_front" + +rm -f ${filename}.log +rm -f ${outputfile} + +# run test +one-quantize \ +--input_data ${datafile} \ +--input_path ${inputfile} \ +--ampq \ +--ampq_qerror_ratio "0.5" \ +--ampq_algorithm "bisection" \ +--bisection_type ${bisection_type} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-quantize_019.test b/compiler/one-cmds/tests/one-quantize_019.test new file mode 100644 index 000000000..3001fad4c --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_019.test @@ -0,0 +1,51 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# ampq test for bisection_type = 'i16_back' (output nodes will be quantized to int16) +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +outputfile="./inception_v3.q_opt.one-quantize_019.circle" +datafile="./inception_v3_test_data.h5" +bisection_type="i16_back" + +rm -f ${filename}.log +rm -f ${outputfile} + +# run test +one-quantize \ +--input_data ${datafile} \ +--input_path ${inputfile} \ +--ampq \ +--ampq_qerror_ratio "0.5" \ +--ampq_algorithm "bisection" \ +--bisection_type ${bisection_type} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-quantize_020.test b/compiler/one-cmds/tests/one-quantize_020.test new file mode 100644 index 000000000..5167295ee --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_020.test @@ -0,0 +1,51 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# ampq test with bisection_type set to auto +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +outputfile="./inception_v3.q_opt.one-quantize_020.circle" +datafile="./inception_v3_test_data.h5" +bisection_type="auto" + +rm -f ${filename}.log +rm -f ${outputfile} + +# run test +one-quantize \ +--input_data ${datafile} \ +--input_path ${inputfile} \ +--ampq \ +--ampq_qerror_ratio "0.5" \ +--ampq_algorithm "bisection" \ +--bisection_type ${bisection_type} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-quantize_021.test b/compiler/one-cmds/tests/one-quantize_021.test new file mode 100644 index 000000000..b6abc6682 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_021.test @@ -0,0 +1,47 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Test moving average parameters (moving average per Image) +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +outputfile="./inception_v3.one-quantize_021.circle" + +rm -f ${filename}.log +rm -f ${outputfile} + +# run test +one-quantize \ +--input_path ${inputfile} \ +--mode moving_average \ +--moving_avg_batch 1 \ +--moving_avg_const 0.01 \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/one-quantize_neg_001.test b/compiler/one-cmds/tests/one-quantize_neg_001.test new file mode 100644 index 000000000..dd2617f65 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_001.test @@ -0,0 +1,52 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with unsupported input dtype + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Unsupported input type" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +inputdata="./inception_v3_test_data.h5" +outputfile="./inception_v3.quantized.circle" + +rm -rf ${outputfile} +rm -f ${filename}.log + +# test begin + +one-quantize \ +--input_dtype float64 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ${inputdata} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-quantize_neg_002.test b/compiler/one-cmds/tests/one-quantize_neg_002.test new file mode 100644 index 000000000..c5ad693f7 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_002.test @@ -0,0 +1,51 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with unsupported input dtype + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Unsupported output type" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +inputdata="./inception_v3_test_data.h5" +outputfile="./inception_v3.quantized.circle" + +rm -rf ${outputfile} +rm -f ${filename}.log + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint16 \ +--input_path ${inputfile} \ +--input_data ${inputdata} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-quantize_neg_003.test b/compiler/one-cmds/tests/one-quantize_neg_003.test new file mode 100644 index 000000000..af2db72c5 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_003.test @@ -0,0 +1,50 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with wrong representative dataset + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Buffer size does not match" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +outputfile="./inception_v3.quantized.circle" + +rm -rf ${outputfile} +rm -f ${filename}.log + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ./mobilenet_test_data.h5 \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-quantize_neg_004.test b/compiler/one-cmds/tests/one-quantize_neg_004.test new file mode 100644 index 000000000..eb50564e7 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_004.test @@ -0,0 +1,50 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid output path + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Failed to export" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +inputdata="./inception_v3_test_data.h5" +outputfile="." + +rm -f ${filename}.log + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ${inputdata} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-quantize_neg_005.test b/compiler/one-cmds/tests/one-quantize_neg_005.test new file mode 100644 index 000000000..6f5f489dc --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_005.test @@ -0,0 +1,50 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid input path + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Invalid input file" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./while_3.pbtxt" +inputdata="./inception_v3_test_data.h5" +outputfile="./inception_v3.quantized.circle" + +rm -f ${filename}.log + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ${inputdata} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-quantize_neg_006.test b/compiler/one-cmds/tests/one-quantize_neg_006.test new file mode 100644 index 000000000..f5c965f85 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_006.test @@ -0,0 +1,50 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid input path + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Failed to open file: ./inception_v2.circle" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v2.circle" +inputdata="./inception_v3_test_data.h5" +outputfile="./inception_v3.quantized.circle" + +rm -f ${filename}.log + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ${inputdata} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-quantize_neg_007.test b/compiler/one-cmds/tests/one-quantize_neg_007.test new file mode 100644 index 000000000..50b549524 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_007.test @@ -0,0 +1,50 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid input_data + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Given data file is not HDF5" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +inputdata="./inception_v3.circle" +outputfile="./inception_v3.quantized.circle" + +rm -f ${filename}.log + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ${inputdata} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-quantize_neg_008.test b/compiler/one-cmds/tests/one-quantize_neg_008.test new file mode 100644 index 000000000..f2675f421 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_008.test @@ -0,0 +1,51 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid mode + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Unsupported mode" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +inputdata="./inception_v3_test_data.h5" +outputfile="./inception_v3.quantized.circle" + +rm -f ${filename}.log + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ${inputdata} \ +--mode average \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-quantize_neg_009.test b/compiler/one-cmds/tests/one-quantize_neg_009.test new file mode 100644 index 000000000..21901609e --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_009.test @@ -0,0 +1,51 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid max_percentile + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Percentile must be ranged from" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +inputdata="./inception_v3_test_data.h5" +outputfile="./inception_v3.quantized.circle" + +rm -f ${filename}.log + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ${inputdata} \ +--max_percentile 101 \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-quantize_neg_010.test b/compiler/one-cmds/tests/one-quantize_neg_010.test new file mode 100644 index 000000000..bd7c0dd6e --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_010.test @@ -0,0 +1,51 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid max_percentile + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Percentile must be ranged from" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +inputdata="./inception_v3_test_data.h5" +outputfile="./inception_v3.quantized.circle" + +rm -f ${filename}.log + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ${inputdata} \ +--max_percentile -1 \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-quantize_neg_011.test b/compiler/one-cmds/tests/one-quantize_neg_011.test new file mode 100644 index 000000000..14552f09a --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_011.test @@ -0,0 +1,51 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid min_percentile + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Percentile must be ranged from" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +inputdata="./inception_v3_test_data.h5" +outputfile="./inception_v3.quantized.circle" + +rm -f ${filename}.log + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ${inputdata} \ +--min_percentile 101 \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-quantize_neg_012.test b/compiler/one-cmds/tests/one-quantize_neg_012.test new file mode 100644 index 000000000..963783c82 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_012.test @@ -0,0 +1,51 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid min_percentile + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Percentile must be ranged from" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +inputdata="./inception_v3_test_data.h5" +outputfile="./inception_v3.quantized.circle" + +rm -f ${filename}.log + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ${inputdata} \ +--min_percentile -1 \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-quantize_neg_013.test b/compiler/one-cmds/tests/one-quantize_neg_013.test new file mode 100644 index 000000000..4b81c8706 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_013.test @@ -0,0 +1,51 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid min_percentile + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Unsupported granularity" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +inputdata="./inception_v3_test_data.h5" +outputfile="./inception_v3.quantized.circle" + +rm -f ${filename}.log + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ${inputdata} \ +--granularity layered \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-quantize_neg_014.test b/compiler/one-cmds/tests/one-quantize_neg_014.test new file mode 100644 index 000000000..911537097 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_014.test @@ -0,0 +1,52 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid min_percentile + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Given data file is not HDF5" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +inputdata="./datalist.txt" +outputfile="./inception_v3.quantized.circle" + +rm -f ${filename}.log + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ${inputdata} \ +--input_data_format h5 \ +--granularity channel \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-quantize_neg_015.test b/compiler/one-cmds/tests/one-quantize_neg_015.test new file mode 100644 index 000000000..1acb20fae --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_015.test @@ -0,0 +1,52 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid min_percentile + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Cannot open file" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +inputdata="./inception_v3_test_data.h5" +outputfile="./inception_v3.quantized.circle" + +rm -f ${filename}.log + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ${inputdata} \ +--input_data_format list \ +--granularity channel \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-quantize_neg_016.test b/compiler/one-cmds/tests/one-quantize_neg_016.test new file mode 100644 index 000000000..b419ff528 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_016.test @@ -0,0 +1,52 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid min_percentile + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Unsupported input data format" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +inputdata="./datalist.txt" +outputfile="./inception_v3.quantized.circle" + +rm -f ${filename}.log + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ${inputdata} \ +--input_data_format h5list \ +--granularity channel \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-quantize_neg_017.test b/compiler/one-cmds/tests/one-quantize_neg_017.test new file mode 100644 index 000000000..5326f18d5 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_017.test @@ -0,0 +1,52 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid min_percentile + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Cannot open directory" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +inputdata="./inception_v3_test_data.h5" +outputfile="./inception_v3.quantized.circle" + +rm -f ${filename}.log + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ${inputdata} \ +--input_data_format directory \ +--granularity channel \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-quantize_neg_018.test b/compiler/one-cmds/tests/one-quantize_neg_018.test new file mode 100644 index 000000000..6470efcc7 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_018.test @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid min_percentile + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "following arguments are required: --zero_point" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.mat.q8.circle" +outputfile="./inception_v3.neg_018.q8.circle" + +rm -f ${filename}.log + +# run test +one-quantize \ +--force_quantparam \ +--tensor_name input \ +--scale 2.3 \ +--input_path ${inputfile} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-quantize_neg_019.test b/compiler/one-cmds/tests/one-quantize_neg_019.test new file mode 100644 index 000000000..9f6e35f4a --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_019.test @@ -0,0 +1,50 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with invalid min_percentile + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Unsupported input type" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +outputfile="./inception_v3.quantized.neg_019.circle" + +rm -f ${filename}.log + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype int16 \ +--granularity channel \ +--input_type float64 \ +--input_path ${inputfile} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-quantize_neg_020.test b/compiler/one-cmds/tests/one-quantize_neg_020.test new file mode 100644 index 000000000..46a4f9d19 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_020.test @@ -0,0 +1,48 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# check error message is printed when qconfig file is not json + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Failed to decode" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +outputfile="./inception_v3.quantized.neg_020.circle" + +rm -f ${filename}.log + +# run test +one-quantize \ +--input_dtype float32 \ +--quant_config one-quantize_neg_020.test \ +--input_path ${inputfile} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-quantize_neg_021.test b/compiler/one-cmds/tests/one-quantize_neg_021.test new file mode 100644 index 000000000..31a3182ba --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_021.test @@ -0,0 +1,50 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Wrong number of input_type in one-quantize + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Invalid number of input dtype" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./reshape_matmul.circle" +outputfile="./reshape_matmul.quantized.neg_021.circle" + +rm -f ${filename}.log + +# run test with wrong number of input_type +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--granularity channel \ +--input_type uint8,int16,uint8 \ +--input_path ${inputfile} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-quantize_neg_022.test b/compiler/one-cmds/tests/one-quantize_neg_022.test new file mode 100644 index 000000000..519394175 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_022.test @@ -0,0 +1,48 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Wrong number of input_type in one-quantize + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "following arguments are required: --input_model_dtype" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./mobilenet_edgetpu_224_1.0_int8.circle" +outputfile="./mobilenet_edgetpu_224_1.0_int8.one-quantize_neg_022.circle" + +rm -f ${filename}.log + +# run test with wrong input model dtype +one-quantize \ +--requantize \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/one-quantize_neg_023.test b/compiler/one-cmds/tests/one-quantize_neg_023.test new file mode 100644 index 000000000..7ed97c18c --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_023.test @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Wrong type of calibration parameter + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "moving_avg_batch must be integer" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +outputfile="./inception_v3.one-quantize_neg_023.circle" + +rm -f ${filename}.log + +# run test with wrong parameter dtype +# moving_avg_batch must be integer +one-quantize \ +--input_path ${inputfile} \ +--mode moving_average \ +--moving_avg_batch 0.1 \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_001.cfg b/compiler/one-cmds/tests/onecc_001.cfg new file mode 100644 index 000000000..f33101074 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_001.cfg @@ -0,0 +1,20 @@ +[onecc] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=True +one-quantize=False +one-pack=False +one-codegen=False + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.onecc_001.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v2 + +[one-optimize] +input_path=inception_v3.onecc_001.circle +output_path=inception_v3.opt.circle diff --git a/compiler/one-cmds/tests/onecc_001.test b/compiler/one-cmds/tests/onecc_001.test new file mode 100644 index 000000000..73fbdd6f7 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_001.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import-tf -> one-optimize + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_001.cfg" +outputfile="inception_v3.opt.circle" + +rm -f ${filename}.log +rm -f ${outputfile} + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_002.cfg b/compiler/one-cmds/tests/onecc_002.cfg new file mode 100644 index 000000000..0338ccb33 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_002.cfg @@ -0,0 +1,24 @@ +[onecc] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=True +one-quantize=False +one-pack=True +one-codegen=False + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.onecc_002.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v2 + +[one-optimize] +input_path=inception_v3.onecc_002.circle +output_path=inception_v3.opt.circle + +[one-pack] +input_path=inception_v3.opt.circle +output_path=inception_v3_pkg diff --git a/compiler/one-cmds/tests/onecc_002.test b/compiler/one-cmds/tests/onecc_002.test new file mode 100644 index 000000000..f154f66d0 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_002.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import-tf -> one-optimize -> one-pack + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_002.cfg" +outputfile="inception_v3_pkg" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_003.cfg b/compiler/one-cmds/tests/onecc_003.cfg new file mode 100644 index 000000000..da5c73e11 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_003.cfg @@ -0,0 +1,21 @@ +[onecc] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=False +one-quantize=True +one-pack=False +one-codegen=False + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.onecc_003.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v1 + +[one-quantize] +input_path=inception_v3.onecc_003.circle +output_path=inception_v3.quantized.circle +input_data=inception_v3_test_data.h5 diff --git a/compiler/one-cmds/tests/onecc_003.test b/compiler/one-cmds/tests/onecc_003.test new file mode 100644 index 000000000..140a99f6b --- /dev/null +++ b/compiler/one-cmds/tests/onecc_003.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import-tf -> one-quantize + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_003.cfg" +outputfile="inception_v3.quantized.circle" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_004.cfg b/compiler/one-cmds/tests/onecc_004.cfg new file mode 100644 index 000000000..e155430f2 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_004.cfg @@ -0,0 +1,20 @@ +[onecc] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=False +one-quantize=False +one-pack=False +one-codegen=True + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.onecc_004.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v1 + +[one-codegen] +backend=dummy +command=-o sample.tvn inception_v3.onecc_004.circle diff --git a/compiler/one-cmds/tests/onecc_004.test b/compiler/one-cmds/tests/onecc_004.test new file mode 100644 index 000000000..b532d190b --- /dev/null +++ b/compiler/one-cmds/tests/onecc_004.test @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import-tf -> one-codegen + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-compile + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_004.cfg" +outputfile="sample.tvn" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# copy dummy-compile to bin folder +cp dummy-compile ../bin/dummy-compile + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +rm -rf ../bin/dummy-compile + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_005.cfg b/compiler/one-cmds/tests/onecc_005.cfg new file mode 100644 index 000000000..ff4ed84f1 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_005.cfg @@ -0,0 +1,20 @@ +[onecc] +one-import-tf=False +one-import-tflite=True +one-import-bcq=False +one-optimize=True +one-quantize=False +one-pack=False +one-codegen=True + +[one-import-tflite] +input_path=inception_v3.tflite +output_path=inception_v3.onecc_005.circle + +[one-optimize] +input_path=inception_v3.onecc_005.circle +output_path=inception_v3.opt.circle + +[one-codegen] +backend=dummy +command=-o sample.tvn inception_v3.opt.circle diff --git a/compiler/one-cmds/tests/onecc_005.test b/compiler/one-cmds/tests/onecc_005.test new file mode 100644 index 000000000..48c81e518 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_005.test @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import-tflite -> one-optimize -> one-codgen + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-compile + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_005.cfg" +outputfile="sample.tvn" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# copy dummy-compile to bin folder +cp dummy-compile ../bin/dummy-compile + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +rm -rf ../bin/dummy-compile + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_006.cfg b/compiler/one-cmds/tests/onecc_006.cfg new file mode 100644 index 000000000..dd58e6bca --- /dev/null +++ b/compiler/one-cmds/tests/onecc_006.cfg @@ -0,0 +1,29 @@ +[onecc] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=True +one-quantize=True +one-pack=False +one-codegen=True + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.onecc_006.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v1 + +[one-optimize] +input_path=inception_v3.onecc_006.circle +output_path=inception_v3.opt.circle + +[one-quantize] +input_path=inception_v3.opt.circle +output_path=inception_v3.quantized.circle +input_data=inception_v3_test_data.h5 + +[one-codegen] +backend=dummy +command=-o sample.tvn inception_v3.quantized.circle diff --git a/compiler/one-cmds/tests/onecc_006.test b/compiler/one-cmds/tests/onecc_006.test new file mode 100644 index 000000000..451d34f8e --- /dev/null +++ b/compiler/one-cmds/tests/onecc_006.test @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import-tf -> one-optimize -> one-quantize -> one-codegen + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-compile + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_006.cfg" +outputfile="sample.tvn" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# copy dummy-compile to bin folder +cp dummy-compile ../bin/dummy-compile + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +rm -rf ../bin/dummy-compile + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_007.cfg b/compiler/one-cmds/tests/onecc_007.cfg new file mode 100644 index 000000000..2d3ecac09 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_007.cfg @@ -0,0 +1,29 @@ +[onecc] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=False +one-quantize=True +one-pack=True +one-codegen=False + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.onecc_007.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v1 + +[one-optimize] +input_path=inception_v3.onecc_007.circle +output_path=inception_v3.opt.circle + +[one-quantize] +input_path=inception_v3.opt.circle +output_path=inception_v3.quantized.circle +input_data=inception_v3_test_data.h5 + +[one-pack] +input_path=inception_v3.quantized.circle +output_path=inception_v3_pkg diff --git a/compiler/one-cmds/tests/onecc_007.test b/compiler/one-cmds/tests/onecc_007.test new file mode 100644 index 000000000..ee3c262ba --- /dev/null +++ b/compiler/one-cmds/tests/onecc_007.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import-tf -> one-optimize -> one-quantize -> one-pack + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_007.cfg" +outputfile="inception_v3_pkg" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_008.cfg b/compiler/one-cmds/tests/onecc_008.cfg new file mode 100644 index 000000000..020e274e1 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_008.cfg @@ -0,0 +1,22 @@ +[onecc] +one-import-tf=False +one-import-tflite=False +one-import-bcq=False +one-import-onnx=True +one-optimize=True +one-quantize=False +one-pack=False +one-codegen=True + +[one-import-onnx] +input_path=test_onnx_model.onnx +output_path=test_onnx_model.circle + +[one-optimize] +input_path=test_onnx_model.circle +output_path=test_onnx_model.opt.circle +remove_redundant_transpose=True + +[one-codegen] +backend=dummy +command=-o test_onnx_model.bin test_onnx_model.opt.circle diff --git a/compiler/one-cmds/tests/onecc_008.test b/compiler/one-cmds/tests/onecc_008.test new file mode 100644 index 000000000..f2d25f1d4 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_008.test @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import-tf -> one-optimize -> one-quantize -> one-codegen + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-compile + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_008.cfg" +outputfile="test_onnx_model.bin" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# copy dummy-compile to bin folder +cp dummy-compile ../bin/dummy-compile + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +rm -rf ../bin/dummy-compile + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_009.cfg b/compiler/one-cmds/tests/onecc_009.cfg new file mode 100644 index 000000000..86121c557 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_009.cfg @@ -0,0 +1,23 @@ +[onecc] +one-import-tf=False +one-import-tflite=False +one-import-bcq=False +one-import-onnx=True +one-optimize=True +one-quantize=False +one-pack=False +one-codegen=True + +[one-import-onnx] +input_path=onnx_conv2d_conv2d.onnx +output_path=onnx_conv2d_conv2d.circle + +[one-optimize] +input_path=onnx_conv2d_conv2d.circle +output_path=onnx_conv2d_conv2d.opt.circle +remove_redundant_transpose=True +convert_nchw_to_nhwc=True + +[one-codegen] +backend=dummy +command=-o onnx_conv2d_conv2d.bin onnx_conv2d_conv2d.opt.circle diff --git a/compiler/one-cmds/tests/onecc_009.test b/compiler/one-cmds/tests/onecc_009.test new file mode 100644 index 000000000..0b4537e02 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_009.test @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import-onnx -> one-optimize -> one-codegen + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-compile + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_009.cfg" +outputfile="onnx_conv2d_conv2d.bin" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# copy dummy-compile to bin folder +cp dummy-compile ../bin/dummy-compile + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +rm -rf ../bin/dummy-compile + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_010.cfg b/compiler/one-cmds/tests/onecc_010.cfg new file mode 100644 index 000000000..d9f2a3d83 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_010.cfg @@ -0,0 +1,17 @@ +[onecc] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=False +one-quantize=False +one-pack=False +one-codegen=False + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.alt.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v1 +save_intermediate=True diff --git a/compiler/one-cmds/tests/onecc_010.test b/compiler/one-cmds/tests/onecc_010.test new file mode 100644 index 000000000..85192ed26 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_010.test @@ -0,0 +1,48 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import-tf: intermediate file should exist + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_010.cfg" +outputfile="inception_v3.alt.circle" +intermfile="inception_v3.alt.tflite" + +rm -f ${filename}.log +rm -rf ${outputfile} +rm -rf ${intermfile} + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi +if [[ ! -s "${intermfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_011.cfg b/compiler/one-cmds/tests/onecc_011.cfg new file mode 100644 index 000000000..aa9457f09 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_011.cfg @@ -0,0 +1,14 @@ +[onecc] +one-import-tf=False +one-import-tflite=False +one-import-bcq=False +one-import-onnx=True +one-optimize=False +one-quantize=False +one-pack=False +one-codegen=False + +[one-import-onnx] +input_path=test_onnx_model.onnx +output_path=test_onnx_model.circle +save_intermediate=True diff --git a/compiler/one-cmds/tests/onecc_011.test b/compiler/one-cmds/tests/onecc_011.test new file mode 100644 index 000000000..eeb59b4b9 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_011.test @@ -0,0 +1,48 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import-onnx + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_011.cfg" +outputfile="test_onnx_model.circle" +intermfile="test_onnx_model.tflite" + +rm -f ${filename}.log +rm -rf ${outputfile} +rm -rf ${intermfile} + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi +if [[ ! -s "${intermfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_012.cfg b/compiler/one-cmds/tests/onecc_012.cfg new file mode 100644 index 000000000..92f61a14c --- /dev/null +++ b/compiler/one-cmds/tests/onecc_012.cfg @@ -0,0 +1,22 @@ +[onecc] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=False +one-quantize=True +one-pack=False +one-codegen=False + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.onecc_012.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v1 + +[one-quantize] +input_path=inception_v3.onecc_012.circle +output_path=inception_v3.list.quantized.circle +input_data=datalist.txt +input_data_format=list diff --git a/compiler/one-cmds/tests/onecc_012.test b/compiler/one-cmds/tests/onecc_012.test new file mode 100644 index 000000000..f5abe94ca --- /dev/null +++ b/compiler/one-cmds/tests/onecc_012.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import-tf -> one-quantize + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_012.cfg" +outputfile="inception_v3.list.quantized.circle" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_013.cfg b/compiler/one-cmds/tests/onecc_013.cfg new file mode 100644 index 000000000..4ed687168 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_013.cfg @@ -0,0 +1,7 @@ +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.onecc_13.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v1 diff --git a/compiler/one-cmds/tests/onecc_013.test b/compiler/one-cmds/tests/onecc_013.test new file mode 100644 index 000000000..bca0cbefc --- /dev/null +++ b/compiler/one-cmds/tests/onecc_013.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import {tf} with config file + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_013.cfg" +outputfile="inception_v3.onecc_13.circle" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test +onecc import tf -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_014.cfg b/compiler/one-cmds/tests/onecc_014.cfg new file mode 100644 index 000000000..8478be756 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_014.cfg @@ -0,0 +1,7 @@ +[one-import-tflite] +input_path=inception_v3.tflite +output_path=inception_v3.onecc_014.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v1 diff --git a/compiler/one-cmds/tests/onecc_014.test b/compiler/one-cmds/tests/onecc_014.test new file mode 100644 index 000000000..3e93a69ab --- /dev/null +++ b/compiler/one-cmds/tests/onecc_014.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import {tflite} with config file + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_014.cfg" +outputfile="inception_v3.onecc_014.circle" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test +onecc import tflite -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_015.cfg b/compiler/one-cmds/tests/onecc_015.cfg new file mode 100644 index 000000000..7abfa7d86 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_015.cfg @@ -0,0 +1,5 @@ +[one-import-bcq] +input_path=bcq.pb +output_path=bcq.circle +input_arrays=Placeholder +output_arrays=MatMul diff --git a/compiler/one-cmds/tests/onecc_015.test b/compiler/one-cmds/tests/onecc_015.test new file mode 100644 index 000000000..d92bf78a4 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_015.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import {bcq} with config file + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_015.cfg" +outputfile="bcq.circle" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test +onecc import bcq -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_016.cfg b/compiler/one-cmds/tests/onecc_016.cfg new file mode 100644 index 000000000..ea0110bf9 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_016.cfg @@ -0,0 +1,3 @@ +[one-import-onnx] +input_path=test_onnx_model.onnx +output_path=test_onnx_model.circle diff --git a/compiler/one-cmds/tests/onecc_016.test b/compiler/one-cmds/tests/onecc_016.test new file mode 100644 index 000000000..09e514375 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_016.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import {onnx} with config file + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_016.cfg" +outputfile="test_onnx_model.circle" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test +onecc import onnx -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_017.test b/compiler/one-cmds/tests/onecc_017.test new file mode 100644 index 000000000..359a6e7ce --- /dev/null +++ b/compiler/one-cmds/tests/onecc_017.test @@ -0,0 +1,48 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-optimize + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="inception_v3.circle" +outputfile="inception_v3.opt.circle" + +if [[ ! -s "${inputfile}" ]]; then + echo "${filename_ext} ERROR: Missing inputfile" + trap_err_onexit +fi + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test +onecc optimize -i ${inputfile} -o ${outputfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_018.test b/compiler/one-cmds/tests/onecc_018.test new file mode 100644 index 000000000..cd2ac599a --- /dev/null +++ b/compiler/one-cmds/tests/onecc_018.test @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-quantize + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="inception_v3.opt.circle" +inputdata="inception_v3_test_data.h5" +outputfile="inception_v3.quantized.circle" + +if [[ ! -s "${inputfile}" && ! -s "${inputdata}" ]]; then + echo "${filename_ext} ERROR: Missing inputfile" + trap_err_onexit +fi + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test +onecc quantize -i ${inputfile} -o ${outputfile} -d ${inputdata} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_019.test b/compiler/one-cmds/tests/onecc_019.test new file mode 100644 index 000000000..23e0e3fa5 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_019.test @@ -0,0 +1,48 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-pack + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="inception_v3.quantized.circle" +outputfile="inception_v3_pkg" + +if [[ ! -s "${inputfile}" ]]; then + echo "${filename_ext} ERROR: Missing inputfile" + trap_err_onexit +fi + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test +onecc pack -i ${inputfile} -o ${outputfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_020.test b/compiler/one-cmds/tests/onecc_020.test new file mode 100644 index 000000000..d914e9b28 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_020.test @@ -0,0 +1,54 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-codegen + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="sample.circle" +outputfile="sample.dummy" + +# prepare dummy file +touch ${inputfile} + +if [[ ! -f "${inputfile}" ]]; then + echo "${filename_ext} ERROR: Missing inputfile" + trap_err_onexit +fi + +rm -f ${filename}.log +rm -rf ${outputfile} + +# copy dummy-compile to bin folder +cp dummy-compile ../bin/dummy-compile + +# run test +onecc codegen -b dummy -o ${outputfile} ${inputfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_021.cfg b/compiler/one-cmds/tests/onecc_021.cfg new file mode 100644 index 000000000..e2d3e6bd8 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_021.cfg @@ -0,0 +1,14 @@ +[onecc] +one-import-tf=False +one-import-tflite=False +one-import-bcq=False +one-import-onnx=False +one-optimize=False +one-quantize=False +one-pack=False +one-codegen=False +one-profile=True + +[one-profile] +backend=dummy +command=test_onnx_model.bin diff --git a/compiler/one-cmds/tests/onecc_021.test b/compiler/one-cmds/tests/onecc_021.test new file mode 100644 index 000000000..85e9aa70d --- /dev/null +++ b/compiler/one-cmds/tests/onecc_021.test @@ -0,0 +1,48 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-profile + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-profile + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_021.cfg" + +# copy dummy-profile to bin folder +cp dummy-profile ../bin/dummy-profile + +rm -f ${filename}.log + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +rm -rf ../bin/dummy-profile + +if grep -q "dummy-profile dummy output!!!" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 +fi + +trap_err_onexit diff --git a/compiler/one-cmds/tests/onecc_022.cfg b/compiler/one-cmds/tests/onecc_022.cfg new file mode 100644 index 000000000..9741d5173 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_022.cfg @@ -0,0 +1,18 @@ +[onecc] +one-import-tf=False +one-import-tflite=False +one-import-bcq=False +one-import-onnx=False +one-optimize=False +one-quantize=True +one-pack=False +one-codegen=False +one-profile=False + +[one-quantize] +input_path=inception_v3.mat.q8.circle +output_path=inception_v3.onecc_022.q8.circle +force_quantparam=True +tensor_name=input +scale=2.1 +zero_point=45 diff --git a/compiler/one-cmds/tests/onecc_022.test b/compiler/one-cmds/tests/onecc_022.test new file mode 100644 index 000000000..6f5d565be --- /dev/null +++ b/compiler/one-cmds/tests/onecc_022.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-quantize + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_022.cfg" +outputfile="inception_v3.onecc_022.q8.circle" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_023.cfg b/compiler/one-cmds/tests/onecc_023.cfg new file mode 100644 index 000000000..edbcc6f78 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_023.cfg @@ -0,0 +1,15 @@ +[onecc] +one-import-tf=False +one-import-tflite=False +one-import-bcq=False +one-optimize=False +one-quantize=True +one-pack=False +one-codegen=False + +[one-quantize] +input_path=inception_v3.circle +output_path=inception_v3.onecc_023.q16.iq8.circle +quantized_dtype=int16 +granularity=channel +input_type=uint8 diff --git a/compiler/one-cmds/tests/onecc_023.test b/compiler/one-cmds/tests/onecc_023.test new file mode 100644 index 000000000..9448f4094 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_023.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import-tf -> one-quantize + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_023.cfg" +outputfile="inception_v3.onecc_023.q16.iq8.circle" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_024.cfg b/compiler/one-cmds/tests/onecc_024.cfg new file mode 100644 index 000000000..053758fef --- /dev/null +++ b/compiler/one-cmds/tests/onecc_024.cfg @@ -0,0 +1,22 @@ +[onecc] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-import-onnx=False +one-optimize=True +one-quantize=False +one-pack=False +one-codegen=False + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.onecc_024.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v1 + +[one-optimize] +input_path=inception_v3.onecc_024.circle +output_path=inception_v3.opt.circle +make_batchnorm_gamma_positive=False diff --git a/compiler/one-cmds/tests/onecc_024.test b/compiler/one-cmds/tests/onecc_024.test new file mode 100644 index 000000000..d1e1d92c8 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_024.test @@ -0,0 +1,78 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Use `OONECC_024` optimization option + +: ' +This test assumes below directories. + +[one hierarchy] + one + ├── backends + ├── bin + ├── doc + ├── include + ├── lib + ├── optimization + └── test # pwd +' + +OPT_ALREADY_EXIST=true + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +clean_envir() +{ + rm -rf ../optimization/OONECC_024.cfg + if [ "$OPT_ALREADY_EXIST" = false ]; then + rm -rf ../optimization + fi +} + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + clean_envir + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_024.cfg" +outputfile="inception_v3.opt.circle" + +rm -f ${filename}.log +rm -rf ${outputfile} + +if [ ! -d "../optimization" ]; then + mkdir -p ../optimization + OPT_ALREADY_EXIST=false +fi + +cp OONECC_024.cfg ../optimization + +# run test +LUCI_LOG=5 onecc -C ${configfile} -OONECC_024 > ${filename}.log 2>&1 + +clean_envir + +if ! grep -q "MakeBatchNormGammaPositivePass" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 +fi + +trap_err_onexit diff --git a/compiler/one-cmds/tests/onecc_025.cfg b/compiler/one-cmds/tests/onecc_025.cfg new file mode 100644 index 000000000..02e54b0d7 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_025.cfg @@ -0,0 +1,20 @@ +[onecc] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=True +one-quantize=False +one-pack=False +one-codegen=False + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.onecc_025.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v2 + +[one-optimize] +input_path=inception_v3.onecc_025.circle +output_path=inception_v3.opt.circle diff --git a/compiler/one-cmds/tests/onecc_025.test b/compiler/one-cmds/tests/onecc_025.test new file mode 100644 index 000000000..fff944088 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_025.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-import-tf -> one-optimize with the configuration file that includes `onecc` section + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_001.cfg" +outputfile="inception_v3.opt.circle" + +rm -f ${filename}.log +rm -f ${outputfile} + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_026.cfg b/compiler/one-cmds/tests/onecc_026.cfg new file mode 100644 index 000000000..c27a13654 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_026.cfg @@ -0,0 +1,16 @@ +[onecc] +one-import-tf=False +one-import-tflite=False +one-import-bcq=False +one-optimize=False +one-quantize=True +one-pack=False +one-codegen=False + +[one-quantize] +input_path=inception_v3.circle +output_path=inception_v3.onecc_026.q.circle +input_data=inception_v3_test_data.h5 +evaluate_result=True +test_data=inception_v3_test_data.h5 +print_mpeir=True diff --git a/compiler/one-cmds/tests/onecc_026.test b/compiler/one-cmds/tests/onecc_026.test new file mode 100644 index 000000000..cd09e1102 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_026.test @@ -0,0 +1,47 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +check_message() +{ + if grep -q "MPEIR for InceptionV3/Predictions/Reshape_1 is" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + trap_err_onexit +} + +trap trap_err_onexit ERR + +configfile="onecc_026.cfg" +outputfile="inception_v3.onecc_026.q.circle" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +check_message diff --git a/compiler/one-cmds/tests/onecc_027.cfg b/compiler/one-cmds/tests/onecc_027.cfg new file mode 100644 index 000000000..1b9a2b90b --- /dev/null +++ b/compiler/one-cmds/tests/onecc_027.cfg @@ -0,0 +1,15 @@ +[onecc] +one-import-tf=False +one-import-tflite=False +one-import-bcq=False +one-import-onnx=False +one-optimize=False +one-quantize=False +one-pack=False +one-codegen=False +one-profile=False +one-infer=True + +[one-infer] +driver=dummy-infer +command=test_onnx_model.bin diff --git a/compiler/one-cmds/tests/onecc_027.test b/compiler/one-cmds/tests/onecc_027.test new file mode 100644 index 000000000..54f0d2535 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_027.test @@ -0,0 +1,48 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-infer + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-profile + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_027.cfg" + +# copy dummy-infer to bin folder +cp dummy-infer ../bin/dummy-infer + +rm -f ${filename}.log + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +rm -rf ../bin/dummy-infer + +if grep -q "dummy-infer dummy output!!!" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 +fi + +trap_err_onexit diff --git a/compiler/one-cmds/tests/onecc_028.test b/compiler/one-cmds/tests/onecc_028.test new file mode 100644 index 000000000..ea2357941 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_028.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# run a workflow where one-import-tf -> one-optimize -> one-pack + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +workflowfile="onecc_028.workflow.json" +outputfile="inception_v3_pkg" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test +onecc -W ${workflowfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_028.workflow.json b/compiler/one-cmds/tests/onecc_028.workflow.json new file mode 100644 index 000000000..983648273 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_028.workflow.json @@ -0,0 +1,37 @@ +{ + "workflows": [ + "MY_WORKFLOW" + ], + "MY_WORKFLOW": { + "steps": [ + "IMPORT_TF", + "OPTIMIZE", + "PACK" + ], + "IMPORT_TF": { + "one-cmd": "one-import-tf", + "commands": { + "input_path": "inception_v3.pb", + "output_path": "inception_v3.onecc_028.circle", + "input_arrays": "input", + "input_shapes": "1,299,299,3", + "output_arrays": "InceptionV3/Predictions/Reshape_1", + "converter_version": "v2" + } + }, + "OPTIMIZE": { + "one-cmd": "one-optimize", + "commands": { + "input_path": "inception_v3.onecc_028.circle", + "output_path": "inception_v3.opt.circle" + } + }, + "PACK": { + "one-cmd": "one-pack", + "commands": { + "input_path": "inception_v3.opt.circle", + "output_path": "inception_v3_pkg" + } + } + } +} diff --git a/compiler/one-cmds/tests/onecc_029.test b/compiler/one-cmds/tests/onecc_029.test new file mode 100644 index 000000000..9fb0ec34e --- /dev/null +++ b/compiler/one-cmds/tests/onecc_029.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# run a workflow where one-import-tf -> one-quantize + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +workflowfile="onecc_029.workflow.json" +outputfile="inception_v3.quantized.circle" + +rm -rf ${outputfile} +rm -f ${filename}.log + +# run test +onecc -W ${workflowfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_029.workflow.json b/compiler/one-cmds/tests/onecc_029.workflow.json new file mode 100644 index 000000000..826888d19 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_029.workflow.json @@ -0,0 +1,30 @@ +{ + "workflows": [ + "QUANTIZE_WORKFLOW" + ], + "QUANTIZE_WORKFLOW": { + "steps": [ + "IMPORT_TF", + "QUANTIZE" + ], + "IMPORT_TF": { + "one-cmd": "one-import-tf", + "commands": { + "input_path": "inception_v3.pb", + "output_path": "inception_v3.onecc_029.circle", + "input_arrays": "input", + "input_shapes": "1,299,299,3", + "output_arrays": "InceptionV3/Predictions/Reshape_1", + "converter_version": "v2" + } + }, + "QUANTIZE": { + "one-cmd": "one-quantize", + "commands": { + "input_path": "inception_v3.onecc_029.circle", + "output_path": "inception_v3.quantized.circle", + "input_data": "inception_v3_test_data.h5" + } + } + } +} diff --git a/compiler/one-cmds/tests/onecc_030.test b/compiler/one-cmds/tests/onecc_030.test new file mode 100644 index 000000000..88f0ab884 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_030.test @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# run a workflow where one-import-tf -> one-codegen + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-compile + exit 255 +} + +trap trap_err_onexit ERR + +workflowfile="onecc_030.workflow.json" +outputfile="sample.tvn" + +rm -rf ${outputfile} +rm -f ${filename}.log + +# copy dummy-compile to bin folder +cp dummy-compile ../bin/dummy-compile + +# run test +onecc -W ${workflowfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +rm -rf ../bin/dummy-compile + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_030.workflow.json b/compiler/one-cmds/tests/onecc_030.workflow.json new file mode 100644 index 000000000..e4a2467a2 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_030.workflow.json @@ -0,0 +1,29 @@ +{ + "workflows": [ + "codegen_wf" + ], + "codegen_wf": { + "steps": [ + "import_tf", + "codegen" + ], + "import_tf": { + "one-cmd": "one-import-tf", + "commands": { + "input_path": "inception_v3.pb", + "output_path": "inception_v3.onecc_030.circle", + "input_arrays": "input", + "input_shapes": "1,299,299,3", + "output_arrays": "InceptionV3/Predictions/Reshape_1", + "converter_version": "v2" + } + }, + "codegen": { + "one-cmd": "one-codegen", + "commands": { + "backend": "dummy", + "command": "-o sample.tvn inception_v3.onecc_030.circle" + } + } + } +} diff --git a/compiler/one-cmds/tests/onecc_031.test b/compiler/one-cmds/tests/onecc_031.test new file mode 100644 index 000000000..33c9664ad --- /dev/null +++ b/compiler/one-cmds/tests/onecc_031.test @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# run a workflow where one-import-tflite -> one-optimize -> one-codgen + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-compile + exit 255 +} + +trap trap_err_onexit ERR + +workflowfile="onecc_031.workflow.json" +outputfile="sample.tvn" + +rm -rf ${outputfile} +rm -f ${filename}.log + +# copy dummy-compile to bin folder +cp dummy-compile ../bin/dummy-compile + +# run test +onecc -W ${workflowfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +rm -rf ../bin/dummy-compile + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_031.workflow.json b/compiler/one-cmds/tests/onecc_031.workflow.json new file mode 100644 index 000000000..7018ca6eb --- /dev/null +++ b/compiler/one-cmds/tests/onecc_031.workflow.json @@ -0,0 +1,33 @@ +{ + "workflows": [ + "wf" + ], + "wf": { + "steps": [ + "import", + "optimize", + "codegen" + ], + "import": { + "one-cmd": "one-import-tflite", + "commands": { + "input_path": "inception_v3.tflite", + "output_path": "inception_v3.onecc_031.circle" + } + }, + "optimize": { + "one-cmd": "one-optimize", + "commands": { + "input_path": "inception_v3.onecc_031.circle", + "output_path": "inception_v3.opt.circle" + } + }, + "codegen": { + "one-cmd": "one-codegen", + "commands": { + "backend": "dummy", + "command": "-o sample.tvn inception_v3.opt.circle" + } + } + } +} diff --git a/compiler/one-cmds/tests/onecc_032.test b/compiler/one-cmds/tests/onecc_032.test new file mode 100644 index 000000000..5884f578e --- /dev/null +++ b/compiler/one-cmds/tests/onecc_032.test @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# run a workflow where one-import-tf -> one-optimize -> one-quantize -> one-codegen + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-compile + exit 255 +} + +trap trap_err_onexit ERR + +workflowfile="onecc_032.workflow.json" +outputfile="sample.tvn" + +rm -rf ${outputfile} +rm -f ${filename}.log + +# copy dummy-compile to bin folder +cp dummy-compile ../bin/dummy-compile + +# run test +onecc -W ${workflowfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +rm -rf ../bin/dummy-compile + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_032.workflow.json b/compiler/one-cmds/tests/onecc_032.workflow.json new file mode 100644 index 000000000..7a794c8f3 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_032.workflow.json @@ -0,0 +1,42 @@ +{ + "workflows": [ + "wf" + ], + "wf": { + "steps": [ + "import", + "optimize", + "quantize", + "codegen" + ], + "import": { + "one-cmd": "one-import-tflite", + "commands": { + "input_path": "inception_v3.tflite", + "output_path": "inception_v3.onecc_032.circle" + } + }, + "optimize": { + "one-cmd": "one-optimize", + "commands": { + "input_path": "inception_v3.onecc_032.circle", + "output_path": "inception_v3.opt.circle" + } + }, + "quantize": { + "one-cmd": "one-quantize", + "commands": { + "input_path": "inception_v3.onecc_032.circle", + "output_path": "inception_v3.quantized.circle", + "input_data": "inception_v3_test_data.h5" + } + }, + "codegen": { + "one-cmd": "one-codegen", + "commands": { + "backend": "dummy", + "command": "-o sample.tvn inception_v3.quantized.circle" + } + } + } +} diff --git a/compiler/one-cmds/tests/onecc_033.test b/compiler/one-cmds/tests/onecc_033.test new file mode 100644 index 000000000..b2655febc --- /dev/null +++ b/compiler/one-cmds/tests/onecc_033.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# run a workflow where one-import-tf -> one-optimize -> one-quantize -> one-pack + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +workflowfile="onecc_033.workflow.json" +outputfile="inception_v3_pkg" + +rm -rf ${outputfile} +rm -f ${filename}.log + +# run test +onecc -W ${workflowfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_033.workflow.json b/compiler/one-cmds/tests/onecc_033.workflow.json new file mode 100644 index 000000000..2edd5a896 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_033.workflow.json @@ -0,0 +1,42 @@ +{ + "workflows": [ + "wf" + ], + "wf": { + "steps": [ + "import", + "optimize", + "quantize", + "pack" + ], + "import": { + "one-cmd": "one-import-tflite", + "commands": { + "input_path": "inception_v3.tflite", + "output_path": "inception_v3.onecc_033.circle" + } + }, + "optimize": { + "one-cmd": "one-optimize", + "commands": { + "input_path": "inception_v3.onecc_033.circle", + "output_path": "inception_v3.opt.circle" + } + }, + "quantize": { + "one-cmd": "one-quantize", + "commands": { + "input_path": "inception_v3.onecc_033.circle", + "output_path": "inception_v3.quantized.circle", + "input_data": "inception_v3_test_data.h5" + } + }, + "pack": { + "one-cmd": "one-pack", + "commands": { + "input_path": "inception_v3.quantized.circle", + "output_path": "inception_v3_pkg" + } + } + } +} diff --git a/compiler/one-cmds/tests/onecc_034.test b/compiler/one-cmds/tests/onecc_034.test new file mode 100644 index 000000000..9c88dff1c --- /dev/null +++ b/compiler/one-cmds/tests/onecc_034.test @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# run a workflow where one-import-onnx -> one-optimize -> one-codegen + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-compile + exit 255 +} + +trap trap_err_onexit ERR + +workflowfile="onecc_034.workflow.json" +outputfile="onnx_conv2d_conv2d.bin" + +rm -rf ${outputfile} +rm -f ${filename}.log + +# copy dummy-compile to bin folder +cp dummy-compile ../bin/dummy-compile + +# run test +onecc -W ${workflowfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +rm -rf ../bin/dummy-compile + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_034.workflow.json b/compiler/one-cmds/tests/onecc_034.workflow.json new file mode 100644 index 000000000..bc3cbbf58 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_034.workflow.json @@ -0,0 +1,35 @@ +{ + "workflows": [ + "wf" + ], + "wf": { + "steps": [ + "import", + "optimize", + "codegen" + ], + "import": { + "one-cmd": "one-import-onnx", + "commands": { + "input_path": "onnx_conv2d_conv2d.onnx", + "output_path": "onnx_conv2d_conv2d.circle" + } + }, + "optimize": { + "one-cmd": "one-optimize", + "commands": { + "input_path": "onnx_conv2d_conv2d.circle", + "output_path": "onnx_conv2d_conv2d.opt.circle", + "remove_redundant_transpose": "True", + "convert_nchw_to_nhwc": "True" + } + }, + "codegen": { + "one-cmd": "one-codegen", + "commands": { + "backend": "dummy", + "command": "-o onnx_conv2d_conv2d.bin onnx_conv2d_conv2d.opt.circle" + } + } + } +} diff --git a/compiler/one-cmds/tests/onecc_035.test b/compiler/one-cmds/tests/onecc_035.test new file mode 100644 index 000000000..851da6544 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_035.test @@ -0,0 +1,48 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# run a workflow where one-import-tf generates intermediate files + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +workflowfile="onecc_035.workflow.json" +outputfile="inception_v3.alt.circle" +intermfile="inception_v3.alt.tflite" + +rm -rf ${outputfile} +rm -rf ${intermfile} +rm -f ${filename}.log + +# run test +onecc -W ${workflowfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi +if [[ ! -s "${intermfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_035.workflow.json b/compiler/one-cmds/tests/onecc_035.workflow.json new file mode 100644 index 000000000..6abf1f32b --- /dev/null +++ b/compiler/one-cmds/tests/onecc_035.workflow.json @@ -0,0 +1,22 @@ +{ + "workflows": [ + "wf" + ], + "wf": { + "steps": [ + "import" + ], + "import": { + "one-cmd": "one-import-tf", + "commands": { + "input_path": "inception_v3.pb", + "output_path": "inception_v3.alt.circle", + "input_arrays": "input", + "input_shapes": "1,299,299,3", + "output_arrays": "InceptionV3/Predictions/Reshape_1", + "converter_version": "v1", + "save_intermediate": "True" + } + } + } +} diff --git a/compiler/one-cmds/tests/onecc_036.test b/compiler/one-cmds/tests/onecc_036.test new file mode 100644 index 000000000..00f4641b7 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_036.test @@ -0,0 +1,48 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# run a workflow where one-import-onnx generates intermediate files + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +workflowfile="onecc_036.workflow.json" +outputfile="test_onnx_model.circle" +intermfile="test_onnx_model.tflite" + +rm -rf ${outputfile} +rm -rf ${intermfile} +rm -f ${filename}.log + +# run test +onecc -W ${workflowfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi +if [[ ! -s "${intermfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_036.workflow.json b/compiler/one-cmds/tests/onecc_036.workflow.json new file mode 100644 index 000000000..5fa29edb5 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_036.workflow.json @@ -0,0 +1,18 @@ +{ + "workflows": [ + "wf" + ], + "wf": { + "steps": [ + "import" + ], + "import": { + "one-cmd": "one-import-onnx", + "commands": { + "input_path": "test_onnx_model.onnx", + "output_path": "test_onnx_model.circle", + "save_intermediate": "True" + } + } + } +} diff --git a/compiler/one-cmds/tests/onecc_037.test b/compiler/one-cmds/tests/onecc_037.test new file mode 100644 index 000000000..596bbfdf9 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_037.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# run a workflow where one-import-tf -> one-optimize + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +workflowfile="onecc_037.workflow.json" +outputfile="inception_v3.opt.circle" + +rm -rf ${outputfile} +rm -f ${filename}.log + +# run test +onecc -W ${workflowfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_037.workflow.json b/compiler/one-cmds/tests/onecc_037.workflow.json new file mode 100644 index 000000000..ebd6b34d6 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_037.workflow.json @@ -0,0 +1,29 @@ +{ + "workflows": [ + "SIMPLE_WORKFLOW" + ], + "SIMPLE_WORKFLOW": { + "steps": [ + "IMPORT", + "OPTIMIZE" + ], + "IMPORT": { + "one-cmd": "one-import-tf", + "commands": { + "input_path": "inception_v3.pb", + "output_path": "inception_v3.onecc_037.circle", + "input_arrays": "input", + "input_shapes": "1,299,299,3", + "output_arrays": "InceptionV3/Predictions/Reshape_1", + "converter_version": "v2" + } + }, + "OPTIMIZE": { + "one-cmd": "one-optimize", + "commands": { + "input_path": "inception_v3.onecc_037.circle", + "output_path": "inception_v3.opt.circle" + } + } + } +} diff --git a/compiler/one-cmds/tests/onecc_038.test b/compiler/one-cmds/tests/onecc_038.test new file mode 100644 index 000000000..41f633335 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_038.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# run a workflow where one-import-tf -> one-quantize + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +workflowfile="onecc_038.workflow.json" +outputfile="inception_v3.list.quantized.circle" + +rm -rf ${outputfile} +rm -f ${filename}.log + +# run test +onecc -W ${workflowfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_038.workflow.json b/compiler/one-cmds/tests/onecc_038.workflow.json new file mode 100644 index 000000000..d31045efe --- /dev/null +++ b/compiler/one-cmds/tests/onecc_038.workflow.json @@ -0,0 +1,31 @@ +{ + "workflows": [ + "SIMPLE_WORKFLOW" + ], + "SIMPLE_WORKFLOW": { + "steps": [ + "IMPORT", + "QUANTIZE" + ], + "IMPORT": { + "one-cmd": "one-import-tf", + "commands": { + "input_path": "inception_v3.pb", + "output_path": "inception_v3.onecc_038.circle", + "input_arrays": "input", + "input_shapes": "1,299,299,3", + "output_arrays": "InceptionV3/Predictions/Reshape_1", + "converter_version": "v2" + } + }, + "QUANTIZE": { + "one-cmd": "one-quantize", + "commands": { + "input_path": "inception_v3.onecc_038.circle", + "output_path": "inception_v3.list.quantized.circle", + "input_data": "datalist.txt", + "input_data_format": "list" + } + } + } +} diff --git a/compiler/one-cmds/tests/onecc_039.test b/compiler/one-cmds/tests/onecc_039.test new file mode 100644 index 000000000..b922636ca --- /dev/null +++ b/compiler/one-cmds/tests/onecc_039.test @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# run a workflow where one-quantize quantizes the model and evaluates the result + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +check_message() +{ + if grep -q "MPEIR for InceptionV3/Predictions/Reshape_1 is" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + trap_err_onexit +} + +trap trap_err_onexit ERR + +workflowfile="onecc_039.workflow.json" +outputfile="inception_v3.onecc_039.q.circle" + +rm -rf ${outputfile} +rm -f ${filename}.log + +# run test +onecc -W ${workflowfile} > ${filename}.log 2>&1 + +check_message diff --git a/compiler/one-cmds/tests/onecc_039.workflow.json b/compiler/one-cmds/tests/onecc_039.workflow.json new file mode 100644 index 000000000..55ef56988 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_039.workflow.json @@ -0,0 +1,21 @@ +{ + "workflows": [ + "SIMPLE_WORKFLOW" + ], + "SIMPLE_WORKFLOW": { + "steps": [ + "QUANTIZE" + ], + "QUANTIZE": { + "one-cmd": "one-quantize", + "commands": { + "input_path": "inception_v3.circle", + "output_path": "inception_v3.onecc_026.q.circle", + "input_data": "inception_v3_test_data.h5", + "evaluate_result": "True", + "test_data": "inception_v3_test_data.h5", + "print_mpeir": "True" + } + } + } +} diff --git a/compiler/one-cmds/tests/onecc_040.cfg b/compiler/one-cmds/tests/onecc_040.cfg new file mode 100644 index 000000000..b9f39fd51 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_040.cfg @@ -0,0 +1,20 @@ +[onecc] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=True +one-quantize=False +one-pack=False +one-codegen=False + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.onecc_040.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v2 + +[one-optimize] +input_path=inception_v3.onecc_040.circle +output_path=inception_v3.opt.circle diff --git a/compiler/one-cmds/tests/onecc_040.test b/compiler/one-cmds/tests/onecc_040.test new file mode 100644 index 000000000..4d23025bf --- /dev/null +++ b/compiler/one-cmds/tests/onecc_040.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# run a workflow with cfg reference + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +workflowfile="onecc_040.workflow.json" +outputfile="inception_v3.opt.circle" + +rm -rf ${outputfile} +rm -f ${filename}.log + +# run test +onecc -W ${workflowfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_040.workflow.json b/compiler/one-cmds/tests/onecc_040.workflow.json new file mode 100644 index 000000000..2d4119b21 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_040.workflow.json @@ -0,0 +1,10 @@ +{ + "workflows": [ + "MY_WORKFLOW" + ], + "MY_WORKFLOW": { + "cfg-reference": { + "path": "onecc_040.cfg" + } + } +} diff --git a/compiler/one-cmds/tests/onecc_041.cfg b/compiler/one-cmds/tests/onecc_041.cfg new file mode 100644 index 000000000..16135f074 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_041.cfg @@ -0,0 +1,16 @@ +[onecc] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=False +one-quantize=False +one-pack=False +one-codegen=False + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3_without_opt.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v2 diff --git a/compiler/one-cmds/tests/onecc_041.test b/compiler/one-cmds/tests/onecc_041.test new file mode 100644 index 000000000..c504e6953 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_041.test @@ -0,0 +1,59 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# run a workflows + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +check_message() +{ + if grep -q "Do inference of inception_v3_without_opt\.circle" "${filename}.log" && + grep -q "Do inference of inception_v3\.opt\.circle" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + trap_err_onexit +} + +trap trap_err_onexit ERR + +workflowfile="onecc_041.workflow.json" +outputfile1="inception_v3_without_opt.circle" +outputfile2="inception_v3.opt.circle" + +cp dummy-inferV2 ../bin/dummy-inferV2 + +rm -rf ${outputfile1} {outputfile2} +rm -f ${filename}.log + +# run test +onecc -W ${workflowfile} > ${filename}.log 2>&1 + +rm -rf ../bin/dummy-inferV2 + +if [[ ! -s "${outputfile1}" ]] && [[ ! -s "${outputfile2}" ]]; then + trap_err_onexit +fi + +check_message diff --git a/compiler/one-cmds/tests/onecc_041.workflow.json b/compiler/one-cmds/tests/onecc_041.workflow.json new file mode 100644 index 000000000..e19494cd2 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_041.workflow.json @@ -0,0 +1,61 @@ +{ + "workflows": [ + "WITHOUT_OPT", + "WITH_OPT", + "INFER" + ], + "INFER": { + "run-after": [ + "WITHOUT_OPT", + "WITH_OPT" + ], + "steps": [ + "INFER1", + "INFER2" + ], + "INFER1": { + "one-cmd": "one-infer", + "commands" : { + "driver": "dummy-inferV2", + "command": "inception_v3_without_opt.circle" + } + }, + "INFER2": { + "one-cmd": "one-infer", + "commands": { + "driver": "dummy-inferV2", + "command": "inception_v3.opt.circle" + } + } + }, + "WITHOUT_OPT": { + "cfg-reference": { + "path": "onecc_041.cfg" + } + }, + "WITH_OPT": { + "steps": [ + "IMPORT_TF", + "OPTIMIZE" + ], + "IMPORT_TF": { + "one-cmd": "one-import-tf", + "commands": { + "input_path": "inception_v3.pb", + "output_path": "inception_v3.onecc_041.circle", + "input_arrays": "input", + "input_shapes": "1,299,299,3", + "output_arrays": "InceptionV3/Predictions/Reshape_1", + "converter_version": "v2" + } + }, + "OPTIMIZE": { + "one-cmd": "one-optimize", + "commands": { + "input_path": "inception_v3.onecc_041.circle", + "output_path": "inception_v3.opt.circle" + } + } + } + +} diff --git a/compiler/one-cmds/tests/onecc_042.cfg b/compiler/one-cmds/tests/onecc_042.cfg new file mode 100644 index 000000000..988c76860 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_042.cfg @@ -0,0 +1,9 @@ +[Environment] +SPM_SIZE=256KB + +[onecc] +one-codegen=True + +[one-codegen] +backend=dummyEnv +command=dummy_env.bin diff --git a/compiler/one-cmds/tests/onecc_042.test b/compiler/one-cmds/tests/onecc_042.test new file mode 100644 index 000000000..c8a15fa4f --- /dev/null +++ b/compiler/one-cmds/tests/onecc_042.test @@ -0,0 +1,55 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# one-codegen with Environment section + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" +outputfile="dummy_env.bin" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummyEnv-compile + rm -rf ${outputfile} + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_042.cfg" + +rm -rf ${outputfile} +rm -rf ${filename}.log + +# copy dummyEnv-compile to bin folder +cp dummyEnv-compile ../bin/dummyEnv-compile + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +if grep -q "SPM_SIZE=256KB" "${outputfile}"; then + echo "${filename_ext} SUCCESS" + rm -rf ../bin/dummyEnv-compile + rm -rf ${outputfile} + exit 0 +fi + +trap_err_onexit diff --git a/compiler/one-cmds/tests/onecc_043.cfg b/compiler/one-cmds/tests/onecc_043.cfg new file mode 100644 index 000000000..7d5ee87a8 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_043.cfg @@ -0,0 +1,14 @@ +[onecc] +one-import-tf=False +one-import-tflite=False +one-import-bcq=False +one-import-onnx=False +one-optimize=True +one-quantize=False +one-pack=False +one-codegen=False +include=O1 + +[one-optimize] +input_path=inception_v3.circle +output_path=inception_v3.onecc_043.opt.circle diff --git a/compiler/one-cmds/tests/onecc_043.test b/compiler/one-cmds/tests/onecc_043.test new file mode 100644 index 000000000..f99039ef6 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_043.test @@ -0,0 +1,61 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Test for "O1=True" option in onecc config file + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_043.cfg" +outputfile="inception_v3.onecc_043.opt.circle" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +# O1.list is dynamically created from onelib/export_constant.py +readarray -t O1_OPTS < "O1.list" +readarray -t NO_O1_OPTS < "non-O1.list" + +for opt in "${O1_OPTS[@]}" +do + if ! grep -q ${opt} ${outputfile}.log; then + trap_err_onexit + fi +done + +for no_opt in "${NO_O1_OPTS[@]}" +do + if grep -q ${no_opt} ${outputfile}.log; then + trap_err_onexit + fi +done + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_044.cfg b/compiler/one-cmds/tests/onecc_044.cfg new file mode 100644 index 000000000..f7cdde863 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_044.cfg @@ -0,0 +1,20 @@ +[onecc] +one-import-tf=False +one-import-tflite=False +one-import-bcq=False +one-import-onnx=True +one-optimize=True +one-quantize=False +one-pack=False +one-codegen=False +include=O1 + +[one-import-onnx] +input_path=test_onnx_model.onnx +output_path=test_onnx_model.circle + +[one-optimize] +input_path=test_onnx_model.circle +output_path=test_onnx_model.onecc_044.opt.circle +convert_nchw_to_nhwc=True +fold_add_v2=False diff --git a/compiler/one-cmds/tests/onecc_044.test b/compiler/one-cmds/tests/onecc_044.test new file mode 100644 index 000000000..1706cf9ec --- /dev/null +++ b/compiler/one-cmds/tests/onecc_044.test @@ -0,0 +1,74 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Test for "O1=True" option with other options + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_044.cfg" +outputfile="test_onnx_model.onecc_044.opt.circle" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +readarray -t OPTS < "O1.list" +readarray -t NO_OPTS < "non-O1.list" + +OPTS+=("convert_nchw_to_nhwc") +for i in "${!NO_OPTS[@]}"; do + if [[ ${NO_OPTS[i]} = "convert_nchw_to_nhwc" ]]; then + unset 'NO_OPTS[i]' + fi +done + +NO_OPTS+=("fold_add_v2") +for i in "${!OPTS[@]}"; do + if [[ ${OPTS[i]} = "fold_add_v2" ]]; then + unset 'OPTS[i]' + fi +done + +for opt in "${OPTS[@]}" +do + if ! grep -q ${opt} ${outputfile}.log; then + trap_err_onexit + fi +done + +for no_opt in "${NO_OPTS[@]}" +do + if grep -q ${no_opt} ${outputfile}.log; then + trap_err_onexit + fi +done + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_045.cfg b/compiler/one-cmds/tests/onecc_045.cfg new file mode 100644 index 000000000..d0ee39f38 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_045.cfg @@ -0,0 +1,13 @@ +[onecc] +one-import-tf=False +one-import-tflite=False +one-import-bcq=False +one-optimize=False +one-quantize=True +one-pack=False +one-codegen=False + +[one-quantize] +input_path=reshape_matmul.circle +output_path=reshape_matmul.onecc_045.q.circle +input_type=uint8,int16 diff --git a/compiler/one-cmds/tests/onecc_045.test b/compiler/one-cmds/tests/onecc_045.test new file mode 100644 index 000000000..2b5c0a21a --- /dev/null +++ b/compiler/one-cmds/tests/onecc_045.test @@ -0,0 +1,65 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +# TODO Resolve circledump not found +# https://github.com/Samsung/ONE/issues/10550 +if ! command -v circledump &> /dev/null +then + echo "${filename_ext} SKIPPED" + exit 0 +fi + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./reshape_matmul.circle" +configfile="onecc_045.cfg" +outputfile="reshape_matmul.onecc_045.q.circle" + +rm -f ${filename}.log +rm -f ${filename}.first.cdump +rm -f ${filename}.second.cdump +rm -f ${outputfile} + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +circledump ${outputfile} | grep "T(0:0)" > ${filename}.first.cdump +circledump ${outputfile} | grep "T(0:1)" > ${filename}.second.cdump + +# check dtype of the first input (uint8) +if ! grep -q "UINT8" "${filename}.first.cdump"; then + trap_err_onexit +fi + +# check dtype of the second input (int16) +if ! grep -q "INT16" "${filename}.second.cdump"; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_046.cfg b/compiler/one-cmds/tests/onecc_046.cfg new file mode 100644 index 000000000..28927355b --- /dev/null +++ b/compiler/one-cmds/tests/onecc_046.cfg @@ -0,0 +1,7 @@ +[onecc] +one-codegen=True + +[one-codegen] +backends=dummy,dummyV2 +dummy=-o onecc_046.tvn inception_v3.onecc_046.circle +dummyV2=-O onecc_046.2.tvn inception_v3.onecc_046.2.circle diff --git a/compiler/one-cmds/tests/onecc_046.test b/compiler/one-cmds/tests/onecc_046.test new file mode 100644 index 000000000..a11b181d5 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_046.test @@ -0,0 +1,58 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# 'backends' key in configuration file + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-compile + rm -rf ../bin/dummyV2-compile + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_046.cfg" +outputfile="onecc_046.tvn" +outputfile2="onecc_046.2.tvn" + +rm -f ${filename}.log +rm -rf ${outputfile} +rm -rf ${outputfile2} + +# copy dummy tools to bin folder +cp dummy-compile ../bin/dummy-compile +cp dummyV2-compile ../bin/dummyV2-compile + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +if [[ ! -s "${outputfile2}" ]]; then + trap_err_onexit +fi + +rm -rf ../bin/dummy-compile +rm -rf ../bin/dummyV2-compile + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_047.cfg b/compiler/one-cmds/tests/onecc_047.cfg new file mode 100644 index 000000000..df2eef5f8 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_047.cfg @@ -0,0 +1,7 @@ +[onecc] +one-codegen=True + +[one-codegen] +backends=dummy,dummyV2 +dummy=-o onecc_047.tvn inception_v3.onecc_047.circle +dummyV2=-O onecc_047.2.tvn inception_v3.onecc_047.2.circle diff --git a/compiler/one-cmds/tests/onecc_047.test b/compiler/one-cmds/tests/onecc_047.test new file mode 100644 index 000000000..345042091 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_047.test @@ -0,0 +1,59 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# 'backends' key in configuration file but run codegen for only one backend + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-compile + rm -rf ../bin/dummyV2-compile + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_047.cfg" +outputfile="onecc_047.tvn" +outputfile2="onecc_047.2.tvn" + +rm -f ${filename}.log +rm -rf ${outputfile} +rm -rf ${outputfile2} + +# copy dummy tools to bin folder +cp dummy-compile ../bin/dummy-compile +cp dummyV2-compile ../bin/dummyV2-compile + +# run test +onecc -C ${configfile} -b dummyV2 > ${filename}.log 2>&1 + +# shouldn't be generated +if [[ -s "${outputfile}" ]]; then + trap_err_onexit +fi + +if [[ ! -s "${outputfile2}" ]]; then + trap_err_onexit +fi + +rm -rf ../bin/dummy-compile +rm -rf ../bin/dummyV2-compile + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_048.cfg b/compiler/one-cmds/tests/onecc_048.cfg new file mode 100644 index 000000000..c4c0acc40 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_048.cfg @@ -0,0 +1,6 @@ +[onecc] +one-codegen=True + +[one-codegen] +backend=dummyV2 +command=-O onecc_048.tvn inception_v3.onecc_048.circle diff --git a/compiler/one-cmds/tests/onecc_048.test b/compiler/one-cmds/tests/onecc_048.test new file mode 100644 index 000000000..d4eff54cf --- /dev/null +++ b/compiler/one-cmds/tests/onecc_048.test @@ -0,0 +1,49 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# 'backend' option from command line with 'backend' key in configuration file + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummyV2-compile + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_048.cfg" +outputfile="onecc_048.tvn" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# copy dummy tools to bin folder +cp dummyV2-compile ../bin/dummyV2-compile + +# run test +onecc -C ${configfile} -b dummyV2 > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +rm -rf ../bin/dummyV2-compile + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_049.cfg b/compiler/one-cmds/tests/onecc_049.cfg new file mode 100644 index 000000000..021d9a45e --- /dev/null +++ b/compiler/one-cmds/tests/onecc_049.cfg @@ -0,0 +1,7 @@ +[onecc] +one-profile=True + +[one-profile] +backends=dummy,dummyV2 +dummy=dummy.bin +dummyV2=dummyV2.bin diff --git a/compiler/one-cmds/tests/onecc_049.test b/compiler/one-cmds/tests/onecc_049.test new file mode 100644 index 000000000..45fd8a74b --- /dev/null +++ b/compiler/one-cmds/tests/onecc_049.test @@ -0,0 +1,54 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# 'backends' key in one-profile section + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-profile + rm -rf ../bin/dummyV2-profile + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_049.cfg" + +rm -f ${filename}.log + +# copy dummy tools to bin folder +cp dummy-profile ../bin/dummy-profile +cp dummyV2-profile ../bin/dummyV2-profile + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +if ! grep -q "dummy-profile dummy output!!!" "${filename}.log"; then + trap_err_onexit +fi + +if ! grep -q "dummyV2-profile dummy output!!!" "${filename}.log"; then + trap_err_onexit +fi + +rm -rf ../bin/dummy-profile +rm -rf ../bin/dummyV2-profile + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_050.cfg b/compiler/one-cmds/tests/onecc_050.cfg new file mode 100644 index 000000000..021d9a45e --- /dev/null +++ b/compiler/one-cmds/tests/onecc_050.cfg @@ -0,0 +1,7 @@ +[onecc] +one-profile=True + +[one-profile] +backends=dummy,dummyV2 +dummy=dummy.bin +dummyV2=dummyV2.bin diff --git a/compiler/one-cmds/tests/onecc_050.test b/compiler/one-cmds/tests/onecc_050.test new file mode 100644 index 000000000..8ebfd1e81 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_050.test @@ -0,0 +1,54 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# 'backends' key in configuration file but run one-profile for only one backend + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-profile + rm -rf ../bin/dummyV2-profile + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_050.cfg" + +rm -f ${filename}.log + +# copy dummy tools to bin folder +cp dummy-profile ../bin/dummy-profile +cp dummyV2-profile ../bin/dummyV2-profile + +# run test +onecc -C ${configfile} -b dummyV2 > ${filename}.log 2>&1 + +if grep -q "dummy-profile dummy output!!!" "${filename}.log"; then + trap_err_onexit +fi + +if ! grep -q "dummyV2-profile dummy output!!!" "${filename}.log"; then + trap_err_onexit +fi + +rm -rf ../bin/dummy-profile +rm -rf ../bin/dummyV2-profile + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_051.cfg b/compiler/one-cmds/tests/onecc_051.cfg new file mode 100644 index 000000000..ecf983f71 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_051.cfg @@ -0,0 +1,6 @@ +[onecc] +one-profile=True + +[one-profile] +backend=dummyV2 +command=dummyV2.bin diff --git a/compiler/one-cmds/tests/onecc_051.test b/compiler/one-cmds/tests/onecc_051.test new file mode 100644 index 000000000..97967096c --- /dev/null +++ b/compiler/one-cmds/tests/onecc_051.test @@ -0,0 +1,48 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# 'backend' option from command line with 'backend' key in configuration file + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-profile + rm -rf ../bin/dummyV2-profile + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_051.cfg" + +rm -f ${filename}.log + +# copy dummy tools to bin folder +cp dummyV2-profile ../bin/dummyV2-profile + +# run test +onecc -C ${configfile} -b dummyV2 > ${filename}.log 2>&1 + +if ! grep -q "dummyV2-profile dummy output!!!" "${filename}.log"; then + trap_err_onexit +fi + +rm -rf ../bin/dummyV2-profile + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_052.cfg b/compiler/one-cmds/tests/onecc_052.cfg new file mode 100644 index 000000000..e884ea9a8 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_052.cfg @@ -0,0 +1,13 @@ +[onecc] +one-codegen=True +one-profile=True + +[one-codegen] +backends=dummy,dummyV2 +dummy=-o onecc_052.tvn inception_v3.onecc_052.circle +dummyV2=-O onecc_052.2.tvn inception_v3.onecc_052.2.circle + +[one-profile] +backends=dummy,dummyV2 +dummy=dummy.bin +dummyV2=dummyV2.bin diff --git a/compiler/one-cmds/tests/onecc_052.test b/compiler/one-cmds/tests/onecc_052.test new file mode 100644 index 000000000..39bc6ed68 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_052.test @@ -0,0 +1,74 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# 'backends' key with one-profile and one-codgen section + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-profile + rm -rf ../bin/dummyV2-profile + rm -rf ../bin/dummy-compile + rm -rf ../bin/dummyV2-compile + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_052.cfg" +outputfile="onecc_052.tvn" +outputfile2="onecc_052.2.tvn" + +rm -f ${filename}.log +rm -rf ${outputfile} +rm -rf ${outputfile2} + +# copy dummy tools to bin folder +cp dummy-profile ../bin/dummy-profile +cp dummyV2-profile ../bin/dummyV2-profile +cp dummy-compile ../bin/dummy-compile +cp dummyV2-compile ../bin/dummyV2-compile + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +if ! grep -q "dummy-profile dummy output!!!" "${filename}.log"; then + trap_err_onexit +fi + +if ! grep -q "dummyV2-profile dummy output!!!" "${filename}.log"; then + trap_err_onexit +fi + +if [[ ! -s "${outputfile}" ]]; then + echo "ERROR: Not found ${outputfile}" >> ${filename}.log + trap_err_onexit +fi + +if [[ ! -s "${outputfile2}" ]]; then +echo "ERROR: Not found ${outputfile2}" >> ${filename}.log + trap_err_onexit +fi + +rm -rf ../bin/dummy-profile +rm -rf ../bin/dummyV2-profile +rm -rf ../bin/dummy-compile +rm -rf ../bin/dummyV2-compile + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_053.cfg b/compiler/one-cmds/tests/onecc_053.cfg new file mode 100644 index 000000000..8cbe799b1 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_053.cfg @@ -0,0 +1,13 @@ +[onecc] +one-codegen=True +one-profile=True + +[one-codegen] +backends=dummy,dummyV2 +dummy=-o onecc_053.tvn inception_v3.onecc_053.circle +dummyV2=-O onecc_053.2.tvn inception_v3.onecc_053.2.circle + +[one-profile] +backends=dummy,dummyV2 +dummy=dummy.bin +dummyV2=dummyV2.bin diff --git a/compiler/one-cmds/tests/onecc_053.test b/compiler/one-cmds/tests/onecc_053.test new file mode 100644 index 000000000..20f0209ad --- /dev/null +++ b/compiler/one-cmds/tests/onecc_053.test @@ -0,0 +1,74 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# 'backend' option with one-profile and one-codgen section + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-profile + rm -rf ../bin/dummyV2-profile + rm -rf ../bin/dummy-compile + rm -rf ../bin/dummyV2-compile + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_053.cfg" +outputfile="onecc_053.tvn" +outputfile2="onecc_053.2.tvn" + +rm -f ${filename}.log +rm -rf ${outputfile} +rm -rf ${outputfile2} + +# copy dummy tools to bin folder +cp dummy-profile ../bin/dummy-profile +cp dummyV2-profile ../bin/dummyV2-profile +cp dummy-compile ../bin/dummy-compile +cp dummyV2-compile ../bin/dummyV2-compile + +# run test +onecc -C ${configfile} -b dummyV2 > ${filename}.log 2>&1 + +if grep -q "dummy-profile dummy output!!!" "${filename}.log"; then + trap_err_onexit +fi + +if ! grep -q "dummyV2-profile dummy output!!!" "${filename}.log"; then + trap_err_onexit +fi + +if [[ -s "${outputfile}" ]]; then + echo "ERROR: Found ${outputfile}" >> ${filename}.log + trap_err_onexit +fi + +if [[ ! -s "${outputfile2}" ]]; then +echo "ERROR: Not found ${outputfile2}" >> ${filename}.log + trap_err_onexit +fi + +rm -rf ../bin/dummy-profile +rm -rf ../bin/dummyV2-profile +rm -rf ../bin/dummy-compile +rm -rf ../bin/dummyV2-compile + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_054.cfg b/compiler/one-cmds/tests/onecc_054.cfg new file mode 100644 index 000000000..63ad06ccf --- /dev/null +++ b/compiler/one-cmds/tests/onecc_054.cfg @@ -0,0 +1,7 @@ +[onecc] +one-codegen=True + +[one-codegen] +backends=dummy,dummyV2 +dummy=-o onecc_054.tvn inception_v3.onecc_054.circle +dummyV2=-O onecc_054.2.tvn inception_v3.onecc_054.2.circle diff --git a/compiler/one-cmds/tests/onecc_054.test b/compiler/one-cmds/tests/onecc_054.test new file mode 100644 index 000000000..14853a8a3 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_054.test @@ -0,0 +1,65 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# overwrite one-codegen command with `backends` key + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummy-compile + rm -rf ../bin/dummyV2-compile + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_054.cfg" +outputfile0="onecc_054_overwrite.tvn" +outputfile1="onecc_054.tvn" +outputfile2="onecc_054.2.tvn" + +rm -f ${filename}.log +rm -rf ${outputfile0} +rm -rf ${outputfile1} +rm -rf ${outputfile2} + +# copy dummy tools to bin folder +cp dummy-compile ../bin/dummy-compile +cp dummyV2-compile ../bin/dummyV2-compile + +# run test +onecc codegen -C ${configfile} -b dummyV2 -- \ + -O onecc_054_overwrite.tvn onecc.circle > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile0}" ]]; then + trap_err_onexit +fi + +# shouldn't be generated +if [[ -s "${outputfile1}" ]]; then + trap_err_onexit +fi +if [[ -s "${outputfile2}" ]]; then + trap_err_onexit +fi + +rm -rf ../bin/dummy-compile +rm -rf ../bin/dummyV2-compile + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_055.cfg b/compiler/one-cmds/tests/onecc_055.cfg new file mode 100644 index 000000000..c4c0acc40 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_055.cfg @@ -0,0 +1,6 @@ +[onecc] +one-codegen=True + +[one-codegen] +backend=dummyV2 +command=-O onecc_048.tvn inception_v3.onecc_048.circle diff --git a/compiler/one-cmds/tests/onecc_055.test b/compiler/one-cmds/tests/onecc_055.test new file mode 100644 index 000000000..c13aa4b08 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_055.test @@ -0,0 +1,57 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# overwrite one-codegen command with `backend` and `command` key + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummyV2-compile + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_055.cfg" +outputfile0="onecc_055.tvn" +outputfile1="onecc_055_overwrite.tvn" + +rm -f ${filename}.log +rm -rf ${outputfile0} +rm -rf ${outputfile1} + +# copy dummy tools to bin folder +cp dummyV2-compile ../bin/dummyV2-compile + +# run test +onecc codegen -C ${configfile} -b dummyV2 -- \ + -O onecc_055_overwrite.tvn onecc.circle > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile1}" ]]; then + trap_err_onexit +fi + +# shouldn't be generated +if [[ -s "${outputfile0}" ]]; then + trap_err_onexit +fi + +rm -rf ../bin/dummyV2-compile + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_056.cfg b/compiler/one-cmds/tests/onecc_056.cfg new file mode 100644 index 000000000..1d30fd78b --- /dev/null +++ b/compiler/one-cmds/tests/onecc_056.cfg @@ -0,0 +1,6 @@ +[onecc] +one-profile=True + +[one-profile] +backend=dummyV3 +command=onecc_056 diff --git a/compiler/one-cmds/tests/onecc_056.test b/compiler/one-cmds/tests/onecc_056.test new file mode 100644 index 000000000..159cafbb4 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_056.test @@ -0,0 +1,48 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# overwrite one-profile command with 'backend' key + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummyV3-profile + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_056.cfg" + +rm -f ${filename}.log + +# copy dummy tools to bin folder +cp dummyV3-profile ../bin/dummyV3-profile + +# run test +onecc profile -C ${configfile} -b dummyV3 -- \ + onecc_056_overwrite > ${filename}.log 2>&1 + +if ! grep -q "dummyV3-profile with onecc_056_overwrite" "${filename}.log"; then + trap_err_onexit +fi + +rm -rf ../bin/dummyV3-profile + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_057.cfg b/compiler/one-cmds/tests/onecc_057.cfg new file mode 100644 index 000000000..dbe4f531a --- /dev/null +++ b/compiler/one-cmds/tests/onecc_057.cfg @@ -0,0 +1,7 @@ +[onecc] +one-profile=True + +[one-profile] +backends=dummyV2,dummyV3 +dummyV2=dummyV2.bin +dummyV3=onecc_057 diff --git a/compiler/one-cmds/tests/onecc_057.test b/compiler/one-cmds/tests/onecc_057.test new file mode 100644 index 000000000..f0076093b --- /dev/null +++ b/compiler/one-cmds/tests/onecc_057.test @@ -0,0 +1,51 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# overwrite one-profile command with `backends` key + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + rm -rf ../bin/dummyV2-profile + rm -rf ../bin/dummyV3-profile + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_057.cfg" + +rm -f ${filename}.log + +# copy dummy tools to bin folder +cp dummyV2-profile ../bin/dummyV2-profile +cp dummyV3-profile ../bin/dummyV3-profile + +# run test +onecc profile -C ${configfile} -b dummyV3 -- \ + onecc_057_overwrite > ${filename}.log 2>&1 + +if ! grep -q "dummyV3-profile with onecc_057_overwrite" "${filename}.log"; then + trap_err_onexit +fi + +rm -rf ../bin/dummyV2-profile +rm -rf ../bin/dummyV3-profile + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_058.cfg b/compiler/one-cmds/tests/onecc_058.cfg new file mode 100644 index 000000000..1d0b6d1f2 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_058.cfg @@ -0,0 +1,9 @@ +[onecc] +one-quantize=True + +[one-quantize] +requantize=True +input_path=mobilenet_edgetpu_224_1.0_int8.circle +output_path=mobilenet_edgetpu_224_1.0_int8.onecc_058.circle +input_model_dtype=int8 +quantized_dtype=uint8 diff --git a/compiler/one-cmds/tests/onecc_058.test b/compiler/one-cmds/tests/onecc_058.test new file mode 100644 index 000000000..6f60eed8a --- /dev/null +++ b/compiler/one-cmds/tests/onecc_058.test @@ -0,0 +1,41 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_058.cfg" +outputfile="mobilenet_edgetpu_224_1.0_int8.onecc_058.circle" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_neg_001.test b/compiler/one-cmds/tests/onecc_neg_001.test new file mode 100644 index 000000000..fe83e35b5 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_001.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with missing configuration file + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Not found given configuration file" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_neg_001.cfg" + +rm -f ${filename}.log + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_002.cfg b/compiler/one-cmds/tests/onecc_neg_002.cfg new file mode 100644 index 000000000..e597a39a5 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_002.cfg @@ -0,0 +1,20 @@ +[onecc] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=True +one-quantize=False +one-pack=True +one-codegen=False + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.onecc_neg_002.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v2 + +[one-optimize] +input_path=inception_v3.onecc_neg_002.circle +output_path=inception_v3.opt.circle diff --git a/compiler/one-cmds/tests/onecc_neg_002.test b/compiler/one-cmds/tests/onecc_neg_002.test new file mode 100644 index 000000000..04918ab74 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_002.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with missing one-pack section in configuration file + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "configuration file must have 'one-pack' section" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_neg_002.cfg" + +rm -f ${filename}.log + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_003.cfg b/compiler/one-cmds/tests/onecc_neg_003.cfg new file mode 100644 index 000000000..e4718efe3 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_003.cfg @@ -0,0 +1,15 @@ +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.onecc_neg_003.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v2 + +[one-optimize] +input_path=inception_v3.onecc_neg_003.circle +output_path=inception_v3.opt.circle + +[one-pack] +input_path=inception_v3.opt.circle +output_path=inception_v3_pkg diff --git a/compiler/one-cmds/tests/onecc_neg_003.test b/compiler/one-cmds/tests/onecc_neg_003.test new file mode 100644 index 000000000..4c64c5ab8 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_003.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with missing onecc section in configuration file + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "\[onecc\] section is required in configuration file" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_neg_003.cfg" + +rm -f ${filename}.log + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_004.cfg b/compiler/one-cmds/tests/onecc_neg_004.cfg new file mode 100644 index 000000000..53e819109 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_004.cfg @@ -0,0 +1,24 @@ +[onecc] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=True +one-quantize=False +one-pack=False +one-codegen=False + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.onecc_neg_004.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v2 + +[one-optimize] +input_path=inception_v3.onecc_neg_004.circle +output_path=inception_v3.opt.circle + +[one-optimize] +input_path=inception_v4.circle +output_path=inception_v4.opt.circle diff --git a/compiler/one-cmds/tests/onecc_neg_004.test b/compiler/one-cmds/tests/onecc_neg_004.test new file mode 100644 index 000000000..30fb34593 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_004.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with duplicate section + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "section 'one-optimize' already exists" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_neg_004.cfg" + +rm -f ${filename}.log + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_005.cfg b/compiler/one-cmds/tests/onecc_neg_005.cfg new file mode 100644 index 000000000..1b449c750 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_005.cfg @@ -0,0 +1,16 @@ +[onecc] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=False +one-quantize=False +one-pack=False +one-codegen=False + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3.alt.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v2 diff --git a/compiler/one-cmds/tests/onecc_neg_005.test b/compiler/one-cmds/tests/onecc_neg_005.test new file mode 100644 index 000000000..1d2248593 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_005.test @@ -0,0 +1,50 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative one-import-tf intermediate file should not exist + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_neg_005.cfg" +outputfile="inception_v3.alt.circle" +intermfile="inception_v3.alt.tflite" + +rm -rf ${outputfile} +rm -rf ${intermfile} +rm -f ${filename}.log + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +# output should exist +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi +# intermediate file should not exist +if [[ -f "${intermfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_neg_006.cfg b/compiler/one-cmds/tests/onecc_neg_006.cfg new file mode 100644 index 000000000..63ef42bfb --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_006.cfg @@ -0,0 +1,13 @@ +[onecc] +one-import-tf=False +one-import-tflite=False +one-import-bcq=False +one-import-onnx=True +one-optimize=False +one-quantize=False +one-pack=False +one-codegen=False + +[one-import-onnx] +input_path=test_onnx_model.onnx +output_path=test_onnx_model.circle diff --git a/compiler/one-cmds/tests/onecc_neg_006.test b/compiler/one-cmds/tests/onecc_neg_006.test new file mode 100644 index 000000000..194a7ea43 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_006.test @@ -0,0 +1,50 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative one-import-tf intermediate file should not exist + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_neg_006.cfg" +outputfile="test_onnx_model.circle" +intermfile="test_onnx_model.tflite" + +rm -rf ${outputfile} +rm -rf ${intermfile} +rm -f ${filename}.log + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +# output should exist +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi +# intermediate file should not exist +if [[ -f "${intermfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/onecc_neg_007.test b/compiler/one-cmds/tests/onecc_neg_007.test new file mode 100644 index 000000000..264a74e48 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_007.test @@ -0,0 +1,41 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative subcommand + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "unrecognized arguments" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +rm -f ${filename}.log + +# run test +onecc wronginput > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_008.test b/compiler/one-cmds/tests/onecc_neg_008.test new file mode 100644 index 000000000..67b2c6ff3 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_008.test @@ -0,0 +1,41 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative subcommand with empty argument + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "error" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +rm -f ${filename}.log + +# run test +onecc > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_009.test b/compiler/one-cmds/tests/onecc_neg_009.test new file mode 100644 index 000000000..26ad7da60 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_009.test @@ -0,0 +1,71 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Valid optimization option but invalid configuration file path + +: ' +This test assumes below directories. + +[one hierarchy] + one + ├── backends + ├── bin + ├── doc + ├── include + ├── lib + ├── optimization + └── test # pwd +' + +OPT_ALREADY_EXIST=true + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + rm -rf ../optimization/OONECC_NEG_009.cfg + if [ "$OPT_ALREADY_EXIST" = false ]; then + rm -rf ../optimization + fi + if grep -q "Not found given configuration file" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +if [ ! -d "../optimization" ]; then + mkdir -p ../optimization + OPT_ALREADY_EXIST=false +fi + + +touch ../optimization/OONECC_NEG_009.cfg + +configfile=".." + +rm -f ${filename}.log + +# run test +onecc -C ${configfile} -OONECC_NEG_009 > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_010.test b/compiler/one-cmds/tests/onecc_neg_010.test new file mode 100644 index 000000000..98605902c --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_010.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Invalid optimization option + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Invalid optimization option" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile=".." + +rm -f ${filename}.log + +# run test +onecc -C ${configfile} -OONECC_NEG_010 > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_011.cfg b/compiler/one-cmds/tests/onecc_neg_011.cfg new file mode 100644 index 000000000..b5873245b --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_011.cfg @@ -0,0 +1,13 @@ +[onecc] +one-import-tf=False +one-import-tflite=False +one-import-bcq=False +one-optimize=True +one-quantize=False +one-pack=False +one-codegen=False + +[one-optimize] +input_path=inception_v3.circle +output_path=inception_v3.opt.circle +wrong_opt=True diff --git a/compiler/one-cmds/tests/onecc_neg_011.test b/compiler/one-cmds/tests/onecc_neg_011.test new file mode 100644 index 000000000..5df6fc830 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_011.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# generate error for unrecognized opitmization option + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "following arguments are unrecognized" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_neg_011.cfg" + +rm -f ${filename}.log + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_012.cfg b/compiler/one-cmds/tests/onecc_neg_012.cfg new file mode 100644 index 000000000..732409139 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_012.cfg @@ -0,0 +1,14 @@ +[onecc] +one-import-tf=False +one-import-tflite=False +one-import-bcq=False +one-optimize=False +one-quantize=False +one-pack=False +one-codegen=False +one-profile=False +one-infer=True + +[one-infer] +driver=dummy-infer +command="dummy arguments" diff --git a/compiler/one-cmds/tests/onecc_neg_012.test b/compiler/one-cmds/tests/onecc_neg_012.test new file mode 100644 index 000000000..45ed13d32 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_012.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Check the case when driver does not exist + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "dummy-infer not found" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_neg_012.cfg" + +rm -f ${filename}.log + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_013.test b/compiler/one-cmds/tests/onecc_neg_013.test new file mode 100644 index 000000000..95ac3c95c --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_013.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# negative usage with missing workflow file + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Not found given workflow file" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +workflowfile="onecc_neg_013.workflow.json" + +rm -f ${filename}.log + +# run test +onecc -W ${workflowfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_014.test b/compiler/one-cmds/tests/onecc_neg_014.test new file mode 100644 index 000000000..704acfae9 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_014.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# invalid workflow file + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Invalid workflow file" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +workflowfile="onecc_neg_014.workflow.json" + +rm -f ${filename}.log + +# run test +onecc -W ${workflowfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_014.workflow.json b/compiler/one-cmds/tests/onecc_neg_014.workflow.json new file mode 100644 index 000000000..8d4fd431e --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_014.workflow.json @@ -0,0 +1,3 @@ +{ + INVALID JSON FILE +} diff --git a/compiler/one-cmds/tests/onecc_neg_015.test b/compiler/one-cmds/tests/onecc_neg_015.test new file mode 100644 index 000000000..d15a2f367 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_015.test @@ -0,0 +1,44 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# workflow file has invalid key + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Not found" "${filename}.log" && + grep -q "key in workflow file" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +workflowfile="onecc_neg_015.workflow.json" + +rm -f ${filename}.log + +# run test +onecc -W ${workflowfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_015.workflow.json b/compiler/one-cmds/tests/onecc_neg_015.workflow.json new file mode 100644 index 000000000..4cb752e4e --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_015.workflow.json @@ -0,0 +1,21 @@ +{ + "workflowsssssss": [ + "SIMPLE_WORKFLOW" + ], + "SIMPLE_WORKFLOW": { + "steps": [ + "QUANTIZE" + ], + "QUANTIZE": { + "one-cmd": "one-quantize", + "commands": { + "input_path": "inception_v3.circle", + "output_path": "inception_v3.onecc_026.q.circle", + "input_data": "inception_v3_test_data.h5", + "evaluate_result": "True", + "test_data": "inception_v3_test_data.h5", + "print_mpeir": "True" + } + } + } +} diff --git a/compiler/one-cmds/tests/onecc_neg_016.test b/compiler/one-cmds/tests/onecc_neg_016.test new file mode 100644 index 000000000..23964e928 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_016.test @@ -0,0 +1,44 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# workflow file has invalid key + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Not found" "${filename}.log" && + grep -q "key listed in" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +workflowfile="onecc_neg_016.workflow.json" + +rm -f ${filename}.log + +# run test +onecc -W ${workflowfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_016.workflow.json b/compiler/one-cmds/tests/onecc_neg_016.workflow.json new file mode 100644 index 000000000..c929cf38c --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_016.workflow.json @@ -0,0 +1,21 @@ +{ + "workflows": [ + "SIMPLE_WORKFLOW" + ], + "SIMPLE_WORKFLOWWWWW": { + "steps": [ + "QUANTIZE" + ], + "QUANTIZE": { + "one-cmd": "one-quantize", + "commands": { + "input_path": "inception_v3.circle", + "output_path": "inception_v3.onecc_026.q.circle", + "input_data": "inception_v3_test_data.h5", + "evaluate_result": "True", + "test_data": "inception_v3_test_data.h5", + "print_mpeir": "True" + } + } + } +} diff --git a/compiler/one-cmds/tests/onecc_neg_017.test b/compiler/one-cmds/tests/onecc_neg_017.test new file mode 100644 index 000000000..a345d6259 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_017.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# workflow file has invalid key + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Each workflow should have either" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +workflowfile="onecc_neg_017.workflow.json" + +rm -f ${filename}.log + +# run test +onecc -W ${workflowfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_017.workflow.json b/compiler/one-cmds/tests/onecc_neg_017.workflow.json new file mode 100644 index 000000000..22f1415e9 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_017.workflow.json @@ -0,0 +1,18 @@ +{ + "workflows": [ + "SIMPLE_WORKFLOW" + ], + "SIMPLE_WORKFLOW": { + "QUANTIZE": { + "one-cmd": "one-quantize", + "commands": { + "input_path": "inception_v3.circle", + "output_path": "inception_v3.onecc_026.q.circle", + "input_data": "inception_v3_test_data.h5", + "evaluate_result": "True", + "test_data": "inception_v3_test_data.h5", + "print_mpeir": "True" + } + } + } +} diff --git a/compiler/one-cmds/tests/onecc_neg_018.test b/compiler/one-cmds/tests/onecc_neg_018.test new file mode 100644 index 000000000..b70fae4e8 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_018.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# workflow file has invalid key + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "are exclusive key" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +workflowfile="onecc_neg_018.workflow.json" + +rm -f ${filename}.log + +# run test +onecc -W ${workflowfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_018.workflow.json b/compiler/one-cmds/tests/onecc_neg_018.workflow.json new file mode 100644 index 000000000..e0754d392 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_018.workflow.json @@ -0,0 +1,24 @@ +{ + "workflows": [ + "MY_WORKFLOW" + ], + "MY_WORKFLOW": { + "steps": [ + "IMPORT_TF" + ], + "cfg-reference": { + "path": "/path/to/ini/format/file" + }, + "IMPORT_TF": { + "one-cmd": "one-import-tf", + "commands": { + "input_path": "inception_v3.pb", + "output_path": "inception_v3.onecc_neg_018.circle", + "input_arrays": "input", + "input_shapes": "1,299,299,3", + "output_arrays": "InceptionV3/Predictions/Reshape_1", + "converter_version": "v2" + } + } + } +} diff --git a/compiler/one-cmds/tests/onecc_neg_019.test b/compiler/one-cmds/tests/onecc_neg_019.test new file mode 100644 index 000000000..430438d61 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_019.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# workflow file has invalid key + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Each step should have" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +workflowfile="onecc_neg_019.workflow.json" + +rm -f ${filename}.log + +# run test +onecc -W ${workflowfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_019.workflow.json b/compiler/one-cmds/tests/onecc_neg_019.workflow.json new file mode 100644 index 000000000..995c6bf4a --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_019.workflow.json @@ -0,0 +1,21 @@ +{ + "workflows": [ + "MY_WORKFLOW" + ], + "MY_WORKFLOW": { + "steps": [ + "IMPORT_TF" + ], + "IMPORT_TF": { + "one-cmddddddddd": "one-import-tf", + "commands": { + "input_path": "inception_v3.pb", + "output_path": "inception_v3.onecc_neg_019.circle", + "input_arrays": "input", + "input_shapes": "1,299,299,3", + "output_arrays": "InceptionV3/Predictions/Reshape_1", + "converter_version": "v2" + } + } + } +} diff --git a/compiler/one-cmds/tests/onecc_neg_020.test b/compiler/one-cmds/tests/onecc_neg_020.test new file mode 100644 index 000000000..b86a23116 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_020.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# workflow file has invalid key + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Each step should have" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +workflowfile="onecc_neg_020.workflow.json" + +rm -f ${filename}.log + +# run test +onecc -W ${workflowfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_020.workflow.json b/compiler/one-cmds/tests/onecc_neg_020.workflow.json new file mode 100644 index 000000000..89f0d59af --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_020.workflow.json @@ -0,0 +1,21 @@ +{ + "workflows": [ + "MY_WORKFLOW" + ], + "MY_WORKFLOW": { + "steps": [ + "IMPORT_TF" + ], + "IMPORT_TF": { + "one-cmd": "one-import-tf", + "commandssssssssss": { + "input_path": "inception_v3.pb", + "output_path": "inception_v3.onecc_neg_020.circle", + "input_arrays": "input", + "input_shapes": "1,299,299,3", + "output_arrays": "InceptionV3/Predictions/Reshape_1", + "converter_version": "v2" + } + } + } +} diff --git a/compiler/one-cmds/tests/onecc_neg_021.test b/compiler/one-cmds/tests/onecc_neg_021.test new file mode 100644 index 000000000..ef023b133 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_021.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# workflows have a cycle + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Workflows should not have a cycle" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +workflowfile="onecc_neg_021.workflow.json" + +rm -f ${filename}.log + +# run test +onecc -W ${workflowfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_021.workflow.json b/compiler/one-cmds/tests/onecc_neg_021.workflow.json new file mode 100644 index 000000000..c326d41a6 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_021.workflow.json @@ -0,0 +1,44 @@ +{ + "workflows": [ + "CYCLE_WF1", + "CYCLE_WF2" + ], + "CYCLE_WF1": { + "run-after": [ + "CYCLE_WF2" + ], + "steps": [ + "IMPORT_TF" + ], + "IMPORT_TF": { + "one-cmd": "one-import-tf", + "commands": { + "input_path": "inception_v3.pb", + "output_path": "inception_v3.onecc_neg_021.circle", + "input_arrays": "input", + "input_shapes": "1,299,299,3", + "output_arrays": "InceptionV3/Predictions/Reshape_1", + "converter_version": "v2" + } + } + }, + "CYCLE_WF2": { + "run-after": [ + "CYCLE_WF1" + ], + "steps": [ + "IMPORT_TF" + ], + "IMPORT_TF": { + "one-cmd": "one-import-tf", + "commands": { + "input_path": "inception_v3.pb", + "output_path": "inception_v3.onecc_neg_021.circle", + "input_arrays": "input", + "input_shapes": "1,299,299,3", + "output_arrays": "InceptionV3/Predictions/Reshape_1", + "converter_version": "v2" + } + } + } +} diff --git a/compiler/one-cmds/tests/onecc_neg_022.cfg b/compiler/one-cmds/tests/onecc_neg_022.cfg new file mode 100644 index 000000000..16135f074 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_022.cfg @@ -0,0 +1,16 @@ +[onecc] +one-import-tf=True +one-import-tflite=False +one-import-bcq=False +one-optimize=False +one-quantize=False +one-pack=False +one-codegen=False + +[one-import-tf] +input_path=inception_v3.pb +output_path=inception_v3_without_opt.circle +input_arrays=input +input_shapes=1,299,299,3 +output_arrays=InceptionV3/Predictions/Reshape_1 +converter_version=v2 diff --git a/compiler/one-cmds/tests/onecc_neg_022.test b/compiler/one-cmds/tests/onecc_neg_022.test new file mode 100644 index 000000000..002908a7a --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_022.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# workflows have a cycle + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Workflows should not have a cycle" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +workflowfile="onecc_neg_022.workflow.json" + +rm -f ${filename}.log + +# run test +onecc -W ${workflowfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_022.workflow.json b/compiler/one-cmds/tests/onecc_neg_022.workflow.json new file mode 100644 index 000000000..1f4508134 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_022.workflow.json @@ -0,0 +1,63 @@ +{ + "workflows": [ + "WITHOUT_OPT", + "WITH_OPT", + "INFER" + ], + "INFER": { + "run-after": [ + "WITHOUT_OPT", + "WITH_OPT" + ], + "steps": [ + "INFER1", + "INFER2" + ], + "INFER1": { + "one-cmd": "one-infer", + "commands" : { + "driver": "dummy-inferV2", + "command": "inception_v3_without_opt.circle" + } + }, + "INFER2": { + "one-cmd": "one-infer", + "commands": { + "driver": "dummy-inferV2", + "command": "inception_v3.opt.circle" + } + } + }, + "WITHOUT_OPT": { + "cfg-reference": { + "path": "onecc_041.cfg" + } + }, + "WITH_OPT": { + "run-after": [ + "WITHOUT_OPT" + ], + "steps": [ + "IMPORT_TF", + "OPTIMIZE" + ], + "IMPORT_TF": { + "one-cmd": "one-import-tf", + "commands": { + "input_path": "inception_v3.pb", + "output_path": "inception_v3.onecc_neg_022.circle", + "input_arrays": "input", + "input_shapes": "1,299,299,3", + "output_arrays": "InceptionV3/Predictions/Reshape_1", + "converter_version": "v2" + } + }, + "OPTIMIZE": { + "one-cmd": "one-optimize", + "commands": { + "input_path": "inception_v3.onecc_neg_022.circle", + "output_path": "inception_v3.opt.circle" + } + } + } +} diff --git a/compiler/one-cmds/tests/onecc_neg_023.test b/compiler/one-cmds/tests/onecc_neg_023.test new file mode 100644 index 000000000..436c7c3b3 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_023.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# workflows have wrong optimize option + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Change outputs failed" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +workflowfile="onecc_neg_023.workflow.json" + +rm -f ${filename}.log + +# run test +onecc -W ${workflowfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_023.workflow.json b/compiler/one-cmds/tests/onecc_neg_023.workflow.json new file mode 100644 index 000000000..2d763f098 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_023.workflow.json @@ -0,0 +1,30 @@ +{ + "workflows": [ + "WITH_OPT" + ], + "WITH_OPT": { + "steps": [ + "IMPORT_TF", + "OPTIMIZE" + ], + "IMPORT_TF": { + "one-cmd": "one-import-tf", + "commands": { + "input_path": "inception_v3.pb", + "output_path": "inception_v3.onecc_neg_023.circle", + "input_arrays": "input", + "input_shapes": "1,299,299,3", + "output_arrays": "InceptionV3/Predictions/Reshape_1", + "converter_version": "v2" + } + }, + "OPTIMIZE": { + "one-cmd": "one-optimize", + "commands": { + "input_path": "inception_v3.onecc_neg_023.circle", + "output_path": "inception_v3.opt.circle", + "change_outputs": "non_existing_node_name" + } + } + } +} diff --git a/compiler/one-cmds/tests/onecc_neg_024.cfg b/compiler/one-cmds/tests/onecc_neg_024.cfg new file mode 100644 index 000000000..0e9ebc63c --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_024.cfg @@ -0,0 +1,20 @@ +[onecc] +one-import-tf=False +one-import-tflite=False +one-import-bcq=False +one-import-onnx=True +one-optimize=True +one-quantize=False +one-pack=False +one-codegen=False +include=O # invalid (too short group option) + +[one-import-onnx] +input_path=test_onnx_model.onnx +output_path=test_onnx_model.circle + +[one-optimize] +input_path=test_onnx_model.circle +output_path=test_onnx_model.onecc_neg_024.opt.circle +convert_nchw_to_nhwc=True +fold_add_v2=False diff --git a/compiler/one-cmds/tests/onecc_neg_024.test b/compiler/one-cmds/tests/onecc_neg_024.test new file mode 100644 index 000000000..16952baba --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_024.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# invalid group option + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Invalid group option" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_neg_024.cfg" + +rm -f ${filename}.log + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_025.cfg b/compiler/one-cmds/tests/onecc_neg_025.cfg new file mode 100644 index 000000000..e41c6e63c --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_025.cfg @@ -0,0 +1,20 @@ +[onecc] +one-import-tf=False +one-import-tflite=False +one-import-bcq=False +one-import-onnx=True +one-optimize=True +one-quantize=False +one-pack=False +one-codegen=False +include=A1 # invalid (must start with 'O') + +[one-import-onnx] +input_path=test_onnx_model.onnx +output_path=test_onnx_model.circle + +[one-optimize] +input_path=test_onnx_model.circle +output_path=test_onnx_model.onecc_neg_024.opt.circle +convert_nchw_to_nhwc=True +fold_add_v2=False diff --git a/compiler/one-cmds/tests/onecc_neg_025.test b/compiler/one-cmds/tests/onecc_neg_025.test new file mode 100644 index 000000000..4ddc31002 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_025.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# invalid group option + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Invalid group option" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_neg_025.cfg" + +rm -f ${filename}.log + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_026.cfg b/compiler/one-cmds/tests/onecc_neg_026.cfg new file mode 100644 index 000000000..2efddb1d2 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_026.cfg @@ -0,0 +1,13 @@ +[onecc] +one-import-tf=False +one-import-tflite=False +one-import-bcq=False +one-optimize=False +one-quantize=True +one-pack=False +one-codegen=False + +[one-quantize] +input_path=reshape_matmul.circle +output_path=reshape_matmul.onecc_045.q.circle +input_type=uint8,int16,uint8 diff --git a/compiler/one-cmds/tests/onecc_neg_026.test b/compiler/one-cmds/tests/onecc_neg_026.test new file mode 100644 index 000000000..f90c1ec47 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_026.test @@ -0,0 +1,44 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Wrong number of input_type in one-quantize + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Invalid number of input dtype" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./reshape_matmul.circle" +configfile="onecc_neg_026.cfg" + +rm -f ${filename}.log + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_027.cfg b/compiler/one-cmds/tests/onecc_neg_027.cfg new file mode 100644 index 000000000..27f3f67cf --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_027.cfg @@ -0,0 +1,7 @@ +[onecc] +one-codegen=True + +[one-codegen] +backends=dummy,dummyV2 +dummy=-o sample.tvn inception_v3.onecc_neg_027.circle +# dummyV2=-O sample2.tvn inception_v3.onecc_neg_027.circle diff --git a/compiler/one-cmds/tests/onecc_neg_027.test b/compiler/one-cmds/tests/onecc_neg_027.test new file mode 100644 index 000000000..f96825623 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_027.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# not found the command for given backend + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Not found the command for dummyV2" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_neg_027.cfg" + +rm -f ${filename}.log + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_028.cfg b/compiler/one-cmds/tests/onecc_neg_028.cfg new file mode 100644 index 000000000..ca19c53ba --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_028.cfg @@ -0,0 +1,9 @@ +[onecc] +one-codegen=True + +[one-codegen] +backend=dummy3 +command=-o sample.tvn inception_v3.onecc_neg_028.circle +backends=dummy,dummy2 +dummy=-o sample.tvn inception_v3.onecc_neg_028.circle +dummyV2=-O sample2.tvn inception_v3.onecc_neg_028.circle diff --git a/compiler/one-cmds/tests/onecc_neg_028.test b/compiler/one-cmds/tests/onecc_neg_028.test new file mode 100644 index 000000000..beba24ab6 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_028.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# use 'backend' and 'backends' option simultaneously + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "option cannot be used simultaneously" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_neg_028.cfg" + +rm -f ${filename}.log + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_029.cfg b/compiler/one-cmds/tests/onecc_neg_029.cfg new file mode 100644 index 000000000..02f527b87 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_029.cfg @@ -0,0 +1,6 @@ +[onecc] +one-codegen=True + +[one-codegen] +backend=dummy3 +command=-o sample.tvn inception_v3.onecc_neg_029.circle diff --git a/compiler/one-cmds/tests/onecc_neg_029.test b/compiler/one-cmds/tests/onecc_neg_029.test new file mode 100644 index 000000000..5ced5fe67 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_029.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# not found the command of given backend + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Not found the command of given backend" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_neg_029.cfg" + +rm -f ${filename}.log + +# run test +onecc -C ${configfile} --backend dummy2 > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_030.cfg b/compiler/one-cmds/tests/onecc_neg_030.cfg new file mode 100644 index 000000000..0d573c1ad --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_030.cfg @@ -0,0 +1,6 @@ +[onecc] +one-codegen=True + +[one-codegen] +backends=dummy3 +dummy3=-o sample.tvn inception_v3.onecc_neg_030.circle diff --git a/compiler/one-cmds/tests/onecc_neg_030.test b/compiler/one-cmds/tests/onecc_neg_030.test new file mode 100644 index 000000000..404a9b885 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_030.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# not found the command of given backend + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Not found the command of given backend" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_neg_030.cfg" + +rm -f ${filename}.log + +# run test +onecc -C ${configfile} --backend dummy2 > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_031.test b/compiler/one-cmds/tests/onecc_neg_031.test new file mode 100644 index 000000000..c7d857562 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_031.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# use 'backend' option with 'workflow' option + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "'backend' option can be used only with 'config' option" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +workflowfile="onecc_neg_031.workflow.json" + +rm -f ${filename}.log + +# run test +onecc -W ${workflowfile} --backend dummy > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_031.workflow.json b/compiler/one-cmds/tests/onecc_neg_031.workflow.json new file mode 100644 index 000000000..d323cc94f --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_031.workflow.json @@ -0,0 +1,29 @@ +{ + "workflows": [ + "codegen_wf" + ], + "codegen_wf": { + "steps": [ + "import_tf", + "codegen" + ], + "import_tf": { + "one-cmd": "one-import-tf", + "commands": { + "input_path": "inception_v3.pb", + "output_path": "inception_v3.onecc_neg_031.circle", + "input_arrays": "input", + "input_shapes": "1,299,299,3", + "output_arrays": "InceptionV3/Predictions/Reshape_1", + "converter_version": "v2" + } + }, + "codegen": { + "one-cmd": "one-codegen", + "commands": { + "backend": "dummy", + "command": "-o sample.tvn inception_v3.onecc_neg_031.circle" + } + } + } +} diff --git a/compiler/one-cmds/tests/onecc_neg_032.cfg b/compiler/one-cmds/tests/onecc_neg_032.cfg new file mode 100644 index 000000000..949194806 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_032.cfg @@ -0,0 +1,7 @@ +[onecc] +one-profile=True + +[one-profile] +backends=dummy,dummyV2 +dummy=dummy.bin +# dummyV2=dummyV2.bin diff --git a/compiler/one-cmds/tests/onecc_neg_032.test b/compiler/one-cmds/tests/onecc_neg_032.test new file mode 100644 index 000000000..12b70cbc4 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_032.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# not found the command for given backend + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Not found the command for dummyV2" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_neg_032.cfg" + +rm -f ${filename}.log + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_033.cfg b/compiler/one-cmds/tests/onecc_neg_033.cfg new file mode 100644 index 000000000..6c77870b1 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_033.cfg @@ -0,0 +1,9 @@ +[onecc] +one-profile=True + +[one-profile] +backend=dummyV3 +command=dummyV3.bin +backends=dummy,dummyV2 +dummy=dummy.bin +dummyV2=dummyB2.bin diff --git a/compiler/one-cmds/tests/onecc_neg_033.test b/compiler/one-cmds/tests/onecc_neg_033.test new file mode 100644 index 000000000..51b7ca073 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_033.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# use 'backend' and 'backends' option simultaneously + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "option cannot be used simultaneously" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_neg_033.cfg" + +rm -f ${filename}.log + +# run test +onecc -C ${configfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_034.cfg b/compiler/one-cmds/tests/onecc_neg_034.cfg new file mode 100644 index 000000000..8c64628b4 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_034.cfg @@ -0,0 +1,6 @@ +[onecc] +one-profile=True + +[one-profile] +backend=dummy +command=dummy.bin diff --git a/compiler/one-cmds/tests/onecc_neg_034.test b/compiler/one-cmds/tests/onecc_neg_034.test new file mode 100644 index 000000000..58cc8d3d1 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_034.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# not found the command of given backend + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Not found the command of given backend" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_neg_034.cfg" + +rm -f ${filename}.log + +# run test +onecc -C ${configfile} --backend dummyV2 > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_035.cfg b/compiler/one-cmds/tests/onecc_neg_035.cfg new file mode 100644 index 000000000..6468d73bc --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_035.cfg @@ -0,0 +1,6 @@ +[onecc] +one-profile=True + +[one-profile] +backends=dummyV2 +dummyV2=dummyV2.bin diff --git a/compiler/one-cmds/tests/onecc_neg_035.test b/compiler/one-cmds/tests/onecc_neg_035.test new file mode 100644 index 000000000..cae5ba1c8 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_035.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# not found the command of given backend + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Not found the command of given backend" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +configfile="onecc_neg_035.cfg" + +rm -f ${filename}.log + +# run test +onecc -C ${configfile} --backend dummy > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_036.test b/compiler/one-cmds/tests/onecc_neg_036.test new file mode 100644 index 000000000..929457575 --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_036.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# use 'backend' option with 'workflow' option + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "'backend' option can be used only with 'config' option" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +workflowfile="onecc_neg_036.workflow.json" + +rm -f ${filename}.log + +# run test +onecc -W ${workflowfile} --backend dummy > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/onecc_neg_036.workflow.json b/compiler/one-cmds/tests/onecc_neg_036.workflow.json new file mode 100644 index 000000000..9acd4d26e --- /dev/null +++ b/compiler/one-cmds/tests/onecc_neg_036.workflow.json @@ -0,0 +1,29 @@ +{ + "workflows": [ + "profile_wf" + ], + "profile_wf": { + "steps": [ + "import_tf", + "profile" + ], + "import_tf": { + "one-cmd": "one-import-tf", + "commands": { + "input_path": "inception_v3.pb", + "output_path": "inception_v3.onecc_neg_036.circle", + "input_arrays": "input", + "input_shapes": "1,299,299,3", + "output_arrays": "InceptionV3/Predictions/Reshape_1", + "converter_version": "v2" + } + }, + "profile": { + "one-cmd": "one-profile", + "commands": { + "backend": "dummy", + "command": "dummy.bin" + } + } + } +} diff --git a/compiler/one-cmds/tests/onnx-operations/CMakeLists.txt b/compiler/one-cmds/tests/onnx-operations/CMakeLists.txt new file mode 100644 index 000000000..e6b2b354a --- /dev/null +++ b/compiler/one-cmds/tests/onnx-operations/CMakeLists.txt @@ -0,0 +1,86 @@ +# Install one-cmds test scripts for onnx models + +# Gather test scripts +set(EXAMPLES_DIR "${NNAS_PROJECT_SOURCE_DIR}/res/PyTorchExamples/examples") +file(GLOB TEST_EXAMPLES RELATIVE "${EXAMPLES_DIR}" "${EXAMPLES_DIR}/*") + +set(TEST_DST test/onnx-operations) + +install(DIRECTORY "${NNAS_PROJECT_SOURCE_DIR}/res/PyTorchExamples/" DESTINATION "${TEST_DST}") + +set(ONNX_IMPORT_OPTIONS "--unroll_rnn --unroll_lstm") + +foreach(TEST_ITEM IN ITEMS ${TEST_EXAMPLES}) + set(TEST_SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/${TEST_ITEM}.test") + + # generate test script + file(WRITE "${TEST_SCRIPT}" "#!/bin/bash\n\n") + file(APPEND "${TEST_SCRIPT}" "filename_ext=\"\$(basename -- $0)\"\n") + file(APPEND "${TEST_SCRIPT}" "filename=\"\${filename_ext%.*}\"\n") + file(APPEND "${TEST_SCRIPT}" "trap_err_onexit()\n") + file(APPEND "${TEST_SCRIPT}" "{\n") + file(APPEND "${TEST_SCRIPT}" "echo \"\${filename_ext} FAILED\"\n") + file(APPEND "${TEST_SCRIPT}" "exit 255\n") + file(APPEND "${TEST_SCRIPT}" "}\n") + file(APPEND "${TEST_SCRIPT}" "trap trap_err_onexit ERR\n") + file(APPEND "${TEST_SCRIPT}" "outputfile=\"${TEST_ITEM}.circle\"\n") + file(APPEND "${TEST_SCRIPT}" "one-import-onnx --input_path=${TEST_ITEM}.onnx --output_path=${TEST_ITEM}.circle\ + ${ONNX_IMPORT_OPTIONS} &> /dev/null\n") + file(APPEND "${TEST_SCRIPT}" "if [[ ! -s \"\${outputfile}\" ]]; then\n") + file(APPEND "${TEST_SCRIPT}" "trap_err_onexit\n") + file(APPEND "${TEST_SCRIPT}" "fi\n") + file(APPEND "${TEST_SCRIPT}" "echo \"\${filename_ext} SUCCESS\"\n") + + install(FILES "${TEST_SCRIPT}" DESTINATION "${TEST_DST}") +endforeach(TEST_ITEM) + + +# Create a script to run the tests at installation folder +set(DRIVER_SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/runtestall.sh") + +file(WRITE "${DRIVER_SCRIPT}" "#!/bin/bash\n\n") +file(APPEND "${DRIVER_SCRIPT}" "SCRIPT_PATH=$(cd $(dirname \${BASH_SOURCE[0]}) && pwd)\n") +file(APPEND "${DRIVER_SCRIPT}" "pushd $SCRIPT_PATH > /dev/null\n") +file(APPEND "${DRIVER_SCRIPT}" "rm -rf runtestall.log\n") +file(APPEND "${DRIVER_SCRIPT}" "export PATH=$SCRIPT_PATH/../bin:$PATH\n") +file(APPEND "${DRIVER_SCRIPT}" "if [[ $# -ge 1 ]]; then\n") +file(APPEND "${DRIVER_SCRIPT}" " USER_PATH=$1\n") +file(APPEND "${DRIVER_SCRIPT}" " export PATH=$USER_PATH:$PATH\n") +file(APPEND "${DRIVER_SCRIPT}" "fi\n") +file(APPEND "${DRIVER_SCRIPT}" "\n") +file(APPEND "${DRIVER_SCRIPT}" "# refer https://github.com/Samsung/ONE/issues/6286\n") +file(APPEND "${DRIVER_SCRIPT}" "set -o pipefail\n\n") +file(APPEND "${DRIVER_SCRIPT}" "fail_count=0\n") +file(APPEND "${DRIVER_SCRIPT}" "trap \"(( fail_count++ ))\" ERR\n\n") + +foreach(TEST_ITEM IN ITEMS ${TEST_EXAMPLES}) + file(APPEND "${DRIVER_SCRIPT}" "/bin/bash \"${TEST_ITEM}.test\" | tee -a runtestall.log\n") +endforeach(TEST_ITEM) + +file(APPEND "${DRIVER_SCRIPT}" "popd > /dev/null\n\n") + +file(APPEND "${DRIVER_SCRIPT}" +"if [[ $fail_count != 0 ]]; then + echo \"$fail_count TESTS FAILED\" + exit 255 +else + echo \"ALL TESTS PASSED!\" +fi\n +") + +set(PREPARE_TEST_MATERIALS_SH "${CMAKE_CURRENT_SOURCE_DIR}/prepare_test_materials.sh") + +install(FILES "${DRIVER_SCRIPT}" + PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE + DESTINATION "${TEST_DST}") + +install(FILES "${PREPARE_TEST_MATERIALS_SH}" + PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE + DESTINATION "${TEST_DST}") + +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/README.md" + DESTINATION "${TEST_DST}") diff --git a/compiler/one-cmds/tests/onnx-operations/README.md b/compiler/one-cmds/tests/onnx-operations/README.md new file mode 100644 index 000000000..928fb84dd --- /dev/null +++ b/compiler/one-cmds/tests/onnx-operations/README.md @@ -0,0 +1,28 @@ +## Overview + +This directory contains auxilliary tests for small onnx target models. + +Most of the models contains single operations, but some contains multiple operations, that represents one operation with complex semantics. + +Models for these tests are taken from res/PyTorchExamples. + +## To run all tests + +Steps: +1) run 'one-prepare-venv' in bin folder to prepare python virtual-env with TensorFlow + - you need to run this only once + - read 'doc/how-to-prepare-virtualenv.txt' for more information + ``` + bin/one-prepare-venv + ``` +2) run 'test/onnx-operations/prepare_test_materials.sh' to download test material models + - you need to run this only once + - you need internet connection to download files + - you may need to install 'wget' and 'unzip' packages + ``` + test/onnx-operations/prepare_test_materials.sh + ``` +3) run 'test/onnx-operations/runtestall.sh' to run the test + ``` + test/onnx-operations/runtestall.sh + ``` diff --git a/compiler/one-cmds/tests/onnx-operations/prepare_test_materials.sh b/compiler/one-cmds/tests/onnx-operations/prepare_test_materials.sh new file mode 100644 index 000000000..274a60f0a --- /dev/null +++ b/compiler/one-cmds/tests/onnx-operations/prepare_test_materials.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +pushd $SCRIPT_PATH > /dev/null + +for test_case in examples/*; do + python3 ptem.py $(basename ${test_case}) +done + +cp output/*.onnx . + +popd > /dev/null diff --git a/compiler/one-cmds/tests/onnx_legalize_run_compare.py b/compiler/one-cmds/tests/onnx_legalize_run_compare.py new file mode 100644 index 000000000..9b02b74af --- /dev/null +++ b/compiler/one-cmds/tests/onnx_legalize_run_compare.py @@ -0,0 +1,129 @@ +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import onnxruntime as rt +import onnx +import sys +import numpy as np +import importlib.util + + +def _generate_inputs(model): + """Generate random inputs for given model + + Args: + model (onnx.onnx_ml_pb2.ModelProto): target model + + Returns: + dict from str to numpy.ndarray: generated inputs + """ + inputs = {} + for input in model.graph.input: + # check if elem type is float32 + # list of types could be extended, this is a property of current testsuite + assert ( + input.type.tensor_type.elem_type == onnx.TensorProto.DataType.Value("FLOAT")) + input_shape = [] + for dim in input.type.tensor_type.shape.dim: + input_shape += [dim.dim_value] + inputs[input.name] = np.random.random(input_shape).astype(np.float32) + return inputs + + +def _run_model(model, inputs): + """Run given model + + Args: + model (onnx.onnx_ml_pb2.ModelProto): target model + inputs (dict from str to numpy.ndarray): sample inputs + + Returns: + list of numpy.ndarray: inference outputs + """ + output_names = list(map(lambda output: output.name, model.graph.output)) + session = rt.InferenceSession(model.SerializeToString()) + outputs = session.run(output_names, inputs) + return outputs + + +def _compare_results(ref_outputs, test_outputs, tolerance): + """Generate random inputs for given model + + Args: + ref_outputs (list of numpy.ndarray): reference values (original model results) + test_outputs (list of numpy.ndarray): tested values (modified model results) + tolerance (float): maximum acceptable relative difference + + Returns: + bool: True if outputs considered equal, False otherwise + """ + num_outputs = len(ref_outputs) + assert (len(test_outputs) == num_outputs) + for i in range(num_outputs): + if ref_outputs[i].shape != test_outputs[i].shape: + print("output {} shape mismatch: ref({}) vs test({})".format( + i, ref_outputs[i].shape, test_outputs[i].shape)) + return False + + abs_difference = np.abs(ref_outputs[i] - test_outputs[i]) + abs_ref_maximum = np.abs(ref_outputs[i]).max() + peak_error = abs_difference.max() / abs_ref_maximum + + if peak_error > tolerance: + print("output {} peak error to value ratio {} is too big".format( + i, peak_error)) + return False + return True + + +if __name__ == '__main__': + if len(sys.argv) < 6: + exit('expecting 5 arguments:\n' + ' - path to input model\n' + ' - path to "legalized" model\n' + ' - path to onnx_legalizer.py\n' + ' - base name for generated test inputs\n' + ' - output tolerance') + input_model_path = sys.argv[1] + output_model_path = sys.argv[2] + onnx_legalizer_path = sys.argv[3] + input_dump_path = sys.argv[4] + tolerance = float(sys.argv[5]) + + onnx_legalizer_spec = importlib.util.spec_from_file_location( + "onnx_legalizer", onnx_legalizer_path) + onnx_legalizer = importlib.util.module_from_spec(onnx_legalizer_spec) + onnx_legalizer_spec.loader.exec_module(onnx_legalizer) + + model = onnx.load(input_model_path) + + inputs = _generate_inputs(model) + + for i in inputs: + np.save('{}_{}.npy'.format(input_dump_path, i), inputs[i]) + + ref_outputs = _run_model(model, inputs) + + options = onnx_legalizer.LegalizeOptions() + options.unroll_rnn = True + options.unroll_lstm = True + onnx_legalizer.legalize(model, options) + + with open(output_model_path, 'wb') as f: + f.write(model.SerializeToString()) + + test_outputs = _run_model(model, inputs) + + if not _compare_results(ref_outputs, test_outputs, tolerance): + exit('comparison failed') diff --git a/compiler/one-cmds/tests/prepare_test_materials.sh b/compiler/one-cmds/tests/prepare_test_materials.sh new file mode 100644 index 000000000..915beff43 --- /dev/null +++ b/compiler/one-cmds/tests/prepare_test_materials.sh @@ -0,0 +1,192 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# See https://github.com/Samsung/ONE/issues/4155 for information + +SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +pushd $SCRIPT_PATH > /dev/null + +if [[ ! -s "inception_v3.pb" ]]; then + rm -rf inception_v3_2018_04_27.tgz + wget -nv https://storage.googleapis.com/download.tensorflow.org/models/tflite/model_zoo/upload_20180427/inception_v3_2018_04_27.tgz + tar zxvf inception_v3_2018_04_27.tgz +fi + +if [[ ! -s "mobilenet_edgetpu_224_1.0_int8.tflite" ]]; then + wget -nv https://github.com/mlcommons/mobile_models/raw/main/v0_7/tflite/mobilenet_edgetpu_224_1.0_int8.tflite +fi + +if [[ ! -s "while_3.pbtxt" ]]; then + rm -rf while_3.zip + wget -nv https://github.com/Samsung/ONE/files/5095630/while_3.zip + unzip while_3.zip + # https://github.com/Samsung/ONE/issues/4155#issuecomment-689320297 +fi + +if [[ ! -s "mobilenet_test_data.h5" ]]; then + rm -rf mobilenet_test_data.zip + wget -nv https://github.com/Samsung/ONE/files/5139460/mobilenet_test_data.zip + unzip mobilenet_test_data.zip + # https://github.com/Samsung/ONE/issues/4155#issuecomment-689321538 +fi + +if [[ ! -s "bcq.pb" ]]; then + rm -rf bcq.pb.zip + wget -nv https://github.com/Samsung/ONE/files/5153842/bcq.pb.zip + unzip bcq.pb.zip + # https://github.com/Samsung/ONE/issues/4155#issuecomment-689324597 +fi + +if [[ ! -s "img_files" ]]; then + rm -rf img_files.zip + wget -nv https://github.com/Samsung/ONE/files/5499172/img_files.zip + unzip img_files.zip + # https://github.com/Samsung/ONE/issues/3213#issuecomment-722757499 +fi + +if [ ! -d "raw_files" ] || [ ! -s "datalist.txt" ]; then + ../bin/venv/bin/python preprocess_images.py +fi + +if [[ ! -s "inception_v3_test_data.h5" ]]; then + ../bin/venv/bin/python ../bin/rawdata2hdf5 \ + --data_list datalist.txt \ + --output_path inception_v3_test_data.h5 +fi + +if [[ ! -d "test_saved_model" ]]; then + rm -rf test_saved_model.zip + wget -nv https://github.com/Samsung/ONE/files/5516226/test_saved_model.zip + unzip test_saved_model.zip + # https://github.com/Samsung/ONE/issues/4268#issuecomment-724578237 +fi + +if [[ ! -s "test_keras_model.h5" ]]; then + rm -rf test_keras_model.zip + wget -nv https://github.com/Samsung/ONE/files/5520777/test_keras_model.zip + unzip test_keras_model.zip + # https://github.com/Samsung/ONE/issues/4268#issuecomment-725025805 +fi + +if [[ ! -s "test_onnx_model.onnx" ]]; then + rm -rf test_onnx_model.zip + wget -nv https://github.com/Samsung/ONE/files/5768243/test_onnx_model.zip + unzip test_onnx_model.zip + # https://github.com/Samsung/ONE/issues/5548#issuecomment-754373360 +fi + +if [[ ! -s "onnx_conv2d_conv2d.onnx" ]]; then + rm -rf onnx_conv2d_conv2d.zip + wget -nv https://github.com/Samsung/ONE/files/5774648/onnx_conv2d_conv2d.zip + unzip onnx_conv2d_conv2d.zip + # https://github.com/Samsung/ONE/issues/5577#issuecomment-755078444 +fi + +if [[ ! -s "reshape_matmul.onnx" ]]; then + rm -rf reshape_matmul.zip + wget -nv https://github.com/Samsung/ONE/files/12358217/reshape_matmul.zip + unzip reshape_matmul.zip + # https://github.com/Samsung/ONE/issues/9405#issuecomment-1680322410 +fi + +# prepare 'reshape_matmul.circle' file used for tests +if [[ ! -s "reshape_matmul.circle" ]]; then + ../bin/one-import onnx \ + --experimental_disable_batchmatmul_unfold \ + -i reshape_matmul.onnx \ + -o reshape_matmul.circle +fi + +if [[ ! -s "Net_InstanceNorm_003.part" ]]; then + rm -rf Net_InstanceNorm_003.zip + wget -nv https://github.com/Samsung/ONE/files/8608844/Net_InstanceNorm_003.zip + unzip Net_InstanceNorm_003.zip + # https://github.com/Samsung/ONE/issues/8570#issuecomment-1115804257 +fi + +if [[ ! -s "UnidirSeqLSTM.tflite" ]]; then + rm -rf UnidirSeqLSTM.zip + wget -nv https://github.com/Samsung/ONE/files/10055255/UnidirSeqLSTM.zip + unzip UnidirSeqLSTM.zip + # https://github.com/Samsung/ONE/issues/9940#issuecomment-1293282484 +fi + +function files_missing() { + condition="test " + + for f in "${@}"; do + condition="${condition} ! -s ${f} -o" + done + + # last condition is always false to properly close last "or" + condition="${condition} -z non_zero_string " + ${condition} +} + +declare -a TEST_RECCURENT_MODELS=(\ + "RNN.onnx" "RNN-nobias.onnx" "RNN-relu.onnx" "RNN-bi.onnx" "RNN-noinit.onnx"\ + "LSTM.onnx" "LSTM-bi.onnx" "LSTM-noinit.onnx" "LSTM-nobias.onnx" +) + +if files_missing "${TEST_RECCURENT_MODELS[@]}"; then + rm -rf test_onnx_recurrent_models.zip + wget -nv https://github.com/Samsung/ONE/files/8067909/test_onnx_recurrent_models.zip + unzip test_onnx_recurrent_models.zip + # https://github.com/Samsung/ONE/issues/8395#issuecomment-1040072097 +fi + +declare -a NEG_TEST_RECCURENT_MODELS=("rnn_variable.onnx" "lstm_variable.onnx") + +if files_missing "${NEG_TEST_RECCURENT_MODELS[@]}"; then + rm -rf neg_test_onnx_recurrent_models.zip + wget -nv https://github.com/Samsung/ONE/files/8137183/neg_test_onnx_recurrent_models.zip + unzip neg_test_onnx_recurrent_models.zip + # https://github.com/Samsung/ONE/issues/8395#issuecomment-1050364375 +fi + +# prepare 'inception_v3.circle' file used for quantization test +inputfile="./inception_v3.pb" +outputfile="./inception_v3.circle" + +if [[ ! -s ${outputfile} ]]; then + ../bin/one-import-tf \ + --input_path ${inputfile} \ + --output_path ${outputfile} \ + --input_arrays input --input_shapes "1,299,299,3" \ + --output_arrays InceptionV3/Predictions/Reshape_1 +fi + +# prepare 'inception_v3.mat.q8.circle' file used for quantization test +inputfile="./inception_v3.circle" +outputfile="./inception_v3.mat.q8.circle" + +if [[ ! -s ${outputfile} ]]; then + ../bin/one-quantize \ + --input_path ${inputfile} \ + --output_path ${outputfile} +fi + +# prepare 'mobilenet_edgetpu_224_1.0_int8.circle' file used for requantization test +inputfile="./mobilenet_edgetpu_224_1.0_int8.tflite" +outputfile="./mobilenet_edgetpu_224_1.0_int8.circle" + +if [[ ! -s ${outputfile} ]]; then + ../bin/one-import-tflite \ + --input_path ${inputfile} \ + --output_path ${outputfile} +fi + +popd > /dev/null diff --git a/compiler/one-cmds/tests/preprocess_images.py b/compiler/one-cmds/tests/preprocess_images.py new file mode 100644 index 000000000..ced6e3a08 --- /dev/null +++ b/compiler/one-cmds/tests/preprocess_images.py @@ -0,0 +1,38 @@ +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os, shutil, PIL.Image, numpy as np + +input_dir = 'img_files' +output_dir = 'raw_files' +list_file = 'datalist.txt' + +if os.path.exists(output_dir): + shutil.rmtree(output_dir, ignore_errors=True) +os.makedirs(output_dir) + +for (root, _, files) in os.walk(input_dir): + datalist = open(list_file, 'w') + for f in files: + with PIL.Image.open(root + '/' + f) as image: + # To handle ANTIALIAS deprecation + ANTIALIAS = PIL.Image.Resampling.LANCZOS if hasattr( + PIL.Image, "Resampling") else PIL.Image.ANTIALIAS + + img = np.array(image.resize((299, 299), ANTIALIAS)).astype(np.float32) + img = ((img / 255) - 0.5) * 2.0 + output_file = output_dir + '/' + f.replace('jpg', 'data') + img.tofile(output_file) + datalist.writelines(os.path.abspath(output_file) + '\n') + datalist.close() diff --git a/compiler/one-cmds/tests/print_onnx_model.py b/compiler/one-cmds/tests/print_onnx_model.py new file mode 100644 index 000000000..ecab0f6da --- /dev/null +++ b/compiler/one-cmds/tests/print_onnx_model.py @@ -0,0 +1,20 @@ +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import onnx +import sys + +if __name__ == '__main__': + model = onnx.load(sys.argv[1]) + print(model) diff --git a/compiler/one-cmds/tests/pytorch-operations/CMakeLists.txt b/compiler/one-cmds/tests/pytorch-operations/CMakeLists.txt new file mode 100644 index 000000000..10f30a5c9 --- /dev/null +++ b/compiler/one-cmds/tests/pytorch-operations/CMakeLists.txt @@ -0,0 +1,109 @@ +# Install one-cmds test scripts for pytorch models + +# Gather test scripts +set(EXAMPLES_DIR "${NNAS_PROJECT_SOURCE_DIR}/res/PyTorchExamples/examples") +file(GLOB TEST_EXAMPLES RELATIVE "${EXAMPLES_DIR}" "${EXAMPLES_DIR}/*") +file(GLOB SPECIAL_TEST_ITEMS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "./*.test") + +set(TEST_DST test/pytorch-operations) + +install(DIRECTORY "${NNAS_PROJECT_SOURCE_DIR}/res/PyTorchExamples/" DESTINATION "${TEST_DST}") + +set(PYTORCH_IMPORT_OPTIONS "--unroll_rnn --unroll_lstm") + +foreach(TEST_ITEM IN ITEMS ${TEST_EXAMPLES}) + set(TEST_SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/${TEST_ITEM}.test") + + # generate test script + file(WRITE "${TEST_SCRIPT}" "#!/bin/bash\n\n") + file(APPEND "${TEST_SCRIPT}" "filename_ext=\"\$(basename -- $0)\"\n") + file(APPEND "${TEST_SCRIPT}" "filename=\"\${filename_ext%.*}\"\n") + file(APPEND "${TEST_SCRIPT}" "trap_err_onexit()\n") + file(APPEND "${TEST_SCRIPT}" "{\n") + file(APPEND "${TEST_SCRIPT}" " echo \"\${filename_ext} FAILED\"\n") + file(APPEND "${TEST_SCRIPT}" " exit 255\n") + file(APPEND "${TEST_SCRIPT}" "}\n") + file(APPEND "${TEST_SCRIPT}" "trap trap_err_onexit ERR\n") + file(APPEND "${TEST_SCRIPT}" "outputfile=\"${TEST_ITEM}.circle\"\n") + file(APPEND "${TEST_SCRIPT}" "input_shapes=\$(head -n 1 ${TEST_ITEM}.spec)\n") + file(APPEND "${TEST_SCRIPT}" "input_types=\$(tail -n 1 ${TEST_ITEM}.spec)\n") + file(APPEND "${TEST_SCRIPT}" "one-import-pytorch --input_path=${TEST_ITEM}.pth --output_path=${TEST_ITEM}.circle\ + ${PYTORCH_IMPORT_OPTIONS} --input_shapes=\${input_shapes} --input_types=\${input_types} &> /dev/null\n") + file(APPEND "${TEST_SCRIPT}" "if [[ ! -s \"\${outputfile}\" ]]; then\n") + file(APPEND "${TEST_SCRIPT}" " trap_err_onexit\n") + file(APPEND "${TEST_SCRIPT}" "fi\n") + file(APPEND "${TEST_SCRIPT}" "echo \"\${filename_ext} SUCCESS\"\n") + + install(FILES "${TEST_SCRIPT}" DESTINATION "${TEST_DST}") +endforeach(TEST_ITEM) + + +# Create a script to run the tests at installation folder +set(DRIVER_SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/runtestall.sh") + +file(WRITE "${DRIVER_SCRIPT}" "#!/bin/bash\n\n") +file(APPEND "${DRIVER_SCRIPT}" "SCRIPT_PATH=$(cd $(dirname \${BASH_SOURCE[0]}) && pwd)\n") +file(APPEND "${DRIVER_SCRIPT}" "pushd $SCRIPT_PATH > /dev/null\n") +file(APPEND "${DRIVER_SCRIPT}" "rm -rf runtestall.log\n") +file(APPEND "${DRIVER_SCRIPT}" "export PATH=$SCRIPT_PATH/../bin:$PATH\n") +file(APPEND "${DRIVER_SCRIPT}" "if [[ $# -ge 1 ]]; then\n") +file(APPEND "${DRIVER_SCRIPT}" " USER_PATH=$1\n") +file(APPEND "${DRIVER_SCRIPT}" " export PATH=$USER_PATH:$PATH\n") +file(APPEND "${DRIVER_SCRIPT}" "fi\n") +file(APPEND "${DRIVER_SCRIPT}" "\n") +file(APPEND "${DRIVER_SCRIPT}" "# refer https://github.com/Samsung/ONE/issues/6286\n") +file(APPEND "${DRIVER_SCRIPT}" "set -o pipefail\n\n") +file(APPEND "${DRIVER_SCRIPT}" "fail_count=0\n") +file(APPEND "${DRIVER_SCRIPT}" "trap \"(( fail_count++ ))\" ERR\n\n") + +foreach(TEST_ITEM IN ITEMS ${TEST_EXAMPLES}) + file(APPEND "${DRIVER_SCRIPT}" "/bin/bash \"${TEST_ITEM}.test\" | tee -a runtestall.log\n") +endforeach(TEST_ITEM) + +file(APPEND "${DRIVER_SCRIPT}" "\necho \"special test items\" | tee -a runtestall.log\n\n") + +foreach(TEST_ITEM IN ITEMS ${SPECIAL_TEST_ITEMS}) + file(APPEND "${DRIVER_SCRIPT}" "/bin/bash \"${TEST_ITEM}\" | tee -a runtestall.log\n") +endforeach(TEST_ITEM) + +file(APPEND "${DRIVER_SCRIPT}" "popd > /dev/null\n\n") + +file(APPEND "${DRIVER_SCRIPT}" +"if [[ $fail_count != 0 ]]; then + echo \"$fail_count TESTS FAILED\" + exit 255 +else + echo \"ALL TESTS PASSED!\" +fi\n +") + +set(PREPARE_TEST_MATERIALS_SH "${CMAKE_CURRENT_SOURCE_DIR}/prepare_test_materials.sh") +set(EXAMPLE_GENERATOR "${CMAKE_CURRENT_SOURCE_DIR}/example_generator.py") +set(AUX_GENERATOR "${CMAKE_CURRENT_SOURCE_DIR}/aux_generator.py") + +install(FILES "${DRIVER_SCRIPT}" + PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE + DESTINATION "${TEST_DST}") + +install(FILES "${PREPARE_TEST_MATERIALS_SH}" + PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE + DESTINATION "${TEST_DST}") + +install(FILES "${EXAMPLE_GENERATOR}" "${AUX_GENERATOR}" + PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE + DESTINATION "${TEST_DST}") + +install(FILES ${SPECIAL_TEST_ITEMS} + PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE + DESTINATION "${TEST_DST}") + +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/README.md" + DESTINATION "${TEST_DST}") diff --git a/compiler/one-cmds/tests/pytorch-operations/README.md b/compiler/one-cmds/tests/pytorch-operations/README.md new file mode 100644 index 000000000..231a10eb4 --- /dev/null +++ b/compiler/one-cmds/tests/pytorch-operations/README.md @@ -0,0 +1,28 @@ +## Overview + +This directory contains auxilliary tests for small pytorch target models. + +Most of the models contains single operations, but some contains multiple operations, that represents one operation with complex semantics. + +Models for these tests are taken from res/PyTorchExamples. + +## To run all tests + +Steps: +1) run 'one-prepare-venv' in bin folder to prepare python virtual-env with TensorFlow + - you need to run this only once + - read 'doc/how-to-prepare-virtualenv.txt' for more information + ``` + bin/one-prepare-venv + ``` +2) run 'test/pytorch-operations/prepare_test_materials.sh' to download test material models + - you need to run this only once + - you need internet connection to download files + - you may need to install 'wget' and 'unzip' packages + ``` + test/pytorch-operations/prepare_test_materials.sh + ``` +3) run 'test/pytorch-operations/runtestall.sh' to run the test + ``` + test/pytoch-operations/runtestall.sh + ``` diff --git a/compiler/one-cmds/tests/pytorch-operations/aux_generator.py b/compiler/one-cmds/tests/pytorch-operations/aux_generator.py new file mode 100644 index 000000000..6c9afcded --- /dev/null +++ b/compiler/one-cmds/tests/pytorch-operations/aux_generator.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python3 + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# PyTorch aux tests generator + +import torch +import torch.nn as nn +import json +import zipfile +import os + + +# model +class net_abs(nn.Module): + def __init__(self): + super().__init__() + + def forward(self, input): + return torch.abs(input) + + +if __name__ == '__main__': + model = net_abs() + # save "entire" model for entire_model.test + torch.save(model, 'entire_model.pth') + + # save state_dict file for state_dict_model.test + state_dict_path = 'state_dict_model.pth' + torch.save(model.state_dict(), state_dict_path) + + # create files for mar_torchscript_model.test + torchscript_path = 'torchscript_model.pth' + inp = torch.randn(1, 2, 3, 3) + traced_model = torch.jit.trace(model, inp) + torch.jit.save(traced_model, torchscript_path) + # create manifest + manifest = {} + manifest['createdOn'] = '11/11/1111 11:11:11' + manifest['runtime'] = 'python' + manifest['model'] = {} + manifest['model']['modelName'] = 'torchscript_model', + manifest['model']['serializedFile'] = torchscript_path + manifest['model']['handler'] = 'image_classifier' + manifest['model']['modelVersion'] = '1.0' + manifest['archiverVersion'] = '0.4.2' + + with zipfile.ZipFile('mar_torchscript_model.mar', 'w') as mar_file: + with mar_file.open('MAR-INF/MANIFEST.json', 'w') as manifest_file: + manifest_file.write(json.dumps(manifest).encode()) + mar_file.write(torchscript_path) + + # create files for mar_state_dict_model.test + model_file_path = os.path.basename(__file__) + # create manifest + manifest = {} + manifest['createdOn'] = '11/11/1111 11:11:11' + manifest['runtime'] = 'python' + manifest['model'] = {} + manifest['model']['modelName'] = 'state_dict_model', + manifest['model']['serializedFile'] = state_dict_path + manifest['model']['handler'] = 'image_classifier' + manifest['model']['modelFile'] = model_file_path + manifest['model']['modelVersion'] = '1.0' + manifest['archiverVersion'] = '0.4.2' + + with zipfile.ZipFile('mar_state_dict_model.mar', 'w') as mar_file: + with mar_file.open('MAR-INF/MANIFEST.json', 'w') as manifest_file: + manifest_file.write(json.dumps(manifest).encode()) + mar_file.write(state_dict_path) + mar_file.write(model_file_path) diff --git a/compiler/one-cmds/tests/pytorch-operations/entire_model.test b/compiler/one-cmds/tests/pytorch-operations/entire_model.test new file mode 100644 index 000000000..a72a56ffd --- /dev/null +++ b/compiler/one-cmds/tests/pytorch-operations/entire_model.test @@ -0,0 +1,40 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Test one-import-pytorch ability to import NN model stored in python file and serialized "entire" model. +# "Entire" model is serialized with `torch.save(model)` method. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +outputfile="entire_model.circle" + +# run test +one-import-pytorch --input_path=entire_model.pth --python_path=aux_generator.py --output_path=${outputfile} --input_shapes=1,2,3,3 --input_types=float32 &> /dev/null + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/pytorch-operations/example_generator.py b/compiler/one-cmds/tests/pytorch-operations/example_generator.py new file mode 100644 index 000000000..2e3cdcf5b --- /dev/null +++ b/compiler/one-cmds/tests/pytorch-operations/example_generator.py @@ -0,0 +1,117 @@ +#!/usr/bin/env python3 + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# PyTorch Example manager + +import torch +import importlib.machinery +import importlib.util +import argparse +import os + +from pathlib import Path + +print("PyTorch version=", torch.__version__) + +parser = argparse.ArgumentParser(description='Process PyTorch python examples') + +parser.add_argument('examples', metavar='EXAMPLES', nargs='+') + +args = parser.parse_args() + +output_folder = "./" + +Path(output_folder).mkdir(parents=True, exist_ok=True) + + +class JitWrapper(torch.nn.Module): + def __init__(self, model): + super().__init__() + self.model = model + + def forward(self, *args): + if len(args) == 1: + return self.model.forward(args[0]) + else: + return self.model.forward(args) + + +for example in args.examples: + print("Generate '" + example + ".pth'", end='') + # load example code + # replace - with _ in name, otherwise pytorch generates invalid torchscript + module_name = "examples." + example.replace('-', '_') + module_loader = importlib.machinery.SourceFileLoader( + module_name, os.path.join("examples", example, "__init__.py")) + module_spec = importlib.util.spec_from_loader(module_name, module_loader) + module = importlib.util.module_from_spec(module_spec) + module_loader.exec_module(module) + + jittable_model = JitWrapper(module._model_) + + traced_model = torch.jit.trace(jittable_model, module._dummy_) + # save .pth + torch.jit.save(traced_model, output_folder + example + ".pth") + + input_shapes = "" + input_types = "" + + input_samples = module._dummy_ + if isinstance(input_samples, torch.Tensor): + input_samples = [input_samples] + for inp_idx in range(len(input_samples)): + input_data = input_samples[inp_idx] + + shape = input_data.shape + for dim in range(len(shape)): + input_shapes += str(shape[dim]) + if dim != len(shape) - 1: + input_shapes += "," + + if input_data.dtype == torch.bool: + input_types += "bool" + elif input_data.dtype == torch.uint8: + input_types += "uint8" + elif input_data.dtype == torch.int8: + input_types += "int8" + elif input_data.dtype == torch.int16: + input_types += "int16" + elif input_data.dtype == torch.int32: + input_types += "int32" + elif input_data.dtype == torch.int64: + input_types += "int16" + elif input_data.dtype == torch.float16: + input_types += "float32" + elif input_data.dtype == torch.float32: + input_types += "float32" + elif input_data.dtype == torch.float64: + input_types += "float64" + elif input_data.dtype == torch.complex64: + input_types += "complex64" + elif input_data.dtype == torch.complex128: + input_types += "complex128" + else: + raise ValueError('unsupported dtype') + + if inp_idx != len(input_samples) - 1: + input_shapes += ":" + input_types += "," + + with open(example + ".spec", "w") as spec_file: + print(input_shapes, file=spec_file) + print(input_types, file=spec_file) + + print(" - Done") diff --git a/compiler/one-cmds/tests/pytorch-operations/mar_state_dict_model.test b/compiler/one-cmds/tests/pytorch-operations/mar_state_dict_model.test new file mode 100644 index 000000000..9892dbbed --- /dev/null +++ b/compiler/one-cmds/tests/pytorch-operations/mar_state_dict_model.test @@ -0,0 +1,40 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Test one-import-pytorch ability to import .mar file. +# .mar file contains python source of the model and serialized state_dict. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +outputfile="mar_state_dict_model.circle" + +# run test +one-import-pytorch --input_path=mar_state_dict_model.mar --output_path=${outputfile} --input_shapes=1,2,3,3 --input_types=float32 &> /dev/null + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/pytorch-operations/mar_torchscript_model.test b/compiler/one-cmds/tests/pytorch-operations/mar_torchscript_model.test new file mode 100644 index 000000000..3ac38a42e --- /dev/null +++ b/compiler/one-cmds/tests/pytorch-operations/mar_torchscript_model.test @@ -0,0 +1,40 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Test one-import-pytorch ability to import .mar file. +# .mar file contains TorchScript. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +outputfile="mar_torchscript_model.circle" + +# run test +one-import-pytorch --input_path=mar_torchscript_model.mar --output_path=${outputfile} --input_shapes=1,2,3,3 --input_types=float32 &> /dev/null + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/pytorch-operations/prepare_test_materials.sh b/compiler/one-cmds/tests/pytorch-operations/prepare_test_materials.sh new file mode 100644 index 000000000..5f38610d7 --- /dev/null +++ b/compiler/one-cmds/tests/pytorch-operations/prepare_test_materials.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +pushd $SCRIPT_PATH > /dev/null + +for test_case in examples/*; do + python3 example_generator.py $(basename ${test_case}) +done + +python3 aux_generator.py + +popd > /dev/null diff --git a/compiler/one-cmds/tests/pytorch-operations/state_dict_model.test b/compiler/one-cmds/tests/pytorch-operations/state_dict_model.test new file mode 100644 index 000000000..ecd2a8112 --- /dev/null +++ b/compiler/one-cmds/tests/pytorch-operations/state_dict_model.test @@ -0,0 +1,39 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Test one-import-pytorch ability to import NN model from .py file and serialized state_dict file. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +outputfile="state_dict_model.circle" + +# run test +one-import-pytorch --input_path=state_dict_model.pth --python_path=aux_generator.py --output_path=${outputfile} --input_shapes=1,2,3,3 --input_types=float32 &> /dev/null + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/pytorch-operations/torchscript_model.test b/compiler/one-cmds/tests/pytorch-operations/torchscript_model.test new file mode 100644 index 000000000..590e5b369 --- /dev/null +++ b/compiler/one-cmds/tests/pytorch-operations/torchscript_model.test @@ -0,0 +1,39 @@ +#!/bin/bash + +# Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Test one-import-pytorch ability to import TorchScript file. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +outputfile="torchscript_model.circle" + +# run test +one-import-pytorch --input_path=torchscript_model.pth --output_path=${outputfile} --input_shapes=1,2,3,3 --input_types=float32 &> /dev/null + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/rawdata2hdf5_001.test b/compiler/one-cmds/tests/rawdata2hdf5_001.test new file mode 100644 index 000000000..ceefcf725 --- /dev/null +++ b/compiler/one-cmds/tests/rawdata2hdf5_001.test @@ -0,0 +1,42 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +outputfile="./output_testdata.h5" + +rm -f ${filename}.log +rm -rf ${outputfile} + +# run test +rawdata2hdf5 \ +--data_list datalist.txt \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +if [[ ! -s "${outputfile}" ]]; then + trap_err_onexit +fi + +echo "${filename_ext} SUCCESS" diff --git a/compiler/one-cmds/tests/rawdata2hdf5_neg_001.test b/compiler/one-cmds/tests/rawdata2hdf5_neg_001.test new file mode 100644 index 000000000..fb7803760 --- /dev/null +++ b/compiler/one-cmds/tests/rawdata2hdf5_neg_001.test @@ -0,0 +1,48 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "No such file" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./wronglist.txt" +outputfile="./output_testdata.h5" + +rm -rf ${inputfile} +rm -f ${filename}.log + +touch ${inputfile} +echo "non-existing-file.data" >> ${inputfile} + +# run test +rawdata2hdf5 \ +--data_list ${inputfile} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/rawdata2hdf5_neg_002.test b/compiler/one-cmds/tests/rawdata2hdf5_neg_002.test new file mode 100644 index 000000000..7a9e231e3 --- /dev/null +++ b/compiler/one-cmds/tests/rawdata2hdf5_neg_002.test @@ -0,0 +1,44 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "UnicodeDecodeError" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.circle" +outputfile="./output_testdata.h5" + +rm -f ${filename}.log + +# run test +rawdata2hdf5 \ +--data_list ${inputfile} \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/rawdata2hdf5_neg_003.test b/compiler/one-cmds/tests/rawdata2hdf5_neg_003.test new file mode 100644 index 000000000..c69f935a4 --- /dev/null +++ b/compiler/one-cmds/tests/rawdata2hdf5_neg_003.test @@ -0,0 +1,42 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "the following arguments are required: -l/--data_list" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +outputfile="./output_testdata.h5" + +rm -f ${filename}.log + +# run test +rawdata2hdf5 \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 diff --git a/compiler/one-cmds/tests/rawdata2hdf5_neg_004.test b/compiler/one-cmds/tests/rawdata2hdf5_neg_004.test new file mode 100644 index 000000000..df0620122 --- /dev/null +++ b/compiler/one-cmds/tests/rawdata2hdf5_neg_004.test @@ -0,0 +1,43 @@ +#!/bin/bash + +# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "Unable to create file" "${filename}.log"; then + echo "${filename_ext} SUCCESS" + exit 0 + fi + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +outputfile="./non_existing_dir/output_testdata.h5" + +rm -f ${filename}.log + +# run test +rawdata2hdf5 \ +--data_list datalist.txt \ +--output_path ${outputfile} > ${filename}.log 2>&1 + +echo "${filename_ext} FAILED" +exit 255 |