tree: 06f33cf5c2419391691a6d2feaf27aec1bfaee0a [path history] [tgz]
  1. __init__.py
  2. CMakeLists.txt
  3. README.md
  4. script_module_v4.ptl
  5. script_module_v5.ptl
  6. script_module_v6.ptl
  7. test_alias_analysis.cpp
  8. test_argument_spec.cpp
  9. test_autodiff.cpp
  10. test_backend.cpp
  11. test_backend_compiler_lib.cpp
  12. test_backend_compiler_preprocess.cpp
  13. test_backend_lib.cpp
  14. test_class_import.cpp
  15. test_class_parser.cpp
  16. test_class_type.cpp
  17. test_cleanup_passes.cpp
  18. test_code_template.cpp
  19. test_concat_opt.cpp
  20. test_constant_pooling.cpp
  21. test_create_autodiff_subgraphs.cpp
  22. test_cs_debug_info_serialization.cpp
  23. test_custom_class.cpp
  24. test_custom_class_registrations.cpp
  25. test_custom_class_registrations.h
  26. test_custom_operators.cpp
  27. test_dce.cpp
  28. test_fuser.cpp
  29. test_gpu.cpp
  30. test_gpu_shift.cpp
  31. test_gpu_validator.h
  32. test_graph_executor.cpp
  33. test_graph_iterator.cpp
  34. test_inliner.cpp
  35. test_interface.cpp
  36. test_interpreter.cpp
  37. test_interpreter_async.pt
  38. test_ir.cpp
  39. test_irparser.cpp
  40. test_jit_logging_levels.cpp
  41. test_jit_type.cpp
  42. test_lite_interpreter.cpp
  43. test_lite_trainer.cpp
  44. test_memory_dag.cpp
  45. test_misc.cpp
  46. test_mobile_type_parser.cpp
  47. test_module_api.cpp
  48. test_peephole_optimize.cpp
  49. test_qualified_name.cpp
  50. test_save_load.cpp
  51. test_schema_matching.cpp
  52. test_script_profile.cpp
  53. test_stack_opt.cpp
  54. test_subgraph_matcher.cpp
  55. test_subgraph_rewriter.cpp
  56. test_subgraph_utils.cpp
  57. test_union.cpp
  58. test_utils.cpp
  59. test_utils.h
  60. tests_setup.py
  61. torch_python_test.cpp
test/cpp/jit/README.md

JIT C++ Tests

Adding a new test

First, create a new test file. Test files should have be placed in this directory, with a name that starts with test_, like test_foo.cpp.

In general a single test suite

Add your test file to the JIT_TEST_SRCS list in test/cpp/jit/CMakeLists.txt.

A test file may look like:

#include <gtest/gtest.h>

using namespace ::torch::jit

TEST(FooTest, BarBaz) {
   // ...
}

// Append '_CUDA' to the test case name will automatically filter it out if CUDA
// is not compiled.
TEST(FooTest, NeedsAGpu_CUDA) {
   // ...
}

// Similarly, if only one GPU is detected, tests with `_MultiCUDA` at the end
// will not be run.
TEST(FooTest, NeedsMultipleGpus_MultiCUDA) {
   // ...
}

Building and running the tests

The following commands assume you are in PyTorch root.

# ... Build PyTorch from source, e.g.
python setup.py develop
# (re)build just the binary
ninja -C build bin/test_jit
# run tests
build/bin/test_jit --gtest_filter='glob_style_filter*'