torch-mlir/build_tools/torchscript_e2e_heavydep_tests
Ashay Rane 874fdb7e42
build: improve robustness of cmake and shell scripts (#1018)
On my local machine, `unzip` didn't exist (producing a "command not
found" error), but CMake ignored the error.  Although the build did
succeed (because it found a previously-built version of libtorch), it
seems better to abort builds on such failures, so this patch checks the
return code of all external process invocations.

Along similar lines, this patch also updates the shell scripts in
`build_tools` to extensively use double-quoting to prevent unintentional
word splitting or globbing.  Since some of the scripts execute `rm`
while using shell variables, this patch also adds the preamble `set -u`
to abort execution if an undefined variable is referenced, so that we
reduce the chances of executing `rm -rf /` if the path expression
happens to refer to an undefined variable.
2022-07-06 14:39:30 -07:00
..
README.md Remove the last mentions of npcomp from torch-mlir 2021-10-05 20:17:23 +00:00
generate_serialized_tests.sh build: improve robustness of cmake and shell scripts (#1018) 2022-07-06 14:39:30 -07:00
hf_sequence_classification.py Remove heavy_deps models that don't get serialized. 2022-04-29 17:21:25 +05:30
main.py Add simple neural_net and bert_training scripts. 2022-05-19 06:18:42 +05:30
train_models.py Add simple neural_net and bert_training scripts. 2022-05-19 06:18:42 +05:30
vision_models.py Remove heavy_deps models that don't get serialized. 2022-04-29 17:21:25 +05:30

README.md

Additional end-to-end tests with heavy dependencies (heavydep tests)

Some end-to-end tests require additional dependencies which don't make sense to include as part of the default torch-mlir setup. Additionally, these dependencies often don't work with the same HEAD PyTorch version that torch-mlir builds against at the C++ level.

We have a self-contained script that generates all the needed artifacts from a self-contained virtual environment. It can be used like so:

# Build the virtual environment in the specified directory and generate the
# serialized test artifacts in the other specified directory.
# This command is safe to re-run if you have already built the virtual
# environment and just changed the tests.
build_tools/torchscript_e2e_heavydep_tests/generate_serialized_tests.sh \
  path/to/heavydep_venv \
  path/to/heavydep_serialized_tests

# Add the --serialized-test-dir flag to point at the directory containing the
# serialized tests. All other functionality is the same as the normal invocation
# of torchscript_e2e_test.sh, but the serialized tests will be available.
tools/torchscript_e2e_test.sh --serialized-test-dir=path/to/heavydep_serialized_tests

The tests use the same (pure-Python) test framework as the normal torchscript_e2e_test.sh, but the tests are added in build_tools/torchscript_e2e_heavydep_tests instead of frontends/pytorch/e2e_testing/torchscript.

We rely critically on serialized TorchScript compatibility across PyTorch versions to transport the tests + pure-Python compatibility of the torch API, which has worked well so far.