Skip to content

Commit

Permalink
[one-cmds] Add more tests for one-import-onnx-ext (Samsung#13936)
Browse files Browse the repository at this point in the history
This will add more tests for one-import-onnx-ext.
- new material download is also added in prepare_test_materials.sh

ONE-DCO-1.0-Signed-off-by: SaeHie Park <[email protected]>
  • Loading branch information
seanshpark authored Sep 5, 2024
1 parent 4e04e6a commit b097991
Show file tree
Hide file tree
Showing 5 changed files with 228 additions and 0 deletions.
55 changes: 55 additions & 0 deletions compiler/one-cmds/tests/one-import-onnx_ext_002.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

# Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT 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
# force to use 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_002.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 \
--force_ext \
--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
60 changes: 60 additions & 0 deletions compiler/one-cmds/tests/one-import-onnx_ext_003.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

# Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT 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
# test for model that onnx-tf fails and should run 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_tf_error_model.onnx"
outputfile="./onnx_tf_error_model.onnx.onnx_ext_003.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

# input file should exist
if [[ ! -f ${inputfile} ]]; then
trap_err_onexit
fi

# run test
one-import-onnx \
--input_path ${inputfile} \
--output_path ${outputfile} > ${logfile} 2>&1

# onnx-tf should fail and the extension should run
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
50 changes: 50 additions & 0 deletions compiler/one-cmds/tests/one-import-onnx_ext_004.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

# Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT 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
# force_ext is given but onne-import-onnx-ext is not installed

filename_ext="$(basename -- $0)"
filename="${filename_ext%.*}"

trap_err_onexit()
{
echo "${filename_ext} FAILED"
exit 255
}

trap trap_err_onexit ERR

inputfile="./onnx_conv2d_conv2d.onnx"
outputfile="./onnx_conv2d_conv2d.onnx_ext_004.circle"
logfile=${filename}.log

rm -f ${outputfile}
rm -f ${logfile}

# be sure to remove one-import-onnx-ext
rm -f ../bin/one-import-onnx-ext

# run test
one-import-onnx \
--force_ext \
--input_path ${inputfile} \
--output_path ${outputfile} > ${logfile} 2>&1

# one-import-onnx should execute without error

echo "${filename_ext} SUCCESS"
exit 0
55 changes: 55 additions & 0 deletions compiler/one-cmds/tests/one-import-onnx_ext_neg_001.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

# Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT 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
# error for both force_ext and disable_ext given

filename_ext="$(basename -- $0)"
filename="${filename_ext%.*}"

trap_err_onexit()
{
rm -f ../bin/one-import-onnx-ext
if grep -q "one-import-onnx: error" "${logfile}"; then
echo "${filename_ext} SUCCESS"
exit 0
fi
exit 255
}

trap trap_err_onexit ERR

inputfile="./onnx_conv2d_conv2d.onnx"
outputfile="./onnx_conv2d_conv2d.onnx_ext_neg_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 \
--force_ext \
--disable_ext \
--input_path ${inputfile} \
--output_path ${outputfile} > ${logfile} 2>&1

rm -f ../bin/one-import-onnx-ext

echo "${filename_ext} FAILED"
exit 255
8 changes: 8 additions & 0 deletions compiler/one-cmds/tests/prepare_test_materials.sh
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,12 @@ if [[ ! -s ${outputfile} ]]; then
--output_path ${outputfile}
fi

# prepare onnx_tf_error_model.onnx for one-import-onnx-ext test
if [[ ! -s "onnx_tf_error_model.onnx" ]]; then
rm -rf onnx_tf_error_model.zip
wget -nv https://github.com/user-attachments/files/16856219/onnx_tf_error_model.zip
unzip onnx_tf_error_model.zip
# https://github.com/Samsung/ONE/issues/13491#issuecomment-2327458991
fi

popd > /dev/null

0 comments on commit b097991

Please sign in to comment.