mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 00:21:07 +01:00
Summary: And add a new tool to update it in the future, which follows the policy of using "latest as of 18 months ago". This policy is meant to balance: * recent enough to increase the odds of being able to successfully export * old enough to increase the odds of exported model being runnable by different ONNX implementations Related changes: * test_models.py: explicitly fix opset_version to 9 rather than relying on default. Caffe2 doesn't support newer versions. * symbolic_helper.py: * Remove a misleading comment * Remove unnecessary check in `_set_opset_version` * Use a range to define `_onnx_stable_opsets` * test_pytorch_common.py: * Rename a variable from min -> max. I think it was a copy-paste error. * Make skip test messages more informative. * Remove unused `skipIfONNXShapeInference`. More on that below. * test_pytorch_onnx_onnxruntime.py: * Make all the `TestCase` classes explicitly specify opset version. * Make `test_unsupported_pad` respect `opset_version` by using `run_test` * Unrelated simplification: make it obvious that all tests run with `onnx_shape_inference=True`. AFAICT this was already the case. * There was one test that was entirely disabled (test_tolist) because it was asking to be skipped whenever `onnx_shape_inference=True`, but it was always True. I changed the model being tested so as to preserve the intended test coverage but still have the test actually pass. Pull Request resolved: https://github.com/pytorch/pytorch/pull/73898 Reviewed By: msaroufim Differential Revision: D35264615 Pulled By: malfet fbshipit-source-id: cda8fbdffe4cc8210d8d96e659e3a9adf1b5f1d2 (cherry picked from commit b5e639e88828d34442282d0b50c977e610a2ba3a)
93 lines
3.0 KiB
Bash
Executable File
93 lines
3.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -ex
|
|
|
|
UNKNOWN=()
|
|
|
|
# defaults
|
|
PARALLEL=0
|
|
|
|
while [[ $# -gt 0 ]]
|
|
do
|
|
arg="$1"
|
|
case $arg in
|
|
-p|--parallel)
|
|
PARALLEL=1
|
|
shift # past argument
|
|
;;
|
|
*) # unknown option
|
|
UNKNOWN+=("$1") # save it in an array for later
|
|
shift # past argument
|
|
;;
|
|
esac
|
|
done
|
|
set -- "${UNKNOWN[@]}" # leave UNKNOWN
|
|
|
|
if [[ $PARALLEL == 1 ]]; then
|
|
pip install pytest-xdist
|
|
fi
|
|
|
|
pip install pytest scipy hypothesis # these may not be necessary
|
|
pip install pytest-cov # installing since `coverage run -m pytest ..` doesn't work
|
|
pip install -e tools/coverage_plugins_package # allows coverage to run w/o failing due to a missing plug-in
|
|
|
|
# realpath might not be available on MacOS
|
|
script_path=$(python -c "import os; import sys; print(os.path.realpath(sys.argv[1]))" "${BASH_SOURCE[0]}")
|
|
top_dir=$(dirname $(dirname $(dirname "$script_path")))
|
|
test_paths=(
|
|
"$top_dir/test/onnx"
|
|
)
|
|
|
|
args=()
|
|
args+=("-v")
|
|
args+=("--cov")
|
|
args+=("--cov-report")
|
|
args+=("xml:test/coverage.xml")
|
|
args+=("--cov-append")
|
|
if [[ $PARALLEL == 1 ]]; then
|
|
args+=("-n")
|
|
args+=("3")
|
|
fi
|
|
|
|
# onnxruntime only support py3
|
|
# "Python.h" not found in py2, needed by TorchScript custom op compilation.
|
|
if [[ "$BUILD_ENVIRONMENT" == *ort_test1* || "${SHARD_NUMBER}" == "1" ]]; then
|
|
# These exclusions are for tests that take a long time / a lot of GPU
|
|
# memory to run; they should be passing (and you will test them if you
|
|
# run them locally
|
|
pytest "${args[@]}" \
|
|
--ignore "$top_dir/test/onnx/test_pytorch_onnx_onnxruntime.py" \
|
|
--ignore "$top_dir/test/onnx/test_custom_ops.py" \
|
|
--ignore "$top_dir/test/onnx/test_models_onnxruntime.py" \
|
|
--ignore "$top_dir/test/onnx/test_utility_funs.py" \
|
|
--ignore "$top_dir/test/onnx/test_pytorch_onnx_caffe2.py" \
|
|
--ignore "$top_dir/test/onnx/test_pytorch_onnx_shape_inference.py" \
|
|
--ignore "$top_dir/test/onnx/test_pytorch_onnx_onnxruntime_cuda.py" \
|
|
--ignore "$top_dir/test/onnx/test_pytorch_onnx_caffe2_quantized.py" \
|
|
"${test_paths[@]}"
|
|
|
|
pytest "${args[@]}" \
|
|
"$top_dir/test/onnx/test_pytorch_onnx_onnxruntime.py::TestONNXRuntime_opset7" \
|
|
"$top_dir/test/onnx/test_pytorch_onnx_onnxruntime.py::TestONNXRuntime_opset8" \
|
|
"$top_dir/test/onnx/test_pytorch_onnx_onnxruntime.py::TestONNXRuntime_opset9" \
|
|
"$top_dir/test/onnx/test_custom_ops.py" \
|
|
"$top_dir/test/onnx/test_models_onnxruntime.py" \
|
|
"$top_dir/test/onnx/test_utility_funs.py" \
|
|
"$top_dir/test/onnx/test_pytorch_onnx_caffe2.py" \
|
|
"$top_dir/test/onnx/test_pytorch_onnx_caffe2_quantized.py" \
|
|
"$top_dir/test/onnx/test_pytorch_onnx_shape_inference.py"
|
|
fi
|
|
|
|
if [[ "$BUILD_ENVIRONMENT" == *ort_test2* || "${SHARD_NUMBER}" == "2" ]]; then
|
|
# Update the loop for new opsets
|
|
for i in $(seq 10 15); do
|
|
pytest "${args[@]}" \
|
|
"$top_dir/test/onnx/test_pytorch_onnx_onnxruntime.py::TestONNXRuntime_opset$i"
|
|
done
|
|
fi
|
|
|
|
# Our CI expects both coverage.xml and .coverage to be within test/
|
|
if [ -d .coverage ]; then
|
|
mv .coverage test/.coverage
|
|
fi
|