diff options
author | Chunseok Lee <chunseok.lee@samsung.com> | 2020-10-28 12:16:55 +0900 |
---|---|---|
committer | Chunseok Lee <chunseok.lee@samsung.com> | 2020-10-28 12:16:55 +0900 |
commit | c55f8a6db48cda9d3a78048338b7f18c4cca62b8 (patch) | |
tree | 761ee8e171e5203f5c598ad93b2e7e0bc2e31aa2 /compiler/one-cmds/tests | |
parent | 74476a2d0296bdad70a2f7f90bc7419a8b05bffd (diff) | |
download | nnfw-c55f8a6db48cda9d3a78048338b7f18c4cca62b8.tar.gz nnfw-c55f8a6db48cda9d3a78048338b7f18c4cca62b8.tar.bz2 nnfw-c55f8a6db48cda9d3a78048338b7f18c4cca62b8.zip |
Imported Upstream version 1.10.0upstream/1.10.0submit/tizen/20201028.104702submit/tizen/20201028.031836accepted/tizen/unified/20201029.124827
Diffstat (limited to 'compiler/one-cmds/tests')
46 files changed, 2348 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..cb1081d28 --- /dev/null +++ b/compiler/one-cmds/tests/CMakeLists.txt @@ -0,0 +1,49 @@ +# Install one-cmds test scripts + +# Gather test scripts +file(GLOB TESTITEMS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "./*.test") + +# 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") + +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) + +file(APPEND "${DRIVER_SCRIPT}" "popd> /dev/null") + +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) + +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 ${CMAKE_CURRENT_SOURCE_DIR}/README.txt + DESTINATION test) 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-import-bcq_001.test b/compiler/one-cmds/tests/one-import-bcq_001.test new file mode 100644 index 000000000..74b8bab32 --- /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 -rf $outputfile +rm -rf $outputfile.log + +# run test +one-import-bcq \ +--input_path ${inputfile} \ +--output_path ${outputfile} \ +--input_arrays Placeholder \ +--output_arrays MatMul >> /dev/null + +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..9a2b455ef --- /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 -rf ${outputfile}.log + +# run test +one-import-bcq \ +--input_path ${inputfile} \ +--output_path ${outputfile} \ +--input_arrays Placeholder_null \ +--output_arrays MatMul > ${filename}.log + +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..5779aa03e --- /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 -rf ${outputfile}.log + +# run test +one-import-bcq \ +--input_path ${inputfile} \ +--output_path ${outputfile} \ +--input_arrays Placeholder \ +--output_arrays MatMul_null > ${filename}.log + +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..3a8e6368b --- /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 "input model not found" "${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 -rf ${outputfile}.log + +# run test +one-import-bcq \ +--input_path ${inputfile} \ +--output_path ${outputfile} \ +--input_arrays Placeholder \ +--output_arrays MatMul > ${filename}.log + +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..dc83b98c8 --- /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 -rf ${outputfile}.log + +# run test +one-import-bcq \ +--input_path ${inputfile} \ +--output_path ${outputfile} \ +--input_arrays Placeholder \ +--output_arrays MatMul > ${filename}.log + +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..ad1196a67 --- /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 -rf ${outputfile}.log + +# run test +one-import-bcq \ +--input_path ${inputfile} \ +--output_path ${outputfile} \ +--input_arrays Placeholder \ +--output_arrays MatMul > ${filename}.log + +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..f761aa7c0 --- /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 -rf ${outputfile}.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 + +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..5013254f5 --- /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 -rf ${outputfile}.log + +# run test +one-import-bcq \ +--input_path ${inputfile} \ +--output_path ${outputfile} \ +--input_arrays Placeholder --input_shapes "30,30" \ +--output_arrays MatMul > ${filename}.log + +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..e7d5d2e03 --- /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 -rf ${outputfile}.log + +# run test +one-import-bcq \ +--input_path ${inputfile} \ +--output_path ${outputfile} \ +--input_arrays Placeholder --input_shapes "32,O" \ +--output_arrays MatMul > ${filename}.log + +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..ef990438a --- /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 -rf ${outputfile}.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 + +echo "${filename_ext} FAILED" +exit 255 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..165f49193 --- /dev/null +++ b/compiler/one-cmds/tests/one-import_001.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() +{ + 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 + +# 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 >> /dev/null + +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..5a233d2f3 --- /dev/null +++ b/compiler/one-cmds/tests/one-import_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 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 + + echo "${filename_ext} FAILED" + exit 255 +} + +trap trap_err_onexit ERR + +inputfile="./inception_v3.tflite" +outputfile="./inception_v3.circle" + +rm -rf ${outputfile} +rm -rf ${outputfile}.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 + +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..78b77511a --- /dev/null +++ b/compiler/one-cmds/tests/one-import_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 unsupported dynamic tensor + +filename_ext="$(basename -- $0)" +filename="${filename_ext%.*}" + +trap_err_onexit() +{ + if grep -q "is incompatible with 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 ${outputfile}.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 + +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..b0e95b6d1 --- /dev/null +++ b/compiler/one-cmds/tests/one-import_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 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="./inception_v3.pb" +outputfile="./inception_v3.circle" + +rm -rf ${outputfile} +rm -rf ${outputfile}.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 + +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..afb206ad9 --- /dev/null +++ b/compiler/one-cmds/tests/one-import_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 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" + +rm -rf ${outputfile} +rm -rf ${outputfile}.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 + +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..045fb89b7 --- /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.circle" + +rm -rf ${outputfile} +rm -rf ${outputfile}.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 + +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..bb3e2344c --- /dev/null +++ b/compiler/one-cmds/tests/one-import_neg_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. + +# 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.circle" + +rm -rf ${outputfile} +rm -rf ${outputfile}.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 + +echo "${filename_ext} FAILED" +exit 255 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..bcfc4bcc9 --- /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.circle" + +rm -rf ${outputfile} +rm -rf ${outputfile}.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 + +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..2f48fd708 --- /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.circle" + +rm -rf ${outputfile} +rm -rf ${outputfile}.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 + +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..79e463d64 --- /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 ${outputfile}.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 + +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..05677a6d4 --- /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.circle" + +rm -rf ${outputfile} +rm -rf ${outputfile}.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 + +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..240a62506 --- /dev/null +++ b/compiler/one-cmds/tests/one-optimize_001.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. + +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 -rf ${outputfile} + +# to create inception_v3.circle +if [[ ! -s ${inputfile} ]]; then + /bin/bash one-import_001.test >> /dev/null + return_code=$? + if [[ ${return_code} != 0 ]]; then + trap_err_onexit + fi +fi + +# run test +one-optimize --all \ +--input_path ${inputfile} \ +--output_path ${outputfile} >> /dev/null + +if [[ ! -s "${outputfile}" ]]; 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..4ee509697 --- /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 -rf ${outputfile}.log + +# run test +one-optimize --all \ +--input_path ${inputfile} \ +--output_path ${outputfile} > ${filename}.log + +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..811b4d814 --- /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 "input model not found" "${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 -rf ${outputfile}.log + +# run test +one-optimize --all \ +--input_path ${inputfile} \ +--output_path ${outputfile} > ${filename}.log + +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..17f53b9a4 --- /dev/null +++ b/compiler/one-cmds/tests/one-optimize_neg_003.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 without output folder 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" + +# to create inception_v3.circle +if [[ ! -s ${inputfile} ]]; then + /bin/bash one-import_001.test >> /dev/null + return_code=$? + if [[ ${return_code} != 0 ]]; then + trap_err_onexit + fi +fi + +# run test +one-optimize --all \ +--input_path ${inputfile} > ${filename}.log + +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..3d746dffd --- /dev/null +++ b/compiler/one-cmds/tests/one-pack_001.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. + +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 -rf ${outputfolder} + +# to create inception_v3.circle +if [[ ! -s ${inputfile} ]]; then + /bin/bash one-import_001.test >> /dev/null + return_code=$? + if [[ ${return_code} != 0 ]]; then + trap_err_onexit + fi +fi + +# run test +one-pack \ +-i ${inputfile} \ +-o ${outputfolder} >> /dev/null + +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..de1eab9c7 --- /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 "input model not found" "${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 + +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..6427c260e --- /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 + +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..bf91a5226 --- /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 "output path not set" "${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 + +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..ef25ac800 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_001.test @@ -0,0 +1,54 @@ +#!/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 -rf ${outputfile} + +# to create inception_v3.circle +if [[ ! -s ${inputfile} ]]; then + /bin/bash one-import_001.test >> /dev/null + return_code=$? + if [[ ${return_code} != 0 ]]; then + trap_err_onexit + fi +fi + +# 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 >> /dev/null + +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..ccf16fbf8 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_001.test @@ -0,0 +1,61 @@ +#!/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 -rf ${outputfile}.log + +# test begin + +# to create inception_v3.circle +if [[ ! -s ${inputfile} ]]; then + /bin/bash one-import_001.test >> /dev/null + return_code=$? + if [[ ${return_code} != 0 ]]; then + trap_err_onexit + fi +fi + +one-quantize \ +--input_dtype float64 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ${inputdata} \ +--output_path ${outputfile} > ${filename}.log + +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..387e53637 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_002.test @@ -0,0 +1,60 @@ +#!/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 -rf ${outputfile}.log + +# to create inception_v3.circle +if [[ ! -s ${inputfile} ]]; then + /bin/bash one-import_001.test >> /dev/null + return_code=$? + if [[ ${return_code} != 0 ]]; then + trap_err_onexit + fi +fi + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint16 \ +--input_path ${inputfile} \ +--input_data ${inputdata} \ +--output_path ${outputfile} > ${filename}.log + +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..47cf0691f --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_003.test @@ -0,0 +1,59 @@ +#!/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 "Input shape mismatch" "${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 -rf ${outputfile}.log + +# to create inception_v3.circle +if [[ ! -s ${inputfile} ]]; then + /bin/bash one-import_001.test >> /dev/null + return_code=$? + if [[ ${return_code} != 0 ]]; then + trap_err_onexit + fi +fi + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ./mobilenet_test_data.h5 \ +--output_path ${outputfile} > ${filename}.log + +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..8d53ca1d1 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_004.test @@ -0,0 +1,59 @@ +#!/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 -rf ${outputfile}.log + +# to create inception_v3.circle +if [[ ! -s ${inputfile} ]]; then + /bin/bash one-import_001.test >> /dev/null + return_code=$? + if [[ ${return_code} != 0 ]]; then + trap_err_onexit + fi +fi + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ${inputdata} \ +--output_path ${outputfile} > ${filename}.log + +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..4504730d0 --- /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 -rf ${outputfile}.log + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ${inputdata} \ +--output_path ${outputfile} > ${filename}.log + +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..2ecbc0413 --- /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 "input model not found" "${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 -rf ${outputfile}.log + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ${inputdata} \ +--output_path ${outputfile} > ${filename}.log + +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..4796f9e89 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_007.test @@ -0,0 +1,59 @@ +#!/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 -rf ${outputfile}.log + +# to create inception_v3.circle +if [[ ! -s ${inputfile} ]]; then + /bin/bash one-import_001.test >> /dev/null + return_code=$? + if [[ ${return_code} != 0 ]]; then + trap_err_onexit + fi +fi + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ${inputdata} \ +--output_path ${outputfile} > ${filename}.log + +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..1656c6ba2 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_008.test @@ -0,0 +1,60 @@ +#!/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 -rf ${outputfile}.log + +# to create inception_v3.circle +if [[ ! -s ${inputfile} ]]; then + /bin/bash one-import_001.test >> /dev/null + return_code=$? + if [[ ${return_code} != 0 ]]; then + trap_err_onexit + fi +fi + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ${inputdata} \ +--mode average \ +--output_path ${outputfile} > ${filename}.log + +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..6ecc5c32f --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_009.test @@ -0,0 +1,60 @@ +#!/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 -rf ${outputfile}.log + +# to create inception_v3.circle +if [[ ! -s ${inputfile} ]]; then + /bin/bash one-import_001.test >> /dev/null + return_code=$? + if [[ ${return_code} != 0 ]]; then + trap_err_onexit + fi +fi + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ${inputdata} \ +--max_percentile 101 \ +--output_path ${outputfile} > ${filename}.log + +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..209645990 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_010.test @@ -0,0 +1,60 @@ +#!/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 -rf ${outputfile}.log + +# to create inception_v3.circle +if [[ ! -s ${inputfile} ]]; then + /bin/bash one-import_001.test >> /dev/null + return_code=$? + if [[ ${return_code} != 0 ]]; then + trap_err_onexit + fi +fi + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ${inputdata} \ +--max_percentile -1 \ +--output_path ${outputfile} > ${filename}.log + +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..ea44c2ffe --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_011.test @@ -0,0 +1,60 @@ +#!/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 -rf ${outputfile}.log + +# to create inception_v3.circle +if [[ ! -s ${inputfile} ]]; then + /bin/bash one-import_001.test >> /dev/null + return_code=$? + if [[ ${return_code} != 0 ]]; then + trap_err_onexit + fi +fi + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ${inputdata} \ +--min_percentile 101 \ +--output_path ${outputfile} > ${filename}.log + +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..b744051ae --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_012.test @@ -0,0 +1,60 @@ +#!/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 -rf ${outputfile}.log + +# to create inception_v3.circle +if [[ ! -s ${inputfile} ]]; then + /bin/bash one-import_001.test >> /dev/null + return_code=$? + if [[ ${return_code} != 0 ]]; then + trap_err_onexit + fi +fi + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ${inputdata} \ +--min_percentile -1 \ +--output_path ${outputfile} > ${filename}.log + +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..dec1cbd06 --- /dev/null +++ b/compiler/one-cmds/tests/one-quantize_neg_013.test @@ -0,0 +1,60 @@ +#!/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 -rf ${outputfile}.log + +# to create inception_v3.circle +if [[ ! -s ${inputfile} ]]; then + /bin/bash one-import_001.test >> /dev/null + return_code=$? + if [[ ${return_code} != 0 ]]; then + trap_err_onexit + fi +fi + +# run test +one-quantize \ +--input_dtype float32 \ +--quantized_dtype uint8 \ +--input_path ${inputfile} \ +--input_data ${inputdata} \ +--granularity layered \ +--output_path ${outputfile} > ${filename}.log + +echo "${filename_ext} FAILED" +exit 255 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..e241f44b5 --- /dev/null +++ b/compiler/one-cmds/tests/prepare_test_materials.sh @@ -0,0 +1,64 @@ +#!/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 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 "while_3.pbtxt" ]]; then + rm -rf while_3.zip + wget https://github.com/Samsung/ONE/files/5095630/while_3.zip + unzip while_3.zip +fi + +if [[ ! -s "inception_v3_test_data.h5" ]]; then + rm -rf inception_v3_test_data.zip + wget https://github.com/Samsung/ONE/files/5139370/inception_v3_test_data.zip + unzip inception_v3_test_data.zip +fi + +if [[ ! -s "mobilenet_test_data.h5" ]]; then + rm -rf mobilenet_test_data.zip + wget https://github.com/Samsung/ONE/files/5139460/mobilenet_test_data.zip + unzip mobilenet_test_data.zip +fi + +if [[ ! -s "bcq.pb" ]]; then + rm -rf bcq.pb.zip + wget https://github.com/Samsung/ONE/files/5153842/bcq.pb.zip + unzip bcq.pb.zip +fi + +# prepare 'inception_v3.circle' file used for quantizatio 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 + +popd > /dev/null |