diff --git a/tests/scripts/setup-pytest-env.sh b/tests/scripts/setup-pytest-env.sh index b77d3f37cd3e..34b8c61e40b2 100755 --- a/tests/scripts/setup-pytest-env.sh +++ b/tests/scripts/setup-pytest-env.sh @@ -33,12 +33,17 @@ export TVM_PYTEST_RESULT_DIR="${TVM_PATH}/build/pytest-results" mkdir -p "${TVM_PYTEST_RESULT_DIR}" function run_pytest() { - test_suite_name="$1" + local ffi_type="$1" shift - for ffi_type in ${TVM_PYTEST_FFI_TYPES:-ctypes cython}; do - TVM_FFI=${ffi_type} python3 -m pytest \ + local test_suite_name="$1" + shift + if [ -z "${ffi_type}" -o -z "${test_suite_name}" ]; then + echo "error: run_pytest called incorrectly: run_pytest ${ffi_type} ${test_suite_name} $@" + echo "usage: run_pytest [pytest args...]" + exit 2 + fi + TVM_FFI=${ffi_type} python3 -m pytest \ -o "junit_suite_name=${test_suite_name}-${ffi_type}" \ "--junit-xml=${TVM_PYTEST_RESULT_DIR}/${test_suite_name}-${ffi_type}.xml" \ "$@" - done } diff --git a/tests/scripts/task_python_arm_compute_library.sh b/tests/scripts/task_python_arm_compute_library.sh index 4c1992b58692..7df894d93399 100755 --- a/tests/scripts/task_python_arm_compute_library.sh +++ b/tests/scripts/task_python_arm_compute_library.sh @@ -27,5 +27,4 @@ source tests/scripts/setup-pytest-env.sh find . -type f -path "*.pyc" | xargs rm -f make cython3 -TVM_PYTEST_FFI_TYPES=ctypes run_pytest python-arm_compute_lib \ - tests/python/contrib/test_arm_compute_lib +run_pytest ctypes python-arm_compute_lib tests/python/contrib/test_arm_compute_lib diff --git a/tests/scripts/task_python_ethosn_tests.sh b/tests/scripts/task_python_ethosn_tests.sh index 472ca38149a1..981d5715fac6 100755 --- a/tests/scripts/task_python_ethosn_tests.sh +++ b/tests/scripts/task_python_ethosn_tests.sh @@ -27,4 +27,4 @@ source tests/scripts/setup-pytest-env.sh find . -type f -path "*.pyc" | xargs rm -f make cython3 -TVM_PYTEST_FFI_TYPES=ctypes run_pytest python-ethosn tests/python/contrib/test_ethosn +run_pytest ctypes python-ethosn tests/python/contrib/test_ethosn diff --git a/tests/scripts/task_python_frontend.sh b/tests/scripts/task_python_frontend.sh index 6b1d8e5038fb..62a0fa1e7fc8 100755 --- a/tests/scripts/task_python_frontend.sh +++ b/tests/scripts/task_python_frontend.sh @@ -32,22 +32,22 @@ find . -type f -path "*.pyc" | xargs rm -f make cython3 echo "Running relay MXNet frontend test..." -TVM_PYTHON_FFI_TYPES=cython run_pytest python-frontend-mxnet tests/python/frontend/mxnet +run_pytest cython python-frontend-mxnet tests/python/frontend/mxnet echo "Running relay ONNX frontend test..." -TVM_PYTHON_FFI_TYPES=cython run_pytest python-frontend-onnx tests/python/frontend/onnx +run_pytest cython python-frontend-onnx tests/python/frontend/onnx echo "Running relay CoreML frontend test..." -TVM_PYTHON_FFI_TYPES=cython run_pytest python-frontend-coreml tests/python/frontend/coreml +run_pytest cython python-frontend-coreml tests/python/frontend/coreml echo "Running relay Tensorflow frontend test..." -TVM_PYTHON_FFI_TYPES=cython run_pytest python-frontend-tensorflow tests/python/frontend/tensorflow +run_pytest cython python-frontend-tensorflow tests/python/frontend/tensorflow echo "Running relay caffe2 frontend test..." -TVM_PYTHON_FFI_TYPES=cython run_pytest python-frontend-caffe2 tests/python/frontend/caffe2 +run_pytest cython python-frontend-caffe2 tests/python/frontend/caffe2 echo "Running relay DarkNet frontend test..." -TVM_PYTHON_FFI_TYPES=cython run_pytest python-frontend-darknet tests/python/frontend/darknet +run_pytest cython python-frontend-darknet tests/python/frontend/darknet echo "Running relay PyTorch frontend test..." -TVM_PYTHON_FFI_TYPES=cython run_pytest python-frontend-pytorch tests/python/frontend/pytorch +run_pytest cython python-frontend-pytorch tests/python/frontend/pytorch diff --git a/tests/scripts/task_python_frontend_cpu.sh b/tests/scripts/task_python_frontend_cpu.sh index a5cd3ba8ef09..208714c64988 100755 --- a/tests/scripts/task_python_frontend_cpu.sh +++ b/tests/scripts/task_python_frontend_cpu.sh @@ -33,10 +33,10 @@ find . -type f -path "*.pyc" | xargs rm -f make cython3 echo "Running relay TFLite frontend test..." -TVM_PYTHON_FFI_TYPES=cython run_pytest python-frontend-tflite tests/python/frontend/tflite +run_pytest cython python-frontend-tflite tests/python/frontend/tflite echo "Running relay Keras frontend test..." -TVM_PYTHON_FFI_TYPES=cython run_pytest python-frontend-keras tests/python/frontend/keras +run_pytest cython python-frontend-keras tests/python/frontend/keras echo "Running relay Caffe frontend test..." -TVM_PYTHON_FFI_TYPES=cython run_pytest python-frontend-caffe tests/python/frontend/caffe +run_pytest cython python-frontend-caffe tests/python/frontend/caffe diff --git a/tests/scripts/task_python_integration.sh b/tests/scripts/task_python_integration.sh index dc96097fb115..e21aa065a024 100755 --- a/tests/scripts/task_python_integration.sh +++ b/tests/scripts/task_python_integration.sh @@ -27,6 +27,7 @@ export LD_LIBRARY_PATH="build:${LD_LIBRARY_PATH:-}" export TVM_BIND_THREADS=0 export TVM_NUM_THREADS=2 +# NOTE: also set by task_python_integration_gpuonly.sh. if [ -z "${TVM_INTEGRATION_TESTSUITE_NAME:-}" ]; then TVM_INTEGRATION_TESTSUITE_NAME=python-integration fi @@ -43,28 +44,29 @@ rm -rf lib make cd ../.. -run_pytest ${TVM_INTEGRATION_TESTSUITE_NAME}-extensions apps/extension/tests +run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-extensions apps/extension/tests +run_pytest cython ${TVM_INTEGRATION_TESTSUITE_NAME}-extensions apps/extension/tests # Test dso plugin cd apps/dso_plugin_module rm -rf lib make cd ../.. -run_pytest ${TVM_INTEGRATION_TESTSUITE_NAME}-dso_plugin_module apps/dso_plugin_module +run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-dso_plugin_module apps/dso_plugin_module +run_pytest cython ${TVM_INTEGRATION_TESTSUITE_NAME}-dso_plugin_module apps/dso_plugin_module # Do not enable TensorFlow op # TVM_FFI=cython sh prepare_and_test_tfop_module.sh # TVM_FFI=ctypes sh prepare_and_test_tfop_module.sh -TVM_PYTEST_FFI_TYPES=ctypes run_pytest ${TVM_INTEGRATION_TESTSUITE_NAME} tests/python/integration -TVM_PYTEST_FFI_TYPES=ctypes run_pytest ${TVM_INTEGRATION_TESTSUITE_NAME}-contrib tests/python/contrib +run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME} tests/python/integration +run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-contrib tests/python/contrib TVM_TEST_TARGETS="${TVM_RELAY_TEST_TARGETS:-llvm;cuda}" \ - TVM_PYTEST_FFI_TYPES=ctypes \ - run_pytest ${TVM_INTEGRATION_TESTSUITE_NAME}-relay tests/python/relay + run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-relay tests/python/relay # Command line driver test -TVM_PYTEST_FFI_TYPES=ctypes run_pytest ${TVM_INTEGRATION_TESTSUITE_NAME}-driver tests/python/driver +run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-driver tests/python/driver # Do not enable OpenGL -# run_pytest ${TVM_INTEGRATION_TESTSUITE_NAME}-webgl tests/webgl +# run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-webgl tests/webgl diff --git a/tests/scripts/task_python_microtvm.sh b/tests/scripts/task_python_microtvm.sh index ddedff37c6c2..ba8018667895 100755 --- a/tests/scripts/task_python_microtvm.sh +++ b/tests/scripts/task_python_microtvm.sh @@ -25,4 +25,4 @@ source tests/scripts/setup-pytest-env.sh find . -type f -path "*.pyc" | xargs rm -f make cython3 -run_pytest python-microtvm-qemu tests/micro/qemu +run_pytest ctypes python-microtvm-qemu tests/micro/qemu diff --git a/tests/scripts/task_python_nightly.sh b/tests/scripts/task_python_nightly.sh index bff0650b0bed..16c94dfdad31 100755 --- a/tests/scripts/task_python_nightly.sh +++ b/tests/scripts/task_python_nightly.sh @@ -27,4 +27,4 @@ make cython3 # cleanup pycache find . -type f -path "*.pyc" | xargs rm -f -TVM_PYTEST_FFI_TYPES=cython run_pytest python-topi-nightly tests/python/topi/nightly +run_pytest cython python-topi-nightly tests/python/topi/nightly diff --git a/tests/scripts/task_python_topi.sh b/tests/scripts/task_python_topi.sh index e5eb6f28276a..9a5991e6a766 100755 --- a/tests/scripts/task_python_topi.sh +++ b/tests/scripts/task_python_topi.sh @@ -31,4 +31,4 @@ make cython3 # cleanup pycache find . -type f -path "*.pyc" | xargs rm -f -TVM_PYTHON_FFI_TYPES=cython run_pytest python-topi tests/python/topi/ +run_pytest cython python-topi tests/python/topi/ diff --git a/tests/scripts/task_python_unittest.sh b/tests/scripts/task_python_unittest.sh index b63d79a99562..54a36f6dcfd4 100755 --- a/tests/scripts/task_python_unittest.sh +++ b/tests/scripts/task_python_unittest.sh @@ -25,9 +25,15 @@ source tests/scripts/setup-pytest-env.sh find . -type f -path "*.pyc" | xargs rm -f make cython3 +# NOTE: also set by task_python_unittest_gpuonly.sh. if [ -z "${TVM_UNITTEST_TESTSUITE_NAME:-}" ]; then TVM_UNITTEST_TESTSUITE_NAME=python-unittest fi -run_pytest ${TVM_UNITTEST_TESTSUITE_NAME}-platform-minimal-test tests/python/all-platform-minimal-test -run_pytest ${TVM_UNITTEST_TESTSUITE_NAME} tests/python/unittest +# First run minimal test on both ctypes and cython. +run_pytest ctypes ${TVM_UNITTEST_TESTSUITE_NAME}-platform-minimal-test tests/python/all-platform-minimal-test +run_pytest cython ${TVM_UNITTEST_TESTSUITE_NAME}-platform-minimal-test tests/python/all-platform-minimal-test + +# Then run all unittests on both ctypes and cython. +run_pytest ctypes ${TVM_UNITTEST_TESTSUITE_NAME} tests/python/unittest +run_pytest cython ${TVM_UNITTEST_TESTSUITE_NAME} tests/python/unittest diff --git a/tests/scripts/task_python_vta_fsim.sh b/tests/scripts/task_python_vta_fsim.sh index 74d14db95d30..4074fb888351 100755 --- a/tests/scripts/task_python_vta_fsim.sh +++ b/tests/scripts/task_python_vta_fsim.sh @@ -40,10 +40,8 @@ cp ${VTA_HW_PATH}/config/fsim_sample.json ${VTA_HW_PATH}/config/vta_config.json # Run unit tests in functional/fast simulator echo "Running unittest in fsim..." -TVM_PYTEST_FFI_TYPES=cython run_pytest python-vta-fsim-unittest \ - ${TVM_PATH}/vta/tests/python/unittest +run_pytest cython python-vta-fsim-unittest ${TVM_PATH}/vta/tests/python/unittest # Run unit tests in functional/fast simulator echo "Running integration test in fsim..." -TVM_PYTEST_FFI_TYPES=cython run_pytest python-vta-fsim-integration \ - ${TVM_PATH}/vta/tests/python/integration +run_pytest cython python-vta-fsim-integration ${TVM_PATH}/vta/tests/python/integration diff --git a/tests/scripts/task_python_vta_tsim.sh b/tests/scripts/task_python_vta_tsim.sh index 4a5c9d7da877..3a6a35e5a06f 100755 --- a/tests/scripts/task_python_vta_tsim.sh +++ b/tests/scripts/task_python_vta_tsim.sh @@ -55,13 +55,11 @@ make -C ${VTA_HW_PATH}/hardware/chisel USE_THREADS=0 lib # Run unit tests in cycle accurate simulator echo "Running unittest in tsim..." -TVM_PYTEST_FFI_TYPES=cython run_pytest python-vta-tsim-unittest \ - ${TVM_PATH}/vta/tests/python/unittest +run_pytest cython python-vta-tsim-unittest ${TVM_PATH}/vta/tests/python/unittest # Run unit tests in cycle accurate simulator echo "Running integration test in tsim..." -TVM_PYTEST_FFI_TYPES=cython run_pytest python-vta-tsim-integration \ - ${TVM_PATH}/vta/tests/python/integration +run_pytest cython python-vta-tsim-integration ${TVM_PATH}/vta/tests/python/integration # Reset default fsim simulation cp ${VTA_HW_PATH}/config/fsim_sample.json ${VTA_HW_PATH}/config/vta_config.json