Skip to content

Commit

Permalink
[ci] Clean up test script a bit (pytorch#2017)
Browse files Browse the repository at this point in the history
Description:

Reduced the # of environment variables
Moved list of failing tests to external files
Added some quoting to make shellcheck happy
Testing:
Ran it on my Mac (after changing .so to .dylib and back)
shellcheck test.sh

Documentation: N/A
  • Loading branch information
bertmaher authored Nov 14, 2018
1 parent c2c91fd commit 9697fb8
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 22 deletions.
7 changes: 7 additions & 0 deletions .circleci/onnxifi_driver_test/crashed.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*test_softmax_axis_0*
*test_batchnorm_epsilon*
*test_batchnorm_example*
*test_sum_example*
*test_flatten_axis0*
*test_transpose_default*
*test_sum_one_input*
23 changes: 23 additions & 0 deletions .circleci/onnxifi_driver_test/failed.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
*test_averagepool_1d_default*
*test_average_2d_precomputed_same_upper*
*test_reshape_reduced_dims*
*test_maxpool_with_argmax_2d_precomputed_pads*
*test_reshape_negative_dim*
*test_maxpool_3d_default*
*test_maxpool_2d_same_upper*
*test_averagepool_2d_precomputed_same_upper*
*test_reshape_extended_dims*
*test_averagepool_2d_same_upper*
*test_gemm_broadcast*
*test_gemm_broadcast*
*test_reshape_one_dim*
*test_averagepool_2d_pads*
*test_maxpool_1d_default*
*test_maxpool_2d_same_lower*
*test_gemm_nobroadcast*
*test_maxpool_2d_precomputed_same_upper*
*test_maxpool_with_argmax_2d_precomputed_strides*
*test_averagepool_2d_precomputed_pads*
*test_reshape_reordered_dims*
*test_averagepool_2d_same_lower*
*test_averagepool_3d_default*
39 changes: 17 additions & 22 deletions .circleci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,31 @@

# This script runs all tests in glow, including onnxifi gtests


set -euxo pipefail

GLOW_DIR=$PWD
GLOW_BUILD_DIR=${GLOW_DIR}/build
cd ${GLOW_BUILD_DIR}

TEST_NAME=$CIRCLE_JOB
export GLOW_SRC=$PWD
export GLOW_BUILD_DIR=${GLOW_SRC}/build
export LOADER=${GLOW_BUILD_DIR}/bin/image-classifier

# Pass in which tests to run (one of {test, test_unopt}).
run_unit_tests() {
CTEST_PARALLEL_LEVEL=4 ninja ${1} || ( cat Testing/Temporary/LastTest.log && exit 1 )
CTEST_PARALLEL_LEVEL=4 ninja "${1}" || ( cat Testing/Temporary/LastTest.log && exit 1 )
}

# Pass one of {YES, NO} for QUANTIZE.
run_and_check_bundle() {
echo "Checking lenet_mnist bundle with QUANTIZE=${1}"
cd ${GLOW_SRC}/examples/bundles/lenet_mnist/
cd "${GLOW_SRC}/examples/bundles/lenet_mnist/"
( QUANTIZE=${1} make &> raw_results.txt ) || ( cat raw_results.txt && exit 1 )
( tail -n72 raw_results.txt | grep -F "Result: " > results.txt ) || ( cat raw_results.txt && exit 1 )
diff results.txt ${GLOW_SRC}/.ci/lenet_mnist_expected_output.txt
diff results.txt "${GLOW_SRC}/.ci/lenet_mnist_expected_output.txt"
rm results.txt raw_results.txt
echo "Successfully completed checking lenet_mnist bundle with QUANTIZE=${1}"
}

export GLOW_SRC=${PWD}/..
export LOADER=${GLOW_SRC}/build/bin/image-classifier

case ${TEST_NAME} in
# Run unit tests and bundle tests.
cd "${GLOW_BUILD_DIR}"
case ${CIRCLE_JOB} in
ASAN)
run_unit_tests test
;;
Expand All @@ -43,29 +39,28 @@ case ${TEST_NAME} in
;;

*)
echo "Error, '${TEST_NAME}' not valid mode; Must be one of {ASAN, DEBUG}."
echo "Error, '${CIRCLE_JOB}' not valid mode; Must be one of {ASAN, DEBUG}."
exit 1
;;
esac


# Run ONNX test
ONNX_DIR="${GLOW_DIR}/thirdparty/onnx"
ONNX_DIR="${GLOW_SRC}/thirdparty/onnx"
# ONNX test data dir
TESTDATA_DIR="${ONNX_DIR}/onnx/backend/test/data/node"

# Asan is not enbaled in onnx, therefore we should skip it for now.
# TODO: Enable asan test. Rui Zhu.
if [[ "$CIRCLE_JOB" != ASAN ]]; then
# Banned known buggy test cases from gtest
CRASHED_TEST_CASES="*test_softmax_axis_0*:*test_batchnorm_epsilon*:*test_batchnorm_example*:*test_sum_example*:*test_flatten_axis0*:*test_transpose_default*:*test_sum_one_input*"
FAILED_TEST_CASES="*test_averagepool_1d_default*:*test_average_2d_precomputed_same_upper*:*test_reshape_reduced_dims*:*test_maxpool_with_argmax_2d_precomputed_pads*:*test_reshape_negative_dim*:*test_maxpool_3d_default*:*test_maxpool_2d_same_upper*:*test_averagepool_2d_precomputed_same_upper*:*test_reshape_extended_dims*:*test_averagepool_2d_same_upper*:*test_gemm_broadcast*:*test_gemm_broadcast*:*test_reshape_one_dim*:*test_averagepool_2d_pads*:*test_maxpool_1d_default*:*test_maxpool_2d_same_lower*:*test_gemm_nobroadcast*:*test_maxpool_2d_precomputed_same_upper*:*test_maxpool_with_argmax_2d_precomputed_strides*:*test_averagepool_2d_precomputed_pads*:*test_reshape_reordered_dims*:*test_averagepool_2d_same_lower*:*test_averagepool_3d_default*"
EXCLUDED_TEST_CASES=${CRASHED_TEST_CASES}":"${FAILED_TEST_CASES}
CRASHED_TEST_CASES="$(paste -sd: "${GLOW_SRC}"/.circleci/onnxifi_driver_test/crashed.txt)"
FAILED_TEST_CASES="$(paste -sd: "${GLOW_SRC}"/.circleci/onnxifi_driver_test/failed.txt)"
EXCLUDED_TEST_CASES="${CRASHED_TEST_CASES}:${FAILED_TEST_CASES}"

# Setup glow onnxifi backend so test driver can load it
cp ${GLOW_BUILD_DIR}/lib/Onnxifi/libonnxifi-glow.so ${GLOW_DIR}/libonnxifi.so
export LD_LIBRARY_PATH=${GLOW_DIR}
cp "${GLOW_BUILD_DIR}/lib/Onnxifi/libonnxifi-glow.so" "${GLOW_SRC}/libonnxifi.so"
export LD_LIBRARY_PATH=${GLOW_SRC}

# Run Onnxifi gtest
GTEST_FILTER=*-${EXCLUDED_TEST_CASES} ${GLOW_BUILD_DIR}/onnxifi_test_driver_gtests ${TESTDATA_DIR}
GTEST_FILTER="*-${EXCLUDED_TEST_CASES}" "${GLOW_BUILD_DIR}/onnxifi_test_driver_gtests" "${TESTDATA_DIR}"
fi

0 comments on commit 9697fb8

Please sign in to comment.